Home | History | Annotate | Download | only in core
      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 # Utility variables.
     18 empty :=
     19 space := $(empty) $(empty)
     20 comma := ,
     21 # Note that make will eat the newline just before endef.
     22 define newline
     23 
     24 
     25 endef
     26 # The pound character "#"
     27 define pound
     28 #
     29 endef
     30 # Unfortunately you can't simply define backslash as \ or \\.
     31 backslash := \a
     32 backslash := $(patsubst %a,%,$(backslash))
     33 
     34 # Tell python not to spam the source tree with .pyc files.  This
     35 # only has an effect on python 2.6 and above.
     36 export PYTHONDONTWRITEBYTECODE := 1
     37 
     38 ifneq ($(filter --color=always, $(GREP_OPTIONS)),)
     39 $(warning The build system needs unmodified output of grep.)
     40 $(error Please remove --color=always from your  $$GREP_OPTIONS)
     41 endif
     42 
     43 # Standard source directories.
     44 SRC_DOCS:= $(TOPDIR)docs
     45 # TODO: Enforce some kind of layering; only add include paths
     46 #       when a module links against a particular library.
     47 # TODO: See if we can remove most of these from the global list.
     48 SRC_HEADERS := \
     49 	$(TOPDIR)system/core/include \
     50 	$(TOPDIR)system/media/audio/include \
     51 	$(TOPDIR)hardware/libhardware/include \
     52 	$(TOPDIR)hardware/libhardware_legacy/include \
     53 	$(TOPDIR)hardware/ril/include \
     54 	$(TOPDIR)libnativehelper/include \
     55 	$(TOPDIR)frameworks/native/include \
     56 	$(TOPDIR)frameworks/native/opengl/include \
     57 	$(TOPDIR)frameworks/av/include \
     58 	$(TOPDIR)frameworks/base/include
     59 SRC_HOST_HEADERS:=$(TOPDIR)tools/include
     60 SRC_LIBRARIES:= $(TOPDIR)libs
     61 SRC_SERVERS:= $(TOPDIR)servers
     62 SRC_TARGET_DIR := $(TOPDIR)build/target
     63 SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api
     64 SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
     65 SRC_TEST_API_DIR := $(TOPDIR)prebuilts/sdk/test-api
     66 
     67 # Some specific paths to tools
     68 SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
     69 
     70 # Various mappings to avoid hard-coding paths all over the place
     71 include $(BUILD_SYSTEM)/pathmap.mk
     72 
     73 # ###############################################################
     74 # Build system internal files
     75 # ###############################################################
     76 
     77 BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
     78 
     79 CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
     80 BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
     81 BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
     82 BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
     83 BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
     84 BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
     85 BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
     86 BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
     87 BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
     88 BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
     89 BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
     90 BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
     91 BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
     92 BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
     93 BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
     94 BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
     95 BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
     96 BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
     97 BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk
     98 BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
     99 BUILD_FUZZ_TEST := $(BUILD_SYSTEM)/fuzz_test.mk
    100 BUILD_HOST_FUZZ_TEST := $(BUILD_SYSTEM)/host_fuzz_test.mk
    101 
    102 BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk
    103 BUILD_HOST_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/host_shared_test_lib.mk
    104 BUILD_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/static_test_lib.mk
    105 BUILD_HOST_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/host_static_test_lib.mk
    106 
    107 BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk
    108 BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk
    109 BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
    110 
    111 
    112 # ###############################################################
    113 # Parse out any modifier targets.
    114 # ###############################################################
    115 
    116 # The 'showcommands' goal says to show the full command
    117 # lines being executed, instead of a short message about
    118 # the kind of operation being done.
    119 SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
    120 hide := $(if $(SHOW_COMMANDS),,@)
    121 
    122 ################################################################
    123 # Tools needed in product configuration makefiles.
    124 ################################################################
    125 NORMALIZE_PATH := build/tools/normalize_path.py
    126 
    127 # $(1): the paths to be normalized
    128 define normalize-paths
    129 $(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
    130 endef
    131 
    132 # ###############################################################
    133 # Set common values
    134 # ###############################################################
    135 
    136 # Set the extensions used for various packages
    137 COMMON_PACKAGE_SUFFIX := .zip
    138 COMMON_JAVA_PACKAGE_SUFFIX := .jar
    139 COMMON_ANDROID_PACKAGE_SUFFIX := .apk
    140 
    141 ifdef TMPDIR
    142 JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
    143 else
    144 JAVA_TMPDIR_ARG :=
    145 endif
    146 
    147 # ###############################################################
    148 # Include sub-configuration files
    149 # ###############################################################
    150 
    151 # ---------------------------------------------------------------
    152 # Try to include buildspec.mk, which will try to set stuff up.
    153 # If this file doesn't exist, the environment variables will
    154 # be used, and if that doesn't work, then the default is an
    155 # arm build
    156 ifndef ANDROID_BUILDSPEC
    157 ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
    158 endif
    159 -include $(ANDROID_BUILDSPEC)
    160 
    161 # ---------------------------------------------------------------
    162 # Define most of the global variables.  These are the ones that
    163 # are specific to the user's build configuration.
    164 include $(BUILD_SYSTEM)/envsetup.mk
    165 
    166 # Pruned directory options used when using findleaves.py
    167 # See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
    168 FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(OUT_DIR) $(SCAN_EXCLUDE_DIRS) .repo .git)
    169 
    170 # The build system exposes several variables for where to find the kernel
    171 # headers:
    172 #   TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
    173 #       device being built. It is set as $(TARGET_DEVICE_DIR)/kernel-headers,
    174 #       e.g. device/samsung/tuna/kernel-headers. This directory is not
    175 #       explicitly set by anyone, the build system always adds this subdir.
    176 #
    177 #   TARGET_BOARD_KERNEL_HEADERS is specified by the BoardConfig.mk file
    178 #       to allow other directories to be included. This is useful if there's
    179 #       some common place where a few headers are being kept for a group
    180 #       of devices. For example, device/<vendor>/common/kernel-headers could
    181 #       contain some headers for several of <vendor>'s devices.
    182 #
    183 #   TARGET_PRODUCT_KERNEL_HEADERS is generated by the product inheritance
    184 #       graph. This allows architecture products to provide headers for the
    185 #       devices using that architecture. For example,
    186 #       hardware/ti/omap4xxx/omap4.mk will specify
    187 #       PRODUCT_VENDOR_KERNEL_HEADERS variable that specify where the omap4
    188 #       specific headers are, e.g. hardware/ti/omap4xxx/kernel-headers.
    189 #       The build system then combines all the values specified by all the
    190 #       PRODUCT_VENDOR_KERNEL_HEADERS directives in the product inheritance
    191 #       tree and then exports a TARGET_PRODUCT_KERNEL_HEADERS variable.
    192 #
    193 # The layout of subdirs in any of the kernel-headers dir should mirror the
    194 # layout of the kernel include/ directory. For example,
    195 #     device/samsung/tuna/kernel-headers/linux/,
    196 #     hardware/ti/omap4xxx/kernel-headers/media/,
    197 #     etc.
    198 #
    199 # NOTE: These directories MUST contain post-processed headers using the
    200 # bionic/libc/kernel/clean_header.py tool. Additionally, the original kernel
    201 # headers must also be checked in, but in a different subdirectory. By
    202 # convention, the originals should be checked into original-kernel-headers
    203 # directory of the same parent dir. For example,
    204 #     device/samsung/tuna/kernel-headers            <----- post-processed
    205 #     device/samsung/tuna/original-kernel-headers   <----- originals
    206 #
    207 TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
    208 
    209 define validate-kernel-headers
    210 $(if $(firstword $(foreach hdr_dir,$(1),\
    211          $(filter-out kernel-headers,$(notdir $(hdr_dir))))),\
    212      $(error Kernel header dirs must be end in kernel-headers: $(1)))
    213 endef
    214 # also allow the board config to provide additional directories since
    215 # there could be device/oem/base_hw and device/oem/derived_hw
    216 # that both are valid devices but derived_hw needs to use kernel headers
    217 # from base_hw.
    218 TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
    219 TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
    220 $(call validate-kernel-headers,$(TARGET_BOARD_KERNEL_HEADERS))
    221 
    222 # then add product-inherited includes, to allow for
    223 # hardware/sivendor/chip/chip.mk to include their own headers
    224 TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
    225 TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
    226 $(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
    227 
    228 # Clean up/verify variables defined by the board config file.
    229 TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
    230 TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
    231 ifeq ($(TARGET_CPU_ABI),)
    232   $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
    233 endif
    234 TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
    235 
    236 # Commands to generate .toc file common to ELF .so files.
    237 define _gen_toc_command_for_elf
    238 $(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
    239 $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) --dyn-syms $(1) | awk '{$$2=""; $$3=""; print}' >> $(2)
    240 endef
    241 
    242 # Commands to generate .toc file from Darwin dynamic library.
    243 define _gen_toc_command_for_macho
    244 $(hide) otool -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
    245 $(hide) nm -gP $(1) | cut -f1-2 -d" " | grep -v U$$ >> $(2)
    246 endef
    247 
    248 combo_target := HOST_
    249 combo_2nd_arch_prefix :=
    250 include $(BUILD_SYSTEM)/combo/select.mk
    251 
    252 # Load the 2nd host arch if it's needed.
    253 ifdef HOST_2ND_ARCH
    254 combo_target := HOST_
    255 combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
    256 include $(BUILD_SYSTEM)/combo/select.mk
    257 endif
    258 
    259 # Load the windows cross compiler under Linux
    260 ifdef HOST_CROSS_OS
    261 combo_target := HOST_CROSS_
    262 combo_2nd_arch_prefix :=
    263 include $(BUILD_SYSTEM)/combo/select.mk
    264 
    265 ifdef HOST_CROSS_2ND_ARCH
    266 combo_target := HOST_CROSS_
    267 combo_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
    268 include $(BUILD_SYSTEM)/combo/select.mk
    269 endif
    270 endif
    271 
    272 # on windows, the tools have .exe at the end, and we depend on the
    273 # host config stuff being done first
    274 
    275 combo_target := TARGET_
    276 combo_2nd_arch_prefix :=
    277 include $(BUILD_SYSTEM)/combo/select.mk
    278 
    279 # Load the 2nd target arch if it's needed.
    280 ifdef TARGET_2ND_ARCH
    281 combo_target := TARGET_
    282 combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
    283 include $(BUILD_SYSTEM)/combo/select.mk
    284 endif
    285 
    286 include $(BUILD_SYSTEM)/ccache.mk
    287 include $(BUILD_SYSTEM)/goma.mk
    288 
    289 ifdef TARGET_PREFER_32_BIT
    290 TARGET_PREFER_32_BIT_APPS := true
    291 TARGET_PREFER_32_BIT_EXECUTABLES := true
    292 endif
    293 
    294 ifeq (,$(TARGET_SUPPORTS_32_BIT_APPS)$(TARGET_SUPPORTS_64_BIT_APPS))
    295   TARGET_SUPPORTS_32_BIT_APPS := true
    296 endif
    297 
    298 # "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
    299 # comma separated lists of the 32 and 64 bit ABIs (in order of
    300 # preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
    301 # are defined by the board config, we use them. Else, we construct
    302 # these lists based on whether TARGET_IS_64_BIT is set.
    303 #
    304 # Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
    305 # is always 32 bits. If this isn't the case, these variables should
    306 # be overriden in the board configuration.
    307 ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
    308   ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
    309     TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
    310   endif
    311 endif
    312 
    313 ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
    314   ifneq (true,$(TARGET_IS_64_BIT))
    315     TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
    316   else
    317     ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
    318       # For a 64 bit target, assume that the 2ND_CPU_ABI
    319       # is a 32 bit ABI.
    320       TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
    321     endif
    322   endif
    323 endif
    324 
    325 # "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
    326 # of preference) that the target supports. If a TARGET_CPU_ABI_LIST
    327 # is specified by the board configuration, we use that. If not, we
    328 # build a list out of the TARGET_CPU_ABIs specified by the config.
    329 ifeq (,$(TARGET_CPU_ABI_LIST))
    330   ifeq ($(TARGET_IS_64_BIT)|$(TARGET_PREFER_32_BIT_APPS),true|true)
    331     TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT)
    332   else
    333     TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT)
    334   endif
    335 endif
    336 
    337 # Strip whitespace from the ABI list string.
    338 TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
    339 TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
    340 TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
    341 
    342 # Compute TARGET_TOOLCHAIN_ROOT from TARGET_TOOLS_PREFIX
    343 # if only TARGET_TOOLS_PREFIX is passed to the make command.
    344 ifndef TARGET_TOOLCHAIN_ROOT
    345 TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLS_PREFIX)))
    346 TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT)))
    347 TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT))
    348 endif
    349 
    350 # Normalize WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK
    351 ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
    352   WITH_STATIC_ANALYZER :=
    353 endif
    354 ifeq ($(strip $(WITH_SYNTAX_CHECK)),0)
    355   WITH_SYNTAX_CHECK :=
    356 endif
    357 
    358 # define clang/llvm versions and base directory.
    359 include $(BUILD_SYSTEM)/clang/versions.mk
    360 
    361 # Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
    362 SYNTAX_TOOLS_PREFIX := \
    363     $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/tools/scan-build/libexec
    364 ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
    365   ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer),)
    366     $(warning *** Disable WITH_STATIC_ANALYZER because $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer does not exist)
    367     WITH_STATIC_ANALYZER :=
    368   endif
    369 endif
    370 
    371 # WITH_STATIC_ANALYZER trumps WITH_SYNTAX_CHECK
    372 ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
    373   ifneq ($(strip $(WITH_SYNTAX_CHECK)),)
    374     $(warning *** Disable WITH_SYNTAX_CHECK in the presence of static analyzer WITH_STATIC_ANALYZER)
    375     WITH_SYNTAX_CHECK :=
    376   endif
    377 endif
    378 
    379 # Pick a Java compiler.
    380 include $(BUILD_SYSTEM)/combo/javac.mk
    381 
    382 # ---------------------------------------------------------------
    383 # Check that the configuration is current.  We check that
    384 # BUILD_ENV_SEQUENCE_NUMBER is current against this value.
    385 # Don't fail if we're called from envsetup, so they have a
    386 # chance to update their environment.
    387 
    388 ifeq (,$(strip $(CALLED_FROM_SETUP)))
    389 ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
    390 ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
    391 $(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
    392 $(info *** If you use envsetup/lunch/choosecombo:)
    393 $(info ***   - Re-execute envsetup (". envsetup.sh"))
    394 $(info ***   - Re-run lunch or choosecombo)
    395 $(info *** If you use buildspec.mk:)
    396 $(info ***   - Look at buildspec.mk.default to see what has changed)
    397 $(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
    398 $(error bailing..)
    399 endif
    400 endif
    401 endif
    402 
    403 # Set up PDK so we can use TARGET_BUILD_PDK to select prebuilt tools below
    404 .PHONY: pdk fusion
    405 pdk fusion: $(DEFAULT_GOAL)
    406 
    407 # What to build:
    408 # pdk fusion if:
    409 # 1) PDK_FUSION_PLATFORM_ZIP is passed in from the environment
    410 # or
    411 # 2) the platform.zip exists in the default location
    412 # or
    413 # 3) fusion is a command line build goal,
    414 #    PDK_FUSION_PLATFORM_ZIP is needed anyway, then do we need the 'fusion' goal?
    415 # otherwise pdk only if:
    416 # 1) pdk is a command line build goal
    417 # or
    418 # 2) TARGET_BUILD_PDK is passed in from the environment
    419 
    420 # if PDK_FUSION_PLATFORM_ZIP is specified, do not override.
    421 ifndef PDK_FUSION_PLATFORM_ZIP
    422 # Most PDK project paths should be using vendor/pdk/TARGET_DEVICE
    423 # but some legacy ones (e.g. mini_armv7a_neon generic PDK) were setup
    424 # with vendor/pdk/TARGET_PRODUCT.
    425 _pdk_fusion_default_platform_zip = $(strip \
    426   $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
    427   $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
    428   $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
    429   $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip))
    430 ifneq (,$(_pdk_fusion_default_platform_zip))
    431 PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
    432 TARGET_BUILD_PDK := true
    433 endif # _pdk_fusion_default_platform_zip
    434 endif # !PDK_FUSION_PLATFORM_ZIP
    435 
    436 ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
    437 TARGET_BUILD_PDK := true
    438 ifneq (,$(filter fusion, $(MAKECMDGOALS)))
    439 ifndef PDK_FUSION_PLATFORM_ZIP
    440   $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.)
    441 endif
    442 endif  # fusion
    443 endif  # pdk or fusion
    444 
    445 ifdef PDK_FUSION_PLATFORM_ZIP
    446 TARGET_BUILD_PDK := true
    447 ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
    448   $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
    449 endif
    450 endif
    451 
    452 BUILD_PLATFORM_ZIP := $(filter platform platform-java,$(MAKECMDGOALS))
    453 
    454 #
    455 # Tools that are prebuilts for TARGET_BUILD_APPS
    456 #
    457 
    458 ACP := $(HOST_OUT_EXECUTABLES)/acp
    459 AIDL := $(HOST_OUT_EXECUTABLES)/aidl
    460 AAPT := $(HOST_OUT_EXECUTABLES)/aapt
    461 AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
    462 ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign
    463 SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
    464 SIGNAPK_JNI_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
    465 LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
    466 BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
    467 
    468 DX := $(HOST_OUT_EXECUTABLES)/dx
    469 MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses
    470 
    471 USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
    472 
    473 # Override the definitions above for unbundled and PDK builds
    474 ifneq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)))
    475 prebuilt_sdk_tools := prebuilts/sdk/tools
    476 prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
    477 
    478 ACP := $(prebuilt_sdk_tools_bin)/acp
    479 AIDL := $(prebuilt_sdk_tools_bin)/aidl
    480 AAPT := $(prebuilt_sdk_tools_bin)/aapt
    481 AAPT2 := $(prebuilt_sdk_tools_bin)/aapt2
    482 ZIPALIGN := $(prebuilt_sdk_tools_bin)/zipalign
    483 SIGNAPK_JAR := $(prebuilt_sdk_tools)/lib/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
    484 # Use 64-bit libraries unconditionally because 32-bit JVMs are no longer supported
    485 SIGNAPK_JNI_LIBRARY_PATH := $(prebuilt_sdk_tools)/$(HOST_OS)/lib64
    486 
    487 DX := $(prebuilt_sdk_tools)/dx
    488 MAINDEXCLASSES := $(prebuilt_sdk_tools)/mainDexClasses
    489 
    490 # Don't use prebuilts in PDK
    491 ifneq ($(TARGET_BUILD_PDK),true)
    492 LLVM_RS_CC := $(prebuilt_sdk_tools_bin)/llvm-rs-cc
    493 BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
    494 endif # TARGET_BUILD_PDK
    495 endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
    496 
    497 
    498 # ---------------------------------------------------------------
    499 # Generic tools.
    500 JACK := $(HOST_OUT_EXECUTABLES)/jack
    501 
    502 LEX := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/flex/flex-2.5.39
    503 # The default PKGDATADIR built in the prebuilt bison is a relative path
    504 # external/bison/data.
    505 # To run bison from elsewhere you need to set up enviromental variable
    506 # BISON_PKGDATADIR.
    507 BISON_PKGDATADIR := $(PWD)/external/bison/data
    508 BISON := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/bison/bison
    509 YACC := $(BISON) -d
    510 
    511 YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
    512 
    513 DOXYGEN:= doxygen
    514 AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX)
    515 ifeq ($(HOST_OS),linux)
    516 BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
    517 else
    518 # For non-supported hosts, do not generate breakpad symbols.
    519 BREAKPAD_GENERATE_SYMBOLS := false
    520 endif
    521 PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
    522 VTSC := $(HOST_OUT_EXECUTABLES)/vtsc$(HOST_EXECUTABLE_SUFFIX)
    523 DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
    524 MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
    525 MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
    526 ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
    527 MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
    528 else
    529 MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
    530 endif
    531 APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
    532 FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
    533 MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
    534 BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX)
    535 MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
    536 MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
    537 MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
    538 MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
    539 MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
    540 SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
    541 IMG2SIMG := $(HOST_OUT_EXECUTABLES)/img2simg$(HOST_EXECUTABLE_SUFFIX)
    542 E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
    543 MKTARBALL := build/tools/mktarball.sh
    544 TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
    545 E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
    546 JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
    547 DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
    548 
    549 ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
    550 DEFAULT_JACK_ENABLED:=full
    551 else
    552 DEFAULT_JACK_ENABLED:=
    553 endif
    554 ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
    555 DEFAULT_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
    556 else
    557 DEFAULT_JACK_EXTRA_ARGS := @$(BUILD_SYSTEM)/jack-default.args
    558 endif
    559 # Turn off jack warnings by default.
    560 DEFAULT_JACK_EXTRA_ARGS += --verbose error
    561 
    562 PROGUARD := external/proguard/bin/proguard.sh
    563 JAVATAGS := build/tools/java-event-log-tags.py
    564 RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs
    565 APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
    566 VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
    567 BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
    568 BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
    569 FUTILITY := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/futility/futility
    570 VBOOT_SIGNER := prebuilts/misc/scripts/vboot_signer/vboot_signer.sh
    571 FEC := $(HOST_OUT_EXECUTABLES)/fec
    572 
    573 ifndef TARGET_BUILD_APPS
    574 ZIPTIME := $(HOST_OUT_EXECUTABLES)/ziptime$(HOST_EXECUTABLE_SUFFIX)
    575 endif
    576 
    577 # ijar converts a .jar file to a smaller .jar file which only has its
    578 # interfaces.
    579 IJAR := $(HOST_OUT_EXECUTABLES)/ijar$(BUILD_EXECUTABLE_SUFFIX)
    580 DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump2$(BUILD_EXECUTABLE_SUFFIX)
    581 
    582 # relocation packer
    583 RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
    584 
    585 FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
    586 FINDBUGS := $(FINDBUGS_DIR)/findbugs
    587 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
    588 
    589 # Tool to merge AndroidManifest.xmls
    590 ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge
    591 
    592 COLUMN:= column
    593 
    594 # We may not have the right JAVA_HOME/PATH set up yet when this is run from envsetup.sh.
    595 ifneq ($(CALLED_FROM_SETUP),true)
    596 HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
    597 
    598 ifneq ($(HOST_JDK_TOOLS_JAR),)
    599 ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
    600 $(error Error: could not find jdk tools.jar at $(HOST_JDK_TOOLS_JAR), please check if your JDK was installed correctly)
    601 endif
    602 endif
    603 
    604 # Is the host JDK 64-bit version?
    605 HOST_JDK_IS_64BIT_VERSION :=
    606 ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
    607 HOST_JDK_IS_64BIT_VERSION := true
    608 endif
    609 endif  # CALLED_FROM_SETUP not true
    610 
    611 # It's called md5 on Mac OS and md5sum on Linux
    612 ifeq ($(HOST_OS),darwin)
    613 MD5SUM:=md5 -q
    614 else
    615 MD5SUM:=md5sum
    616 endif
    617 
    618 APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
    619 APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
    620 APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
    621 APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
    622 
    623 # The default key if not set as LOCAL_CERTIFICATE
    624 ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
    625   DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
    626 else
    627   DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
    628 endif
    629 
    630 # ###############################################################
    631 # Set up final options.
    632 # ###############################################################
    633 
    634 ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
    635 $(warning COMMON_GLOBAL_C(PP)FLAGS changed)
    636 $(info *** Device configurations are no longer allowed to change the global flags.)
    637 $(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
    638 $(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
    639 $(error bailing...)
    640 endif
    641 
    642 # These can be changed to modify both host and device modules.
    643 COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
    644 COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
    645 
    646 # Force gcc to always output color diagnostics.  Ninja will strip the ANSI
    647 # color codes if it is not running in a terminal.
    648 ifdef BUILDING_WITH_NINJA
    649 COMMON_GLOBAL_CFLAGS += -fdiagnostics-color
    650 endif
    651 
    652 COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
    653 COMMON_RELEASE_CPPFLAGS:=
    654 
    655 GLOBAL_CFLAGS_NO_OVERRIDE := \
    656     -Werror=int-to-pointer-cast \
    657     -Werror=pointer-to-int-cast \
    658 
    659 GLOBAL_CLANG_CFLAGS_NO_OVERRIDE := \
    660     -Werror=address-of-temporary \
    661     -Werror=null-dereference \
    662     -Werror=return-type \
    663 
    664 GLOBAL_CPPFLAGS_NO_OVERRIDE :=
    665 
    666 # list of flags to turn specific warnings in to errors
    667 TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time
    668 
    669 # We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
    670 # from the debug output. That way two builds in two different
    671 # directories will create the same output.
    672 # /proc doesn't exist on Darwin.
    673 ifeq ($(HOST_OS),linux)
    674 RELATIVE_PWD := PWD=/proc/self/cwd
    675 # Remove this useless prefix from the debug output.
    676 COMMON_GLOBAL_CFLAGS += -fdebug-prefix-map=/proc/self/cwd=
    677 else
    678 RELATIVE_PWD :=
    679 endif
    680 
    681 # Allow the C/C++ macros __DATE__ and __TIME__ to be set to the
    682 # build date and time, so that a build may be repeated.
    683 # Write the date and time to a file so that the command line
    684 # doesn't change every time, which would cause ninja to rebuild
    685 # the files.
    686 $(shell mkdir -p $(OUT_DIR) && \
    687     $(DATE) "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
    688     $(DATE) +%T > $(OUT_DIR)/build_c_time.txt)
    689 BUILD_DATETIME_C_DATE := $$(cat $(OUT_DIR)/build_c_date.txt)
    690 BUILD_DATETIME_C_TIME := $$(cat $(OUT_DIR)/build_c_time.txt)
    691 ifeq ($(OVERRIDE_C_DATE_TIME),true)
    692 COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
    693 endif
    694 
    695 HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
    696 HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    697 
    698 HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    699 HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    700 
    701 TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
    702 TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    703 
    704 TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    705 TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    706 
    707 HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
    708 TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
    709 
    710 HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
    711 TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) \
    712 		$(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
    713 		$(TARGET_PRODUCT_KERNEL_HEADERS)
    714 
    715 # Many host compilers don't support these flags, so we have to make
    716 # sure to only specify them for the target compilers checked in to
    717 # the source tree.
    718 TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
    719 
    720 HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
    721 HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
    722 
    723 TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
    724 TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
    725 
    726 ifdef TARGET_2ND_ARCH
    727 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
    728 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    729 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    730 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    731 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
    732 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
    733 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
    734 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
    735 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
    736 endif
    737 
    738 ifdef HOST_2ND_ARCH
    739 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
    740 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    741 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    742 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    743 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS += -L$($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)
    744 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_PROJECT_INCLUDES := $(HOST_PROJECT_INCLUDES)
    745 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS)
    746 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS)
    747 endif
    748 
    749 ifdef HOST_CROSS_OS
    750 HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $(HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
    751 HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    752 HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    753 HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    754 HOST_CROSS_GLOBAL_LD_DIRS += -L$(HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
    755 HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_CROSS_OUT_HEADERS)
    756 HOST_CROSS_GLOBAL_CFLAGS += $(HOST_CROSS_RELEASE_CFLAGS)
    757 HOST_CROSS_GLOBAL_CPPFLAGS += $(HOST_CROSS_RELEASE_CPPFLAGS)
    758 
    759 ifdef HOST_CROSS_2ND_ARCH
    760 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
    761 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
    762 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
    763 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
    764 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_LD_DIRS += -L$($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
    765 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_HEADERS)
    766 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS)
    767 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS)
    768 endif
    769 endif
    770 
    771 ifdef BRILLO
    772 # Add a C define that identifies Brillo targets. __BRILLO__ should only be used
    773 # to differentiate between Brillo and non-Brillo-but-Android environments. Use
    774 # __ANDROID__ instead to test if something is being built in an Android-derived
    775 # environment (including Brillo) as opposed to an entirely different
    776 # environment (e.g. Chrome OS).
    777 TARGET_GLOBAL_CFLAGS += -D__BRILLO__
    778 ifdef TARGET_2ND_ARCH
    779 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += -D__BRILLO__
    780 endif
    781 endif
    782 
    783 # allow overriding default Java libraries on a per-target basis
    784 ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),)
    785   TARGET_DEFAULT_JAVA_LIBRARIES := core-oj core-libart core-junit ext framework okhttp
    786 endif
    787 
    788 # Flags for DEX2OAT
    789 first_non_empty_of_three = $(if $(1),$(1),$(if $(2),$(2),$(3)))
    790 DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
    791 DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT),$(TARGET_ARCH_VARIANT),default)
    792 DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
    793 
    794 ifdef TARGET_2ND_ARCH
    795 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
    796 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT),$(TARGET_2ND_ARCH_VARIANT),default)
    797 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
    798 endif
    799 
    800 # define clang/llvm tools and global flags
    801 include $(BUILD_SYSTEM)/clang/config.mk
    802 
    803 # ###############################################################
    804 # Collect a list of the SDK versions that we could compile against
    805 # For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
    806 # ###############################################################
    807 
    808 HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
    809 HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
    810 
    811 # The path where app can reference the support library resources.
    812 ifdef TARGET_BUILD_APPS
    813 SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
    814 else
    815 SUPPORT_LIBRARY_ROOT := frameworks/support
    816 endif
    817 
    818 # Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
    819 # The 'current' version is whatever this source tree is.
    820 #
    821 # sgrax     is the opposite of xargs.  It takes the list of args and puts them
    822 #           on each line for sort to process.
    823 # sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
    824 
    825 # Numerically sort a list of numbers
    826 # $(1): the list of numbers to be sorted
    827 define numerically_sort
    828 $(shell function sgrax() { \
    829     while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
    830     } ; \
    831     ( sgrax $(1) | sort -g ) )
    832 endef
    833 
    834 TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
    835     $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
    836     $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
    837 
    838 # We don't have prebuilt test_current SDK yet.
    839 TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS)
    840 
    841 INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
    842 INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
    843 INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt
    844 INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-removed.txt
    845 INTERNAL_PLATFORM_TEST_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-api.txt
    846 INTERNAL_PLATFORM_TEST_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-removed.txt
    847 
    848 # This is the standard way to name a directory containing prebuilt target
    849 # objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
    850 TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
    851 ifdef TARGET_2ND_ARCH
    852 TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
    853 endif
    854 
    855 # Set up RS prebuilt variables for compatibility library
    856 
    857 RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
    858 RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
    859 ifeq (true,$(TARGET_IS_64_BIT))
    860 RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib64 \
    861                        -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib
    862 else
    863 RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-9/arch-$(TARGET_ARCH)/usr/lib
    864 endif
    865 
    866 # API Level lists for Renderscript Compat lib.
    867 RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
    868 RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
    869 
    870 include $(BUILD_SYSTEM)/dumpvar.mk
    871