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
6ifndef KATI
7$(warning Directly using config.mk from make is no longer supported.)
8$(warning )
9$(warning If you are just attempting to build, you probably need to re-source envsetup.sh:)
10$(warning )
11$(warning $$ source build/envsetup.sh)
12$(warning )
13$(warning If you are attempting to emulate get_build_var, use one of the following:)
14$(warning $$ build/soong/soong_ui.bash --dumpvar-mode)
15$(warning $$ build/soong/soong_ui.bash --dumpvars-mode)
16$(warning )
17$(error done)
18endif
19
20BUILD_SYSTEM :=$= build/make/core
21BUILD_SYSTEM_COMMON :=$= build/make/common
22
23include $(BUILD_SYSTEM_COMMON)/core.mk
24
25# Mark variables that should be coming as environment variables from soong_ui
26# as readonly
27.KATI_READONLY := OUT_DIR TMPDIR BUILD_DATETIME_FILE
28ifdef CALLED_FROM_SETUP
29  .KATI_READONLY := CALLED_FROM_SETUP
30endif
31ifdef KATI_PACKAGE_MK_DIR
32  .KATI_READONLY := KATI_PACKAGE_MK_DIR
33endif
34
35# Mark variables deprecated/obsolete
36CHANGES_URL := https://android.googlesource.com/platform/build/+/master/Changes.md
37.KATI_READONLY := CHANGES_URL
38$(KATI_obsolete_var PATH,Do not use PATH directly. See $(CHANGES_URL)#PATH)
39$(KATI_obsolete_var PYTHONPATH,Do not use PYTHONPATH directly. See $(CHANGES_URL)#PYTHONPATH)
40$(KATI_obsolete_var OUT,Use OUT_DIR instead. See $(CHANGES_URL)#OUT)
41$(KATI_obsolete_var ANDROID_HOST_OUT,Use HOST_OUT instead. See $(CHANGES_URL)#ANDROID_HOST_OUT)
42$(KATI_obsolete_var ANDROID_PRODUCT_OUT,Use PRODUCT_OUT instead. See $(CHANGES_URL)#ANDROID_PRODUCT_OUT)
43$(KATI_obsolete_var ANDROID_HOST_OUT_TESTCASES,Use HOST_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_HOST_OUT_TESTCASES)
44$(KATI_obsolete_var ANDROID_TARGET_OUT_TESTCASES,Use TARGET_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_TARGET_OUT_TESTCASES)
45$(KATI_obsolete_var ANDROID_BUILD_TOP,Use '.' instead. See $(CHANGES_URL)#ANDROID_BUILD_TOP)
46$(KATI_obsolete_var \
47  ANDROID_TOOLCHAIN \
48  ANDROID_TOOLCHAIN_2ND_ARCH \
49  ANDROID_DEV_SCRIPTS \
50  ANDROID_EMULATOR_PREBUILTS \
51  ANDROID_PRE_BUILD_PATHS \
52  ,See $(CHANGES_URL)#other_envsetup_variables)
53$(KATI_obsolete_var PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE,Set FCM Version in device manifest instead. See $(CHANGES_URL)#PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE)
54$(KATI_obsolete_var USE_CLANG_PLATFORM_BUILD,Clang is the only supported Android compiler. See $(CHANGES_URL)#USE_CLANG_PLATFORM_BUILD)
55$(KATI_obsolete_var BUILD_DROIDDOC,Droiddoc is only supported in Soong. See details on build/soong/java/droiddoc.go)
56$(KATI_obsolete_var BUILD_APIDIFF,Apidiff is only supported in Soong. See details on build/soong/java/droiddoc.go)
57$(KATI_obsolete_var \
58  DEFAULT_GCC_CPP_STD_VERSION \
59  HOST_GLOBAL_CFLAGS 2ND_HOST_GLOBAL_CFLAGS \
60  HOST_GLOBAL_CONLYFLAGS 2ND_HOST_GLOBAL_CONLYFLAGS \
61  HOST_GLOBAL_CPPFLAGS 2ND_HOST_GLOBAL_CPPFLAGS \
62  HOST_GLOBAL_LDFLAGS 2ND_HOST_GLOBAL_LDFLAGS \
63  HOST_GLOBAL_LLDFLAGS 2ND_HOST_GLOBAL_LLDFLAGS \
64  HOST_CLANG_SUPPORTED 2ND_HOST_CLANG_SUPPORTED \
65  HOST_CC 2ND_HOST_CC \
66  HOST_CXX 2ND_HOST_CXX \
67  HOST_CROSS_GLOBAL_CFLAGS 2ND_HOST_CROSS_GLOBAL_CFLAGS \
68  HOST_CROSS_GLOBAL_CONLYFLAGS 2ND_HOST_CROSS_GLOBAL_CONLYFLAGS \
69  HOST_CROSS_GLOBAL_CPPFLAGS 2ND_HOST_CROSS_GLOBAL_CPPFLAGS \
70  HOST_CROSS_GLOBAL_LDFLAGS 2ND_HOST_CROSS_GLOBAL_LDFLAGS \
71  HOST_CROSS_GLOBAL_LLDFLAGS 2ND_HOST_CROSS_GLOBAL_LLDFLAGS \
72  HOST_CROSS_CLANG_SUPPORTED 2ND_HOST_CROSS_CLANG_SUPPORTED \
73  HOST_CROSS_CC 2ND_HOST_CROSS_CC \
74  HOST_CROSS_CXX 2ND_HOST_CROSS_CXX \
75  TARGET_GLOBAL_CFLAGS 2ND_TARGET_GLOBAL_CFLAGS \
76  TARGET_GLOBAL_CONLYFLAGS 2ND_TARGET_GLOBAL_CONLYFLAGS \
77  TARGET_GLOBAL_CPPFLAGS 2ND_TARGET_GLOBAL_CPPFLAGS \
78  TARGET_GLOBAL_LDFLAGS 2ND_TARGET_GLOBAL_LDFLAGS \
79  TARGET_GLOBAL_LLDFLAGS 2ND_TARGET_GLOBAL_LLDFLAGS \
80  TARGET_CLANG_SUPPORTED 2ND_TARGET_CLANG_SUPPORTED \
81  TARGET_CC 2ND_TARGET_CC \
82  TARGET_CXX 2ND_TARGET_CXX \
83  TARGET_TOOLCHAIN_ROOT 2ND_TARGET_TOOLCHAIN_ROOT \
84  HOST_TOOLCHAIN_ROOT 2ND_HOST_TOOLCHAIN_ROOT \
85  HOST_CROSS_TOOLCHAIN_ROOT 2ND_HOST_CROSS_TOOLCHAIN_ROOT \
86  HOST_TOOLS_PREFIX 2ND_HOST_TOOLS_PREFIX \
87  HOST_CROSS_TOOLS_PREFIX 2ND_HOST_CROSS_TOOLS_PREFIX \
88  HOST_GCC_VERSION 2ND_HOST_GCC_VERSION \
89  HOST_CROSS_GCC_VERSION 2ND_HOST_CROSS_GCC_VERSION \
90  TARGET_NDK_GCC_VERSION 2ND_TARGET_NDK_GCC_VERSION \
91  GLOBAL_CFLAGS_NO_OVERRIDE GLOBAL_CPPFLAGS_NO_OVERRIDE \
92  ,GCC support has been removed. Use Clang instead)
93$(KATI_obsolete_var DIST_DIR dist_goal,Use dist-for-goals instead. See $(CHANGES_URL)#dist)
94$(KATI_obsolete_var TARGET_ANDROID_FILESYSTEM_CONFIG_H,Use TARGET_FS_CONFIG_GEN instead)
95$(KATI_deprecated_var USER,Use BUILD_USERNAME instead. See $(CHANGES_URL)#USER)
96$(KATI_obsolete_var TARGET_ROOT_OUT_SBIN,/sbin has been removed, use /system/bin instead)
97$(KATI_obsolete_var TARGET_ROOT_OUT_SBIN_UNSTRIPPED,/sbin has been removed, use /system/bin instead)
98$(KATI_obsolete_var BUILD_BROKEN_PHONY_TARGETS)
99$(KATI_obsolete_var BUILD_BROKEN_DUP_COPY_HEADERS)
100$(KATI_obsolete_var BUILD_BROKEN_ENG_DEBUG_TAGS)
101$(KATI_obsolete_export It is a global setting. See $(CHANGES_URL)#export_keyword)
102$(KATI_obsolete_var BUILD_BROKEN_ANDROIDMK_EXPORTS)
103$(KATI_obsolete_var PRODUCT_STATIC_BOOT_CONTROL_HAL,Use shared library module instead. See $(CHANGES_URL)#PRODUCT_STATIC_BOOT_CONTROL_HAL)
104$(KATI_obsolete_var \
105  ARCH_ARM_HAVE_ARMV7A \
106  ARCH_DSP_REV \
107  ARCH_HAVE_ALIGNED_DOUBLES \
108  ARCH_MIPS_HAS_DSP \
109  ARCH_MIPS_HAS_FPU \
110  ARCH_MIPS_REV6 \
111  ARCH_X86_HAVE_AES_NI \
112  ARCH_X86_HAVE_AVX \
113  ARCH_X86_HAVE_AVX2 \
114  ARCH_X86_HAVE_AVX512 \
115  ARCH_X86_HAVE_MOVBE \
116  ARCH_X86_HAVE_POPCNT \
117  ARCH_X86_HAVE_SSE4 \
118  ARCH_X86_HAVE_SSE4_2 \
119  ARCH_X86_HAVE_SSSE3 \
120)
121$(KATI_obsolete_var PRODUCT_IOT)
122$(KATI_obsolete_var MD5SUM)
123$(KATI_obsolete_var BOARD_HAL_STATIC_LIBRARIES, See $(CHANGES_URL)#BOARD_HAL_STATIC_LIBRARIES)
124$(KATI_obsolete_var LOCAL_HAL_STATIC_LIBRARIES, See $(CHANGES_URL)#BOARD_HAL_STATIC_LIBRARIES)
125$(KATI_obsolete_var PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_WHITELIST,Use PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST.)
126$(KATI_obsolete_var PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST,Use PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST.)
127
128# Used to force goals to build.  Only use for conditionally defined goals.
129.PHONY: FORCE
130FORCE:
131
132ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
133
134UNAME := $(shell uname -sm)
135
136SRC_TARGET_DIR := $(TOPDIR)build/make/target
137
138# Some specific paths to tools
139SRC_DROIDDOC_DIR := $(TOPDIR)build/make/tools/droiddoc
140
141# Mark some inputs as readonly
142ifdef TARGET_DEVICE_DIR
143  .KATI_READONLY := TARGET_DEVICE_DIR
144endif
145
146ONE_SHOT_MAKEFILE :=
147.KATI_READONLY := ONE_SHOT_MAKEFILE
148
149# Set up efficient math functions which are used in make.
150# Here since this file is included by envsetup as well as during build.
151include $(BUILD_SYSTEM_COMMON)/math.mk
152
153include $(BUILD_SYSTEM_COMMON)/strings.mk
154
155include $(BUILD_SYSTEM_COMMON)/json.mk
156
157# Various mappings to avoid hard-coding paths all over the place
158include $(BUILD_SYSTEM)/pathmap.mk
159
160# Allow projects to define their own globally-available variables
161include $(BUILD_SYSTEM)/project_definitions.mk
162
163# ###############################################################
164# Build system internal files
165# ###############################################################
166
167BUILD_COMBOS :=$= $(BUILD_SYSTEM)/combo
168
169CLEAR_VARS :=$= $(BUILD_SYSTEM)/clear_vars.mk
170
171BUILD_HOST_STATIC_LIBRARY :=$= $(BUILD_SYSTEM)/host_static_library.mk
172BUILD_HOST_SHARED_LIBRARY :=$= $(BUILD_SYSTEM)/host_shared_library.mk
173BUILD_STATIC_LIBRARY :=$= $(BUILD_SYSTEM)/static_library.mk
174BUILD_HEADER_LIBRARY :=$= $(BUILD_SYSTEM)/header_library.mk
175BUILD_AUX_STATIC_LIBRARY :=$= $(BUILD_SYSTEM)/aux_static_library.mk
176BUILD_AUX_EXECUTABLE :=$= $(BUILD_SYSTEM)/aux_executable.mk
177BUILD_SHARED_LIBRARY :=$= $(BUILD_SYSTEM)/shared_library.mk
178BUILD_EXECUTABLE :=$= $(BUILD_SYSTEM)/executable.mk
179BUILD_HOST_EXECUTABLE :=$= $(BUILD_SYSTEM)/host_executable.mk
180BUILD_PACKAGE :=$= $(BUILD_SYSTEM)/package.mk
181BUILD_PHONY_PACKAGE :=$= $(BUILD_SYSTEM)/phony_package.mk
182BUILD_RRO_PACKAGE :=$= $(BUILD_SYSTEM)/build_rro_package.mk
183BUILD_HOST_PREBUILT :=$= $(BUILD_SYSTEM)/host_prebuilt.mk
184BUILD_PREBUILT :=$= $(BUILD_SYSTEM)/prebuilt.mk
185BUILD_MULTI_PREBUILT :=$= $(BUILD_SYSTEM)/multi_prebuilt.mk
186BUILD_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/java_library.mk
187BUILD_STATIC_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/static_java_library.mk
188BUILD_HOST_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_java_library.mk
189BUILD_COPY_HEADERS :=$= $(BUILD_SYSTEM)/copy_headers.mk
190BUILD_NATIVE_TEST :=$= $(BUILD_SYSTEM)/native_test.mk
191BUILD_NATIVE_BENCHMARK :=$= $(BUILD_SYSTEM)/native_benchmark.mk
192BUILD_HOST_NATIVE_TEST :=$= $(BUILD_SYSTEM)/host_native_test.mk
193BUILD_FUZZ_TEST :=$= $(BUILD_SYSTEM)/fuzz_test.mk
194BUILD_HOST_FUZZ_TEST :=$= $(BUILD_SYSTEM)/host_fuzz_test.mk
195
196BUILD_SHARED_TEST_LIBRARY :=$= $(BUILD_SYSTEM)/shared_test_lib.mk
197BUILD_HOST_SHARED_TEST_LIBRARY :=$= $(BUILD_SYSTEM)/host_shared_test_lib.mk
198BUILD_STATIC_TEST_LIBRARY :=$= $(BUILD_SYSTEM)/static_test_lib.mk
199BUILD_HOST_STATIC_TEST_LIBRARY :=$= $(BUILD_SYSTEM)/host_static_test_lib.mk
200
201BUILD_NOTICE_FILE :=$= $(BUILD_SYSTEM)/notice_files.mk
202BUILD_HOST_DALVIK_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_dalvik_java_library.mk
203BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
204
205BUILD_HOST_TEST_CONFIG :=$= $(BUILD_SYSTEM)/host_test_config.mk
206BUILD_TARGET_TEST_CONFIG :=$= $(BUILD_SYSTEM)/target_test_config.mk
207
208include $(BUILD_SYSTEM)/deprecation.mk
209
210# ###############################################################
211# Parse out any modifier targets.
212# ###############################################################
213
214hide := @
215
216################################################################
217# Tools needed in product configuration makefiles.
218################################################################
219NORMALIZE_PATH := build/make/tools/normalize_path.py
220
221# $(1): the paths to be normalized
222define normalize-paths
223$(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
224endef
225
226# ###############################################################
227# Set common values
228# ###############################################################
229
230# Initialize SOONG_CONFIG_NAMESPACES so that it isn't recursive.
231SOONG_CONFIG_NAMESPACES :=
232
233# The add_soong_config_namespace function adds a namespace and initializes it
234# to be empty.
235# $1 is the namespace.
236# Ex: $(call add_soong_config_namespace,acme)
237
238define add_soong_config_namespace
239$(eval SOONG_CONFIG_NAMESPACES += $1) \
240$(eval SOONG_CONFIG_$1 :=)
241endef
242
243# The add_soong_config_var function adds a a list of soong config variables to
244# SOONG_CONFIG_*. The variables and their values are then available to a
245# soong_config_module_type in an Android.bp file.
246# $1 is the namespace. $2 is the list of variables.
247# Ex: $(call add_soong_config_var,acme,COOL_FEATURE_A COOL_FEATURE_B)
248define add_soong_config_var
249$(eval SOONG_CONFIG_$1 += $2) \
250$(foreach v,$2,$(eval SOONG_CONFIG_$1_$v := $($v)))
251endef
252
253# The add_soong_config_var_value function defines a make variable and also adds
254# the variable to SOONG_CONFIG_*.
255# $1 is the namespace. $2 is the variable name. $3 is the variable value.
256# Ex: $(call add_soong_config_var_value,acme,COOL_FEATURE,true)
257
258define add_soong_config_var_value
259$(eval $2 := $3) \
260$(call add_soong_config_var,$1,$2)
261endef
262
263# Set the extensions used for various packages
264COMMON_PACKAGE_SUFFIX := .zip
265COMMON_JAVA_PACKAGE_SUFFIX := .jar
266COMMON_ANDROID_PACKAGE_SUFFIX := .apk
267
268ifdef TMPDIR
269JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
270else
271JAVA_TMPDIR_ARG :=
272endif
273
274# ###############################################################
275# Include sub-configuration files
276# ###############################################################
277
278# ---------------------------------------------------------------
279# Try to include buildspec.mk, which will try to set stuff up.
280# If this file doesn't exist, the environment variables will
281# be used, and if that doesn't work, then the default is an
282# arm build
283ifndef ANDROID_BUILDSPEC
284ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
285endif
286-include $(ANDROID_BUILDSPEC)
287
288# ---------------------------------------------------------------
289# Define most of the global variables.  These are the ones that
290# are specific to the user's build configuration.
291include $(BUILD_SYSTEM)/envsetup.mk
292
293# Pruned directory options used when using findleaves.py
294# See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
295FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(SCAN_EXCLUDE_DIRS) .repo .git)
296
297# The build system exposes several variables for where to find the kernel
298# headers:
299#   TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
300#       device being built. It is set as $(TARGET_DEVICE_DIR)/kernel-headers,
301#       e.g. device/samsung/tuna/kernel-headers. This directory is not
302#       explicitly set by anyone, the build system always adds this subdir.
303#
304#   TARGET_BOARD_KERNEL_HEADERS is specified by the BoardConfig.mk file
305#       to allow other directories to be included. This is useful if there's
306#       some common place where a few headers are being kept for a group
307#       of devices. For example, device/<vendor>/common/kernel-headers could
308#       contain some headers for several of <vendor>'s devices.
309#
310#   TARGET_PRODUCT_KERNEL_HEADERS is generated by the product inheritance
311#       graph. This allows architecture products to provide headers for the
312#       devices using that architecture. For example,
313#       hardware/ti/omap4xxx/omap4.mk will specify
314#       PRODUCT_VENDOR_KERNEL_HEADERS variable that specify where the omap4
315#       specific headers are, e.g. hardware/ti/omap4xxx/kernel-headers.
316#       The build system then combines all the values specified by all the
317#       PRODUCT_VENDOR_KERNEL_HEADERS directives in the product inheritance
318#       tree and then exports a TARGET_PRODUCT_KERNEL_HEADERS variable.
319#
320# The layout of subdirs in any of the kernel-headers dir should mirror the
321# layout of the kernel include/ directory. For example,
322#     device/samsung/tuna/kernel-headers/linux/,
323#     hardware/ti/omap4xxx/kernel-headers/media/,
324#     etc.
325#
326# NOTE: These directories MUST contain post-processed headers using the
327# bionic/libc/kernel/tools/clean_header.py tool. Additionally, the original
328# kernel headers must also be checked in, but in a different subdirectory. By
329# convention, the originals should be checked into original-kernel-headers
330# directory of the same parent dir. For example,
331#     device/samsung/tuna/kernel-headers            <----- post-processed
332#     device/samsung/tuna/original-kernel-headers   <----- originals
333#
334TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
335
336define validate-kernel-headers
337$(if $(firstword $(foreach hdr_dir,$(1),\
338         $(filter-out kernel-headers,$(notdir $(hdr_dir))))),\
339     $(error Kernel header dirs must be end in kernel-headers: $(1)))
340endef
341# also allow the board config to provide additional directories since
342# there could be device/oem/base_hw and device/oem/derived_hw
343# that both are valid devices but derived_hw needs to use kernel headers
344# from base_hw.
345TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
346TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
347$(call validate-kernel-headers,$(TARGET_BOARD_KERNEL_HEADERS))
348
349# then add product-inherited includes, to allow for
350# hardware/sivendor/chip/chip.mk to include their own headers
351TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
352TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
353$(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
354.KATI_READONLY := TARGET_DEVICE_KERNEL_HEADERS TARGET_BOARD_KERNEL_HEADERS TARGET_PRODUCT_KERNEL_HEADERS
355
356# Commands to generate .toc file common to ELF .so files.
357define _gen_toc_command_for_elf
358$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
359$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) --dyn-syms $(1) | awk '{$$2=""; $$3=""; print}' >> $(2)
360endef
361
362# Commands to generate .toc file from Darwin dynamic library.
363define _gen_toc_command_for_macho
364$(hide) $(HOST_OTOOL) -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
365$(hide) $(HOST_NM) -gP $(1) | cut -f1-2 -d" " | (grep -v U$$ >> $(2) || true)
366endef
367
368ifeq ($(CALLED_FROM_SETUP),true)
369include $(BUILD_SYSTEM)/ccache.mk
370include $(BUILD_SYSTEM)/goma.mk
371include $(BUILD_SYSTEM)/rbe.mk
372endif
373
374ifdef TARGET_PREFER_32_BIT
375TARGET_PREFER_32_BIT_APPS := true
376TARGET_PREFER_32_BIT_EXECUTABLES := true
377endif
378
379# GCC version selection
380TARGET_GCC_VERSION := 4.9
381ifdef TARGET_2ND_ARCH
3822ND_TARGET_GCC_VERSION := 4.9
383endif
384
385# Normalize WITH_STATIC_ANALYZER
386ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
387  WITH_STATIC_ANALYZER :=
388endif
389
390# Unset WITH_TIDY_ONLY if global WITH_TIDY_ONLY is not true nor 1.
391ifeq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
392  WITH_TIDY_ONLY :=
393endif
394
395# Pick a Java compiler.
396include $(BUILD_SYSTEM)/combo/javac.mk
397
398# ---------------------------------------------------------------
399# Check that the configuration is current.  We check that
400# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
401# Don't fail if we're called from envsetup, so they have a
402# chance to update their environment.
403
404ifeq (,$(strip $(CALLED_FROM_SETUP)))
405ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
406ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
407$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
408$(info *** If you use envsetup/lunch/choosecombo:)
409$(info ***   - Re-execute envsetup (". envsetup.sh"))
410$(info ***   - Re-run lunch or choosecombo)
411$(info *** If you use buildspec.mk:)
412$(info ***   - Look at buildspec.mk.default to see what has changed)
413$(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
414$(error bailing..)
415endif
416endif
417endif
418
419# Set up PDK so we can use TARGET_BUILD_PDK to select prebuilt tools below
420.PHONY: pdk fusion
421pdk fusion: $(DEFAULT_GOAL)
422
423# What to build:
424# pdk fusion if:
425# 1) PDK_FUSION_PLATFORM_ZIP / PDK_FUSION_PLATFORM_DIR is passed in from the environment
426# or
427# 2) the platform.zip / pdk.mk exists in the default location
428# or
429# 3) fusion is a command line build goal,
430#    PDK_FUSION_PLATFORM_ZIP is needed anyway, then do we need the 'fusion' goal?
431# otherwise pdk only if:
432# 1) pdk is a command line build goal
433# or
434# 2) TARGET_BUILD_PDK is passed in from the environment
435
436# if PDK_FUSION_PLATFORM_ZIP or PDK_FUSION_PLATFORM_DIR is specified, do not override.
437ifeq (,$(strip $(PDK_FUSION_PLATFORM_ZIP)$(PDK_FUSION_PLATFORM_DIR)))
438  # Most PDK project paths should be using vendor/pdk/TARGET_DEVICE
439  # but some legacy ones (e.g. mini_armv7a_neon generic PDK) were setup
440  # with vendor/pdk/TARGET_PRODUCT.
441  # Others are set up with vendor/pdk/TARGET_DEVICE/TARGET_DEVICE-userdebug
442  _pdk_fusion_search_paths := \
443    vendor/pdk/$(TARGET_DEVICE)/$(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)/platform \
444    vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform \
445    vendor/pdk/$(TARGET_DEVICE)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform \
446    vendor/pdk/$(TARGET_PRODUCT)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform \
447    vendor/pdk/$(TARGET_PRODUCT)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform
448
449  _pdk_fusion_default_platform_zip := $(strip $(foreach p,$(_pdk_fusion_search_paths),$(wildcard $(p)/platform.zip)))
450  ifneq (,$(_pdk_fusion_default_platform_zip))
451    PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
452    _pdk_fusion_default_platform_zip :=
453  else
454    _pdk_fusion_default_platform_mk := $(strip $(foreach p,$(_pdk_fusion_search_paths),$(wildcard $(p)/pdk.mk)))
455    ifneq (,$(_pdk_fusion_default_platform_mk))
456      PDK_FUSION_PLATFORM_DIR := $(dir $(word 1,$(_pdk_fusion_default_platform_mk)))
457      _pdk_fusion_default_platform_mk :=
458    endif
459  endif # _pdk_fusion_default_platform_zip
460  _pdk_fusion_search_paths :=
461endif # !PDK_FUSION_PLATFORM_ZIP && !PDK_FUSION_PLATFORM_DIR
462
463ifneq (,$(PDK_FUSION_PLATFORM_ZIP))
464  ifneq (,$(PDK_FUSION_PLATFORM_DIR))
465    $(error Only one of PDK_FUSION_PLATFORM_ZIP or PDK_FUSION_PLATFORM_DIR may be specified)
466  endif
467endif
468
469ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
470TARGET_BUILD_PDK := true
471ifneq (,$(filter fusion, $(MAKECMDGOALS)))
472ifeq (,$(strip $(PDK_FUSION_PLATFORM_ZIP)$(PDK_FUSION_PLATFORM_DIR)))
473  $(error Specify PDK_FUSION_PLATFORM_ZIP or PDK_FUSION_PLATFORM_DIR to do a PDK fusion.)
474endif
475endif  # fusion
476endif  # pdk or fusion
477
478ifdef PDK_FUSION_PLATFORM_ZIP
479TARGET_BUILD_PDK := true
480ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
481  ifneq (,$(wildcard $(patsubst %.zip,%,$(PDK_FUSION_PLATFORM_ZIP))/pdk.mk))
482    PDK_FUSION_PLATFORM_DIR := $(patsubst %.zip,%,$(PDK_FUSION_PLATFORM_ZIP))
483    PDK_FUSION_PLATFORM_ZIP :=
484  else
485    $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
486  endif
487endif
488endif
489
490ifdef PDK_FUSION_PLATFORM_DIR
491TARGET_BUILD_PDK := true
492ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_DIR)/pdk.mk))
493  $(error Cannot find file $(PDK_FUSION_PLATFORM_DIR)/pdk.mk.)
494endif
495endif
496
497BUILD_PLATFORM_ZIP := $(filter platform platform-java,$(MAKECMDGOALS))
498
499# ---------------------------------------------------------------
500# Whether we can expect a full build graph
501ALLOW_MISSING_DEPENDENCIES := $(filter true,$(ALLOW_MISSING_DEPENDENCIES))
502ifneq ($(TARGET_BUILD_APPS),)
503ALLOW_MISSING_DEPENDENCIES := true
504endif
505ifeq ($(TARGET_BUILD_PDK),true)
506ALLOW_MISSING_DEPENDENCIES := true
507endif
508ifneq ($(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),)
509ALLOW_MISSING_DEPENDENCIES := true
510endif
511.KATI_READONLY := ALLOW_MISSING_DEPENDENCIES
512
513TARGET_BUILD_APPS_USE_PREBUILT_SDK :=
514ifdef TARGET_BUILD_APPS
515  ifndef UNBUNDLED_BUILD_SDKS_FROM_SOURCE
516    TARGET_BUILD_APPS_USE_PREBUILT_SDK := true
517  endif
518endif
519
520prebuilt_sdk_tools := prebuilts/sdk/tools
521prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
522
523prebuilt_build_tools := prebuilts/build-tools
524prebuilt_build_tools_wrappers := prebuilts/build-tools/common/bin
525prebuilt_build_tools_jars := prebuilts/build-tools/common/framework
526prebuilt_build_tools_bin_noasan := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/bin
527ifeq ($(filter address,$(SANITIZE_HOST)),)
528prebuilt_build_tools_bin := $(prebuilt_build_tools_bin_noasan)
529else
530prebuilt_build_tools_bin := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/asan/bin
531endif
532
533USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
534
535# Work around for b/68406220
536# This should match the soong version.
537USE_D8 := true
538.KATI_READONLY := USE_D8
539
540#
541# Tools that are prebuilts for TARGET_BUILD_APPS
542#
543ifeq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)))
544  AAPT := $(HOST_OUT_EXECUTABLES)/aapt
545  MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses
546
547else # TARGET_BUILD_APPS || TARGET_BUILD_PDK
548  AAPT := $(prebuilt_sdk_tools_bin)/aapt
549  MAINDEXCLASSES := $(prebuilt_sdk_tools)/mainDexClasses
550endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
551
552ifeq (,$(TARGET_BUILD_APPS))
553  # Use RenderScript prebuilts for unbundled builds but not PDK builds
554  LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
555  BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
556else
557  LLVM_RS_CC := $(prebuilt_sdk_tools_bin)/llvm-rs-cc
558  BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
559endif # TARGET_BUILD_PDK
560
561prebuilt_sdk_tools :=
562prebuilt_sdk_tools_bin :=
563
564ACP := $(prebuilt_build_tools_bin)/acp
565CKATI := $(prebuilt_build_tools_bin)/ckati
566DEPMOD := $(HOST_OUT_EXECUTABLES)/depmod
567FILESLIST := $(SOONG_HOST_OUT_EXECUTABLES)/fileslist
568FILESLIST_UTIL :=$= build/make/tools/fileslist_util.py
569HOST_INIT_VERIFIER := $(HOST_OUT_EXECUTABLES)/host_init_verifier
570XMLLINT := $(SOONG_HOST_OUT_EXECUTABLES)/xmllint
571
572# SOONG_ZIP is exported by Soong, but needs to be defined early for
573# $OUT/dexpreopt.global.  It will be verified against the Soong version.
574SOONG_ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/soong_zip
575
576# ---------------------------------------------------------------
577# Generic tools.
578
579LEX := $(prebuilt_build_tools_bin_noasan)/flex
580# The default PKGDATADIR built in the prebuilt bison is a relative path
581# prebuilts/build-tools/common/bison.
582# To run bison from elsewhere you need to set up enviromental variable
583# BISON_PKGDATADIR.
584BISON_PKGDATADIR := $(PWD)/prebuilts/build-tools/common/bison
585BISON := $(prebuilt_build_tools_bin_noasan)/bison
586YACC := $(BISON) -d
587BISON_DATA := $(wildcard $(BISON_PKGDATADIR)/* $(BISON_PKGDATADIR)/*/*)
588M4 :=$= $(prebuilt_build_tools_bin_noasan)/m4
589
590YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
591
592DOXYGEN:= doxygen
593ifeq ($(HOST_OS),linux)
594BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
595else
596# For non-supported hosts, do not generate breakpad symbols.
597BREAKPAD_GENERATE_SYMBOLS := false
598endif
599PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
600NANOPB_SRCS := $(HOST_OUT_EXECUTABLES)/protoc-gen-nanopb
601VTSC := $(HOST_OUT_EXECUTABLES)/vtsc$(HOST_EXECUTABLE_SUFFIX)
602MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
603MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
604LZ4 := $(HOST_OUT_EXECUTABLES)/lz4$(HOST_EXECUTABLE_SUFFIX)
605ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
606MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
607else
608MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
609endif
610ifeq (,$(strip $(BOARD_CUSTOM_BPTTOOL)))
611BPTTOOL := $(HOST_OUT_EXECUTABLES)/bpttool$(HOST_EXECUTABLE_SUFFIX)
612else
613BPTTOOL := $(BOARD_CUSTOM_BPTTOOL)
614endif
615ifeq (,$(strip $(BOARD_CUSTOM_AVBTOOL)))
616AVBTOOL := $(HOST_OUT_EXECUTABLES)/avbtool$(HOST_EXECUTABLE_SUFFIX)
617else
618AVBTOOL := $(BOARD_CUSTOM_AVBTOOL)
619endif
620APICHECK := $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX)
621FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
622MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs
623MKE2FS_CONF := system/extras/ext4_utils/mke2fs.conf
624MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
625MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
626SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
627E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
628TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
629JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
630DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
631FAT16COPY := build/make/tools/fat16copy.py
632CHECK_ELF_FILE := build/make/tools/check_elf_file.py
633LPMAKE := $(HOST_OUT_EXECUTABLES)/lpmake$(HOST_EXECUTABLE_SUFFIX)
634ADD_IMG_TO_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/add_img_to_target_files$(HOST_EXECUTABLE_SUFFIX)
635BUILD_IMAGE := $(HOST_OUT_EXECUTABLES)/build_image$(HOST_EXECUTABLE_SUFFIX)
636BUILD_SUPER_IMAGE := $(HOST_OUT_EXECUTABLES)/build_super_image$(HOST_EXECUTABLE_SUFFIX)
637IMG_FROM_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/img_from_target_files$(HOST_EXECUTABLE_SUFFIX)
638MAKE_RECOVERY_PATCH := $(HOST_OUT_EXECUTABLES)/make_recovery_patch$(HOST_EXECUTABLE_SUFFIX)
639OTA_FROM_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/ota_from_target_files$(HOST_EXECUTABLE_SUFFIX)
640SPARSE_IMG := $(HOST_OUT_EXECUTABLES)/sparse_img$(HOST_EXECUTABLE_SUFFIX)
641CHECK_PARTITION_SIZES := $(HOST_OUT_EXECUTABLES)/check_partition_sizes$(HOST_EXECUTABLE_SUFFIX)
642
643PROGUARD_HOME := external/proguard
644PROGUARD := $(PROGUARD_HOME)/bin/proguard.sh
645PROGUARD_DEPS := $(PROGUARD) $(PROGUARD_HOME)/lib/proguard.jar
646JAVATAGS := build/make/tools/java-event-log-tags.py
647MERGETAGS := build/make/tools/merge-event-log-tags.py
648APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
649VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
650BUILD_VERITY_METADATA := $(HOST_OUT_EXECUTABLES)/build_verity_metadata
651BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
652BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
653FUTILITY := $(HOST_OUT_EXECUTABLES)/futility-host
654VBOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/vboot_signer
655FEC := $(HOST_OUT_EXECUTABLES)/fec
656
657DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump$(BUILD_EXECUTABLE_SUFFIX)
658PROFMAN := $(HOST_OUT_EXECUTABLES)/profman
659
660FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
661FINDBUGS := $(FINDBUGS_DIR)/findbugs
662
663JETIFIER := prebuilts/sdk/tools/jetifier/jetifier-standalone/bin/jetifier-standalone
664
665EXTRACT_KERNEL := build/make/tools/extract_kernel.py
666
667# Path to tools.jar
668HOST_JDK_TOOLS_JAR := $(ANDROID_JAVA8_HOME)/lib/tools.jar
669
670APICHECK_COMMAND := $(JAVA) -Xmx4g -jar $(APICHECK) --no-banner --compatible-output=yes
671
672# Boolean variable determining if the allow list for compatible properties is enabled
673PRODUCT_COMPATIBLE_PROPERTY := false
674ifneq ($(PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE),)
675  PRODUCT_COMPATIBLE_PROPERTY := $(PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE)
676else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
677  #$(warning no product shipping level defined)
678else ifneq ($(call math_lt,27,$(PRODUCT_SHIPPING_API_LEVEL)),)
679  PRODUCT_COMPATIBLE_PROPERTY := true
680endif
681
682.KATI_READONLY := \
683    PRODUCT_COMPATIBLE_PROPERTY
684
685# Boolean variable determining if Treble is fully enabled
686PRODUCT_FULL_TREBLE := false
687ifneq ($(PRODUCT_FULL_TREBLE_OVERRIDE),)
688  PRODUCT_FULL_TREBLE := $(PRODUCT_FULL_TREBLE_OVERRIDE)
689else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
690  #$(warning no product shipping level defined)
691else ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),26),)
692  PRODUCT_FULL_TREBLE := true
693endif
694
695# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior and remove
696#    references to it here and below.
697ifdef PRODUCT_NOTICE_SPLIT_OVERRIDE
698   $(error PRODUCT_NOTICE_SPLIT_OVERRIDE cannot be set.)
699endif
700
701requirements := \
702    PRODUCT_TREBLE_LINKER_NAMESPACES \
703    PRODUCT_SEPOLICY_SPLIT \
704    PRODUCT_ENFORCE_VINTF_MANIFEST \
705    PRODUCT_NOTICE_SPLIT
706
707# If it is overriden, then the requirement override is taken, otherwise it's
708# PRODUCT_FULL_TREBLE
709$(foreach req,$(requirements),$(eval \
710    $(req) := $(if $($(req)_OVERRIDE),$($(req)_OVERRIDE),$(PRODUCT_FULL_TREBLE))))
711# If the requirement is false for any reason, then it's not PRODUCT_FULL_TREBLE
712$(foreach req,$(requirements),$(eval \
713    PRODUCT_FULL_TREBLE := $(if $(filter false,$($(req))),false,$(PRODUCT_FULL_TREBLE))))
714
715PRODUCT_FULL_TREBLE_OVERRIDE ?=
716$(foreach req,$(requirements),$(eval $(req)_OVERRIDE ?=))
717
718# TODO(b/114488870): disallow PRODUCT_FULL_TREBLE_OVERRIDE from being used.
719.KATI_READONLY := \
720    PRODUCT_FULL_TREBLE_OVERRIDE \
721    $(foreach req,$(requirements),$(req)_OVERRIDE) \
722    $(requirements) \
723    PRODUCT_FULL_TREBLE \
724
725$(KATI_obsolete_var $(foreach req,$(requirements),$(req)_OVERRIDE) \
726    ,This should be referenced without the _OVERRIDE suffix.)
727
728requirements :=
729
730# BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED can be true only if early-mount of
731# partitions is supported. But the early-mount must be supported for full
732# treble products, and so BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED should be set
733# by default for full treble products.
734ifeq ($(PRODUCT_FULL_TREBLE),true)
735  BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED ?= true
736endif
737
738# If PRODUCT_USE_VNDK is true and BOARD_VNDK_VERSION is not defined yet,
739# BOARD_VNDK_VERSION will be set to "current" as default.
740# PRODUCT_USE_VNDK will be true in Android-P or later launching devices.
741PRODUCT_USE_VNDK := false
742ifneq ($(PRODUCT_USE_VNDK_OVERRIDE),)
743  PRODUCT_USE_VNDK := $(PRODUCT_USE_VNDK_OVERRIDE)
744else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
745  # No shipping level defined
746else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),27),true)
747  PRODUCT_USE_VNDK := $(PRODUCT_FULL_TREBLE)
748endif
749
750# Define PRODUCT_PRODUCT_VNDK_VERSION if PRODUCT_USE_VNDK is true and
751# PRODUCT_SHIPPING_API_LEVEL is greater than 29.
752PRODUCT_USE_PRODUCT_VNDK := false
753ifeq ($(PRODUCT_USE_VNDK),true)
754  ifneq ($(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE),)
755    PRODUCT_USE_PRODUCT_VNDK := $(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE)
756  else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
757    # No shipping level defined
758  else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true)
759    PRODUCT_USE_PRODUCT_VNDK := true
760  endif
761
762  ifndef BOARD_VNDK_VERSION
763    BOARD_VNDK_VERSION := current
764  endif
765
766  ifeq ($(PRODUCT_USE_PRODUCT_VNDK),true)
767    ifndef PRODUCT_PRODUCT_VNDK_VERSION
768      PRODUCT_PRODUCT_VNDK_VERSION := current
769    endif
770  endif
771endif
772
773$(KATI_obsolete_var PRODUCT_USE_VNDK,Use BOARD_VNDK_VERSION instead)
774$(KATI_obsolete_var PRODUCT_USE_VNDK_OVERRIDE,Use BOARD_VNDK_VERSION instead)
775$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK,Use PRODUCT_PRODUCT_VNDK_VERSION instead)
776$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK_OVERRIDE,Use PRODUCT_PRODUCT_VNDK_VERSION instead)
777
778# Set BOARD_SYSTEMSDK_VERSIONS to the latest SystemSDK version starting from P-launching
779# devices if unset.
780ifndef BOARD_SYSTEMSDK_VERSIONS
781  ifdef PRODUCT_SHIPPING_API_LEVEL
782  ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),28),)
783    ifeq (REL,$(PLATFORM_VERSION_CODENAME))
784      BOARD_SYSTEMSDK_VERSIONS := $(PLATFORM_SDK_VERSION)
785    else
786      BOARD_SYSTEMSDK_VERSIONS := $(PLATFORM_VERSION_CODENAME)
787    endif
788  endif
789  endif
790endif
791
792
793ifdef PRODUCT_SHIPPING_API_LEVEL
794  ifneq ($(call numbers_less_than,$(PRODUCT_SHIPPING_API_LEVEL),$(BOARD_SYSTEMSDK_VERSIONS)),)
795    $(error BOARD_SYSTEMSDK_VERSIONS ($(BOARD_SYSTEMSDK_VERSIONS)) must all be greater than or equal to PRODUCT_SHIPPING_API_LEVEL ($(PRODUCT_SHIPPING_API_LEVEL)))
796  endif
797  ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),28),)
798    ifneq ($(TARGET_IS_64_BIT), true)
799      ifneq ($(TARGET_USES_64_BIT_BINDER), true)
800        $(error When PRODUCT_SHIPPING_API_LEVEL >= 28, TARGET_USES_64_BIT_BINDER must be true)
801      endif
802    endif
803  endif
804  ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29),)
805    ifneq ($(BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE),)
806      $(error When PRODUCT_SHIPPING_API_LEVEL >= 29, BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE cannot be set)
807    endif
808  endif
809endif
810
811# The default key if not set as LOCAL_CERTIFICATE
812ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
813  DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
814else
815  DEFAULT_SYSTEM_DEV_CERTIFICATE := build/make/target/product/security/testkey
816endif
817.KATI_READONLY := DEFAULT_SYSTEM_DEV_CERTIFICATE
818
819# Certificate for the NetworkStack sepolicy context
820ifdef PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES
821  MAINLINE_SEPOLICY_DEV_CERTIFICATES := $(PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES)
822else
823  MAINLINE_SEPOLICY_DEV_CERTIFICATES := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
824endif
825
826BUILD_NUMBER_FROM_FILE := $$(cat $(SOONG_OUT_DIR)/build_number.txt)
827BUILD_DATETIME_FROM_FILE := $$(cat $(BUILD_DATETIME_FILE))
828
829# SEPolicy versions
830
831# PLATFORM_SEPOLICY_VERSION is a number of the form "NN.m" with "NN" mapping to
832# PLATFORM_SDK_VERSION and "m" as a minor number which allows for SELinux
833# changes independent of PLATFORM_SDK_VERSION.  This value will be set to
834# 10000.0 to represent tip-of-tree development that is inherently unstable and
835# thus designed not to work with any shipping vendor policy.  This is similar in
836# spirit to how DEFAULT_APP_TARGET_SDK is set.
837# The minor version ('m' component) must be updated every time a platform release
838# is made which breaks compatibility with the previous platform sepolicy version,
839# not just on every increase in PLATFORM_SDK_VERSION.  The minor version should
840# be reset to 0 on every bump of the PLATFORM_SDK_VERSION.
841sepolicy_major_vers := 30
842sepolicy_minor_vers := 0
843
844ifneq ($(sepolicy_major_vers), $(PLATFORM_SDK_VERSION))
845$(error sepolicy_major_version does not match PLATFORM_SDK_VERSION, please update.)
846endif
847
848TOT_SEPOLICY_VERSION := 10000.0
849ifneq (REL,$(PLATFORM_VERSION_CODENAME))
850    PLATFORM_SEPOLICY_VERSION := $(TOT_SEPOLICY_VERSION)
851else
852    PLATFORM_SEPOLICY_VERSION := $(join $(addsuffix .,$(sepolicy_major_vers)), $(sepolicy_minor_vers))
853endif
854sepolicy_major_vers :=
855sepolicy_minor_vers :=
856
857# A list of SEPolicy versions, besides PLATFORM_SEPOLICY_VERSION, that the framework supports.
858PLATFORM_SEPOLICY_COMPAT_VERSIONS := \
859    26.0 \
860    27.0 \
861    28.0 \
862    29.0 \
863    30.0 \
864
865.KATI_READONLY := \
866    PLATFORM_SEPOLICY_COMPAT_VERSIONS \
867    PLATFORM_SEPOLICY_VERSION \
868    TOT_SEPOLICY_VERSION \
869
870ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
871  ifneq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
872    $(error PRODUCT_USE_DYNAMIC_PARTITIONS must be true when PRODUCT_RETROFIT_DYNAMIC_PARTITIONS \
873        is set)
874  endif
875  ifdef PRODUCT_SHIPPING_API_LEVEL
876    ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29))
877      $(error Devices with shipping API level $(PRODUCT_SHIPPING_API_LEVEL) must not set \
878          PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)
879    endif
880  endif
881endif
882
883ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
884    ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
885        $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE cannot be true for devices with dynamic partitions)
886    endif
887    ifneq ($(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),true)
888        $(error PRODUCT_USE_DYNAMIC_PARTITION_SIZE must be true for devices with dynamic partitions)
889    endif
890endif
891
892ifeq ($(PRODUCT_BUILD_SUPER_PARTITION),true)
893    ifneq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
894        $(error Can only build super partition for devices with dynamic partitions)
895    endif
896endif
897
898
899ifeq ($(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),true)
900
901ifneq ($(BOARD_SYSTEMIMAGE_PARTITION_SIZE),)
902ifneq ($(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),)
903$(error Should not define BOARD_SYSTEMIMAGE_PARTITION_SIZE and \
904    BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE together)
905endif
906endif
907
908ifneq ($(BOARD_VENDORIMAGE_PARTITION_SIZE),)
909ifneq ($(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),)
910$(error Should not define BOARD_VENDORIMAGE_PARTITION_SIZE and \
911    BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE together)
912endif
913endif
914
915ifneq ($(BOARD_ODMIMAGE_PARTITION_SIZE),)
916ifneq ($(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),)
917$(error Should not define BOARD_ODMIMAGE_PARTITION_SIZE and \
918    BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE together)
919endif
920endif
921
922ifneq ($(BOARD_PRODUCTIMAGE_PARTITION_SIZE),)
923ifneq ($(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),)
924$(error Should not define BOARD_PRODUCTIMAGE_PARTITION_SIZE and \
925    BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE together)
926endif
927endif
928
929ifneq ($(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),)
930ifneq ($(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),)
931$(error Should not define BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE and \
932    BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE together)
933endif
934endif
935
936endif # PRODUCT_USE_DYNAMIC_PARTITION_SIZE
937
938ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
939
940# BOARD_SUPER_PARTITION_GROUPS defines a list of "updatable groups". Each updatable group is a
941# group of partitions that share the same pool of free spaces.
942# For each group in BOARD_SUPER_PARTITION_GROUPS, a BOARD_{GROUP}_SIZE and
943# BOARD_{GROUP}_PARTITION_PARTITION_LIST may be defined.
944#     - BOARD_{GROUP}_SIZE: The maximum sum of sizes of all partitions in the group.
945#       Must not be empty.
946#     - BOARD_{GROUP}_PARTITION_PARTITION_LIST: the list of partitions that belongs to this group.
947#       If empty, no partitions belong to this group, and the sum of sizes is effectively 0.
948$(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)), \
949    $(eval BOARD_$(group)_SIZE := $(strip $(BOARD_$(group)_SIZE))) \
950    $(if $(BOARD_$(group)_SIZE),,$(error BOARD_$(group)_SIZE must not be empty)) \
951    $(eval .KATI_READONLY := BOARD_$(group)_SIZE) \
952    $(eval BOARD_$(group)_PARTITION_LIST ?=) \
953    $(eval .KATI_READONLY := BOARD_$(group)_PARTITION_LIST) \
954)
955
956# BOARD_*_PARTITION_LIST: a list of the following tokens
957valid_super_partition_list := system vendor product system_ext odm
958$(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)), \
959    $(if $(filter-out $(valid_super_partition_list),$(BOARD_$(group)_PARTITION_LIST)), \
960        $(error BOARD_$(group)_PARTITION_LIST contains invalid partition name \
961            $(filter-out $(valid_super_partition_list),$(BOARD_$(group)_PARTITION_LIST)). \
962            Valid names are $(valid_super_partition_list))))
963valid_super_partition_list :=
964
965
966# Define BOARD_SUPER_PARTITION_PARTITION_LIST, the sum of all BOARD_*_PARTITION_LIST
967ifdef BOARD_SUPER_PARTITION_PARTITION_LIST
968$(error BOARD_SUPER_PARTITION_PARTITION_LIST should not be defined, but computed from \
969    BOARD_SUPER_PARTITION_GROUPS and BOARD_*_PARTITION_LIST)
970endif
971BOARD_SUPER_PARTITION_PARTITION_LIST := \
972    $(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)), \
973        $(BOARD_$(group)_PARTITION_LIST))
974.KATI_READONLY := BOARD_SUPER_PARTITION_PARTITION_LIST
975
976ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
977ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
978
979# The metadata device must be specified manually for retrofitting.
980ifeq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),)
981$(error Must specify BOARD_SUPER_PARTITION_METADATA_DEVICE if PRODUCT_RETROFIT_DYNAMIC_PARTITIONS=true.)
982endif
983
984# The super partition block device list must be specified manually for retrofitting.
985ifeq ($(BOARD_SUPER_PARTITION_BLOCK_DEVICES),)
986$(error Must specify BOARD_SUPER_PARTITION_BLOCK_DEVICES if PRODUCT_RETROFIT_DYNAMIC_PARTITIONS=true.)
987endif
988
989# The metadata device must be included in the super partition block device list.
990ifeq (,$(filter $(BOARD_SUPER_PARTITION_METADATA_DEVICE),$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)))
991$(error BOARD_SUPER_PARTITION_METADATA_DEVICE is not listed in BOARD_SUPER_PARTITION_BLOCK_DEVICES.)
992endif
993
994# The metadata device must be supplied to init via the kernel command-line.
995INTERNAL_KERNEL_CMDLINE += androidboot.super_partition=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)
996
997BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE := true
998
999# If "vendor" is listed as one of the dynamic partitions but without its image available (e.g. an
1000# AOSP target built without vendor image), don't build the retrofit full OTA package. Because we
1001# won't be able to build meaningful super_* images for retrofitting purpose.
1002ifneq (,$(filter vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST)))
1003ifndef BUILDING_VENDOR_IMAGE
1004ifndef BOARD_PREBUILT_VENDORIMAGE
1005BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE :=
1006endif # BOARD_PREBUILT_VENDORIMAGE
1007endif # BUILDING_VENDOR_IMAGE
1008endif # BOARD_SUPER_PARTITION_PARTITION_LIST
1009
1010else # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
1011
1012# For normal devices, we populate BOARD_SUPER_PARTITION_BLOCK_DEVICES so the
1013# build can handle both cases consistently.
1014ifeq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),)
1015BOARD_SUPER_PARTITION_METADATA_DEVICE := super
1016endif
1017
1018ifeq ($(BOARD_SUPER_PARTITION_BLOCK_DEVICES),)
1019BOARD_SUPER_PARTITION_BLOCK_DEVICES := $(BOARD_SUPER_PARTITION_METADATA_DEVICE)
1020endif
1021
1022# If only one super block device, default to super partition size.
1023ifeq ($(word 2,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
1024BOARD_SUPER_PARTITION_$(call to-upper,$(strip $(BOARD_SUPER_PARTITION_BLOCK_DEVICES)))_DEVICE_SIZE ?= \
1025    $(BOARD_SUPER_PARTITION_SIZE)
1026endif
1027
1028ifneq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),super)
1029INTERNAL_KERNEL_CMDLINE += androidboot.super_partition=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)
1030endif
1031BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE :=
1032
1033endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
1034endif # BOARD_SUPER_PARTITION_SIZE
1035BOARD_SUPER_PARTITION_BLOCK_DEVICES ?=
1036.KATI_READONLY := BOARD_SUPER_PARTITION_BLOCK_DEVICES
1037BOARD_SUPER_PARTITION_METADATA_DEVICE ?=
1038.KATI_READONLY := BOARD_SUPER_PARTITION_METADATA_DEVICE
1039BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE ?=
1040.KATI_READONLY := BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
1041
1042$(foreach device,$(call to-upper,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)), \
1043    $(eval BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE := $(strip $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))) \
1044    $(if $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE),, \
1045        $(error BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE must not be empty)) \
1046    $(eval .KATI_READONLY := BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))
1047
1048endif # PRODUCT_USE_DYNAMIC_PARTITIONS
1049
1050# ###############################################################
1051# Set up final options.
1052# ###############################################################
1053
1054# We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
1055# from the debug output. That way two builds in two different
1056# directories will create the same output.
1057# /proc doesn't exist on Darwin.
1058ifeq ($(HOST_OS),linux)
1059RELATIVE_PWD := PWD=/proc/self/cwd
1060else
1061RELATIVE_PWD :=
1062endif
1063
1064TARGET_PROJECT_INCLUDES :=
1065TARGET_PROJECT_SYSTEM_INCLUDES := \
1066		$(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
1067		$(TARGET_PRODUCT_KERNEL_HEADERS)
1068
1069ifdef TARGET_2ND_ARCH
1070$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
1071$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_SYSTEM_INCLUDES := $(TARGET_PROJECT_SYSTEM_INCLUDES)
1072endif
1073
1074# Flags for DEX2OAT
1075first_non_empty_of_three = $(if $(1),$(1),$(if $(2),$(2),$(3)))
1076DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
1077DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT),$(TARGET_ARCH_VARIANT),default)
1078DEX2OAT_TARGET_CPU_VARIANT_RUNTIME := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_ARCH_VARIANT),default)
1079DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
1080
1081ifdef TARGET_2ND_ARCH
1082$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
1083$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT),$(TARGET_2ND_ARCH_VARIANT),default)
1084$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT_RUNTIME := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_ARCH_VARIANT),default)
1085$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
1086endif
1087
1088# ###############################################################
1089# Collect a list of the SDK versions that we could compile against
1090# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
1091# ###############################################################
1092
1093HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
1094HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
1095
1096# The path where app can reference the support library resources.
1097ifdef TARGET_BUILD_APPS
1098SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
1099else
1100SUPPORT_LIBRARY_ROOT := frameworks/support
1101endif
1102
1103get-sdk-version = $(if $(findstring _,$(1)),$(subst core_,,$(subst system_,,$(subst test_,,$(1)))),$(1))
1104get-sdk-api = $(if $(findstring _,$(1)),$(patsubst %_$(call get-sdk-version,$(1)),%,$(1)),public)
1105get-prebuilt-sdk-dir = $(HISTORICAL_SDK_VERSIONS_ROOT)/$(call get-sdk-version,$(1))/$(call get-sdk-api,$(1))
1106
1107# Resolve LOCAL_SDK_VERSION to prebuilt module name, e.g.:
1108# 23 -> sdk_public_23_android
1109# system_current -> sdk_system_current_android
1110# $(1): An sdk version (LOCAL_SDK_VERSION)
1111# $(2): optional library name (default: android)
1112define resolve-prebuilt-sdk-module
1113$(if $(findstring _,$(1)),\
1114  sdk_$(1)_$(or $(2),android),\
1115  sdk_public_$(1)_$(or $(2),android))
1116endef
1117
1118# Resolve LOCAL_SDK_VERSION to prebuilt android.jar
1119# $(1): LOCAL_SDK_VERSION
1120resolve-prebuilt-sdk-jar-path = $(call get-prebuilt-sdk-dir,$(1))/android.jar
1121
1122# Resolve LOCAL_SDK_VERSION to prebuilt framework.aidl
1123# $(1): An sdk version (LOCAL_SDK_VERSION)
1124resolve-prebuilt-sdk-aidl-path = $(call get-prebuilt-sdk-dir,$(call get-sdk-version,$(1)))/framework.aidl
1125
1126# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
1127# The 'current' version is whatever this source tree is.
1128#
1129# sgrax     is the opposite of xargs.  It takes the list of args and puts them
1130#           on each line for sort to process.
1131# sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
1132
1133# Numerically sort a list of numbers
1134# $(1): the list of numbers to be sorted
1135define numerically_sort
1136$(shell function sgrax() { \
1137    while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
1138    } ; \
1139    ( sgrax $(1) | sort -g ) )
1140endef
1141
1142# This produces a list like "current/core current/public current/system 4/public"
1143TARGET_AVAILABLE_SDK_VERSIONS := $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/*/android.jar)
1144TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%,$(TARGET_AVAILABLE_SDK_VERSIONS))
1145# Strips and reorganizes the "public", "core" and "system" subdirs.
1146TARGET_AVAILABLE_SDK_VERSIONS := $(subst /public,,$(TARGET_AVAILABLE_SDK_VERSIONS))
1147TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/core,core_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
1148TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/system,system_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
1149# No prebuilt for test_current.
1150TARGET_AVAILABLE_SDK_VERSIONS += test_current
1151TARGET_AVAIALBLE_SDK_VERSIONS := $(call numerically_sort,$(TARGET_AVAILABLE_SDK_VERSIONS))
1152
1153TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS))
1154TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT := $(call numbers_less_than,30,$(TARGET_AVAILABLE_SDK_VERSIONS))
1155
1156# Missing optional uses-libraries so that the platform doesn't create build rules that depend on
1157# them.
1158INTERNAL_PLATFORM_MISSING_USES_LIBRARIES := \
1159  com.google.android.ble \
1160  com.google.android.media.effects \
1161  com.google.android.wearable \
1162
1163# This is the standard way to name a directory containing prebuilt target
1164# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
1165TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
1166ifdef TARGET_2ND_ARCH
1167TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
1168endif
1169
1170# Set up RS prebuilt variables for compatibility library
1171
1172RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
1173RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
1174
1175# API Level lists for Renderscript Compat lib.
1176RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
1177RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
1178
1179# Add BUILD_NUMBER to apps default version name if it's unbundled build.
1180ifdef TARGET_BUILD_APPS
1181TARGET_BUILD_WITH_APPS_VERSION_NAME := true
1182endif
1183
1184ifdef TARGET_BUILD_WITH_APPS_VERSION_NAME
1185APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE)
1186else
1187APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
1188endif
1189
1190# ANDROID_WARNING_ALLOWED_PROJECTS is generated by build/soong.
1191define find_warning_allowed_projects
1192    $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
1193endef
1194
1195GOMA_POOL :=
1196RBE_POOL :=
1197GOMA_OR_RBE_POOL :=
1198# When goma or RBE are enabled, kati will be passed --default_pool=local_pool to put
1199# most rules into the local pool.  Explicitly set the pool to "none" for rules that
1200# should be run outside the local pool, i.e. with -j500.
1201ifneq (,$(filter-out false,$(USE_GOMA)))
1202  GOMA_POOL := none
1203  GOMA_OR_RBE_POOL := none
1204else ifneq (,$(filter-out false,$(USE_RBE)))
1205  RBE_POOL := none
1206  GOMA_OR_RBE_POOL := none
1207endif
1208.KATI_READONLY := GOMA_POOL RBE_POOL GOMA_OR_RBE_POOL
1209
1210# These goals don't need to collect and include Android.mks/CleanSpec.mks
1211# in the source tree.
1212dont_bother_goals := out \
1213    snod systemimage-nodeps \
1214    userdataimage-nodeps \
1215    cacheimage-nodeps \
1216    bptimage-nodeps \
1217    vnod vendorimage-nodeps \
1218    pnod productimage-nodeps \
1219    senod systemextimage-nodeps \
1220    onod odmimage-nodeps \
1221    systemotherimage-nodeps \
1222    ramdisk-nodeps \
1223    ramdisk_debug-nodeps \
1224    ramdisk_test_harness-nodeps \
1225    bootimage-nodeps \
1226    bootimage_debug-nodeps \
1227    bootimage_test_harness-nodeps \
1228    recoveryimage-nodeps \
1229    vbmetaimage-nodeps \
1230    product-graph dump-products
1231
1232ifeq ($(CALLED_FROM_SETUP),true)
1233include $(BUILD_SYSTEM)/ninja_config.mk
1234include $(BUILD_SYSTEM)/soong_config.mk
1235endif
1236
1237-include external/linux-kselftest/android/kselftest_test_list.mk
1238-include external/ltp/android/ltp_package_list.mk
1239DEFAULT_DATA_OUT_MODULES := ltp $(ltp_packages) $(kselftest_modules)
1240.KATI_READONLY := DEFAULT_DATA_OUT_MODULES
1241
1242include $(BUILD_SYSTEM)/dumpvar.mk
1243