blob: c8929958ce92b379c6d5fe976a1756d4b585767b [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# 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
Ying Wang6714dbc2010-03-30 16:42:15 -07006# Only use ANDROID_BUILD_SHELL to wrap around bash.
7# DO NOT use other shells such as zsh.
Ying Wang2ce495a2010-03-30 12:55:13 -07008ifdef ANDROID_BUILD_SHELL
9SHELL := $(ANDROID_BUILD_SHELL)
10else
The Android Open Source Project88b60792009-03-03 19:28:42 -080011# 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
Ying Wang2ce495a2010-03-30 12:55:13 -070015endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080016
Ying Wang157a5e12012-09-27 13:26:25 -070017# Utility variables.
18empty :=
19space := $(empty) $(empty)
20comma := ,
Ying Wang58a5db32014-10-03 11:36:27 -070021# Note that make will eat the newline just before endef.
22define newline
23
24
25endef
Ying Wang127da9e2015-09-22 14:37:53 -070026# The pound character "#"
27define pound
28#
29endef
Ying Wang58a5db32014-10-03 11:36:27 -070030# Unfortunately you can't simply define backslash as \ or \\.
31backslash := \a
32backslash := $(patsubst %a,%,$(backslash))
Ying Wang157a5e12012-09-27 13:26:25 -070033
Joe Onoratobc8abb62010-01-04 12:57:38 -080034# Tell python not to spam the source tree with .pyc files. This
35# only has an effect on python 2.6 and above.
36export PYTHONDONTWRITEBYTECODE := 1
37
Michael Wright9dca07e2016-01-18 18:13:03 -080038ifneq ($(filter --color=always, $(GREP_OPTIONS)),)
Ying Wangd9d01322015-05-18 11:15:06 -070039$(warning The build system needs unmodified output of grep.)
Michael Wright9dca07e2016-01-18 18:13:03 -080040$(error Please remove --color=always from your $$GREP_OPTIONS)
Ying Wangd9d01322015-05-18 11:15:06 -070041endif
42
The Android Open Source Project88b60792009-03-03 19:28:42 -080043# Standard source directories.
44SRC_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.
48SRC_HEADERS := \
49 $(TOPDIR)system/core/include \
Rom Lemarchand93dda7c2015-04-03 15:09:11 -070050 $(TOPDIR)system/media/audio/include \
The Android Open Source Project88b60792009-03-03 19:28:42 -080051 $(TOPDIR)hardware/libhardware/include \
52 $(TOPDIR)hardware/libhardware_legacy/include \
53 $(TOPDIR)hardware/ril/include \
Elliott Hughes89898df2012-05-03 16:37:40 -070054 $(TOPDIR)libnativehelper/include \
Mathias Agopianbd118e62012-03-05 16:04:31 -080055 $(TOPDIR)frameworks/native/include \
56 $(TOPDIR)frameworks/native/opengl/include \
James Dongc49ee712012-03-23 18:46:42 -070057 $(TOPDIR)frameworks/av/include \
Derek Sollenbergeraa426722014-02-27 14:02:37 -050058 $(TOPDIR)frameworks/base/include
The Android Open Source Project88b60792009-03-03 19:28:42 -080059SRC_HOST_HEADERS:=$(TOPDIR)tools/include
60SRC_LIBRARIES:= $(TOPDIR)libs
61SRC_SERVERS:= $(TOPDIR)servers
62SRC_TARGET_DIR := $(TOPDIR)build/target
Ying Wang19cc22b2012-12-04 15:07:34 -080063SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api
Ying Wang829f68b2014-06-26 17:54:28 -070064SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
Michael Wright0fb087f2015-11-06 15:20:51 +000065SRC_TEST_API_DIR := $(TOPDIR)prebuilts/sdk/test-api
The Android Open Source Project88b60792009-03-03 19:28:42 -080066
67# Some specific paths to tools
68SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
69
70# Various mappings to avoid hard-coding paths all over the place
71include $(BUILD_SYSTEM)/pathmap.mk
72
73# ###############################################################
74# Build system internal files
75# ###############################################################
76
77BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
78
79CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
80BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
81BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
82BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080083BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
84BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080085BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
86BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
Dima Zavinf625bf22010-09-16 00:25:16 -070087BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080088BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
89BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
90BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
91BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
92BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
93BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
94BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
95BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
Ying Wang4c681742010-07-20 11:08:47 -070096BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
Colin Cross52a341b2013-11-15 14:37:23 -080097BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk
Ying Wang4c681742010-07-20 11:08:47 -070098BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
Dan Albert36b6f042015-07-30 16:56:30 -070099BUILD_FUZZ_TEST := $(BUILD_SYSTEM)/fuzz_test.mk
100BUILD_HOST_FUZZ_TEST := $(BUILD_SYSTEM)/host_fuzz_test.mk
Christopher Ferris70ca5e52014-02-04 22:09:16 -0800101
102BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk
103BUILD_HOST_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/host_shared_test_lib.mk
104BUILD_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/static_test_lib.mk
105BUILD_HOST_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/host_static_test_lib.mk
106
Ying Wang13d69502012-11-01 17:22:33 -0700107BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk
Narayan Kamath0dd273a2013-10-28 13:20:52 +0000108BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk
109BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
110
The Android Open Source Project88b60792009-03-03 19:28:42 -0800111
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.
119SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
Ying Wangbb1da5e2015-07-28 17:57:45 -0700120hide := $(if $(SHOW_COMMANDS),,@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121
Ying Wanga1742612015-10-28 14:33:40 -0700122################################################################
123# Tools needed in product configuration makefiles.
124################################################################
125NORMALIZE_PATH := build/tools/normalize_path.py
126
127# $(1): the paths to be normalized
128define normalize-paths
129$(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
130endef
131
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# ###############################################################
133# Set common values
134# ###############################################################
135
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136# Set the extensions used for various packages
137COMMON_PACKAGE_SUFFIX := .zip
138COMMON_JAVA_PACKAGE_SUFFIX := .jar
139COMMON_ANDROID_PACKAGE_SUFFIX := .apk
140
Yohann Rousself528e132015-03-13 12:08:26 +0100141ifdef TMPDIR
142JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
143else
144JAVA_TMPDIR_ARG :=
145endif
146
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147# ###############################################################
148# Include sub-configuration files
149# ###############################################################
150
151# ---------------------------------------------------------------
152# Try to include buildspec.mk, which will try to set stuff up.
Brian Carlstrom1aeee8b2013-06-27 12:02:46 -0700153# If this file doesn't exist, the environment variables will
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154# be used, and if that doesn't work, then the default is an
155# arm build
Ying Wangd4495e92011-11-02 13:49:08 -0700156ifndef ANDROID_BUILDSPEC
157ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
158endif
159-include $(ANDROID_BUILDSPEC)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160
161# ---------------------------------------------------------------
162# Define most of the global variables. These are the ones that
163# are specific to the user's build configuration.
164include $(BUILD_SYSTEM)/envsetup.mk
165
C. Sean Youngcf469982015-06-09 12:35:45 -0500166# Pruned directory options used when using findleaves.py
167# See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
168FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(OUT_DIR) $(SCAN_EXCLUDE_DIRS) .repo .git)
169
Dima Zavin06e758a2012-03-30 10:45:38 -0700170# 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#
Dima Zavin4e16f962012-03-14 23:50:17 -0700207TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
208
Dima Zavinf9269902012-03-16 09:57:11 -0700209define 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)))
213endef
Dima Zavin4e16f962012-03-14 23:50:17 -0700214# 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.
218TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
219TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
Dima Zavinf9269902012-03-16 09:57:11 -0700220$(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
224TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
225TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
226$(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
Dima Zavin4e16f962012-03-14 23:50:17 -0700227
Patrick Scott87c86572009-06-23 15:25:06 -0400228# Clean up/verify variables defined by the board config file.
229TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
230TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
231ifeq ($(TARGET_CPU_ABI),)
232 $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
233endif
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800234TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
Patrick Scott87c86572009-06-23 15:25:06 -0400235
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900236# Commands to generate .toc file common to ELF .so files.
237define _gen_toc_command_for_elf
Shinichiro Hamajif0972f72015-11-05 12:51:08 +0900238$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
Shinichiro Hamaji2b0caa32016-01-06 15:13:25 +0900239$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) --dyn-syms $(1) | awk '{$$2=""; $$3=""; print}' >> $(2)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900240endef
241
242# Commands to generate .toc file from Darwin dynamic library.
243define _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)
246endef
247
The Android Open Source Project88b60792009-03-03 19:28:42 -0800248combo_target := HOST_
Ying Wange1d44c32013-12-27 11:09:36 -0800249combo_2nd_arch_prefix :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800250include $(BUILD_SYSTEM)/combo/select.mk
251
Ying Wang6feb6d52014-04-17 10:03:35 -0700252# Load the 2nd host arch if it's needed.
253ifdef HOST_2ND_ARCH
254combo_target := HOST_
255combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
256include $(BUILD_SYSTEM)/combo/select.mk
257endif
258
Dan Willemsen057aaea2015-08-14 12:59:50 -0700259# Load the windows cross compiler under Linux
260ifdef HOST_CROSS_OS
261combo_target := HOST_CROSS_
262combo_2nd_arch_prefix :=
263include $(BUILD_SYSTEM)/combo/select.mk
Dan Willemsen7e57b8c2016-02-05 16:20:19 -0800264
265ifdef HOST_CROSS_2ND_ARCH
266combo_target := HOST_CROSS_
267combo_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
268include $(BUILD_SYSTEM)/combo/select.mk
269endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700270endif
271
The Android Open Source Project88b60792009-03-03 19:28:42 -0800272# on windows, the tools have .exe at the end, and we depend on the
273# host config stuff being done first
274
275combo_target := TARGET_
Ying Wange1d44c32013-12-27 11:09:36 -0800276combo_2nd_arch_prefix :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800277include $(BUILD_SYSTEM)/combo/select.mk
278
Ying Wange1d44c32013-12-27 11:09:36 -0800279# Load the 2nd target arch if it's needed.
280ifdef TARGET_2ND_ARCH
281combo_target := TARGET_
282combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
283include $(BUILD_SYSTEM)/combo/select.mk
284endif
285
Ying Wang57d90602015-07-20 18:40:18 -0700286include $(BUILD_SYSTEM)/ccache.mk
Shinichiro Hamajiee482fd2015-08-17 17:38:24 +0900287include $(BUILD_SYSTEM)/goma.mk
Ying Wang57d90602015-07-20 18:40:18 -0700288
Colin Crossa3339e92014-04-30 18:09:13 -0700289ifdef TARGET_PREFER_32_BIT
290TARGET_PREFER_32_BIT_APPS := true
291TARGET_PREFER_32_BIT_EXECUTABLES := true
292endif
293
Colin Cross2a4f0ff2014-04-30 18:18:02 -0700294ifeq (,$(TARGET_SUPPORTS_32_BIT_APPS)$(TARGET_SUPPORTS_64_BIT_APPS))
295 TARGET_SUPPORTS_32_BIT_APPS := true
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100296endif
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
Brian Carlstromd7950462014-06-16 16:51:42 -0700306# be overriden in the board configuration.
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100307ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
Colin Cross2a4f0ff2014-04-30 18:18:02 -0700308 ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100309 TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
310 endif
311endif
312
313ifeq (,$(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
Colin Cross2a4f0ff2014-04-30 18:18:02 -0700317 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
323endif
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.
329ifeq (,$(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)
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100334 endif
335endif
336
337# Strip whitespace from the ABI list string.
338TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
339TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
340TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
341
Ying Wangdf2b4b32012-01-12 16:38:17 -0800342# Compute TARGET_TOOLCHAIN_ROOT from TARGET_TOOLS_PREFIX
343# if only TARGET_TOOLS_PREFIX is passed to the make command.
344ifndef TARGET_TOOLCHAIN_ROOT
345TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLS_PREFIX)))
346TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT)))
347TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT))
348endif
349
Andrew Hsieh906cb782013-09-10 17:37:14 +0800350# Normalize WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK
351ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
352 WITH_STATIC_ANALYZER :=
353endif
354ifeq ($(strip $(WITH_SYNTAX_CHECK)),0)
355 WITH_SYNTAX_CHECK :=
356endif
357
Chih-Hung Hsieh71d8cbd2016-02-02 11:30:39 -0800358# define clang/llvm versions and base directory.
359include $(BUILD_SYSTEM)/clang/versions.mk
360
Andrew Hsieh906cb782013-09-10 17:37:14 +0800361# Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
Chih-Hung Hsieh71d8cbd2016-02-02 11:30:39 -0800362SYNTAX_TOOLS_PREFIX := \
363 $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/tools/scan-build/libexec
Andrew Hsieh906cb782013-09-10 17:37:14 +0800364ifneq ($(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
369endif
Andrew Hsiehe7c2d142013-08-27 17:55:46 +0800370
Andrew Hsieh906cb782013-09-10 17:37:14 +0800371# WITH_STATIC_ANALYZER trumps WITH_SYNTAX_CHECK
372ifneq ($(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
377endif
378
The Android Open Source Project88b60792009-03-03 19:28:42 -0800379# Pick a Java compiler.
380include $(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
388ifeq (,$(strip $(CALLED_FROM_SETUP)))
389ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
390ifneq ($(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..)
399endif
400endif
401endif
402
Colin Cross6b66fcf2016-01-26 15:59:50 -0800403# Set up PDK so we can use TARGET_BUILD_PDK to select prebuilt tools below
404.PHONY: pdk fusion
405pdk 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.
421ifndef 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))
430ifneq (,$(_pdk_fusion_default_platform_zip))
431PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
432TARGET_BUILD_PDK := true
433endif # _pdk_fusion_default_platform_zip
434endif # !PDK_FUSION_PLATFORM_ZIP
435
436ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
437TARGET_BUILD_PDK := true
438ifneq (,$(filter fusion, $(MAKECMDGOALS)))
439ifndef PDK_FUSION_PLATFORM_ZIP
440 $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.)
441endif
442endif # fusion
443endif # pdk or fusion
444
445ifdef PDK_FUSION_PLATFORM_ZIP
446TARGET_BUILD_PDK := true
447ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
448 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
449endif
450endif
451
Ying Wang3a61eeb2016-03-11 10:32:01 -0800452BUILD_PLATFORM_ZIP := $(filter platform platform-java,$(MAKECMDGOALS))
453
Colin Crossfd082472015-12-02 16:33:04 -0800454#
455# Tools that are prebuilts for TARGET_BUILD_APPS
456#
457
458ACP := $(HOST_OUT_EXECUTABLES)/acp
459AIDL := $(HOST_OUT_EXECUTABLES)/aidl
460AAPT := $(HOST_OUT_EXECUTABLES)/aapt
Ying Wangdd71c852015-12-04 13:59:18 -0800461AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
Colin Crossfd082472015-12-02 16:33:04 -0800462ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign
463SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
Alex Klyubin9667b182015-12-10 13:38:50 -0800464SIGNAPK_JNI_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
Colin Crossfd082472015-12-02 16:33:04 -0800465LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
466BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
467
468DX := $(HOST_OUT_EXECUTABLES)/dx
469MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses
470
Colin Crossd3f3ab72016-01-20 16:08:49 -0800471USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
472
Colin Crossfd082472015-12-02 16:33:04 -0800473# Override the definitions above for unbundled and PDK builds
474ifneq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)))
475prebuilt_sdk_tools := prebuilts/sdk/tools
476prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
477
478ACP := $(prebuilt_sdk_tools_bin)/acp
479AIDL := $(prebuilt_sdk_tools_bin)/aidl
480AAPT := $(prebuilt_sdk_tools_bin)/aapt
Ying Wangdd71c852015-12-04 13:59:18 -0800481AAPT2 := $(prebuilt_sdk_tools_bin)/aapt2
Colin Crossfd082472015-12-02 16:33:04 -0800482ZIPALIGN := $(prebuilt_sdk_tools_bin)/zipalign
483SIGNAPK_JAR := $(prebuilt_sdk_tools)/lib/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
Alex Klyubin9667b182015-12-10 13:38:50 -0800484# Use 64-bit libraries unconditionally because 32-bit JVMs are no longer supported
485SIGNAPK_JNI_LIBRARY_PATH := $(prebuilt_sdk_tools)/$(HOST_OS)/lib64
Colin Crossfd082472015-12-02 16:33:04 -0800486
487DX := $(prebuilt_sdk_tools)/dx
488MAINDEXCLASSES := $(prebuilt_sdk_tools)/mainDexClasses
489
490# Don't use prebuilts in PDK
491ifneq ($(TARGET_BUILD_PDK),true)
492LLVM_RS_CC := $(prebuilt_sdk_tools_bin)/llvm-rs-cc
493BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
494endif # TARGET_BUILD_PDK
495endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
496
The Android Open Source Project88b60792009-03-03 19:28:42 -0800497
498# ---------------------------------------------------------------
499# Generic tools.
Yohann Rousselabee3a92015-03-10 16:50:55 +0100500JACK := $(HOST_OUT_EXECUTABLES)/jack
The Android Open Source Project88b60792009-03-03 19:28:42 -0800501
Ying Wang63741532014-05-16 09:37:23 -0700502LEX := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/flex/flex-2.5.39
Ying Wang854be682013-04-05 18:02:16 -0700503# 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.
507BISON_PKGDATADIR := $(PWD)/external/bison/data
Ying Wang6feb6d52014-04-17 10:03:35 -0700508BISON := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/bison/bison
Ying Wang854be682013-04-05 18:02:16 -0700509YACC := $(BISON) -d
510
Ying Wang7b913ce2014-06-05 19:05:47 -0700511YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
512
The Android Open Source Project88b60792009-03-03 19:28:42 -0800513DOXYGEN:= doxygen
Christopher Wiley2df75d12015-10-14 17:27:24 -0700514AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX)
Steve Fungcb2e67f2015-09-24 01:40:52 -0700515ifeq ($(HOST_OS),linux)
516BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
517else
518# For non-supported hosts, do not generate breakpad symbols.
519BREAKPAD_GENERATE_SYMBOLS := false
520endif
Wink Savillee7890832010-11-05 11:28:51 -0700521PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
Christopher Wileybc2be462015-07-29 17:14:24 -0700522DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700524MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
Bjorn Andersson612e2cd2012-11-25 16:53:44 -0800525ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800526MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
Bjorn Andersson612e2cd2012-11-25 16:53:44 -0800527else
528MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
529endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800530APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
531FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
Colin Cross9dd4ba82010-08-03 14:43:15 -0700532MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
Mohamad Ayyashf8765552016-03-02 21:07:23 -0800533BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX)
Ying Wang542903a2010-11-17 15:40:38 -0800534MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
Mohamad Ayyash68946952015-03-03 12:30:37 -0800535MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
536MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700537MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
538MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
Ying Wang69e9b4d2012-11-26 18:10:23 -0800539SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
Mohamad Ayyash353265b2015-06-24 15:42:19 -0700540IMG2SIMG := $(HOST_OUT_EXECUTABLES)/img2simg$(HOST_EXECUTABLE_SUFFIX)
Ying Wang69e9b4d2012-11-26 18:10:23 -0800541E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542MKTARBALL := build/tools/mktarball.sh
Colin Cross0a7b2c52010-05-07 02:23:59 -0700543TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
544E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
Steve Howardef5c6402010-05-03 15:01:38 -0700545JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
Ying Wanged0361f2015-04-19 09:55:39 -0700546DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
Yohann Roussel28096662015-02-02 12:18:20 +0100547
Yohann Roussel37822c42015-01-09 10:36:40 +0100548ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
549DEFAULT_JACK_ENABLED:=full
550else
551DEFAULT_JACK_ENABLED:=
552endif
Yohann Roussele163b4e2015-04-09 10:10:21 +0000553ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
554DEFAULT_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
555else
Yohann Rousselb6bfb582015-05-13 16:03:28 +0200556DEFAULT_JACK_EXTRA_ARGS := @$(BUILD_SYSTEM)/jack-default.args
Yohann Roussele163b4e2015-04-09 10:10:21 +0000557endif
Yohann Rousselec46a3b2015-03-05 18:35:05 +0100558# Turn off jack warnings by default.
559DEFAULT_JACK_EXTRA_ARGS += --verbose error
Yohann Rousself528e132015-03-13 12:08:26 +0100560
Joe Onorato2daa2b32009-08-30 13:39:24 -0700561PROGUARD := external/proguard/bin/proguard.sh
Doug Zongker9bd49622009-11-30 14:28:59 -0800562JAVATAGS := build/tools/java-event-log-tags.py
Ying Wanga3b75932013-08-14 16:59:00 -0700563RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs
Colin Cross8a30f722014-04-28 16:27:32 -0700564APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
565VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
Colin Cross477cf2b2014-04-16 18:49:56 -0700566BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
Geremy Condra740b6632014-07-08 20:07:41 -0700567BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
David Riley17be3d32015-03-03 08:54:11 -0800568FUTILITY := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/futility/futility
569VBOOT_SIGNER := prebuilts/misc/scripts/vboot_signer/vboot_signer.sh
Sami Tolvanenf99b5312015-05-20 07:30:57 +0100570FEC := $(HOST_OUT_EXECUTABLES)/fec
The Android Open Source Project88b60792009-03-03 19:28:42 -0800571
Dan Willemsena25ddad2015-11-03 16:09:49 -0800572ifndef TARGET_BUILD_APPS
Dan Willemsen48a621c2015-10-29 16:33:05 -0700573ZIPTIME := $(HOST_OUT_EXECUTABLES)/ziptime$(HOST_EXECUTABLE_SUFFIX)
Dan Willemsena25ddad2015-11-03 16:09:49 -0800574endif
Dmitriy Ivanov4c2d1a62015-04-20 16:59:05 -0700575
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900576# ijar converts a .jar file to a smaller .jar file which only has its
577# interfaces.
578IJAR := $(HOST_OUT_EXECUTABLES)/ijar$(BUILD_EXECUTABLE_SUFFIX)
Shinichiro Hamajif972a4a2015-12-09 18:06:20 +0900579DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump2$(BUILD_EXECUTABLE_SUFFIX)
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900580
Dmitriy Ivanov4c2d1a62015-04-20 16:59:05 -0700581# relocation packer
582RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
583
Yuncheol Heo623d7062014-05-20 17:04:16 +0900584FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
585FINDBUGS := $(FINDBUGS_DIR)/findbugs
The Android Open Source Project88b60792009-03-03 19:28:42 -0800586EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
587
Ying Wangdc7fee92014-02-05 18:24:45 -0800588# Tool to merge AndroidManifest.xmls
589ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge
590
The Android Open Source Project88b60792009-03-03 19:28:42 -0800591COLUMN:= column
The Android Open Source Project88b60792009-03-03 19:28:42 -0800592
Ying Wang7fcd2f92015-11-02 15:56:58 -0800593# We may not have the right JAVA_HOME/PATH set up yet when this is run from envsetup.sh.
594ifneq ($(CALLED_FROM_SETUP),true)
Narayan Kamathab2e2e72013-12-05 15:20:41 +0000595HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
Narayan Kamathab2e2e72013-12-05 15:20:41 +0000596
597ifneq ($(HOST_JDK_TOOLS_JAR),)
Ying Wangec5e7292010-04-26 18:36:52 -0700598ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
Colin Cross112753c2015-10-23 14:33:51 -0700599$(error Error: could not find jdk tools.jar at $(HOST_JDK_TOOLS_JAR), please check if your JDK was installed correctly)
Ying Wangec5e7292010-04-26 18:36:52 -0700600endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601endif
602
Ying Wang053dccb2011-05-24 15:46:15 -0700603# Is the host JDK 64-bit version?
604HOST_JDK_IS_64BIT_VERSION :=
605ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
606HOST_JDK_IS_64BIT_VERSION := true
607endif
Ying Wang7fcd2f92015-11-02 15:56:58 -0800608endif # CALLED_FROM_SETUP not true
Ying Wang053dccb2011-05-24 15:46:15 -0700609
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610# It's called md5 on Mac OS and md5sum on Linux
611ifeq ($(HOST_OS),darwin)
612MD5SUM:=md5 -q
613else
614MD5SUM:=md5sum
615endif
616
Joe Onorato2a6e0522011-04-08 17:32:52 -0700617APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
618APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
619APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
620APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
621
Ying Wang3c21fe52011-10-04 10:50:08 -0700622# The default key if not set as LOCAL_CERTIFICATE
623ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
624 DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
625else
626 DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
627endif
628
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629# ###############################################################
630# Set up final options.
631# ###############################################################
632
Dan Willemsen93b8a122015-12-16 13:10:35 -0800633ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
634$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
635$(info *** Device configurations are no longer allowed to change the global flags.)
636$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
637$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
638$(error bailing...)
639endif
640
641# These can be changed to modify both host and device modules.
642COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
643COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
644
645# Force gcc to always output color diagnostics. Ninja will strip the ANSI
646# color codes if it is not running in a terminal.
Colin Crossdbd43842016-01-04 14:31:25 -0800647ifdef BUILDING_WITH_NINJA
Dan Willemsen93b8a122015-12-16 13:10:35 -0800648COMMON_GLOBAL_CFLAGS += -fdiagnostics-color
Colin Crossdbd43842016-01-04 14:31:25 -0800649endif
Dan Willemsen93b8a122015-12-16 13:10:35 -0800650
651COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
652COMMON_RELEASE_CPPFLAGS:=
653
654GLOBAL_CFLAGS_NO_OVERRIDE := \
655 -Werror=int-to-pointer-cast \
656 -Werror=pointer-to-int-cast \
657
658GLOBAL_CLANG_CFLAGS_NO_OVERRIDE := \
659 -Werror=address-of-temporary \
660 -Werror=null-dereference \
661 -Werror=return-type \
662
663GLOBAL_CPPFLAGS_NO_OVERRIDE :=
664
665# list of flags to turn specific warnings in to errors
Dan Willemseneff06112016-01-06 14:27:53 -0800666TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time
Dan Willemsen93b8a122015-12-16 13:10:35 -0800667
668# We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
669# from the debug output. That way two builds in two different
670# directories will create the same output.
671# /proc doesn't exist on Darwin.
672ifeq ($(HOST_OS),linux)
673RELATIVE_PWD := PWD=/proc/self/cwd
674# Remove this useless prefix from the debug output.
675COMMON_GLOBAL_CFLAGS += -fdebug-prefix-map=/proc/self/cwd=
676else
677RELATIVE_PWD :=
678endif
679
680# Allow the C/C++ macros __DATE__ and __TIME__ to be set to the
681# build date and time, so that a build may be repeated.
682# Write the date and time to a file so that the command line
683# doesn't change every time, which would cause ninja to rebuild
684# the files.
685$(shell mkdir -p $(OUT_DIR) && \
686 $(DATE) "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
687 $(DATE) +%T > $(OUT_DIR)/build_c_time.txt)
688BUILD_DATETIME_C_DATE := $$(cat $(OUT_DIR)/build_c_date.txt)
689BUILD_DATETIME_C_TIME := $$(cat $(OUT_DIR)/build_c_time.txt)
690ifeq ($(OVERRIDE_C_DATE_TIME),true)
691COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
692endif
693
The Android Open Source Project88b60792009-03-03 19:28:42 -0800694HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800695HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
696
697HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800698HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
699
700TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800701TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
702
703TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800704TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
705
706HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
707TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
708
709HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
Dima Zavin4e16f962012-03-14 23:50:17 -0700710TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) \
Dima Zavin8e4042c2012-03-30 10:24:31 -0700711 $(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
712 $(TARGET_PRODUCT_KERNEL_HEADERS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800713
714# Many host compilers don't support these flags, so we have to make
715# sure to only specify them for the target compilers checked in to
Jeff Browne33ba4c2011-07-11 22:11:46 -0700716# the source tree.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800717TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800718
Dave Bort95282482009-04-23 18:44:55 -0700719HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
720HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800721
Dave Bort95282482009-04-23 18:44:55 -0700722TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
723TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800724
Ying Wange1d44c32013-12-27 11:09:36 -0800725ifdef TARGET_2ND_ARCH
Ying Wang9fb35262014-02-21 16:17:05 -0800726$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
727$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
728$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
729$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
730$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
731$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
732$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
Ying Wang9fb35262014-02-21 16:17:05 -0800733$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
734$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
Ying Wange1d44c32013-12-27 11:09:36 -0800735endif
736
Ying Wang6feb6d52014-04-17 10:03:35 -0700737ifdef HOST_2ND_ARCH
738$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
739$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
740$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
741$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
742$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS += -L$($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)
743$(HOST_2ND_ARCH_VAR_PREFIX)HOST_PROJECT_INCLUDES := $(HOST_PROJECT_INCLUDES)
744$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS)
745$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS)
746endif
747
Dan Willemsen057aaea2015-08-14 12:59:50 -0700748ifdef HOST_CROSS_OS
Colin Cross12adaf52015-10-02 15:17:47 -0700749HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $(HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
Dan Willemsen057aaea2015-08-14 12:59:50 -0700750HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
751HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
752HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
753HOST_CROSS_GLOBAL_LD_DIRS += -L$(HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
754HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_CROSS_OUT_HEADERS)
755HOST_CROSS_GLOBAL_CFLAGS += $(HOST_CROSS_RELEASE_CFLAGS)
756HOST_CROSS_GLOBAL_CPPFLAGS += $(HOST_CROSS_RELEASE_CPPFLAGS)
Dan Willemsen7e57b8c2016-02-05 16:20:19 -0800757
758ifdef HOST_CROSS_2ND_ARCH
759$(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))
760$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
761$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
762$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
763$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_LD_DIRS += -L$($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
764$(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)
765$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS)
766$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS)
767endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700768endif
769
Dan Willemsende6494b2015-12-16 15:04:51 -0800770ifdef BRILLO
771# Add a C define that identifies Brillo targets. __BRILLO__ should only be used
772# to differentiate between Brillo and non-Brillo-but-Android environments. Use
773# __ANDROID__ instead to test if something is being built in an Android-derived
774# environment (including Brillo) as opposed to an entirely different
775# environment (e.g. Chrome OS).
776TARGET_GLOBAL_CFLAGS += -D__BRILLO__
777ifdef TARGET_2ND_ARCH
778$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += -D__BRILLO__
779endif
780endif
781
Mike Lockwoodc73018c2013-08-06 16:07:13 -0700782# allow overriding default Java libraries on a per-target basis
783ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),)
Piotr Jastrzebski89b94c82015-02-17 16:55:52 +0000784 TARGET_DEFAULT_JAVA_LIBRARIES := core-oj core-libart core-junit ext framework okhttp
Mike Lockwoodc73018c2013-08-06 16:07:13 -0700785endif
786
Ian Rogers5d186ae2014-04-18 15:23:40 -0700787# Flags for DEX2OAT
Andreas Gampe847b00b2015-10-15 20:43:29 -0700788first_non_empty_of_three = $(if $(1),$(1),$(if $(2),$(2),$(3)))
Ian Rogers5d186ae2014-04-18 15:23:40 -0700789DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
Andreas Gampe847b00b2015-10-15 20:43:29 -0700790DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT),$(TARGET_ARCH_VARIANT),default)
Ying Wang8c7e74e2014-03-20 12:13:10 -0700791DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
Ying Wang8c7e74e2014-03-20 12:13:10 -0700792
Ying Wangb9aa5d42014-05-13 13:57:28 -0700793ifdef TARGET_2ND_ARCH
794$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
Andreas Gampe847b00b2015-10-15 20:43:29 -0700795$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT),$(TARGET_2ND_ARCH_VARIANT),default)
Ying Wangb9aa5d42014-05-13 13:57:28 -0700796$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
Ying Wangb9aa5d42014-05-13 13:57:28 -0700797endif
798
Ying Wang1f982832014-02-06 18:08:44 -0800799# define clang/llvm tools and global flags
800include $(BUILD_SYSTEM)/clang/config.mk
yroussel13190052012-01-12 16:09:06 +0100801
The Android Open Source Project88b60792009-03-03 19:28:42 -0800802# ###############################################################
803# Collect a list of the SDK versions that we could compile against
804# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
805# ###############################################################
806
Ying Wang9978faf2011-11-29 10:24:27 -0800807HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
Ying Wangb50bd7f2011-11-29 11:20:16 -0800808HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700809
Ying Wang589e8c52015-05-19 16:03:57 -0700810# The path where app can reference the support library resources.
811ifdef TARGET_BUILD_APPS
812SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
813else
814SUPPORT_LIBRARY_ROOT := frameworks/support
815endif
816
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700817# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
818# The 'current' version is whatever this source tree is.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800819#
820# sgrax is the opposite of xargs. It takes the list of args and puts them
821# on each line for sort to process.
822# sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800823
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700824# Numerically sort a list of numbers
825# $(1): the list of numbers to be sorted
826define numerically_sort
827$(shell function sgrax() { \
828 while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
829 } ; \
830 ( sgrax $(1) | sort -g ) )
831endef
832
Ying Wanga1ff6292012-05-10 18:07:33 -0700833TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700834 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
Ying Wang2f7b92c2014-07-21 13:44:06 -0700835 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
836
Michael Wright0fb087f2015-11-06 15:20:51 +0000837# We don't have prebuilt test_current SDK yet.
838TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800839
Joe Onorato15ee93b2011-04-08 15:03:48 -0700840INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
Hui Shue8af17e2014-02-21 14:18:19 -0800841INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
Ying Wang829f68b2014-06-26 17:54:28 -0700842INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt
843INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-removed.txt
Michael Wright0fb087f2015-11-06 15:20:51 +0000844INTERNAL_PLATFORM_TEST_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-api.txt
845INTERNAL_PLATFORM_TEST_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-removed.txt
Gary King1e80c292010-03-08 17:16:57 -0800846
Bruce Bearef1582e52010-10-14 14:31:48 -0700847# This is the standard way to name a directory containing prebuilt target
848# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
Jeff Browne33ba4c2011-07-11 22:11:46 -0700849TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
Colin Cross12d18eb2014-05-22 12:01:23 -0700850ifdef TARGET_2ND_ARCH
851TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
852endif
Bruce Bearef1582e52010-10-14 14:31:48 -0700853
Tim Murray1a6f09a2013-03-05 11:07:15 -0800854# Set up RS prebuilt variables for compatibility library
855
Tim Murraydc1d0ab2014-09-30 15:08:03 -0700856RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
Tim Murray1a6f09a2013-03-05 11:07:15 -0800857RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
Miao Wang302e9442015-07-28 17:43:51 -0700858ifeq (true,$(TARGET_IS_64_BIT))
Miao Wang57ef7ea2016-03-30 13:29:42 -0700859RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib64 \
860 -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib
Miao Wang302e9442015-07-28 17:43:51 -0700861else
Stephen Hinesba2355c2015-09-30 22:32:05 -0700862RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-9/arch-$(TARGET_ARCH)/usr/lib
Miao Wang302e9442015-07-28 17:43:51 -0700863endif
Tim Murray1a6f09a2013-03-05 11:07:15 -0800864
Miao Wange4359cf2015-01-07 18:18:41 -0800865# API Level lists for Renderscript Compat lib.
866RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
Miao Wangec27a892014-11-20 11:05:18 -0800867RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
Miao Wange4359cf2015-01-07 18:18:41 -0800868
Ying Wang854be682013-04-05 18:02:16 -0700869include $(BUILD_SYSTEM)/dumpvar.mk