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 # Only use ANDROID_BUILD_SHELL to wrap around bash. 7 # DO NOT use other shells such as zsh. 8 ifdef ANDROID_BUILD_SHELL 9 SHELL := $(ANDROID_BUILD_SHELL) 10 else 11 # Use bash, not whatever shell somebody has installed as /bin/sh 12 # This is repeated from main.mk, since envsetup.sh runs this file 13 # directly. 14 SHELL := /bin/bash 15 endif 16 17 # Tell python not to spam the source tree with .pyc files. This 18 # only has an effect on python 2.6 and above. 19 export PYTHONDONTWRITEBYTECODE := 1 20 21 # Standard source directories. 22 SRC_DOCS:= $(TOPDIR)docs 23 # TODO: Enforce some kind of layering; only add include paths 24 # when a module links against a particular library. 25 # TODO: See if we can remove most of these from the global list. 26 SRC_HEADERS := \ 27 $(TOPDIR)system/core/include \ 28 $(TOPDIR)hardware/libhardware/include \ 29 $(TOPDIR)hardware/libhardware_legacy/include \ 30 $(TOPDIR)hardware/ril/include \ 31 $(TOPDIR)dalvik/libnativehelper/include \ 32 $(TOPDIR)frameworks/base/include \ 33 $(TOPDIR)frameworks/base/opengl/include \ 34 $(TOPDIR)frameworks/base/native/include \ 35 $(TOPDIR)external/skia/include 36 SRC_HOST_HEADERS:=$(TOPDIR)tools/include 37 SRC_LIBRARIES:= $(TOPDIR)libs 38 SRC_SERVERS:= $(TOPDIR)servers 39 SRC_TARGET_DIR := $(TOPDIR)build/target 40 SRC_API_DIR := $(TOPDIR)frameworks/base/api 41 42 # Some specific paths to tools 43 SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc 44 45 # Various mappings to avoid hard-coding paths all over the place 46 include $(BUILD_SYSTEM)/pathmap.mk 47 48 # ############################################################### 49 # Build system internal files 50 # ############################################################### 51 52 BUILD_COMBOS:= $(BUILD_SYSTEM)/combo 53 54 CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk 55 BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk 56 BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk 57 BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk 58 BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk 59 BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk 60 BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk 61 BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk 62 BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk 63 BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk 64 BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk 65 BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk 66 BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk 67 BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk 68 BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk 69 BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk 70 BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk 71 BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk 72 BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk 73 BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk 74 BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk 75 76 # ############################################################### 77 # Parse out any modifier targets. 78 # ############################################################### 79 80 # The 'showcommands' goal says to show the full command 81 # lines being executed, instead of a short message about 82 # the kind of operation being done. 83 SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS)) 84 85 86 # ############################################################### 87 # Set common values 88 # ############################################################### 89 90 # These can be changed to modify both host and device modules. 91 COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith 92 COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG 93 94 COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo 95 COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS) 96 97 # Set the extensions used for various packages 98 COMMON_PACKAGE_SUFFIX := .zip 99 COMMON_JAVA_PACKAGE_SUFFIX := .jar 100 COMMON_ANDROID_PACKAGE_SUFFIX := .apk 101 102 # list of flags to turn specific warnings in to errors 103 TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point 104 105 # TODO: do symbol compression 106 TARGET_COMPRESS_MODULE_SYMBOLS := false 107 108 # Default shell is mksh. Other possible value is ash. 109 TARGET_SHELL := mksh 110 111 # ############################################################### 112 # Include sub-configuration files 113 # ############################################################### 114 115 # --------------------------------------------------------------- 116 # Try to include buildspec.mk, which will try to set stuff up. 117 # If this file doesn't exist, the environemnt variables will 118 # be used, and if that doesn't work, then the default is an 119 # arm build 120 -include $(TOPDIR)buildspec.mk 121 122 # --------------------------------------------------------------- 123 # Define most of the global variables. These are the ones that 124 # are specific to the user's build configuration. 125 include $(BUILD_SYSTEM)/envsetup.mk 126 127 # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE) 128 # or under vendor/*/$(TARGET_DEVICE). Search in both places, but 129 # make sure only one exists. 130 # Real boards should always be associated with an OEM vendor. 131 board_config_mk := \ 132 $(strip $(wildcard \ 133 $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \ 134 device/*/$(TARGET_DEVICE)/BoardConfig.mk \ 135 vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \ 136 )) 137 ifeq ($(board_config_mk),) 138 $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE)) 139 endif 140 ifneq ($(words $(board_config_mk)),1) 141 $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk)) 142 endif 143 include $(board_config_mk) 144 TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk))) 145 board_config_mk := 146 147 # Clean up/verify variables defined by the board config file. 148 TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME)) 149 TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI)) 150 ifeq ($(TARGET_CPU_ABI),) 151 $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk)) 152 endif 153 TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2)) 154 155 # $(1): os/arch 156 define select-android-config-h 157 system/core/include/arch/$(1)/AndroidConfig.h 158 endef 159 160 combo_target := HOST_ 161 include $(BUILD_SYSTEM)/combo/select.mk 162 163 # on windows, the tools have .exe at the end, and we depend on the 164 # host config stuff being done first 165 166 combo_target := TARGET_ 167 include $(BUILD_SYSTEM)/combo/select.mk 168 169 # Pick a Java compiler. 170 include $(BUILD_SYSTEM)/combo/javac.mk 171 172 # --------------------------------------------------------------- 173 # Check that the configuration is current. We check that 174 # BUILD_ENV_SEQUENCE_NUMBER is current against this value. 175 # Don't fail if we're called from envsetup, so they have a 176 # chance to update their environment. 177 178 ifeq (,$(strip $(CALLED_FROM_SETUP))) 179 ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER))) 180 ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)) 181 $(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.) 182 $(info *** If you use envsetup/lunch/choosecombo:) 183 $(info *** - Re-execute envsetup (". envsetup.sh")) 184 $(info *** - Re-run lunch or choosecombo) 185 $(info *** If you use buildspec.mk:) 186 $(info *** - Look at buildspec.mk.default to see what has changed) 187 $(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)") 188 $(error bailing..) 189 endif 190 endif 191 endif 192 193 194 # --------------------------------------------------------------- 195 # Generic tools. 196 197 LEX:= flex 198 YACC:= bison -d 199 DOXYGEN:= doxygen 200 AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX) 201 AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX) 202 PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX) 203 ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX) 204 SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX) 205 MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX) 206 MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX) 207 MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX) 208 MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX) 209 APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX) 210 FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX) 211 MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX) 212 MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX) 213 MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh 214 MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh 215 MKTARBALL := build/tools/mktarball.sh 216 TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX) 217 E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX) 218 JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar 219 PROGUARD := external/proguard/bin/proguard.sh 220 JAVATAGS := build/tools/java-event-log-tags.py 221 LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc$(HOST_EXECUTABLE_SUFFIX) 222 LLVM_RS_LINK := $(HOST_OUT_EXECUTABLES)/llvm-rs-link$(HOST_EXECUTABLE_SUFFIX) 223 DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX) 224 DEXPREOPT := dalvik/tools/dex-preopt 225 226 # ACP is always for the build OS, not for the host OS 227 ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX) 228 229 # dx is java behind a shell script; no .exe necessary. 230 DX := $(HOST_OUT_EXECUTABLES)/dx 231 ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX) 232 FINDBUGS := prebuilt/common/findbugs/bin/findbugs 233 LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX) 234 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX) 235 236 # Deal with archaic version of bison on Mac OS X. 237 ifeq ($(filter 1.28,$(shell $(YACC) -V)),) 238 YACC_HEADER_SUFFIX:= .hpp 239 else 240 YACC_HEADER_SUFFIX:= .cpp.h 241 endif 242 243 # Don't use column under Windows, cygwin or not 244 ifeq ($(HOST_OS),windows) 245 COLUMN:= cat 246 else 247 COLUMN:= column 248 endif 249 250 dir := $(shell uname) 251 ifeq ($(HOST_OS),windows) 252 dir := $(HOST_OS) 253 endif 254 ifeq ($(HOST_OS),darwin) 255 dir := $(HOST_OS)-$(HOST_ARCH) 256 endif 257 OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX) 258 259 ifeq ($(HOST_OS),darwin) 260 # Mac OS' screwy version of java uses a non-standard directory layout 261 # and doesn't even seem to have tools.jar. On the other hand, javac seems 262 # to be able to magically find the classes in there, wherever they are, so 263 # leave this blank 264 HOST_JDK_TOOLS_JAR := 265 else 266 HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh) 267 ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),) 268 $(error Error: could not find jdk tools.jar, please install JDK6, \ 269 which you can download from java.sun.com) 270 endif 271 endif 272 273 # Is the host JDK 64-bit version? 274 HOST_JDK_IS_64BIT_VERSION := 275 ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),) 276 HOST_JDK_IS_64BIT_VERSION := true 277 endif 278 279 # It's called md5 on Mac OS and md5sum on Linux 280 ifeq ($(HOST_OS),darwin) 281 MD5SUM:=md5 -q 282 else 283 MD5SUM:=md5sum 284 endif 285 286 APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR) 287 APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) 288 APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX) 289 APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)" 290 291 # The default key if not set as LOCAL_CERTIFICATE 292 ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE 293 DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE) 294 else 295 DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey 296 endif 297 298 # ############################################################### 299 # Set up final options. 300 # ############################################################### 301 302 HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS) 303 HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS) 304 305 HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS) 306 HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS) 307 308 TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS) 309 TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS) 310 311 TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS) 312 TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS) 313 314 HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES) 315 TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES) 316 317 HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS) 318 TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) 319 320 # Many host compilers don't support these flags, so we have to make 321 # sure to only specify them for the target compilers checked in to 322 # the source tree. 323 TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS) 324 TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS) 325 326 HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS) 327 HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS) 328 329 TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS) 330 TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS) 331 332 PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true) 333 334 # ############################################################### 335 # Collect a list of the SDK versions that we could compile against 336 # For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE) 337 # ############################################################### 338 339 HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/sdk 340 HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/ndk 341 342 # Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N. 343 # The 'current' version is whatever this source tree is. 344 # 345 # sgrax is the opposite of xargs. It takes the list of args and puts them 346 # on each line for sort to process. 347 # sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3. 348 349 # Numerically sort a list of numbers 350 # $(1): the list of numbers to be sorted 351 define numerically_sort 352 $(shell function sgrax() { \ 353 while [ -n "$$1" ] ; do echo $$1 ; shift ; done \ 354 } ; \ 355 ( sgrax $(1) | sort -g ) ) 356 endef 357 358 TARGET_AVAILABLE_SDK_VERSIONS := current $(call numerically_sort,\ 359 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \ 360 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar))) 361 362 TARGET_AVAILABLE_NDK_VERSIONS := $(call numerically_sort,\ 363 $(patsubst $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r%,%, \ 364 $(wildcard $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r*))) 365 366 INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt 367 368 # This is the standard way to name a directory containing prebuilt target 369 # objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so 370 TARGET_PREBUILT_TAG := android-$(TARGET_ARCH) 371 372 include $(BUILD_SYSTEM)/dumpvar.mk 373