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