The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # This is included by the top-level Makefile. |
| 2 | # It sets up standard variables based on the |
| 3 | # current configuration and platform, which |
| 4 | # are not specific to what is being built. |
| 5 | |
| 6 | # Use bash, not whatever shell somebody has installed as /bin/sh |
| 7 | # This is repeated from main.mk, since envsetup.sh runs this file |
| 8 | # directly. |
| 9 | SHELL := /bin/bash |
| 10 | |
| 11 | # Standard source directories. |
| 12 | SRC_DOCS:= $(TOPDIR)docs |
| 13 | # TODO: Enforce some kind of layering; only add include paths |
| 14 | # when a module links against a particular library. |
| 15 | # TODO: See if we can remove most of these from the global list. |
| 16 | SRC_HEADERS := \ |
| 17 | $(TOPDIR)system/core/include \ |
| 18 | $(TOPDIR)hardware/libhardware/include \ |
| 19 | $(TOPDIR)hardware/libhardware_legacy/include \ |
| 20 | $(TOPDIR)hardware/ril/include \ |
| 21 | $(TOPDIR)dalvik/libnativehelper/include \ |
| 22 | $(TOPDIR)frameworks/base/include \ |
| 23 | $(TOPDIR)frameworks/base/opengl/include \ |
| 24 | $(TOPDIR)external/skia/include |
| 25 | SRC_HOST_HEADERS:=$(TOPDIR)tools/include |
| 26 | SRC_LIBRARIES:= $(TOPDIR)libs |
| 27 | SRC_SERVERS:= $(TOPDIR)servers |
| 28 | SRC_TARGET_DIR := $(TOPDIR)build/target |
| 29 | SRC_API_DIR := $(TOPDIR)frameworks/base/api |
| 30 | |
| 31 | # Some specific paths to tools |
| 32 | SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc |
| 33 | |
| 34 | # Various mappings to avoid hard-coding paths all over the place |
| 35 | include $(BUILD_SYSTEM)/pathmap.mk |
| 36 | |
| 37 | # ############################################################### |
| 38 | # Build system internal files |
| 39 | # ############################################################### |
| 40 | |
| 41 | BUILD_COMBOS:= $(BUILD_SYSTEM)/combo |
| 42 | |
| 43 | CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk |
| 44 | BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk |
| 45 | BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk |
| 46 | BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk |
| 47 | BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk |
| 48 | BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk |
| 49 | BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk |
| 50 | BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk |
| 51 | BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk |
| 52 | BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk |
| 53 | BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk |
| 54 | BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk |
| 55 | BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk |
| 56 | BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk |
| 57 | BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk |
| 58 | BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk |
| 59 | BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk |
| 60 | BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk |
| 61 | BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk |
| 62 | |
| 63 | # ############################################################### |
| 64 | # Parse out any modifier targets. |
| 65 | # ############################################################### |
| 66 | |
| 67 | # The 'showcommands' goal says to show the full command |
| 68 | # lines being executed, instead of a short message about |
| 69 | # the kind of operation being done. |
| 70 | SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS)) |
| 71 | |
| 72 | |
| 73 | # ############################################################### |
| 74 | # Set common values |
| 75 | # ############################################################### |
| 76 | |
| 77 | # These can be changed to modify both host and device modules. |
| 78 | COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused |
| 79 | COMMON_DEBUG_CFLAGS:= |
| 80 | COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG |
| 81 | |
| 82 | COMMON_GLOBAL_CPPFLAGS:= |
| 83 | COMMON_DEBUG_CPPFLAGS:= |
| 84 | COMMON_RELEASE_CPPFLAGS:= |
| 85 | |
| 86 | # Set the extensions used for various packages |
| 87 | COMMON_PACKAGE_SUFFIX := .zip |
| 88 | COMMON_JAVA_PACKAGE_SUFFIX := .jar |
| 89 | COMMON_ANDROID_PACKAGE_SUFFIX := .apk |
| 90 | |
| 91 | # list of flags to turn specific warnings in to errors |
| 92 | TARGET_ERROR_FLAGS := -Werror=return-type |
| 93 | |
| 94 | # ############################################################### |
| 95 | # Include sub-configuration files |
| 96 | # ############################################################### |
| 97 | |
| 98 | # --------------------------------------------------------------- |
| 99 | # Try to include buildspec.mk, which will try to set stuff up. |
| 100 | # If this file doesn't exist, the environemnt variables will |
| 101 | # be used, and if that doesn't work, then the default is an |
| 102 | # arm build |
| 103 | -include $(TOPDIR)buildspec.mk |
| 104 | |
| 105 | # --------------------------------------------------------------- |
| 106 | # Define most of the global variables. These are the ones that |
| 107 | # are specific to the user's build configuration. |
| 108 | include $(BUILD_SYSTEM)/envsetup.mk |
| 109 | |
| 110 | # $(1): os/arch |
| 111 | define select-android-config-h |
| 112 | system/core/include/arch/$(1)/AndroidConfig.h |
| 113 | endef |
| 114 | |
| 115 | combo_target := HOST_ |
| 116 | include $(BUILD_SYSTEM)/combo/select.mk |
| 117 | |
| 118 | # on windows, the tools have .exe at the end, and we depend on the |
| 119 | # host config stuff being done first |
| 120 | |
| 121 | combo_target := TARGET_ |
| 122 | include $(BUILD_SYSTEM)/combo/select.mk |
| 123 | |
| 124 | # Pick a Java compiler. |
| 125 | include $(BUILD_SYSTEM)/combo/javac.mk |
| 126 | |
| 127 | # --------------------------------------------------------------- |
| 128 | # Check that the configuration is current. We check that |
| 129 | # BUILD_ENV_SEQUENCE_NUMBER is current against this value. |
| 130 | # Don't fail if we're called from envsetup, so they have a |
| 131 | # chance to update their environment. |
| 132 | |
| 133 | ifeq (,$(strip $(CALLED_FROM_SETUP))) |
| 134 | ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER))) |
| 135 | ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)) |
| 136 | $(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.) |
| 137 | $(info *** If you use envsetup/lunch/choosecombo:) |
| 138 | $(info *** - Re-execute envsetup (". envsetup.sh")) |
| 139 | $(info *** - Re-run lunch or choosecombo) |
| 140 | $(info *** If you use buildspec.mk:) |
| 141 | $(info *** - Look at buildspec.mk.default to see what has changed) |
| 142 | $(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)") |
| 143 | $(error bailing..) |
| 144 | endif |
| 145 | endif |
| 146 | endif |
| 147 | |
| 148 | |
| 149 | # --------------------------------------------------------------- |
| 150 | # Generic tools. |
| 151 | |
| 152 | LEX:= flex |
| 153 | YACC:= bison -d |
| 154 | DOXYGEN:= doxygen |
| 155 | AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX) |
| 156 | ACP := $(HOST_OUT_EXECUTABLES)/acp$(HOST_EXECUTABLE_SUFFIX) |
| 157 | AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX) |
| 158 | ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX) |
| 159 | SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX) |
| 160 | MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX) |
| 161 | MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX) |
| 162 | MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX) |
| 163 | APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX) |
| 164 | FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX) |
| 165 | MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX) |
| 166 | MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh |
| 167 | MKTARBALL := build/tools/mktarball.sh |
| 168 | TUNE2FS := tune2fs |
| 169 | E2FSCK := e2fsck |
| 170 | JARJAR := java -jar $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar |
| 171 | |
| 172 | # dx is java behind a shell script; no .exe necessary. |
| 173 | DX := $(HOST_OUT_EXECUTABLES)/dx |
| 174 | KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX) |
| 175 | ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX) |
| 176 | FINDBUGS := prebuilt/common/findbugs/bin/findbugs |
| 177 | LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX) |
| 178 | EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX) |
| 179 | |
| 180 | # Binary prelinker/compressor tools |
| 181 | APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX) |
| 182 | LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX) |
| 183 | SOSLIM := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX) |
| 184 | |
| 185 | # Deal with archaic version of bison on Mac OS X. |
| 186 | ifeq ($(filter 1.28,$(shell $(YACC) -V)),) |
| 187 | YACC_HEADER_SUFFIX:= .hpp |
| 188 | else |
| 189 | YACC_HEADER_SUFFIX:= .cpp.h |
| 190 | endif |
| 191 | |
| 192 | # Don't use column under Windows, cygwin or not |
| 193 | ifeq ($(HOST_OS),windows) |
| 194 | COLUMN:= cat |
| 195 | else |
| 196 | COLUMN:= column |
| 197 | endif |
| 198 | |
| 199 | dir := $(shell uname) |
| 200 | ifeq ($(HOST_OS),windows) |
| 201 | dir := $(HOST_OS) |
| 202 | endif |
| 203 | ifeq ($(HOST_OS),darwin) |
| 204 | dir := $(HOST_OS)-$(HOST_ARCH) |
| 205 | endif |
| 206 | OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX) |
| 207 | |
| 208 | ifeq ($(HOST_OS),darwin) |
| 209 | # Mac OS' screwy version of java uses a non-standard directory layout |
| 210 | # and doesn't even seem to have tools.jar. On the other hand, javac seems |
| 211 | # to be able to magically find the classes in there, wherever they are, so |
| 212 | # leave this blank |
| 213 | HOST_JDK_TOOLS_JAR := |
| 214 | else |
| 215 | HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh) |
| 216 | endif |
| 217 | |
| 218 | # It's called md5 on Mac OS and md5sum on Linux |
| 219 | ifeq ($(HOST_OS),darwin) |
| 220 | MD5SUM:=md5 -q |
| 221 | else |
| 222 | MD5SUM:=md5sum |
| 223 | endif |
| 224 | |
| 225 | # ############################################################### |
| 226 | # Set up final options. |
| 227 | # ############################################################### |
| 228 | |
| 229 | HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS) |
| 230 | HOST_DEBUG_CFLAGS += $(COMMON_DEBUG_CFLAGS) |
| 231 | HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS) |
| 232 | |
| 233 | HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS) |
| 234 | HOST_DEBUG_CPPFLAGS += $(COMMON_DEBUG_CPPFLAGS) |
| 235 | HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS) |
| 236 | |
| 237 | TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS) |
| 238 | TARGET_DEBUG_CFLAGS += $(COMMON_DEBUG_CFLAGS) |
| 239 | TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS) |
| 240 | |
| 241 | TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS) |
| 242 | TARGET_DEBUG_CPPFLAGS += $(COMMON_DEBUG_CPPFLAGS) |
| 243 | TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS) |
| 244 | |
| 245 | HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES) |
| 246 | TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES) |
| 247 | |
| 248 | HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS) |
| 249 | TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) |
| 250 | |
| 251 | # Many host compilers don't support these flags, so we have to make |
| 252 | # sure to only specify them for the target compilers checked in to |
| 253 | # the source tree. The simulator uses the target flags but the |
| 254 | # host compiler, so only set them for the target when the target |
| 255 | # is not the simulator. |
| 256 | ifneq ($(TARGET_SIMULATOR),true) |
| 257 | TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS) |
| 258 | TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS) |
| 259 | endif |
| 260 | |
| 261 | ifeq ($(HOST_BUILD_TYPE),release) |
| 262 | HOST_GLOBAL_CFLAGS+= $(HOST_RELEASE_CFLAGS) |
| 263 | HOST_GLOBAL_CPPFLAGS+= $(HOST_RELEASE_CPPFLAGS) |
| 264 | else |
| 265 | HOST_GLOBAL_CFLAGS+= $(HOST_DEBUG_CFLAGS) |
| 266 | HOST_GLOBAL_CPPFLAGS+= $(HOST_DEBUG_CPPFLAGS) |
| 267 | endif |
| 268 | |
| 269 | ifeq ($(TARGET_BUILD_TYPE),release) |
| 270 | TARGET_GLOBAL_CFLAGS+= $(TARGET_RELEASE_CFLAGS) |
| 271 | TARGET_GLOBAL_CPPFLAGS+= $(TARGET_RELEASE_CPPFLAGS) |
| 272 | else |
| 273 | TARGET_GLOBAL_CFLAGS+= $(TARGET_DEBUG_CFLAGS) |
| 274 | TARGET_GLOBAL_CPPFLAGS+= $(TARGET_DEBUG_CPPFLAGS) |
| 275 | endif |
| 276 | |
| 277 | # TODO: do symbol compression |
| 278 | TARGET_COMPRESS_MODULE_SYMBOLS := false |
| 279 | TARGET_PRELINK_MODULE := true |
| 280 | |
| 281 | PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true) |
| 282 | |
| 283 | |
| 284 | # ############################################################### |
| 285 | # Collect a list of the SDK versions that we could compile against |
| 286 | # For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE) |
| 287 | # ############################################################### |
| 288 | |
| 289 | # The files that we can convert into android.jars are are in config/api/*.xml |
| 290 | # The 'current' version is whatever this source tree is. Once the apicheck |
| 291 | # tool can generate the stubs from the xml files, we'll use that to be |
| 292 | # able to build back-versions. In the meantime, 'current' is the only |
| 293 | # one supported. |
| 294 | # |
| 295 | # sgrax is the opposite of xargs. It takes the list of args and puts them |
| 296 | # on each line for sort to process. |
| 297 | # sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3. |
| 298 | TARGET_AVAILABLE_SDK_VERSIONS := current \ |
| 299 | $(shell function sgrax() { \ |
| 300 | while [ -n "$$1" ] ; do echo $$1 ; shift ; done \ |
| 301 | } ; \ |
| 302 | ( sgrax $(patsubst $(SRC_API_DIR)/%.xml,%, \ |
| 303 | $(filter-out $(SRC_API_DIR)/current.xml, \ |
| 304 | $(shell find $(SRC_API_DIR) -name "*.xml"))) | sort -g ) ) |
| 305 | |
| 306 | |
| 307 | INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml |
| 308 | |
| 309 | |
| 310 | |