envsetup.mk revision 4ed21d10e8222ad6aa79e8bf4ef32065a9a603ee
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)PR1 $(1)PD1 $(1)PD2 $(1)PM1 $(1)PM2
29endef
30
31ALL_VERSIONS := O P Q R S T U V W X Y Z
32ALL_VERSIONS := $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
33
34# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is
35# not in [$1, $2]
36# $(1): min platform version
37# $(2): max platform version
38# $(3): default platform version
39define allowed-platform-versions
40$(strip \
41  $(if $(filter $(ALL_VERSIONS),$(1)),,
42    $(error Invalid MIN_PLATFORM_VERSION '$(1)'))
43  $(if $(filter $(ALL_VERSIONS),$(2)),,
44    $(error Invalid MAX_PLATFORM_VERSION '$(2)'))
45  $(if $(filter $(ALL_VERSIONS),$(3)),,
46    $(error Invalid DEFAULT_PLATFORM_VERSION '$(3)'))
47
48  $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2)))
49
50  $(if $(filter $(allowed_versions_),$(1)),,
51    $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)'))
52
53  $(eval allowed_versions_ := $(1) \
54    $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_)))
55
56  $(if $(filter $(allowed_versions_),$(3)),,
57    $(error DEFAULT_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)'))
58
59  $(allowed_versions_))
60endef
61
62#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1))
63#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1))
64
65# Set up version information.
66include $(BUILD_SYSTEM)/version_defaults.mk
67
68ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION))
69
70$(foreach v,$(ENABLED_VERSIONS), \
71  $(eval IS_AT_LEAST_$(v) := true))
72
73# ---------------------------------------------------------------
74# If you update the build system such that the environment setup
75# or buildspec.mk need to be updated, increment this number, and
76# people who haven't re-run those will have to do so before they
77# can build.  Make sure to also update the corresponding value in
78# buildspec.mk.default and envsetup.sh.
79CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 13
80
81# ---------------------------------------------------------------
82# The product defaults to generic on hardware
83# NOTE: This will be overridden in product_config.mk if make
84# was invoked with a PRODUCT-xxx-yyy goal.
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
95# ---------------------------------------------------------------
96# Set up configuration for host machine.  We don't do cross-
97# compiles except for arm/mips, so the HOST is whatever we are
98# running on
99
100# HOST_OS
101ifneq (,$(findstring Linux,$(UNAME)))
102  HOST_OS := linux
103endif
104ifneq (,$(findstring Darwin,$(UNAME)))
105  HOST_OS := darwin
106endif
107ifneq (,$(findstring Macintosh,$(UNAME)))
108  HOST_OS := darwin
109endif
110
111HOST_OS_EXTRA := $(shell uname -rsm)
112ifeq ($(HOST_OS),linux)
113  ifneq ($(wildcard /etc/os-release),)
114    HOST_OS_EXTRA += $(shell source /etc/os-release; echo $$PRETTY_NAME)
115  endif
116else ifeq ($(HOST_OS),darwin)
117  HOST_OS_EXTRA += $(shell sw_vers -productVersion)
118endif
119HOST_OS_EXTRA := $(subst $(space),-,$(HOST_OS_EXTRA))
120
121# BUILD_OS is the real host doing the build.
122BUILD_OS := $(HOST_OS)
123
124HOST_CROSS_OS :=
125# We can cross-build Windows binaries on Linux
126ifeq ($(HOST_OS),linux)
127HOST_CROSS_OS := windows
128HOST_CROSS_ARCH := x86
129HOST_CROSS_2ND_ARCH := x86_64
1302ND_HOST_CROSS_IS_64_BIT := true
131endif
132
133ifeq ($(HOST_OS),)
134$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
135endif
136
137# HOST_ARCH
138ifneq (,$(findstring x86_64,$(UNAME)))
139  HOST_ARCH := x86_64
140  HOST_2ND_ARCH := x86
141  HOST_IS_64_BIT := true
142else
143ifneq (,$(findstring i686,$(UNAME))$(findstring x86,$(UNAME)))
144$(error Building on a 32-bit x86 host is not supported: $(UNAME)!)
145endif
146endif
147
148BUILD_ARCH := $(HOST_ARCH)
149BUILD_2ND_ARCH := $(HOST_2ND_ARCH)
150
151ifeq ($(HOST_ARCH),)
152$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
153endif
154
155# the host build defaults to release, and it must be release or debug
156ifeq ($(HOST_BUILD_TYPE),)
157HOST_BUILD_TYPE := release
158endif
159
160ifneq ($(HOST_BUILD_TYPE),release)
161ifneq ($(HOST_BUILD_TYPE),debug)
162$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
163endif
164endif
165
166# We don't want to move all the prebuilt host tools to a $(HOST_OS)-x86_64 dir.
167HOST_PREBUILT_ARCH := x86
168# This is the standard way to name a directory containing prebuilt host
169# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
170HOST_PREBUILT_TAG := $(BUILD_OS)-$(HOST_PREBUILT_ARCH)
171
172# TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT.
173# Define them here so they can be used in product config files.
174TARGET_COPY_OUT_SYSTEM := system
175TARGET_COPY_OUT_SYSTEM_OTHER := system_other
176TARGET_COPY_OUT_DATA := data
177TARGET_COPY_OUT_ASAN := $(TARGET_COPY_OUT_DATA)/asan
178TARGET_COPY_OUT_OEM := oem
179TARGET_COPY_OUT_ODM := odm
180TARGET_COPY_OUT_ROOT := root
181TARGET_COPY_OUT_RECOVERY := recovery
182
183# Returns the non-sanitized version of the path provided in $1.
184define get_non_asan_path
185$(patsubst $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/%,$(PRODUCT_OUT)/%,$1)
186endef
187
188###########################################
189# Define TARGET_COPY_OUT_VENDOR to a placeholder, for at this point
190# we don't know if the device wants to build a separate vendor.img
191# or just build vendor stuff into system.img.
192# A device can set up TARGET_COPY_OUT_VENDOR to "vendor" in its
193# BoardConfig.mk.
194# We'll substitute with the real value after loading BoardConfig.mk.
195_vendor_path_placeholder := ||VENDOR-PATH-PH||
196TARGET_COPY_OUT_VENDOR := $(_vendor_path_placeholder)
197###########################################
198
199#################################################################
200# Set up minimal BOOTCLASSPATH list of jars to build/execute
201# java code with dalvikvm/art.
202TARGET_CORE_JARS := core-oj core-libart conscrypt okhttp bouncycastle apache-xml
203HOST_CORE_JARS := $(addsuffix -hostdex,$(TARGET_CORE_JARS))
204#################################################################
205
206# Read the product specs so we can get TARGET_DEVICE and other
207# variables that we need in order to locate the output files.
208include $(BUILD_SYSTEM)/product_config.mk
209
210build_variant := $(filter-out eng user userdebug,$(TARGET_BUILD_VARIANT))
211ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
212$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
213$(error must be empty or one of: eng user userdebug)
214endif
215
216SDK_HOST_ARCH := x86
217
218# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
219# or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
220# make sure only one exists.
221# Real boards should always be associated with an OEM vendor.
222board_config_mk := \
223	$(strip $(sort $(wildcard \
224		$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
225		$(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
226		$(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
227	)))
228ifeq ($(board_config_mk),)
229  $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
230endif
231ifneq ($(words $(board_config_mk)),1)
232  $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
233endif
234include $(board_config_mk)
235ifeq ($(TARGET_ARCH),)
236  $(error TARGET_ARCH not defined by board config: $(board_config_mk))
237endif
238ifneq ($(MALLOC_IMPL),)
239  $(warning *** Unsupported option MALLOC_IMPL defined by board config: $(board_config_mk).)
240  $(error Use `MALLOC_SVELTE := true` to configure jemalloc for low-memory)
241endif
242TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
243board_config_mk :=
244
245###########################################
246# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR
247ifeq ($(TARGET_COPY_OUT_VENDOR),$(_vendor_path_placeholder))
248TARGET_COPY_OUT_VENDOR := system/vendor
249else ifeq ($(filter vendor system/vendor,$(TARGET_COPY_OUT_VENDOR)),)
250$(error TARGET_COPY_OUT_VENDOR must be either 'vendor' or 'system/vendor', seeing '$(TARGET_COPY_OUT_VENDOR)'.)
251endif
252PRODUCT_COPY_FILES := $(subst $(_vendor_path_placeholder),$(TARGET_COPY_OUT_VENDOR),$(PRODUCT_COPY_FILES))
253
254BOARD_USES_VENDORIMAGE :=
255ifdef BOARD_PREBUILT_VENDORIMAGE
256BOARD_USES_VENDORIMAGE := true
257endif
258ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
259BOARD_USES_VENDORIMAGE := true
260endif
261ifeq ($(TARGET_COPY_OUT_VENDOR),vendor)
262BOARD_USES_VENDORIMAGE := true
263else ifdef BOARD_USES_VENDORIMAGE
264$(error TARGET_COPY_OUT_VENDOR must be set to 'vendor' to use a vendor image)
265endif
266###########################################
267# Ensure that only TARGET_RECOVERY_UPDATER_LIBS *or* AB_OTA_UPDATER is set.
268TARGET_RECOVERY_UPDATER_LIBS ?=
269AB_OTA_UPDATER ?=
270.KATI_READONLY := TARGET_RECOVERY_UPDATER_LIBS AB_OTA_UPDATER
271ifeq ($(AB_OTA_UPDATER),true)
272  ifneq ($(strip $(TARGET_RECOVERY_UPDATER_LIBS)),)
273    $(error Do not use TARGET_RECOVERY_UPDATER_LIBS when using AB_OTA_UPDATER)
274  endif
275endif
276
277# Check BOARD_VNDK_VERSION
278ifdef BOARD_VNDK_VERSION
279  ifneq ($(BOARD_VNDK_VERSION),current)
280    $(error BOARD_VNDK_VERSION: Only "current" is implemented)
281  endif
282
283  TARGET_VENDOR_TEST_SUFFIX := /vendor
284else
285  TARGET_VENDOR_TEST_SUFFIX :=
286endif
287
288# ---------------------------------------------------------------
289# Set up configuration for target machine.
290# The following must be set:
291# 		TARGET_OS = { linux }
292# 		TARGET_ARCH = { arm | x86 | mips }
293
294TARGET_OS := linux
295# TARGET_ARCH should be set by BoardConfig.mk and will be checked later
296ifneq ($(filter %64,$(TARGET_ARCH)),)
297TARGET_IS_64_BIT := true
298endif
299
300# the target build type defaults to release
301ifneq ($(TARGET_BUILD_TYPE),debug)
302TARGET_BUILD_TYPE := release
303endif
304
305# ---------------------------------------------------------------
306# figure out the output directories
307
308ifeq (,$(strip $(OUT_DIR)))
309ifeq (,$(strip $(OUT_DIR_COMMON_BASE)))
310OUT_DIR := $(TOPDIR)out
311else
312OUT_DIR := $(OUT_DIR_COMMON_BASE)/$(notdir $(PWD))
313endif
314endif
315
316SOONG_OUT_DIR := $(OUT_DIR)/soong
317
318DEBUG_OUT_DIR := $(OUT_DIR)/debug
319
320# Move the host or target under the debug/ directory
321# if necessary.
322TARGET_OUT_ROOT_release := $(OUT_DIR)/target
323TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
324TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
325
326HOST_OUT_ROOT_release := $(OUT_DIR)/host
327HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
328HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
329
330# We want to avoid two host bin directories in multilib build.
331HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
332HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
333HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
334SOONG_HOST_OUT := $(SOONG_OUT_DIR)/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
335# TODO: remove
336BUILD_OUT := $(HOST_OUT)
337
338HOST_CROSS_OUT_release := $(HOST_OUT_ROOT_release)/windows-$(HOST_PREBUILT_ARCH)
339HOST_CROSS_OUT_debug := $(HOST_OUT_ROOT_debug)/windows-$(HOST_PREBUILT_ARCH)
340HOST_CROSS_OUT := $(HOST_CROSS_OUT_$(HOST_BUILD_TYPE))
341
342TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
343
344TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
345HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
346
347PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
348
349OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
350
351BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
352SOONG_HOST_OUT_EXECUTABLES := $(SOONG_HOST_OUT)/bin
353
354HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
355HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
356HOST_OUT_RENDERSCRIPT_BITCODE := $(HOST_OUT_SHARED_LIBRARIES)
357HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
358HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
359HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest64
360HOST_OUT_COVERAGE := $(HOST_OUT)/coverage
361
362HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin
363HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib
364HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest
365HOST_CROSS_OUT_COVERAGE := $(HOST_CROSS_OUT)/coverage
366HOST_OUT_TESTCASES := $(HOST_OUT)/testcases
367
368HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
369HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
370HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
371HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
372HOST_OUT_FAKE := $(HOST_OUT)/fake_packages
373
374# Nano environment config
375include $(BUILD_SYSTEM)/aux_config.mk
376
377HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj
378HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $(HOST_CROSS_OUT_INTERMEDIATES)/lib
379HOST_CROSS_OUT_NOTICE_FILES := $(HOST_CROSS_OUT_INTERMEDIATES)/NOTICE_FILES
380
381HOST_OUT_GEN := $(HOST_OUT)/gen
382HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen
383
384HOST_CROSS_OUT_GEN := $(HOST_CROSS_OUT)/gen
385
386# Out for HOST_2ND_ARCH
387HOST_2ND_ARCH_VAR_PREFIX := 2ND_
388HOST_2ND_ARCH_MODULE_SUFFIX := _32
389$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj32
390$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES)/lib
391$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
392$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES := $(HOST_OUT_EXECUTABLES)
393$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT_JAVA_LIBRARIES)
394$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest
395$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_TESTCASES := $(HOST_OUT_TESTCASES)
396
397# The default host library path.
398# It always points to the path where we build libraries in the default bitness.
399HOST_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
400
401# Out for HOST_CROSS_2ND_ARCH
402HOST_CROSS_2ND_ARCH_VAR_PREFIX := 2ND_
403HOST_CROSS_2ND_ARCH_MODULE_SUFFIX := _64
404$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj64
405$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES)/lib
406$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib64
407$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT_EXECUTABLES)
408$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest64
409
410ifneq ($(filter address,$(SANITIZE_TARGET)),)
411  TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_asan
412else
413  TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
414endif
415TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include
416TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
417
418ifneq ($(filter address,$(SANITIZE_TARGET)),)
419  TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj_asan
420else
421  TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
422endif
423
424TARGET_OUT_GEN := $(PRODUCT_OUT)/gen
425TARGET_OUT_COMMON_GEN := $(TARGET_COMMON_OUT_ROOT)/gen
426
427TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
428ifneq ($(filter address,$(SANITIZE_TARGET)),)
429target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system
430ifeq ($(SANITIZE_LITE),true)
431# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
432# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
433target_out_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system
434else
435target_out_app_base := $(TARGET_OUT)
436endif
437else
438target_out_shared_libraries_base := $(TARGET_OUT)
439target_out_app_base := $(TARGET_OUT)
440endif
441
442TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin
443TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin
444ifeq ($(TARGET_IS_64_BIT),true)
445# /system/lib always contains 32-bit libraries,
446# and /system/lib64 (if present) always contains 64-bit libraries.
447TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib64
448else
449TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
450endif
451TARGET_OUT_RENDERSCRIPT_BITCODE := $(TARGET_OUT_SHARED_LIBRARIES)
452TARGET_OUT_JAVA_LIBRARIES := $(TARGET_OUT)/framework
453TARGET_OUT_APPS := $(target_out_app_base)/app
454TARGET_OUT_APPS_PRIVILEGED := $(target_out_app_base)/priv-app
455TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
456TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
457TARGET_OUT_ETC := $(TARGET_OUT)/etc
458TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
459TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
460TARGET_OUT_TESTCASES := $(PRODUCT_OUT)/testcases
461
462ifeq ($(SANITIZE_LITE),true)
463# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
464# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
465TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
466else
467TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
468endif
469
470# Out for TARGET_2ND_ARCH
471TARGET_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
472ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
473# With this you can reference the arm binary translation library with libfoo_arm in PRODUCT_PACKAGES.
474TARGET_2ND_ARCH_MODULE_SUFFIX := _$(TARGET_2ND_ARCH)
475else
476TARGET_2ND_ARCH_MODULE_SUFFIX := $(HOST_2ND_ARCH_MODULE_SUFFIX)
477endif
478
479ifneq ($(filter address,$(SANITIZE_TARGET)),)
480  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)_asan
481else
482  $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)
483endif
484$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)/lib
485ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
486$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib/$(TARGET_2ND_ARCH)
487else
488$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
489endif
490$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
491$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
492$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
493$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
494$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_TESTCASES := $(TARGET_OUT_TESTCASES)
495
496TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
497TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
498TARGET_OUT_DATA_SHARED_LIBRARIES := $(TARGET_OUT_SHARED_LIBRARIES)
499TARGET_OUT_DATA_JAVA_LIBRARIES := $(TARGET_OUT_DATA)/framework
500TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA)/app
501TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
502TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
503TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
504ifeq ($(TARGET_IS_64_BIT),true)
505TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64
506TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest64
507TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64$(TARGET_VENDOR_TEST_SUFFIX)
508TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest64$(TARGET_VENDOR_TEST_SUFFIX)
509else
510TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
511TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
512TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest$(TARGET_VENDOR_TEST_SUFFIX)
513TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest$(TARGET_VENDOR_TEST_SUFFIX)
514endif
515TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
516
517$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
518$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
519$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
520ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
521$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest/$(TARGET_2ND_ARCH)
522$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest/$(TARGET_2ND_ARCH)
523$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest/$(TARGET_2ND_ARCH)$(TARGET_VENDOR_TEST_SUFFIX)
524$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest/$(TARGET_2ND_ARCH)$(TARGET_VENDOR_TEST_SUFFIX)
525else
526$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
527$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
528$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest$(TARGET_VENDOR_TEST_SUFFIX)
529$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest$(TARGET_VENDOR_TEST_SUFFIX)
530endif
531
532TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
533
534TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
535ifneq ($(filter address,$(SANITIZE_TARGET)),)
536target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/vendor
537ifeq ($(SANITIZE_LITE),true)
538# When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not
539# work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
540target_out_vendor_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/vendor
541else
542target_out_vendor_app_base := $(TARGET_OUT_VENDOR)
543endif
544else
545target_out_vendor_shared_libraries_base := $(TARGET_OUT_VENDOR)
546target_out_vendor_app_base := $(TARGET_OUT_VENDOR)
547endif
548
549TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR)/bin
550TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES := $(TARGET_OUT_VENDOR)/xbin
551ifeq ($(TARGET_IS_64_BIT),true)
552TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib64
553else
554TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
555endif
556TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
557TARGET_OUT_VENDOR_JAVA_LIBRARIES := $(TARGET_OUT_VENDOR)/framework
558TARGET_OUT_VENDOR_APPS := $(target_out_vendor_app_base)/app
559TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(target_out_vendor_app_base)/priv-app
560TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
561
562$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
563ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
564$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib/$(TARGET_2ND_ARCH)
565else
566$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
567endif
568$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)
569$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
570$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)
571
572TARGET_OUT_OEM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_OEM)
573TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM)/bin
574ifeq ($(TARGET_IS_64_BIT),true)
575TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib64
576else
577TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
578endif
579# We don't expect Java libraries in the oem.img.
580# TARGET_OUT_OEM_JAVA_LIBRARIES:= $(TARGET_OUT_OEM)/framework
581TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM)/app
582TARGET_OUT_OEM_ETC := $(TARGET_OUT_OEM)/etc
583
584$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM_EXECUTABLES)
585ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
586$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib/$(TARGET_2ND_ARCH)
587else
588$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
589endif
590$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM_APPS)
591
592TARGET_OUT_ODM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM)
593TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM)/bin
594ifeq ($(TARGET_IS_64_BIT),true)
595TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib64
596else
597TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib
598endif
599TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM)/app
600TARGET_OUT_ODM_ETC := $(TARGET_OUT_ODM)/etc
601
602$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM_EXECUTABLES)
603ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
604$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib/$(TARGET_2ND_ARCH)
605else
606$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib
607endif
608$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM_APPS)
609
610TARGET_OUT_BREAKPAD := $(PRODUCT_OUT)/breakpad
611
612TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
613TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
614TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
615TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/$(TARGET_COPY_OUT_VENDOR)/lib
616TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
617TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
618TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
619TARGET_OUT_COVERAGE := $(PRODUCT_OUT)/coverage
620
621TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
622TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
623TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
624TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
625TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
626
627TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RECOVERY)
628TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
629
630TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
631TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
632TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
633
634TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
635TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
636TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
637TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
638
639COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
640PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE NATIVE_TESTS HEADER_LIBRARIES
641
642ifeq (,$(strip $(DIST_DIR)))
643  DIST_DIR := $(OUT_DIR)/dist
644endif
645
646ifndef KATI
647PRINT_BUILD_CONFIG ?= true
648endif
649
650ifeq ($(USE_CLANG_PLATFORM_BUILD),)
651USE_CLANG_PLATFORM_BUILD := true
652endif
653
654ifneq ($(USE_CLANG_PLATFORM_BUILD),true)
655ifneq ($(USE_CLANG_PLATFORM_BUILD),false)
656$(error USE_CLANG_PLATFORM_BUILD must be true or false)
657endif
658endif
659