blob: c70a5e2c689977f842e32790dfa7c996729c0ba0 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Variables we check:
2# HOST_BUILD_TYPE = { release debug }
3# TARGET_SIMULATOR = { true <null> }
4# TARGET_BUILD_TYPE = { release debug }
5# and we output a bunch of variables, see the case statement at
6# the bottom for the full list
7# OUT_DIR is also set to "out" if it's not already set.
8# this allows you to set it to somewhere else if you like
9
Joe Onoratoeefd0212009-05-13 00:45:23 -040010# Set up version information.
11include $(BUILD_SYSTEM)/version_defaults.mk
12
The Android Open Source Project88b60792009-03-03 19:28:42 -080013# ---------------------------------------------------------------
14# If you update the build system such that the environment setup
15# or buildspec.mk need to be updated, increment this number, and
16# people who haven't re-run those will have to do so before they
17# can build. Make sure to also update the corresponding value in
18# buildspec.mk.default and envsetup.sh.
Joe Onoratoaee4daa2010-06-23 14:03:13 -070019CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
The Android Open Source Project88b60792009-03-03 19:28:42 -080020
21# ---------------------------------------------------------------
22# The product defaults to generic on hardware and sim on sim
23# NOTE: This will be overridden in product_config.mk if make
24# was invoked with a PRODUCT-xxx-yyy goal.
25ifeq ($(TARGET_PRODUCT),)
26ifeq ($(TARGET_SIMULATOR),true)
27TARGET_PRODUCT := sim
28else
29TARGET_PRODUCT := generic
30endif
31endif
32
33
34# the variant -- the set of files that are included for a build
35ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
36TARGET_BUILD_VARIANT := eng
37endif
38
39# Read the product specs so we an get TARGET_DEVICE and other
40# variables that we need in order to locate the output files.
41include $(BUILD_SYSTEM)/product_config.mk
42
43build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
44ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
45$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
46$(error must be empty or one of: eng user userdebug tests)
47endif
48
49
50
51# ---------------------------------------------------------------
52# Set up configuration for host machine. We don't do cross-
53# compiles except for arm, so the HOST is whatever we are
54# running on
55
56UNAME := $(shell uname -sm)
57
58# HOST_OS
59ifneq (,$(findstring Linux,$(UNAME)))
60 HOST_OS := linux
61endif
62ifneq (,$(findstring Darwin,$(UNAME)))
63 HOST_OS := darwin
64endif
65ifneq (,$(findstring Macintosh,$(UNAME)))
66 HOST_OS := darwin
67endif
68ifneq (,$(findstring CYGWIN,$(UNAME)))
69 HOST_OS := windows
70endif
Raphael9ca16282010-04-16 17:50:09 -070071
72# BUILD_OS is the real host doing the build.
73BUILD_OS := $(HOST_OS)
74
75# Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the
76# Windows SDK. Only a subset of tools and SDK will manage to build properly.
77ifeq ($(HOST_OS),linux)
The Android Open Source Project88b60792009-03-03 19:28:42 -080078ifneq ($(USE_MINGW),)
79 HOST_OS := windows
80endif
Raphael9ca16282010-04-16 17:50:09 -070081endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080082
83ifeq ($(HOST_OS),)
84$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
85endif
86
87
88# HOST_ARCH
89ifneq (,$(findstring 86,$(UNAME)))
90 HOST_ARCH := x86
91endif
92
93ifneq (,$(findstring Power,$(UNAME)))
94 HOST_ARCH := ppc
95endif
96
Raphael9ca16282010-04-16 17:50:09 -070097BUILD_ARCH := $(HOST_ARCH)
98
The Android Open Source Project88b60792009-03-03 19:28:42 -080099ifeq ($(HOST_ARCH),)
100$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
101endif
102
103# the host build defaults to release, and it must be release or debug
104ifeq ($(HOST_BUILD_TYPE),)
105HOST_BUILD_TYPE := release
106endif
107
108ifneq ($(HOST_BUILD_TYPE),release)
109ifneq ($(HOST_BUILD_TYPE),debug)
110$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
111endif
112endif
113
114# This is the standard way to name a directory containing prebuilt host
115# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
116ifeq ($(HOST_OS),windows)
117 HOST_PREBUILT_TAG := windows
118else
119 HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
120endif
121
Brian Carlstrome9478652010-09-30 14:41:54 -0700122# Default to building dalvikvm on hosts that support it...
Jesse Wilsonce7d5022010-09-22 10:59:10 -0700123ifeq ($(HOST_OS),linux)
Brian Carlstrome9478652010-09-30 14:41:54 -0700124# ... but not if we're building the sim...
Andy McFadden64748112010-09-24 12:04:17 -0700125ifneq ($(TARGET_SIMULATOR),true)
Brian Carlstrome9478652010-09-30 14:41:54 -0700126# ... or if the if the option is already set
127ifeq ($(WITH_HOST_DALVIK),)
Jesse Wilsonce7d5022010-09-22 10:59:10 -0700128 WITH_HOST_DALVIK := true
129endif
Andy McFadden64748112010-09-24 12:04:17 -0700130endif
Brian Carlstrome9478652010-09-30 14:41:54 -0700131endif
Jesse Wilsonce7d5022010-09-22 10:59:10 -0700132
The Android Open Source Project88b60792009-03-03 19:28:42 -0800133
134# ---------------------------------------------------------------
135# Set up configuration for target machine.
136# The following must be set:
137# TARGET_OS = { linux }
138# TARGET_ARCH = { arm | x86 }
139
140
141# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
142# otherwise it's <arch>-linux
143ifeq ($(TARGET_SIMULATOR),true)
144ifneq ($(HOST_OS),linux)
145$(error TARGET_SIMULATOR=true is only supported under Linux)
146endif
147TARGET_ARCH := $(HOST_ARCH)
148TARGET_OS := $(HOST_OS)
149else
150ifeq ($(TARGET_ARCH),)
151TARGET_ARCH := arm
152endif
153TARGET_OS := linux
154endif
155
156# the target build type defaults to release
157ifneq ($(TARGET_BUILD_TYPE),debug)
158TARGET_BUILD_TYPE := release
159endif
160
161# This is the standard way to name a directory containing prebuilt target
162# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
163ifeq ($(TARGET_SIMULATOR),true)
164 TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
165else
166 TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
167endif
168
169# ---------------------------------------------------------------
170# figure out the output directories
171
172ifeq (,$(strip $(OUT_DIR)))
173OUT_DIR := $(TOPDIR)out
174endif
175
176DEBUG_OUT_DIR := $(OUT_DIR)/debug
177
178# Move the host or target under the debug/ directory
179# if necessary.
180TARGET_OUT_ROOT_release := $(OUT_DIR)/target
181TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
182TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
183
184HOST_OUT_ROOT_release := $(OUT_DIR)/host
185HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
186HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
187
188HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
189HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
190HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
191
Raphael9ca16282010-04-16 17:50:09 -0700192BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
193
The Android Open Source Project88b60792009-03-03 19:28:42 -0800194ifeq ($(TARGET_SIMULATOR),true)
195 # Any arch- or os-specific parts of the simulator (everything
196 # under product/) are actually host-dependent.
197 # But, the debug type is controlled by TARGET_BUILD_TYPE and not
198 # HOST_BUILD_TYPE.
Andy McFadden2c86bfd2009-09-10 10:05:14 -0700199 TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr
The Android Open Source Project88b60792009-03-03 19:28:42 -0800200else
201 TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
202endif
203
204TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
205HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
206
207PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
208
209OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
210
Raphael9ca16282010-04-16 17:50:09 -0700211BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin
212
The Android Open Source Project88b60792009-03-03 19:28:42 -0800213HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
214HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
215HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
Joe Onorato64d85d02009-04-09 19:31:12 -0700216HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
The Android Open Source Project88b60792009-03-03 19:28:42 -0800217
218HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
219HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
220HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
221HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
222HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
223HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
224
225TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
226TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
227TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
228TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
229
230TARGET_OUT := $(PRODUCT_OUT)/system
231TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
232TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
233TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
234TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
235TARGET_OUT_APPS:= $(TARGET_OUT)/app
236TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
237TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
238TARGET_OUT_ETC := $(TARGET_OUT)/etc
239TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
240TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
241
242TARGET_OUT_DATA := $(PRODUCT_OUT)/data
243TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
244TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
245TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
246TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
247TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
248TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
249TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
250TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
251
252TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
253TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
254TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
255TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
256TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
257TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
258
259TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
260TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
261TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
262TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
263TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
264
265TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
266TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
267
268TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
269TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
270TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
271
272TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
273TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
274TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
275TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
276
Ying Wanga83940f2010-09-24 18:09:04 -0700277COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
The Android Open Source Project88b60792009-03-03 19:28:42 -0800278
279ifeq (,$(strip $(DIST_DIR)))
280 DIST_DIR := $(OUT_DIR)/dist
281endif
282
283ifeq ($(PRINT_BUILD_CONFIG),)
284PRINT_BUILD_CONFIG := true
285endif
286
287# ---------------------------------------------------------------
288# the setpath shell function in envsetup.sh uses this to figure out
289# what to add to the path given the config we have chosen.
290ifeq ($(CALLED_FROM_SETUP),true)
291
292ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
293
294ifeq ($(TARGET_SIMULATOR),true)
295 ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
296else
297 # this should be copied to HOST_OUT_EXECUTABLES instead
Jing Yuada132a2010-06-16 20:17:19 -0700298 ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.3/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -0800299endif
300ANDROID_BUILD_PATHS := $(ABP)
301ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
302
303# The "dumpvar" stuff lets you say something like
304#
305# CALLED_FROM_SETUP=true \
306# make -f config/envsetup.make dumpvar-TARGET_OUT
307# or
308# CALLED_FROM_SETUP=true \
309# make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
310#
311# The plain (non-abs) version just dumps the value of the named variable.
312# The "abs" version will treat the variable as a path, and dumps an
313# absolute path to it.
314#
315dumpvar_goals := \
316 $(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
317ifdef dumpvar_goals
318
319 ifneq ($(words $(dumpvar_goals)),1)
320 $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
321 endif
322
323 # If the goal is of the form "dumpvar-abs-VARNAME", then
324 # treat VARNAME as a path and return the absolute path to it.
325 absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
326 ifdef absolute_dumpvar
327 dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
328 DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
329 dumpvar_target := dumpvar-abs-$(dumpvar_goals)
330 else
331 DUMPVAR_VALUE := $($(dumpvar_goals))
332 dumpvar_target := dumpvar-$(dumpvar_goals)
333 endif
334
335.PHONY: $(dumpvar_target)
336$(dumpvar_target):
337 @echo $(DUMPVAR_VALUE)
338
339endif # dumpvar_goals
340
341ifneq ($(dumpvar_goals),report_config)
342PRINT_BUILD_CONFIG:=
343endif
344
345endif # CALLED_FROM_SETUP
346
347
348ifneq ($(PRINT_BUILD_CONFIG),)
349$(info ============================================)
Joe Onoratoeefd0212009-05-13 00:45:23 -0400350$(info PLATFORM_VERSION_CODENAME=$(PLATFORM_VERSION_CODENAME))
351$(info PLATFORM_VERSION=$(PLATFORM_VERSION))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800352$(info TARGET_PRODUCT=$(TARGET_PRODUCT))
353$(info TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
354$(info TARGET_SIMULATOR=$(TARGET_SIMULATOR))
355$(info TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
Joe Onorato16fa4b22010-06-09 16:35:58 -0700356$(info TARGET_BUILD_APPS=$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800357$(info TARGET_ARCH=$(TARGET_ARCH))
358$(info HOST_ARCH=$(HOST_ARCH))
359$(info HOST_OS=$(HOST_OS))
360$(info HOST_BUILD_TYPE=$(HOST_BUILD_TYPE))
361$(info BUILD_ID=$(BUILD_ID))
362$(info ============================================)
363endif