1# Variables we check:
2#     HOST_BUILD_TYPE = { release debug }
3#     TARGET_BUILD_TYPE = { release debug }
4# and we output a bunch of variables, see the case statement at
5# the bottom for the full list
6#     OUT_DIR is also set to "out" if it's not already set.
7#         this allows you to set it to somewhere else if you like
8#     SCAN_EXCLUDE_DIRS is an optional, whitespace separated list of
9#         directories that will also be excluded from full checkout tree
10#         searches for source or make files, in addition to OUT_DIR.
11#         This can be useful if you set OUT_DIR to be a different directory
12#         than other outputs of your build system.
13
14# Returns all words in $1 up to and including $2
15define find_and_earlier
16  $(strip $(if $(1),
17    $(firstword $(1))
18    $(if $(filter $(firstword $(1)),$(2)),,
19      $(call find_and_earlier,$(wordlist 2,$(words $(1)),$(1)),$(2)))))
20endef
21
22#$(warning $(call find_and_earlier,A B C,A))
23#$(warning $(call find_and_earlier,A B C,B))
24#$(warning $(call find_and_earlier,A B C,C))
25#$(warning $(call find_and_earlier,A B C,D))
26
27define version-list
28$(1)P1A $(1)P1B $(1)P2A $(1)P2B $(1)D1A $(1)D1B $(1)D2A $(1)D2B $(1)Q1A $(1)Q1B $(1)Q2A $(1)Q2B $(1)Q3A $(1)Q3B
29endef
30
31PREV_VERSIONS := OPR1 OPD1 OPD2 OPM1 OPM2 PPR1 PPD1 PPD2 PPM1 PPM2 QPR1
32ALL_VERSIONS := Q R S T U V W X Y Z
33ALL_VERSIONS := $(PREV_VERSIONS) $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
34PREV_VERSIONS :=
35
36# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is
37# not in [$1, $2]
38# $(1): min platform version
39# $(2): max platform version
40# $(3): default platform version
41define allowed-platform-versions
42$(strip \
43  $(if $(filter $(ALL_VERSIONS),$(1)),,
44    $(error Invalid MIN_PLATFORM_VERSION '$(1)'))
45  $(if $(filter $(ALL_VERSIONS),$(2)),,
46    $(error Invalid MAX_PLATFORM_VERSION '$(2)'))
47  $(if $(filter $(ALL_VERSIONS),$(3)),,
48    $(error Invalid DEFAULT_PLATFORM_VERSION '$(3)'))
49
50  $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2)))
51
52  $(if $(filter $(allowed_versions_),$(1)),,
53    $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)'))
54
55  $(eval allowed_versions_ := $(1) \
56    $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_)))
57
58  $(if $(filter $(allowed_versions_),$(3)),,
59    $(error DEFAULT_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)'))
60
61  $(allowed_versions_))
62endef
63
64#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1))
65#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1))
66
67# Set up version information.
68include $(BUILD_SYSTEM)/version_defaults.mk
69
70ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION))
71
72$(foreach v,$(ENABLED_VERSIONS), \
73  $(eval IS_AT_LEAST_$(v) := true))
74
75# ---------------------------------------------------------------
76# If you update the build system such that the environment setup
77# or buildspec.mk need to be updated, increment this number, and
78# people who haven't re-run those will have to do so before they
79# can build.  Make sure to also update the corresponding value in
80# buildspec.mk.default and envsetup.sh.
81CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 13
82
83# ---------------------------------------------------------------
84# The product defaults to generic on hardware
85ifeq ($(TARGET_PRODUCT),)
86TARGET_PRODUCT := aosp_arm
87endif
88
89
90# the variant -- the set of files that are included for a build
91ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
92TARGET_BUILD_VARIANT := eng
93endif
94
95TARGET_BUILD_APPS ?=
96TARGET_BUILD_UNBUNDLED_IMAGE ?=
97
98# Set to true for an unbundled build, i.e. a build without
99# support for platform targets like the system image. This also
100# disables consistency checks that only apply to full platform
101# builds.
102TARGET_BUILD_UNBUNDLED ?=
103
104# TARGET_BUILD_APPS implies unbundled build, otherwise we default
105# to bundled (i.e. platform targets such as the system image are
106# included).
107ifneq ($(TARGET_BUILD_APPS),)
108  TARGET_BUILD_UNBUNDLED := true
109endif
110
111# TARGET_BUILD_UNBUNDLED_IMAGE also implies unbundled build.
112# (i.e. it targets to only unbundled image, such as the vendor image,
113# ,or the product image).
114ifneq ($(TARGET_BUILD_UNBUNDLED_IMAGE),)
115  TARGET_BUILD_UNBUNDLED := true
116endif
117
118.KATI_READONLY := \
119  TARGET_PRODUCT \
120  TARGET_BUILD_VARIANT \
121  TARGET_BUILD_APPS \
122  TARGET_BUILD_UNBUNDLED \
123  TARGET_BUILD_UNBUNDLED_IMAGE \
124
125# ---------------------------------------------------------------
126# Set up configuration for host machine.  We don't do cross-
127# compiles except for arm, so the HOST is whatever we are
128# running on
129
130# HOST_OS
131ifneq (,$(findstring Linux,$(UNAME)))
132  HOST_OS := linux
133endif
134ifneq (,$(findstring Darwin,$(UNAME)))
135  HOST_OS := darwin
136endif
137
138HOST_OS_EXTRA := $(shell uname -rsm)
139ifeq ($(HOST_OS),linux)
140  ifneq ($(wildcard /etc/os-release),)
141    HOST_OS_EXTRA += $(shell source /etc/os-release; echo $$PRETTY_NAME)
142  endif
143else ifeq ($(HOST_OS),darwin)
144  HOST_OS_EXTRA += $(shell sw_vers -productVersion)
145endif
146HOST_OS_EXTRA := $(subst $(space),-,$(HOST_OS_EXTRA))
147
148# BUILD_OS is the real host doing the build.
149BUILD_OS := $(HOST_OS)
150
151# We can do the cross-build only on Linux
152ifeq ($(HOST_OS),linux)
153  # Windows has been the default host_cross OS
154  ifeq (,$(filter-out windows,$(HOST_CROSS_OS)))
155    # We can only create static host binaries for Linux, so if static host
156    # binaries are requested, turn off Windows cross-builds.
157    ifeq ($(BUILD_HOST_static),)
158      HOST_CROSS_OS := windows
159      HOST_CROSS_ARCH := x86
160      HOST_CROSS_2ND_ARCH := x86_64
161      2ND_HOST_CROSS_IS_64_BIT := true
162    endif
163  else ifeq ($(HOST_CROSS_OS),linux_bionic)
164    ifeq (,$(HOST_CROSS_ARCH))
165      $(error HOST_CROSS_ARCH missing.)
166    endif
167  else
168    $(error Unsupported HOST_CROSS_OS $(HOST_CROSS_OS))
169  endif
170endif
171
172ifeq ($(HOST_OS),)
173$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
174endif
175
176# HOST_ARCH
177ifneq (,$(findstring x86_64,$(UNAME)))
178  HOST_ARCH := x86_64
179  HOST_2ND_ARCH := x86
180  HOST_IS_64_BIT := true
181else
182ifneq (,$(findstring i686,$(UNAME))$(findstring x86,$(UNAME)))
183$(error Building on a 32-bit x86 host is not supported: $(UNAME)!)
184endif
185endif
186
187ifeq ($(HOST_OS),darwin)
188  # Mac no longer supports 32-bit executables
189  HOST_2ND_ARCH :=
190endif
191
192HOST_2ND_ARCH_VAR_PREFIX := 2ND_
193HOST_2ND_ARCH_MODULE_SUFFIX := _32
194HOST_CROSS_2ND_ARCH_VAR_PREFIX := 2ND_
195HOST_CROSS_2ND_ARCH_MODULE_SUFFIX := _64
196TARGET_2ND_ARCH_VAR_PREFIX := 2ND_
197.KATI_READONLY := \
198  HOST_ARCH \
199  HOST_2ND_ARCH \
200  HOST_IS_64_BIT \
201  HOST_2ND_ARCH_VAR_PREFIX \
202  HOST_2ND_ARCH_MODULE_SUFFIX \
203  HOST_CROSS_2ND_ARCH_VAR_PREFIX \
204  HOST_CROSS_2ND_ARCH_MODULE_SUFFIX \
205  TARGET_2ND_ARCH_VAR_PREFIX \
206
207combo_target := HOST_
208combo_2nd_arch_prefix :=
209include $(BUILD_COMBOS)/select.mk
210
211ifdef HOST_2ND_ARCH
212  combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
213  include $(BUILD_SYSTEM)/combo/select.mk
214endif
215
216# Load the windows cross compiler under Linux
217ifdef HOST_CROSS_OS
218  combo_target := HOST_CROSS_
219  combo_2nd_arch_prefix :=
220  include $(BUILD_SYSTEM)/combo/select.mk
221
222  ifdef HOST_CROSS_2ND_ARCH
223    combo_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
224    include $(BUILD_SYSTEM)/combo/select.mk
225  endif
226endif
227
228# on windows, the tools have .exe at the end, and we depend on the
229# host config stuff being done first
230
231BUILD_ARCH := $(HOST_ARCH)
232BUILD_2ND_ARCH := $(HOST_2ND_ARCH)
233
234ifeq ($(HOST_ARCH),)
235$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
236endif
237
238# the host build defaults to release, and it must be release or debug
239ifeq ($(HOST_BUILD_TYPE),)
240HOST_BUILD_TYPE := release
241endif
242
243ifneq ($(HOST_BUILD_TYPE),release)
244ifneq ($(HOST_BUILD_TYPE),debug)
245$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
246endif
247endif
248
249# We don't want to move all the prebuilt host tools to a $(HOST_OS)-x86_64 dir.
250HOST_PREBUILT_ARCH := x86
251# This is the standard way to name a directory containing prebuilt host
252# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
253HOST_PREBUILT_TAG := $(BUILD_OS)-$(HOST_PREBUILT_ARCH)
254
255# TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT.
256# Define them here so they can be used in product config files.
257TARGET_COPY_OUT_SYSTEM := system
258TARGET_COPY_OUT_SYSTEM_OTHER := system_other
259TARGET_COPY_OUT_DATA := data
260TARGET_COPY_OUT_ASAN := $(TARGET_COPY_OUT_DATA)/asan
261TARGET_COPY_OUT_OEM := oem
262TARGET_COPY_OUT_RAMDISK := ramdisk
263TARGET_COPY_OUT_DEBUG_RAMDISK := debug_ramdisk
264TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK := vendor_debug_ramdisk
265TARGET_COPY_OUT_TEST_HARNESS_RAMDISK := test_harness_ramdisk
266TARGET_COPY_OUT_ROOT := root
267TARGET_COPY_OUT_RECOVERY := recovery
268# The directory used for optional partitions depend on the BoardConfig, so
269# they're defined to placeholder values here and swapped after reading the
270# BoardConfig, to be either the partition dir, or a subdir within 'system'.
271_vendor_path_placeholder := ||VENDOR-PATH-PH||
272_product_path_placeholder := ||PRODUCT-PATH-PH||
273_system_ext_path_placeholder := ||SYSTEM_EXT-PATH-PH||
274_odm_path_placeholder := ||ODM-PATH-PH||
275_vendor_dlkm_path_placeholder := ||VENDOR_DLKM-PATH-PH||
276_odm_dlkm_path_placeholder := ||ODM_DLKM-PATH-PH||
277TARGET_COPY_OUT_VENDOR := $(_vendor_path_placeholder)
278TARGET_COPY_OUT_VENDOR_RAMDISK := vendor_ramdisk
279TARGET_COPY_OUT_PRODUCT := $(_product_path_placeholder)
280# TODO(b/135957588) TARGET_COPY_OUT_PRODUCT_SERVICES will copy the target to
281# product
282TARGET_COPY_OUT_PRODUCT_SERVICES := $(_product_path_placeholder)
283TARGET_COPY_OUT_SYSTEM_EXT := $(_system_ext_path_placeholder)
284TARGET_COPY_OUT_ODM := $(_odm_path_placeholder)
285TARGET_COPY_OUT_VENDOR_DLKM := $(_vendor_dlkm_path_placeholder)
286TARGET_COPY_OUT_ODM_DLKM := $(_odm_dlkm_path_placeholder)
287
288# Returns the non-sanitized version of the path provided in $1.
289define get_non_asan_path
290$(patsubst $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/%,$(PRODUCT_OUT)/%,$1)
291endef
292
293#################################################################
294# Set up minimal BOOTCLASSPATH list of jars to build/execute
295# java code with dalvikvm/art.
296# Jars present in the ART apex. These should match exactly the list of
297# Java libraries in the ART apex build rule.
298ART_APEX_JARS := \
299    com.android.art:core-oj \
300    com.android.art:core-libart \
301    com.android.art:okhttp \
302    com.android.art:bouncycastle \
303    com.android.art:apache-xml
304# With EMMA_INSTRUMENT_FRAMEWORK=true the Core libraries depend on jacoco.
305ifeq (true,$(EMMA_INSTRUMENT_FRAMEWORK))
306  ART_APEX_JARS += com.android.art:jacocoagent
307endif
308#################################################################
309
310# Read the product specs so we can get TARGET_DEVICE and other
311# variables that we need in order to locate the output files.
312include $(BUILD_SYSTEM)/product_config.mk
313
314build_variant := $(filter-out eng user userdebug,$(TARGET_BUILD_VARIANT))
315ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
316$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
317$(error must be empty or one of: eng user userdebug)
318endif
319
320SDK_HOST_ARCH := x86
321TARGET_OS := linux
322
323include $(BUILD_SYSTEM)/board_config.mk
324
325# the target build type defaults to release
326ifneq ($(TARGET_BUILD_TYPE),debug)
327TARGET_BUILD_TYPE := release
328endif
329
330# ---------------------------------------------------------------
331# figure out the output directories
332
333SOONG_OUT_DIR := $(OUT_DIR)/soong
334
335TARGET_OUT_ROOT := $(OUT_DIR)/target
336
337HOST_OUT_ROOT := $(OUT_DIR)/host
338
339.KATI_READONLY := SOONG_OUT_DIR TARGET_OUT_ROOT HOST_OUT_ROOT
340
341# We want to avoid two host bin directories in multilib build.
342HOST_OUT := $(HOST_OUT_ROOT)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
343SOONG_HOST_OUT := $(SOONG_OUT_DIR)/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
344
345HOST_CROSS_OUT := $(HOST_OUT_ROOT)/$(HOST_CROSS_OS)-$(HOST_CROSS_ARCH)
346
347.KATI_READONLY := HOST_OUT SOONG_HOST_OUT HOST_CROSS_OUT
348
349TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
350
351TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
352HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
353
354PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
355
356.KATI_READONLY := TARGET_PRODUCT_OUT_ROOT TARGET_COMMON_OUT_ROOT HOST_COMMON_OUT_ROOT PRODUCT_OUT
357
358OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
359OUT_NDK_DOCS := $(TARGET_COMMON_OUT_ROOT)/ndk-docs
360.KATI_READONLY := OUT_DOCS OUT_NDK_DOCS
361
362$(call KATI_obsolete,BUILD_OUT,Use HOST_OUT instead)
363
364BUILD_OUT_EXECUTABLES := $(HOST_OUT)/bin
365SOONG_HOST_OUT_EXECUTABLES := $(SOONG_HOST_OUT)/bin
366.KATI_READONLY := BUILD_OUT_EXECUTABLES SOONG_HOST_OUT_EXECUTABLES
367
368HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
369HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
370HOST_OUT_DYLIB_LIBRARIES := $(HOST_OUT)/lib64
371HOST_OUT_RENDERSCRIPT_BITCODE := $(HOST_OUT_SHARED_LIBRARIES)
372HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
373HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
374HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest64
375HOST_OUT_COVERAGE := $(HOST_OUT)/coverage
376HOST_OUT_TESTCASES := $(HOST_OUT)/testcases
377.KATI_READONLY := \
378  HOST_OUT_EXECUTABLES \
379  HOST_OUT_SHARED_LIBRARIES \
380  HOST_OUT_RENDERSCRIPT_BITCODE \
381  HOST_OUT_JAVA_LIBRARIES \
382  HOST_OUT_SDK_ADDON \
383  HOST_OUT_NATIVE_TESTS \
384  HOST_OUT_COVERAGE \
385  HOST_OUT_TESTCASES
386
387HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin
388HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib
389HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest
390HOST_CROSS_OUT_COVERAGE := $(HOST_CROSS_OUT)/coverage
391HOST_CROSS_OUT_TESTCASES := $(HOST_CROSS_OUT)/testcases
392.KATI_READONLY := \
393  HOST_CROSS_OUT_EXECUTABLES \
394  HOST_CROSS_OUT_SHARED_LIBRARIES \
395  HOST_CROSS_OUT_NATIVE_TESTS \
396  HOST_CROSS_OUT_COVERAGE \
397  HOST_CROSS_OUT_TESTCASES
398
399HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
400HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
401HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
402HOST_OUT_FAKE := $(HOST_OUT)/fake_packages
403.KATI_READONLY := \
404  HOST_OUT_INTERMEDIATES \
405  HOST_OUT_NOTICE_FILES \
406  HOST_OUT_COMMON_INTERMEDIATES \
407  HOST_OUT_FAKE
408
409HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj
410HOST_CROSS_OUT_NOTICE_FILES := $(HOST_CROSS_OUT_INTERMEDIATES)/NOTICE_FILES
411.KATI_READONLY := \
412  HOST_CROSS_OUT_INTERMEDIATES \
413  HOST_CROSS_OUT_NOTICE_FILES
414
415HOST_OUT_GEN := $(HOST_OUT)/gen
416HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen
417.KATI_READONLY := \
418  HOST_OUT_GEN \
419  HOST_OUT_COMMON_GEN
420
421HOST_CROSS_OUT_GEN := $(HOST_CROSS_OUT)/gen
422.KATI_READONLY := HOST_CROSS_OUT_GEN
423
424# Out for HOST_2ND_ARCH
425$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj32
426$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
427$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES := $(HOST_OUT_EXECUTABLES)
428$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT_JAVA_LIBRARIES)
429$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest
430$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_TESTCASES := $(HOST_OUT_TESTCASES)
431.KATI_READONLY := \
432  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES \
433  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES \
434  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES \
435  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES \
436  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_NATIVE_TESTS \
437  $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_TESTCASES
438
439# The default host library path.
440# It always points to the path where we build libraries in the default bitness.
441HOST_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
442.KATI_READONLY := HOST_LIBRARY_PATH
443
444# Out for HOST_CROSS_2ND_ARCH
445$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj64
446$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib64
447$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT_EXECUTABLES)
448$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest64
449.KATI_READONLY := \
450  $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES \
451  $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES \
452  $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES \
453  $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_NATIVE_TESTS
454
455ifneq ($(filter address,$(SANITIZE_TARGET)),)
456  TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_asan
457else
458  TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
459endif
460TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include
461.KATI_READONLY := TARGET_OUT_INTERMEDIATES TARGET_OUT_HEADERS
462
463ifneq ($(filter address,$(SANITIZE_TARGET)),)
464  TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj_asan
465else
466  TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
467endif
468.KATI_READONLY := TARGET_OUT_COMMON_INTERMEDIATES
469
470TARGET_OUT_GEN := $(PRODUCT_OUT)/gen
471TARGET_OUT_COMMON_GEN := $(TARGET_COMMON_OUT_ROOT)/gen
472.KATI_READONLY := TARGET_OUT_GEN TARGET_OUT_COMMON_GEN
473
474TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
475.KATI_READONLY := TARGET_OUT
476ifneq ($(filter address,$(SANITIZE_TARGET)),)
477target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system
478ifeq ($(SANITIZE_LITE),true)
479# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
480# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
481target_out_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system
482else
483target_out_app_base := $(TARGET_OUT)
484endif
485else
486target_out_shared_libraries_base := $(TARGET_OUT)
487target_out_app_base := $(TARGET_OUT)
488endif
489
490TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin
491TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin
492ifeq ($(TARGET_IS_64_BIT),true)
493# /system/lib always contains 32-bit libraries,
494# and /system/lib64 (if present) always contains 64-bit libraries.
495TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib64
496else
497TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
498endif
499TARGET_OUT_RENDERSCRIPT_BITCODE := $(TARGET_OUT_SHARED_LIBRARIES)
500TARGET_OUT_JAVA_LIBRARIES := $(TARGET_OUT)/framework
501TARGET_OUT_APPS := $(target_out_app_base)/app
502TARGET_OUT_APPS_PRIVILEGED := $(target_out_app_base)/priv-app
503TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
504TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
505TARGET_OUT_ETC := $(TARGET_OUT)/etc
506TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
507TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
508TARGET_OUT_TESTCASES := $(PRODUCT_OUT)/testcases
509.KATI_READONLY := \
510  TARGET_OUT_EXECUTABLES \
511  TARGET_OUT_OPTIONAL_EXECUTABLES \
512  TARGET_OUT_SHARED_LIBRARIES \
513  TARGET_OUT_RENDERSCRIPT_BITCODE \
514  TARGET_OUT_JAVA_LIBRARIES \
515  TARGET_OUT_APPS \
516  TARGET_OUT_APPS_PRIVILEGED \
517  TARGET_OUT_KEYLAYOUT \
518  TARGET_OUT_KEYCHARS \
519  TARGET_OUT_ETC \
520  TARGET_OUT_NOTICE_FILES \
521  TARGET_OUT_FAKE \
522  TARGET_OUT_TESTCASES
523
524ifeq ($(SANITIZE_LITE),true)
525# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
526# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
527TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
528else
529TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
530endif
531.KATI_READONLY := TARGET_OUT_SYSTEM_OTHER
532
533# Out for TARGET_2ND_ARCH
534TARGET_2ND_ARCH_MODULE_SUFFIX := $(HOST_2ND_ARCH_MODULE_SUFFIX)
535.KATI_READONLY := TARGET_2ND_ARCH_MODULE_SUFFIX
536
537ifneq ($(filter address,$(SANITIZE_TARGET)),)
538  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)_asan
539else
540  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)
541endif
542$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
543$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
544$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
545$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
546$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
547$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_TESTCASES := $(TARGET_OUT_TESTCASES)
548.KATI_READONLY := \
549  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES \
550  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES \
551  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_RENDERSCRIPT_BITCODE \
552  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES \
553  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS \
554  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED \
555  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_TESTCASES
556
557MODULE_CLASS_APPS := app
558MODULE_CLASS_EXECUTABLES := bin
559MODULE_CLASS_JAVA_LIBRARIES := framework
560MODULE_CLASS_NATIVE_TESTS := nativetest
561MODULE_CLASS_METRIC_TESTS := benchmarktest
562TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
563TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
564TARGET_OUT_DATA_SHARED_LIBRARIES := $(TARGET_OUT_SHARED_LIBRARIES)
565TARGET_OUT_DATA_JAVA_LIBRARIES := $(TARGET_OUT_DATA)/framework
566TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA)/app
567TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
568TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
569TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
570ifeq ($(TARGET_IS_64_BIT),true)
571TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64
572TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest64
573TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64$(TARGET_VENDOR_TEST_SUFFIX)
574TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest64$(TARGET_VENDOR_TEST_SUFFIX)
575else
576TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
577TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
578TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest$(TARGET_VENDOR_TEST_SUFFIX)
579TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest$(TARGET_VENDOR_TEST_SUFFIX)
580endif
581MODULE_CLASS_FAKE := fake_packages
582TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
583.KATI_READONLY := \
584  TARGET_OUT_DATA \
585  TARGET_OUT_DATA_EXECUTABLES \
586  TARGET_OUT_DATA_SHARED_LIBRARIES \
587  TARGET_OUT_DATA_JAVA_LIBRARIES \
588  TARGET_OUT_DATA_APPS \
589  TARGET_OUT_DATA_KEYLAYOUT \
590  TARGET_OUT_DATA_KEYCHARS \
591  TARGET_OUT_DATA_ETC \
592  TARGET_OUT_DATA_NATIVE_TESTS \
593  TARGET_OUT_DATA_METRIC_TESTS \
594  TARGET_OUT_VENDOR_NATIVE_TESTS \
595  TARGET_OUT_VENDOR_METRIC_TESTS \
596  TARGET_OUT_DATA_FAKE \
597  MODULE_CLASS_APPS \
598  MODULE_CLASS_EXECUTABLES \
599  MODULE_CLASS_JAVA_LIBRARIES \
600  MODULE_CLASS_NATIVE_TESTS \
601  MODULE_CLASS_METRIC_TESTS \
602  MODULE_CLASS_FAKE
603
604$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
605$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
606$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
607$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
608$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
609$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest$(TARGET_VENDOR_TEST_SUFFIX)
610$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest$(TARGET_VENDOR_TEST_SUFFIX)
611.KATI_READONLY := \
612  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES \
613  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES \
614  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS \
615  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS \
616  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS \
617  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_NATIVE_TESTS \
618  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_METRIC_TESTS \
619
620TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
621.KATI_READONLY := TARGET_OUT_CACHE
622
623TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
624.KATI_READONLY := TARGET_OUT_VENDOR
625ifneq ($(filter address,$(SANITIZE_TARGET)),)
626target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_VENDOR)
627ifeq ($(SANITIZE_LITE),true)
628# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
629# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
630target_out_vendor_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_VENDOR)
631else
632target_out_vendor_app_base := $(TARGET_OUT_VENDOR)
633endif
634else
635target_out_vendor_shared_libraries_base := $(TARGET_OUT_VENDOR)
636target_out_vendor_app_base := $(TARGET_OUT_VENDOR)
637endif
638
639TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR)/bin
640TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES := $(TARGET_OUT_VENDOR)/xbin
641ifeq ($(TARGET_IS_64_BIT),true)
642TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib64
643else
644TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
645endif
646TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
647TARGET_OUT_VENDOR_JAVA_LIBRARIES := $(TARGET_OUT_VENDOR)/framework
648TARGET_OUT_VENDOR_APPS := $(target_out_vendor_app_base)/app
649TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(target_out_vendor_app_base)/priv-app
650TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
651.KATI_READONLY := \
652  TARGET_OUT_VENDOR_EXECUTABLES \
653  TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES \
654  TARGET_OUT_VENDOR_SHARED_LIBRARIES \
655  TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE \
656  TARGET_OUT_VENDOR_JAVA_LIBRARIES \
657  TARGET_OUT_VENDOR_APPS \
658  TARGET_OUT_VENDOR_APPS_PRIVILEGED \
659  TARGET_OUT_VENDOR_ETC
660
661$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
662$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
663$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)
664$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
665$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)
666.KATI_READONLY := \
667  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES \
668  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES \
669  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE \
670  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS \
671  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS_PRIVILEGED
672
673TARGET_OUT_OEM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_OEM)
674TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM)/bin
675ifeq ($(TARGET_IS_64_BIT),true)
676TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib64
677else
678TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
679endif
680# We don't expect Java libraries in the oem.img.
681# TARGET_OUT_OEM_JAVA_LIBRARIES:= $(TARGET_OUT_OEM)/framework
682TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM)/app
683TARGET_OUT_OEM_ETC := $(TARGET_OUT_OEM)/etc
684.KATI_READONLY := \
685  TARGET_OUT_OEM \
686  TARGET_OUT_OEM_EXECUTABLES \
687  TARGET_OUT_OEM_SHARED_LIBRARIES \
688  TARGET_OUT_OEM_APPS \
689  TARGET_OUT_OEM_ETC
690
691$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM_EXECUTABLES)
692$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
693$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM_APPS)
694.KATI_READONLY := \
695  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_EXECUTABLES \
696  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES \
697  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_APPS \
698
699TARGET_OUT_ODM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM)
700ifneq ($(filter address,$(SANITIZE_TARGET)),)
701target_out_odm_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_OEM)
702ifeq ($(SANITIZE_LITE),true)
703# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
704# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
705target_out_odm_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_OEM)
706else
707target_out_odm_app_base := $(TARGET_OUT_ODM)
708endif
709else
710target_out_odm_shared_libraries_base := $(TARGET_OUT_ODM)
711target_out_odm_app_base := $(TARGET_OUT_ODM)
712endif
713
714TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM)/bin
715TARGET_OUT_ODM_OPTIONAL_EXECUTABLES := $(TARGET_OUT_ODM)/xbin
716ifeq ($(TARGET_IS_64_BIT),true)
717TARGET_OUT_ODM_SHARED_LIBRARIES := $(target_out_odm_shared_libraries_base)/lib64
718else
719TARGET_OUT_ODM_SHARED_LIBRARIES := $(target_out_odm_shared_libraries_base)/lib
720endif
721TARGET_OUT_ODM_RENDERSCRIPT_BITCODE := $(TARGET_OUT_ODM_SHARED_LIBRARIES)
722TARGET_OUT_ODM_JAVA_LIBRARIES := $(TARGET_OUT_ODM)/framework
723TARGET_OUT_ODM_APPS := $(target_out_odm_app_base)/app
724TARGET_OUT_ODM_APPS_PRIVILEGED := $(target_out_odm_app_base)/priv-app
725TARGET_OUT_ODM_ETC := $(TARGET_OUT_ODM)/etc
726.KATI_READONLY := \
727  TARGET_OUT_ODM \
728  TARGET_OUT_ODM_EXECUTABLES \
729  TARGET_OUT_ODM_OPTIONAL_EXECUTABLES \
730  TARGET_OUT_ODM_SHARED_LIBRARIES \
731  TARGET_OUT_ODM_RENDERSCRIPT_BITCODE \
732  TARGET_OUT_ODM_JAVA_LIBRARIES \
733  TARGET_OUT_ODM_APPS \
734  TARGET_OUT_ODM_APPS_PRIVILEGED \
735  TARGET_OUT_ODM_ETC
736
737$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM_EXECUTABLES)
738$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(target_out_odm_shared_libraries_base)/lib
739$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES)
740$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM_APPS)
741$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS_PRIVILEGED := $(TARGET_OUT_ODM_APPS_PRIVILEGED)
742.KATI_READONLY := \
743  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_EXECUTABLES \
744  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES \
745  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_RENDERSCRIPT_BITCODE \
746  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS \
747  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS_PRIVILEGED
748
749TARGET_OUT_VENDOR_DLKM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR_DLKM)
750
751TARGET_OUT_VENDOR_DLKM_ETC := $(TARGET_OUT_VENDOR_DLKM)/etc
752.KATI_READONLY := \
753  TARGET_OUT_VENDOR_DLKM_ETC
754
755# Unlike other partitions, vendor_dlkm should only contain kernel modules.
756TARGET_OUT_VENDOR_DLKM_EXECUTABLES :=
757TARGET_OUT_VENDOR_DLKM_OPTIONAL_EXECUTABLES :=
758TARGET_OUT_VENDOR_DLKM_SHARED_LIBRARIES :=
759TARGET_OUT_VENDOR_DLKM_RENDERSCRIPT_BITCODE :=
760TARGET_OUT_VENDOR_DLKM_JAVA_LIBRARIES :=
761TARGET_OUT_VENDOR_DLKM_APPS :=
762TARGET_OUT_VENDOR_DLKM_APPS_PRIVILEGED :=
763$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_EXECUTABLES :=
764$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_SHARED_LIBRARIES :=
765$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_RENDERSCRIPT_BITCODE :=
766$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_APPS :=
767$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_APPS_PRIVILEGED :=
768$(KATI_obsolete_var \
769    TARGET_OUT_VENDOR_DLKM_EXECUTABLES \
770    TARGET_OUT_VENDOR_DLKM_OPTIONAL_EXECUTABLES \
771    TARGET_OUT_VENDOR_DLKM_SHARED_LIBRARIES \
772    TARGET_OUT_VENDOR_DLKM_RENDERSCRIPT_BITCODE \
773    TARGET_OUT_VENDOR_DLKM_JAVA_LIBRARIES \
774    TARGET_OUT_VENDOR_DLKM_APPS \
775    TARGET_OUT_VENDOR_DLKM_APPS_PRIVILEGED \
776    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_EXECUTABLES \
777    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_SHARED_LIBRARIES \
778    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_RENDERSCRIPT_BITCODE \
779    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_APPS \
780    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_DLKM_APPS_PRIVILEGED \
781    , vendor_dlkm should not contain any executables, libraries, or apps)
782
783TARGET_OUT_ODM_DLKM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM_DLKM)
784
785TARGET_OUT_ODM_DLKM_ETC := $(TARGET_OUT_ODM_DLKM)/etc
786.KATI_READONLY := \
787  TARGET_OUT_ODM_DLKM_ETC
788
789# Unlike other partitions, odm_dlkm should only contain kernel modules.
790TARGET_OUT_ODM_DLKM_EXECUTABLES :=
791TARGET_OUT_ODM_DLKM_OPTIONAL_EXECUTABLES :=
792TARGET_OUT_ODM_DLKM_SHARED_LIBRARIES :=
793TARGET_OUT_ODM_DLKM_RENDERSCRIPT_BITCODE :=
794TARGET_OUT_ODM_DLKM_JAVA_LIBRARIES :=
795TARGET_OUT_ODM_DLKM_APPS :=
796TARGET_OUT_ODM_DLKM_APPS_PRIVILEGED :=
797$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_EXECUTABLES :=
798$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_SHARED_LIBRARIES :=
799$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_RENDERSCRIPT_BITCODE :=
800$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_APPS :=
801$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_APPS_PRIVILEGED :=
802$(KATI_obsolete_var \
803    TARGET_OUT_ODM_DLKM_EXECUTABLES \
804    TARGET_OUT_ODM_DLKM_OPTIONAL_EXECUTABLES \
805    TARGET_OUT_ODM_DLKM_SHARED_LIBRARIES \
806    TARGET_OUT_ODM_DLKM_RENDERSCRIPT_BITCODE \
807    TARGET_OUT_ODM_DLKM_JAVA_LIBRARIES \
808    TARGET_OUT_ODM_DLKM_APPS \
809    TARGET_OUT_ODM_DLKM_APPS_PRIVILEGED \
810    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_EXECUTABLES \
811    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_SHARED_LIBRARIES \
812    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_RENDERSCRIPT_BITCODE \
813    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_APPS \
814    $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_DLKM_APPS_PRIVILEGED \
815    , odm_dlkm should not contain any executables, libraries, or apps)
816
817TARGET_OUT_PRODUCT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_PRODUCT)
818TARGET_OUT_PRODUCT_EXECUTABLES := $(TARGET_OUT_PRODUCT)/bin
819.KATI_READONLY := TARGET_OUT_PRODUCT
820ifneq ($(filter address,$(SANITIZE_TARGET)),)
821target_out_product_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_PRODUCT)
822ifeq ($(SANITIZE_LITE),true)
823# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
824# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
825target_out_product_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_PRODUCT)
826else
827target_out_product_app_base := $(TARGET_OUT_PRODUCT)
828endif
829else
830target_out_product_shared_libraries_base := $(TARGET_OUT_PRODUCT)
831target_out_product_app_base := $(TARGET_OUT_PRODUCT)
832endif
833
834ifeq ($(TARGET_IS_64_BIT),true)
835TARGET_OUT_PRODUCT_SHARED_LIBRARIES := $(target_out_product_shared_libraries_base)/lib64
836else
837TARGET_OUT_PRODUCT_SHARED_LIBRARIES := $(target_out_product_shared_libraries_base)/lib
838endif
839TARGET_OUT_PRODUCT_JAVA_LIBRARIES := $(TARGET_OUT_PRODUCT)/framework
840TARGET_OUT_PRODUCT_APPS := $(target_out_product_app_base)/app
841TARGET_OUT_PRODUCT_APPS_PRIVILEGED := $(target_out_product_app_base)/priv-app
842TARGET_OUT_PRODUCT_ETC := $(TARGET_OUT_PRODUCT)/etc
843.KATI_READONLY := \
844  TARGET_OUT_PRODUCT_EXECUTABLES \
845  TARGET_OUT_PRODUCT_SHARED_LIBRARIES \
846  TARGET_OUT_PRODUCT_JAVA_LIBRARIES \
847  TARGET_OUT_PRODUCT_APPS \
848  TARGET_OUT_PRODUCT_APPS_PRIVILEGED \
849  TARGET_OUT_PRODUCT_ETC
850
851$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_EXECUTABLES := $(TARGET_OUT_PRODUCT_EXECUTABLES)
852$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_SHARED_LIBRARIES := $(target_out_product_shared_libraries_base)/lib
853$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_APPS := $(TARGET_OUT_PRODUCT_APPS)
854$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_APPS_PRIVILEGED := $(TARGET_OUT_PRODUCT_APPS_PRIVILEGED)
855.KATI_READONLY := \
856  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_EXECUTABLES \
857  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_SHARED_LIBRARIES \
858  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_APPS \
859  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_PRODUCT_APPS_PRIVILEGED
860
861TARGET_OUT_SYSTEM_EXT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_EXT)
862ifneq ($(filter address,$(SANITIZE_TARGET)),)
863target_out_system_ext_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_EXT)
864ifeq ($(SANITIZE_LITE),true)
865# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
866# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
867target_out_system_ext_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_EXT)
868else
869target_out_system_ext_app_base := $(TARGET_OUT_SYSTEM_EXT)
870endif
871else
872target_out_system_ext_shared_libraries_base := $(TARGET_OUT_SYSTEM_EXT)
873target_out_system_ext_app_base := $(TARGET_OUT_SYSTEM_EXT)
874endif
875
876ifeq ($(TARGET_IS_64_BIT),true)
877TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES := $(target_out_system_ext_shared_libraries_base)/lib64
878else
879TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES := $(target_out_system_ext_shared_libraries_base)/lib
880endif
881TARGET_OUT_SYSTEM_EXT_JAVA_LIBRARIES:= $(TARGET_OUT_SYSTEM_EXT)/framework
882TARGET_OUT_SYSTEM_EXT_APPS := $(target_out_system_ext_app_base)/app
883TARGET_OUT_SYSTEM_EXT_APPS_PRIVILEGED := $(target_out_system_ext_app_base)/priv-app
884TARGET_OUT_SYSTEM_EXT_ETC := $(TARGET_OUT_SYSTEM_EXT)/etc
885TARGET_OUT_SYSTEM_EXT_EXECUTABLES := $(TARGET_OUT_SYSTEM_EXT)/bin
886.KATI_READONLY := \
887  TARGET_OUT_SYSTEM_EXT_EXECUTABLES \
888  TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES \
889  TARGET_OUT_SYSTEM_EXT_JAVA_LIBRARIES \
890  TARGET_OUT_SYSTEM_EXT_APPS \
891  TARGET_OUT_SYSTEM_EXT_APPS_PRIVILEGED \
892  TARGET_OUT_SYSTEM_EXT_ETC
893
894$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_EXECUTABLES := $(TARGET_OUT_SYSTEM_EXT_EXECUTABLES)
895$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES := $(target_out_system_ext_shared_libraries_base)/lib
896$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_APPS := $(TARGET_OUT_SYSTEM_EXT_APPS)
897$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_APPS_PRIVILEGED := $(TARGET_OUT_SYSTEM_EXT_APPS_PRIVILEGED)
898.KATI_READONLY := \
899  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_EXECUTABLES \
900  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_SHARED_LIBRARIES \
901  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_APPS \
902  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_EXT_APPS_PRIVILEGED
903
904TARGET_OUT_BREAKPAD := $(PRODUCT_OUT)/breakpad
905.KATI_READONLY := TARGET_OUT_BREAKPAD
906
907TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
908TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
909TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
910TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/$(TARGET_COPY_OUT_VENDOR)/lib
911TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
912TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
913TARGET_OUT_COVERAGE := $(PRODUCT_OUT)/coverage
914.KATI_READONLY := \
915  TARGET_OUT_UNSTRIPPED \
916  TARGET_OUT_EXECUTABLES_UNSTRIPPED \
917  TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED \
918  TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED \
919  TARGET_ROOT_OUT_UNSTRIPPED \
920  TARGET_ROOT_OUT_BIN_UNSTRIPPED \
921  TARGET_OUT_COVERAGE
922
923TARGET_RAMDISK_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RAMDISK)
924TARGET_RAMDISK_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
925TARGET_DEBUG_RAMDISK_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DEBUG_RAMDISK)
926TARGET_VENDOR_DEBUG_RAMDISK_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK)
927TARGET_TEST_HARNESS_RAMDISK_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_TEST_HARNESS_RAMDISK)
928
929TARGET_VENDOR_RAMDISK_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR_RAMDISK)
930
931TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
932TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
933TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
934TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
935.KATI_READONLY := \
936  TARGET_ROOT_OUT \
937  TARGET_ROOT_OUT_BIN \
938  TARGET_ROOT_OUT_ETC \
939  TARGET_ROOT_OUT_USR
940
941TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RECOVERY)
942TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
943.KATI_READONLY := \
944  TARGET_RECOVERY_OUT \
945  TARGET_RECOVERY_ROOT_OUT
946
947TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
948TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
949TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
950.KATI_READONLY := \
951  TARGET_SYSLOADER_OUT \
952  TARGET_SYSLOADER_ROOT_OUT \
953  TARGET_SYSLOADER_SYSTEM_OUT
954
955TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
956TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
957TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
958TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
959.KATI_READONLY := \
960  TARGET_INSTALLER_OUT \
961  TARGET_INSTALLER_DATA_OUT \
962  TARGET_INSTALLER_ROOT_OUT \
963  TARGET_INSTALLER_SYSTEM_OUT
964
965COMMON_MODULE_CLASSES := TARGET_NOTICE_FILES HOST_NOTICE_FILES HOST_JAVA_LIBRARIES
966PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE NATIVE_TESTS HEADER_LIBRARIES RLIB_LIBRARIES DYLIB_LIBRARIES
967.KATI_READONLY := COMMON_MODULE_CLASSES PER_ARCH_MODULE_CLASSES
968
969ifeq ($(CALLED_FROM_SETUP),true)
970PRINT_BUILD_CONFIG ?= true
971endif
972