config.mk revision 5e50b342218fe2b9c1af20fd7da3c173bfac0499
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.
8ifdef ANDROID_BUILD_SHELL
9SHELL := $(ANDROID_BUILD_SHELL)
10else
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.
14SHELL := /bin/bash
15endif
16
17# Utility variables.
18empty :=
19space := $(empty) $(empty)
20comma := ,
21# Note that make will eat the newline just before endef.
22define newline
23
24
25endef
26# Unfortunately you can't simply define backslash as \ or \\.
27backslash := \a
28backslash := $(patsubst %a,%,$(backslash))
29
30# Tell python not to spam the source tree with .pyc files.  This
31# only has an effect on python 2.6 and above.
32export PYTHONDONTWRITEBYTECODE := 1
33
34ifneq ($(GREP_OPTIONS),)
35$(warning The build system needs unmodified output of grep.)
36$(error Please unset your $$GREP_OPTIONS.)
37endif
38
39# Standard source directories.
40SRC_DOCS:= $(TOPDIR)docs
41# TODO: Enforce some kind of layering; only add include paths
42#       when a module links against a particular library.
43# TODO: See if we can remove most of these from the global list.
44SRC_HEADERS := \
45	$(TOPDIR)system/core/include \
46	$(TOPDIR)system/media/audio/include \
47	$(TOPDIR)hardware/libhardware/include \
48	$(TOPDIR)hardware/libhardware_legacy/include \
49	$(TOPDIR)hardware/ril/include \
50	$(TOPDIR)libnativehelper/include \
51	$(TOPDIR)frameworks/native/include \
52	$(TOPDIR)frameworks/native/opengl/include \
53	$(TOPDIR)frameworks/av/include \
54	$(TOPDIR)frameworks/base/include
55SRC_HOST_HEADERS:=$(TOPDIR)tools/include
56SRC_LIBRARIES:= $(TOPDIR)libs
57SRC_SERVERS:= $(TOPDIR)servers
58SRC_TARGET_DIR := $(TOPDIR)build/target
59SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api
60SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
61
62# Some specific paths to tools
63SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
64
65# Various mappings to avoid hard-coding paths all over the place
66include $(BUILD_SYSTEM)/pathmap.mk
67
68# ###############################################################
69# Build system internal files
70# ###############################################################
71
72BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
73
74CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
75BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
76BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
77BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
78BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
79BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
80BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
81BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
82BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
83BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
84BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
85BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
86BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
87BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
88BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
89BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
90BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
91BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
92BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk
93BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
94
95BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk
96BUILD_HOST_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/host_shared_test_lib.mk
97BUILD_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/static_test_lib.mk
98BUILD_HOST_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/host_static_test_lib.mk
99
100BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk
101BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk
102BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
103
104
105# ###############################################################
106# Parse out any modifier targets.
107# ###############################################################
108
109# The 'showcommands' goal says to show the full command
110# lines being executed, instead of a short message about
111# the kind of operation being done.
112SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
113
114
115# ###############################################################
116# Set common values
117# ###############################################################
118
119# These can be changed to modify both host and device modules.
120COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
121COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
122
123COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo -std=gnu++11
124COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
125
126GLOBAL_CFLAGS_NO_OVERRIDE := \
127    -Werror=int-to-pointer-cast \
128    -Werror=pointer-to-int-cast \
129
130GLOBAL_CLANG_CFLAGS_NO_OVERRIDE := \
131    -Werror=address-of-temporary \
132    -Werror=null-dereference \
133    -Werror=return-type \
134
135GLOBAL_CPPFLAGS_NO_OVERRIDE :=
136
137# Set the extensions used for various packages
138COMMON_PACKAGE_SUFFIX := .zip
139COMMON_JAVA_PACKAGE_SUFFIX := .jar
140COMMON_ANDROID_PACKAGE_SUFFIX := .apk
141
142# list of flags to turn specific warnings in to errors
143TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
144
145ifdef TMPDIR
146JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
147else
148JAVA_TMPDIR_ARG :=
149endif
150
151# ###############################################################
152# Include sub-configuration files
153# ###############################################################
154
155# ---------------------------------------------------------------
156# Try to include buildspec.mk, which will try to set stuff up.
157# If this file doesn't exist, the environment variables will
158# be used, and if that doesn't work, then the default is an
159# arm build
160ifndef ANDROID_BUILDSPEC
161ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
162endif
163-include $(ANDROID_BUILDSPEC)
164
165# ---------------------------------------------------------------
166# Define most of the global variables.  These are the ones that
167# are specific to the user's build configuration.
168include $(BUILD_SYSTEM)/envsetup.mk
169
170# Pruned directory options used when using findleaves.py
171# See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
172FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(OUT_DIR) $(SCAN_EXCLUDE_DIRS) .repo .git)
173
174# The build system exposes several variables for where to find the kernel
175# headers:
176#   TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
177#       device being built. It is set as $(TARGET_DEVICE_DIR)/kernel-headers,
178#       e.g. device/samsung/tuna/kernel-headers. This directory is not
179#       explicitly set by anyone, the build system always adds this subdir.
180#
181#   TARGET_BOARD_KERNEL_HEADERS is specified by the BoardConfig.mk file
182#       to allow other directories to be included. This is useful if there's
183#       some common place where a few headers are being kept for a group
184#       of devices. For example, device/<vendor>/common/kernel-headers could
185#       contain some headers for several of <vendor>'s devices.
186#
187#   TARGET_PRODUCT_KERNEL_HEADERS is generated by the product inheritance
188#       graph. This allows architecture products to provide headers for the
189#       devices using that architecture. For example,
190#       hardware/ti/omap4xxx/omap4.mk will specify
191#       PRODUCT_VENDOR_KERNEL_HEADERS variable that specify where the omap4
192#       specific headers are, e.g. hardware/ti/omap4xxx/kernel-headers.
193#       The build system then combines all the values specified by all the
194#       PRODUCT_VENDOR_KERNEL_HEADERS directives in the product inheritance
195#       tree and then exports a TARGET_PRODUCT_KERNEL_HEADERS variable.
196#
197# The layout of subdirs in any of the kernel-headers dir should mirror the
198# layout of the kernel include/ directory. For example,
199#     device/samsung/tuna/kernel-headers/linux/,
200#     hardware/ti/omap4xxx/kernel-headers/media/,
201#     etc.
202#
203# NOTE: These directories MUST contain post-processed headers using the
204# bionic/libc/kernel/clean_header.py tool. Additionally, the original kernel
205# headers must also be checked in, but in a different subdirectory. By
206# convention, the originals should be checked into original-kernel-headers
207# directory of the same parent dir. For example,
208#     device/samsung/tuna/kernel-headers            <----- post-processed
209#     device/samsung/tuna/original-kernel-headers   <----- originals
210#
211TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
212
213define validate-kernel-headers
214$(if $(firstword $(foreach hdr_dir,$(1),\
215         $(filter-out kernel-headers,$(notdir $(hdr_dir))))),\
216     $(error Kernel header dirs must be end in kernel-headers: $(1)))
217endef
218# also allow the board config to provide additional directories since
219# there could be device/oem/base_hw and device/oem/derived_hw
220# that both are valid devices but derived_hw needs to use kernel headers
221# from base_hw.
222TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
223TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
224$(call validate-kernel-headers,$(TARGET_BOARD_KERNEL_HEADERS))
225
226# then add product-inherited includes, to allow for
227# hardware/sivendor/chip/chip.mk to include their own headers
228TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
229TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
230$(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
231
232# Clean up/verify variables defined by the board config file.
233TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
234TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
235ifeq ($(TARGET_CPU_ABI),)
236  $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
237endif
238TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
239
240# $(1): os/arch
241define select-android-config-h
242build/core/combo/include/arch/$(1)/AndroidConfig.h
243endef
244
245combo_target := HOST_
246combo_2nd_arch_prefix :=
247include $(BUILD_SYSTEM)/combo/select.mk
248
249# Load the 2nd host arch if it's needed.
250ifdef HOST_2ND_ARCH
251combo_target := HOST_
252combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
253include $(BUILD_SYSTEM)/combo/select.mk
254endif
255
256# on windows, the tools have .exe at the end, and we depend on the
257# host config stuff being done first
258
259combo_target := TARGET_
260combo_2nd_arch_prefix :=
261include $(BUILD_SYSTEM)/combo/select.mk
262
263# Load the 2nd target arch if it's needed.
264ifdef TARGET_2ND_ARCH
265combo_target := TARGET_
266combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
267include $(BUILD_SYSTEM)/combo/select.mk
268endif
269
270ifdef TARGET_PREFER_32_BIT
271TARGET_PREFER_32_BIT_APPS := true
272TARGET_PREFER_32_BIT_EXECUTABLES := true
273endif
274
275ifeq (,$(TARGET_SUPPORTS_32_BIT_APPS)$(TARGET_SUPPORTS_64_BIT_APPS))
276  TARGET_SUPPORTS_32_BIT_APPS := true
277endif
278
279# "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
280# comma separated lists of the 32 and 64 bit ABIs (in order of
281# preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
282# are defined by the board config, we use them. Else, we construct
283# these lists based on whether TARGET_IS_64_BIT is set.
284#
285# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
286# is always 32 bits. If this isn't the case, these variables should
287# be overriden in the board configuration.
288ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
289  ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
290    TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
291  endif
292endif
293
294ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
295  ifneq (true,$(TARGET_IS_64_BIT))
296    TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
297  else
298    ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
299      # For a 64 bit target, assume that the 2ND_CPU_ABI
300      # is a 32 bit ABI.
301      TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
302    endif
303  endif
304endif
305
306# "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
307# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
308# is specified by the board configuration, we use that. If not, we
309# build a list out of the TARGET_CPU_ABIs specified by the config.
310ifeq (,$(TARGET_CPU_ABI_LIST))
311  ifeq ($(TARGET_IS_64_BIT)|$(TARGET_PREFER_32_BIT_APPS),true|true)
312    TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT)
313  else
314    TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT)
315  endif
316endif
317
318# Strip whitespace from the ABI list string.
319TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
320TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
321TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
322
323# Compute TARGET_TOOLCHAIN_ROOT from TARGET_TOOLS_PREFIX
324# if only TARGET_TOOLS_PREFIX is passed to the make command.
325ifndef TARGET_TOOLCHAIN_ROOT
326TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLS_PREFIX)))
327TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT)))
328TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT))
329endif
330
331# Normalize WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK
332ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
333  WITH_STATIC_ANALYZER :=
334endif
335ifeq ($(strip $(WITH_SYNTAX_CHECK)),0)
336  WITH_SYNTAX_CHECK :=
337endif
338
339# Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
340SYNTAX_TOOLS_PREFIX := prebuilts/misc/$(HOST_PREBUILT_TAG)/analyzer/bin
341ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
342  ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer),)
343    $(warning *** Disable WITH_STATIC_ANALYZER because $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer does not exist)
344    WITH_STATIC_ANALYZER :=
345  endif
346endif
347ifneq ($(strip $(WITH_SYNTAX_CHECK)),)
348  ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-syntax),)
349    $(warning *** Disable WITH_SYNTAX_CHECK because $(SYNTAX_TOOLS_PREFIX)/ccc-syntax does not exist)
350    WITH_SYNTAX_CHECK :=
351  endif
352endif
353
354# WITH_STATIC_ANALYZER trumps WITH_SYNTAX_CHECK
355ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
356  ifneq ($(strip $(WITH_SYNTAX_CHECK)),)
357    $(warning *** Disable WITH_SYNTAX_CHECK in the presence of static analyzer WITH_STATIC_ANALYZER)
358    WITH_SYNTAX_CHECK :=
359  endif
360endif
361
362# Pick a Java compiler.
363include $(BUILD_SYSTEM)/combo/javac.mk
364
365# ---------------------------------------------------------------
366# Check that the configuration is current.  We check that
367# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
368# Don't fail if we're called from envsetup, so they have a
369# chance to update their environment.
370
371ifeq (,$(strip $(CALLED_FROM_SETUP)))
372ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
373ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
374$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
375$(info *** If you use envsetup/lunch/choosecombo:)
376$(info ***   - Re-execute envsetup (". envsetup.sh"))
377$(info ***   - Re-run lunch or choosecombo)
378$(info *** If you use buildspec.mk:)
379$(info ***   - Look at buildspec.mk.default to see what has changed)
380$(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
381$(error bailing..)
382endif
383endif
384endif
385
386
387# ---------------------------------------------------------------
388# Generic tools.
389JACK := $(HOST_OUT_EXECUTABLES)/jack
390JACK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/jack.jar
391JILL_JAR := $(HOST_OUT_JAVA_LIBRARIES)/jill.jar
392
393LEX := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/flex/flex-2.5.39
394# The default PKGDATADIR built in the prebuilt bison is a relative path
395# external/bison/data.
396# To run bison from elsewhere you need to set up enviromental variable
397# BISON_PKGDATADIR.
398BISON_PKGDATADIR := $(PWD)/external/bison/data
399BISON := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/bison/bison
400YACC := $(BISON) -d
401
402YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
403
404DOXYGEN:= doxygen
405AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
406AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
407PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
408SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
409MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
410MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
411ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
412MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
413else
414MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
415endif
416APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
417FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
418MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
419MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
420ifeq ($(HOST_OS),linux)
421MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
422MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
423else
424MAKE_SQUASHFS :=
425MKSQUASHFSUSERIMG :=
426endif
427MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
428MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
429SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
430IMG2SIMG := $(HOST_OUT_EXECUTABLES)/img2simg$(HOST_EXECUTABLE_SUFFIX)
431E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
432MKTARBALL := build/tools/mktarball.sh
433TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
434E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
435JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
436DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
437
438ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
439DEFAULT_JACK_ENABLED:=full
440else
441DEFAULT_JACK_ENABLED:=
442endif
443# call jack
444#
445# $(1): jack perf arguments
446define call-jack
447$(JACK) $(1)
448endef
449ifneq ($(ANDROID_JACK_VM_ARGS),)
450JACK_VM_ARGS := $(ANDROID_JACK_VM_ARGS)
451else
452JACK_VM_ARGS := -Dfile.encoding=UTF-8 -XX:+TieredCompilation
453endif
454ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
455DEFAULT_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
456else
457DEFAULT_JACK_EXTRA_ARGS := @$(BUILD_SYSTEM)/jack-default.args
458endif
459# Turn off jack warnings by default.
460DEFAULT_JACK_EXTRA_ARGS += --verbose error
461
462JILL := java -jar $(JILL_JAR)
463PROGUARD := external/proguard/bin/proguard.sh
464JAVATAGS := build/tools/java-event-log-tags.py
465LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc$(HOST_EXECUTABLE_SUFFIX)
466BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat$(HOST_EXECUTABLE_SUFFIX)
467LINT := prebuilts/sdk/tools/lint
468RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs
469APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
470VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
471BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
472BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
473FUTILITY := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/futility/futility
474VBOOT_SIGNER := prebuilts/misc/scripts/vboot_signer/vboot_signer.sh
475
476# ACP is always for the build OS, not for the host OS
477ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)
478
479# dx is java behind a shell script; no .exe necessary.
480DX := $(HOST_OUT_EXECUTABLES)/dx
481ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
482
483# relocation packer
484RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
485
486FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
487FINDBUGS := $(FINDBUGS_DIR)/findbugs
488EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
489
490# Tool to merge AndroidManifest.xmls
491ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge
492
493YACC_HEADER_SUFFIX:= .hpp
494
495# Don't use column under Windows, cygwin or not
496ifeq ($(HOST_OS),windows)
497COLUMN:= cat
498else
499COLUMN:= column
500endif
501
502HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
503
504ifneq ($(HOST_JDK_TOOLS_JAR),)
505ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
506$(error Error: could not find jdk tools.jar, please check if your JDK was installed correctly)
507endif
508endif
509
510# Is the host JDK 64-bit version?
511HOST_JDK_IS_64BIT_VERSION :=
512ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
513HOST_JDK_IS_64BIT_VERSION := true
514endif
515
516# It's called md5 on Mac OS and md5sum on Linux
517ifeq ($(HOST_OS),darwin)
518MD5SUM:=md5 -q
519else
520MD5SUM:=md5sum
521endif
522
523APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
524APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
525APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
526APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
527
528# The default key if not set as LOCAL_CERTIFICATE
529ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
530  DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
531else
532  DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
533endif
534
535# ###############################################################
536# Set up final options.
537# ###############################################################
538
539HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
540HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
541
542HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
543HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
544
545TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
546TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
547
548TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
549TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
550
551HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
552TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
553
554HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
555TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) \
556		$(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
557		$(TARGET_PRODUCT_KERNEL_HEADERS)
558
559# Many host compilers don't support these flags, so we have to make
560# sure to only specify them for the target compilers checked in to
561# the source tree.
562TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
563TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
564
565HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
566HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
567
568TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
569TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
570
571ifdef TARGET_2ND_ARCH
572$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
573$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
574$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
575$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
576$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
577$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
578$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
579$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
580$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
581$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
582endif
583
584ifdef HOST_2ND_ARCH
585$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
586$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
587$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
588$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
589$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS += -L$($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)
590$(HOST_2ND_ARCH_VAR_PREFIX)HOST_PROJECT_INCLUDES := $(HOST_PROJECT_INCLUDES)
591$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS)
592$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS)
593endif
594
595# allow overriding default Java libraries on a per-target basis
596ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),)
597  TARGET_DEFAULT_JAVA_LIBRARIES := core-libart core-junit ext framework
598endif
599
600# Flags for DEX2OAT
601DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
602ifeq ($(TARGET_CPU_VARIANT),)
603ifeq ($(TARGET_ARCH_VARIANT),)
604DEX2OAT_TARGET_CPU_VARIANT := default
605else
606DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
607endif
608else
609DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT)
610endif
611DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
612
613ifdef TARGET_2ND_ARCH
614$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
615$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_2ND_CPU_VARIANT)
616$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
617endif
618
619# define clang/llvm tools and global flags
620include $(BUILD_SYSTEM)/clang/config.mk
621
622# ###############################################################
623# Collect a list of the SDK versions that we could compile against
624# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
625# ###############################################################
626
627HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
628HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
629
630# The path where app can reference the support library resources.
631ifdef TARGET_BUILD_APPS
632SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
633else
634SUPPORT_LIBRARY_ROOT := frameworks/support
635endif
636
637# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
638# The 'current' version is whatever this source tree is.
639#
640# sgrax     is the opposite of xargs.  It takes the list of args and puts them
641#           on each line for sort to process.
642# sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
643
644# Numerically sort a list of numbers
645# $(1): the list of numbers to be sorted
646define numerically_sort
647$(shell function sgrax() { \
648    while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
649    } ; \
650    ( sgrax $(1) | sort -g ) )
651endef
652
653TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
654    $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
655    $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
656
657# We don't have prebuilt system_current SDK yet.
658TARGET_AVAILABLE_SDK_VERSIONS := $(TARGET_AVAILABLE_SDK_VERSIONS)
659
660INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
661INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
662INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt
663INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-removed.txt
664
665# This is the standard way to name a directory containing prebuilt target
666# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
667TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
668ifdef TARGET_2ND_ARCH
669TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
670endif
671
672# Set up RS prebuilt variables for compatibility library
673
674RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
675RS_PREBUILT_LIBPATH := -L prebuilts/ndk/8/platforms/android-9/arch-$(TARGET_ARCH)/usr/lib
676RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
677
678# API Level lists for Renderscript Compat lib.
679RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
680RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
681
682include $(BUILD_SYSTEM)/dumpvar.mk
683