blob: a348eb7dd6545d07e365bbdf7b32eeb974b955db [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Variables we check:
2# HOST_BUILD_TYPE = { release debug }
The Android Open Source Project88b60792009-03-03 19:28:42 -08003# 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
Joe Onoratoeefd0212009-05-13 00:45:23 -04009# Set up version information.
10include $(BUILD_SYSTEM)/version_defaults.mk
11
The Android Open Source Project88b60792009-03-03 19:28:42 -080012# ---------------------------------------------------------------
13# If you update the build system such that the environment setup
14# or buildspec.mk need to be updated, increment this number, and
15# people who haven't re-run those will have to do so before they
16# can build. Make sure to also update the corresponding value in
17# buildspec.mk.default and envsetup.sh.
Jeff Hamilton77dfeae2010-06-21 18:26:38 -050018CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
The Android Open Source Project88b60792009-03-03 19:28:42 -080019
20# ---------------------------------------------------------------
Jeff Browne33ba4c2011-07-11 22:11:46 -070021# The product defaults to generic on hardware
The Android Open Source Project88b60792009-03-03 19:28:42 -080022# NOTE: This will be overridden in product_config.mk if make
23# was invoked with a PRODUCT-xxx-yyy goal.
24ifeq ($(TARGET_PRODUCT),)
Jean-Baptiste Queru0332f0a2010-10-22 09:52:09 -070025TARGET_PRODUCT := full
The Android Open Source Project88b60792009-03-03 19:28:42 -080026endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080027
28
29# the variant -- the set of files that are included for a build
30ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
31TARGET_BUILD_VARIANT := eng
32endif
33
The Android Open Source Project88b60792009-03-03 19:28:42 -080034# ---------------------------------------------------------------
35# Set up configuration for host machine. We don't do cross-
Raghu Gandham8da43102012-07-25 19:57:22 -070036# compiles except for arm/mips, so the HOST is whatever we are
The Android Open Source Project88b60792009-03-03 19:28:42 -080037# running on
38
39UNAME := $(shell uname -sm)
40
41# HOST_OS
42ifneq (,$(findstring Linux,$(UNAME)))
43 HOST_OS := linux
44endif
45ifneq (,$(findstring Darwin,$(UNAME)))
46 HOST_OS := darwin
47endif
48ifneq (,$(findstring Macintosh,$(UNAME)))
49 HOST_OS := darwin
50endif
51ifneq (,$(findstring CYGWIN,$(UNAME)))
52 HOST_OS := windows
53endif
Raphael9ca16282010-04-16 17:50:09 -070054
55# BUILD_OS is the real host doing the build.
56BUILD_OS := $(HOST_OS)
57
58# Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the
59# Windows SDK. Only a subset of tools and SDK will manage to build properly.
60ifeq ($(HOST_OS),linux)
The Android Open Source Project88b60792009-03-03 19:28:42 -080061ifneq ($(USE_MINGW),)
62 HOST_OS := windows
63endif
Raphael9ca16282010-04-16 17:50:09 -070064endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080065
66ifeq ($(HOST_OS),)
67$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
68endif
69
70
71# HOST_ARCH
72ifneq (,$(findstring 86,$(UNAME)))
73 HOST_ARCH := x86
74endif
75
76ifneq (,$(findstring Power,$(UNAME)))
77 HOST_ARCH := ppc
78endif
79
Raphael9ca16282010-04-16 17:50:09 -070080BUILD_ARCH := $(HOST_ARCH)
81
The Android Open Source Project88b60792009-03-03 19:28:42 -080082ifeq ($(HOST_ARCH),)
83$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
84endif
85
86# the host build defaults to release, and it must be release or debug
87ifeq ($(HOST_BUILD_TYPE),)
88HOST_BUILD_TYPE := release
89endif
90
91ifneq ($(HOST_BUILD_TYPE),release)
92ifneq ($(HOST_BUILD_TYPE),debug)
93$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
94endif
95endif
96
97# This is the standard way to name a directory containing prebuilt host
98# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
99ifeq ($(HOST_OS),windows)
100 HOST_PREBUILT_TAG := windows
101else
102 HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
103endif
104
Ying Wang2b6aaa32011-10-27 15:18:39 -0700105# TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT.
106# Define them here so they can be used in product config files.
107TARGET_COPY_OUT_SYSTEM := system
108TARGET_COPY_OUT_DATA := data
109TARGET_COPY_OUT_VENDOR := system/vendor
110TARGET_COPY_OUT_ROOT := root
111TARGET_COPY_OUT_RECOVERY := recovery
112
Ryo Fujiicbb32662011-06-16 16:58:11 -0700113# Read the product specs so we an get TARGET_DEVICE and other
114# variables that we need in order to locate the output files.
115include $(BUILD_SYSTEM)/product_config.mk
Jesse Wilsonce7d5022010-09-22 10:59:10 -0700116
Ying Wangd0244b32011-11-17 14:51:12 -0800117build_variant := $(filter-out eng user userdebug,$(TARGET_BUILD_VARIANT))
Ryo Fujiicbb32662011-06-16 16:58:11 -0700118ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
119$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
Ying Wangd0244b32011-11-17 14:51:12 -0800120$(error must be empty or one of: eng user userdebug)
Ryo Fujiicbb32662011-06-16 16:58:11 -0700121endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800122
Ying Wangc6349742014-01-13 16:14:20 -0800123# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
124# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
125# make sure only one exists.
126# Real boards should always be associated with an OEM vendor.
127board_config_mk := \
128 $(strip $(wildcard \
129 $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
130 $(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
131 $(shell test -d vendor && find vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
132 ))
133ifeq ($(board_config_mk),)
134 $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
135endif
136ifneq ($(words $(board_config_mk)),1)
137 $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
138endif
139include $(board_config_mk)
140ifeq ($(TARGET_ARCH),)
141 $(error TARGET_ARCH not defined by board config: $(board_config_mk))
142endif
143TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
144board_config_mk :=
145
The Android Open Source Project88b60792009-03-03 19:28:42 -0800146# ---------------------------------------------------------------
147# Set up configuration for target machine.
148# The following must be set:
149# TARGET_OS = { linux }
Raghu Gandham8da43102012-07-25 19:57:22 -0700150# TARGET_ARCH = { arm | x86 | mips }
The Android Open Source Project88b60792009-03-03 19:28:42 -0800151
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152TARGET_OS := linux
Raghu Gandham8da43102012-07-25 19:57:22 -0700153# TARGET_ARCH should be set by BoardConfig.mk and will be checked later
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154
155# the target build type defaults to release
156ifneq ($(TARGET_BUILD_TYPE),debug)
157TARGET_BUILD_TYPE := release
158endif
159
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160# ---------------------------------------------------------------
161# figure out the output directories
162
163ifeq (,$(strip $(OUT_DIR)))
Jean-Baptiste Queruffe03c92011-12-06 10:29:46 -0800164ifeq (,$(strip $(OUT_DIR_COMMON_BASE)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800165OUT_DIR := $(TOPDIR)out
Jean-Baptiste Queruffe03c92011-12-06 10:29:46 -0800166else
167OUT_DIR := $(OUT_DIR_COMMON_BASE)/$(notdir $(PWD))
168endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800169endif
170
171DEBUG_OUT_DIR := $(OUT_DIR)/debug
172
173# Move the host or target under the debug/ directory
174# if necessary.
175TARGET_OUT_ROOT_release := $(OUT_DIR)/target
176TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
177TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
178
179HOST_OUT_ROOT_release := $(OUT_DIR)/host
180HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
181HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
182
183HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
184HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
185HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
186
Raphael9ca16282010-04-16 17:50:09 -0700187BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
188
Jeff Browne33ba4c2011-07-11 22:11:46 -0700189TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
The Android Open Source Project88b60792009-03-03 19:28:42 -0800190
191TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
192HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
193
194PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
195
196OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
197
Ying Wangc6349742014-01-13 16:14:20 -0800198BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
Raphael9ca16282010-04-16 17:50:09 -0700199
Ying Wangc6349742014-01-13 16:14:20 -0800200HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
201HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
202HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
Joe Onorato64d85d02009-04-09 19:31:12 -0700203HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204
205HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
Ying Wangc6349742014-01-13 16:14:20 -0800206HOST_OUT_HEADERS := $(HOST_OUT_INTERMEDIATES)/include
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
Ying Wangc6349742014-01-13 16:14:20 -0800208HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
The Android Open Source Project88b60792009-03-03 19:28:42 -0800209HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
210
211TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
Ying Wangc6349742014-01-13 16:14:20 -0800212TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include
The Android Open Source Project88b60792009-03-03 19:28:42 -0800213TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
214TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
215
Ying Wang2b6aaa32011-10-27 15:18:39 -0700216TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
Ying Wangc6349742014-01-13 16:14:20 -0800217TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin
218TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin
219ifneq ($(filter %64,$(TARGET_ARCH)),)
220# /system/lib always contains 32-bit libraries,
221# and /system/lib64 (if present) always contains 64-bit libraries.
222TARGET_OUT_SHARED_LIBRARIES := $(TARGET_OUT)/lib64
223else
224TARGET_OUT_SHARED_LIBRARIES := $(TARGET_OUT)/lib
225endif
226TARGET_OUT_JAVA_LIBRARIES := $(TARGET_OUT)/framework
227TARGET_OUT_APPS := $(TARGET_OUT)/app
Ying Wang5338fbf2013-05-08 15:49:08 -0700228TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT)/priv-app
The Android Open Source Project88b60792009-03-03 19:28:42 -0800229TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
230TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
231TARGET_OUT_ETC := $(TARGET_OUT)/etc
Ying Wangc6349742014-01-13 16:14:20 -0800232TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
Dima Zavin531f5242010-09-27 17:37:17 -0700233TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800234
Ying Wang1d274d22013-12-27 11:09:36 -0800235# Out for TARGET_2ND_ARCH
236TARGET_2ND_ARCH_VAR_PREFIX := 2ND_
Ying Wang6ef65192014-01-15 16:02:16 -0800237TARGET_2ND_ARCH_MODULE_SUFFIX := _32
Ying Wang1d274d22013-12-27 11:09:36 -0800238$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)
239$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)/lib
240$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(TARGET_OUT)/lib
Ying Wangdd814bf2014-01-17 16:17:28 -0800241$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
Colin Crossd9574462014-01-24 13:37:07 -0800242$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
243$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
Ying Wang1d274d22013-12-27 11:09:36 -0800244
Ying Wang2b6aaa32011-10-27 15:18:39 -0700245TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
Ying Wangc6349742014-01-13 16:14:20 -0800246TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
247TARGET_OUT_DATA_SHARED_LIBRARIES := $(TARGET_OUT_SHARED_LIBRARIES)
248TARGET_OUT_DATA_JAVA_LIBRARIES := $(TARGET_OUT_DATA)/framework
249TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA)/app
The Android Open Source Project88b60792009-03-03 19:28:42 -0800250TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
251TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
252TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
Ying Wang4c681742010-07-20 11:08:47 -0700253TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
Tsu Chiang Chuang40da8832012-07-13 13:47:09 -0700254TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800255
Ying Wangb8e01852014-01-23 15:09:04 -0800256$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
257$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
Colin Crossd9574462014-01-24 13:37:07 -0800258$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
Ying Wangb8e01852014-01-23 15:09:04 -0800259
Ying Wang9f8e8db2011-11-04 11:37:01 -0700260TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
261
Ying Wang2b6aaa32011-10-27 15:18:39 -0700262TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
Ying Wangc6349742014-01-13 16:14:20 -0800263TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR)/bin
264TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES := $(TARGET_OUT_VENDOR)/xbin
265ifneq ($(filter %64,$(TARGET_ARCH)),)
266TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib64
267else
268TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib
269endif
270TARGET_OUT_VENDOR_JAVA_LIBRARIES := $(TARGET_OUT_VENDOR)/framework
271TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR)/app
Ying Wang8f779362011-09-13 13:57:26 -0700272TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
273
Ying Wangb8e01852014-01-23 15:09:04 -0800274$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
Ying Wang6ef65192014-01-15 16:02:16 -0800275$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib
Colin Crossd9574462014-01-24 13:37:07 -0800276$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
Ying Wang6ef65192014-01-15 16:02:16 -0800277
The Android Open Source Project88b60792009-03-03 19:28:42 -0800278TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
279TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
280TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
281TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
282TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
283TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
284
Ying Wang2b6aaa32011-10-27 15:18:39 -0700285TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800286TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
287TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
288TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
289TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
290
Ying Wang2b6aaa32011-10-27 15:18:39 -0700291TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RECOVERY)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800292TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
293
294TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
295TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
296TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
297
298TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
299TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
300TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
301TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
302
Ying Wang89686532011-12-16 11:27:52 -0800303TARGET_FACTORY_RAMDISK_OUT := $(PRODUCT_OUT)/factory_ramdisk
304
Ying Wanga83940f2010-09-24 18:09:04 -0700305COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
The Android Open Source Project88b60792009-03-03 19:28:42 -0800306
307ifeq (,$(strip $(DIST_DIR)))
308 DIST_DIR := $(OUT_DIR)/dist
309endif
310
311ifeq ($(PRINT_BUILD_CONFIG),)
312PRINT_BUILD_CONFIG := true
313endif