blob: ba9354931bd1b421500b63d12d55c013248091ed [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
10# ---------------------------------------------------------------
11# If you update the build system such that the environment setup
12# or buildspec.mk need to be updated, increment this number, and
13# people who haven't re-run those will have to do so before they
14# can build. Make sure to also update the corresponding value in
15# buildspec.mk.default and envsetup.sh.
16CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 9
17
18# ---------------------------------------------------------------
19# The product defaults to generic on hardware and sim on sim
20# NOTE: This will be overridden in product_config.mk if make
21# was invoked with a PRODUCT-xxx-yyy goal.
22ifeq ($(TARGET_PRODUCT),)
23ifeq ($(TARGET_SIMULATOR),true)
24TARGET_PRODUCT := sim
25else
26TARGET_PRODUCT := generic
27endif
28endif
29
30
31# the variant -- the set of files that are included for a build
32ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
33TARGET_BUILD_VARIANT := eng
34endif
35
36# Read the product specs so we an get TARGET_DEVICE and other
37# variables that we need in order to locate the output files.
38include $(BUILD_SYSTEM)/product_config.mk
39
40build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
41ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
42$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
43$(error must be empty or one of: eng user userdebug tests)
44endif
45
46
47
48# ---------------------------------------------------------------
49# Set up configuration for host machine. We don't do cross-
50# compiles except for arm, so the HOST is whatever we are
51# running on
52
53UNAME := $(shell uname -sm)
54
55# HOST_OS
56ifneq (,$(findstring Linux,$(UNAME)))
57 HOST_OS := linux
58endif
59ifneq (,$(findstring Darwin,$(UNAME)))
60 HOST_OS := darwin
61endif
62ifneq (,$(findstring Macintosh,$(UNAME)))
63 HOST_OS := darwin
64endif
65ifneq (,$(findstring CYGWIN,$(UNAME)))
66 HOST_OS := windows
67endif
68ifneq ($(USE_MINGW),)
69 HOST_OS := windows
70endif
71
72ifeq ($(HOST_OS),)
73$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
74endif
75
76
77# HOST_ARCH
78ifneq (,$(findstring 86,$(UNAME)))
79 HOST_ARCH := x86
80endif
81
82ifneq (,$(findstring Power,$(UNAME)))
83 HOST_ARCH := ppc
84endif
85
86ifeq ($(HOST_ARCH),)
87$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
88endif
89
90# the host build defaults to release, and it must be release or debug
91ifeq ($(HOST_BUILD_TYPE),)
92HOST_BUILD_TYPE := release
93endif
94
95ifneq ($(HOST_BUILD_TYPE),release)
96ifneq ($(HOST_BUILD_TYPE),debug)
97$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
98endif
99endif
100
101# This is the standard way to name a directory containing prebuilt host
102# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
103ifeq ($(HOST_OS),windows)
104 HOST_PREBUILT_TAG := windows
105else
106 HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
107endif
108
109
110# ---------------------------------------------------------------
111# Set up configuration for target machine.
112# The following must be set:
113# TARGET_OS = { linux }
114# TARGET_ARCH = { arm | x86 }
115
116
117# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
118# otherwise it's <arch>-linux
119ifeq ($(TARGET_SIMULATOR),true)
120ifneq ($(HOST_OS),linux)
121$(error TARGET_SIMULATOR=true is only supported under Linux)
122endif
123TARGET_ARCH := $(HOST_ARCH)
124TARGET_OS := $(HOST_OS)
125else
126ifeq ($(TARGET_ARCH),)
127TARGET_ARCH := arm
128endif
129TARGET_OS := linux
130endif
131
132# the target build type defaults to release
133ifneq ($(TARGET_BUILD_TYPE),debug)
134TARGET_BUILD_TYPE := release
135endif
136
137# This is the standard way to name a directory containing prebuilt target
138# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
139ifeq ($(TARGET_SIMULATOR),true)
140 TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
141else
142 TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
143endif
144
145# ---------------------------------------------------------------
146# figure out the output directories
147
148ifeq (,$(strip $(OUT_DIR)))
149OUT_DIR := $(TOPDIR)out
150endif
151
152DEBUG_OUT_DIR := $(OUT_DIR)/debug
153
154# Move the host or target under the debug/ directory
155# if necessary.
156TARGET_OUT_ROOT_release := $(OUT_DIR)/target
157TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
158TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
159
160HOST_OUT_ROOT_release := $(OUT_DIR)/host
161HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
162HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
163
164HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
165HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
166HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
167
168ifeq ($(TARGET_SIMULATOR),true)
169 # Any arch- or os-specific parts of the simulator (everything
170 # under product/) are actually host-dependent.
171 # But, the debug type is controlled by TARGET_BUILD_TYPE and not
172 # HOST_BUILD_TYPE.
173 TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/product
174else
175 TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
176endif
177
178TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
179HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
180
181PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
182
183OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
184
185HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
186HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
187HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
Joe Onorato64d85d02009-04-09 19:31:12 -0700188HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
The Android Open Source Project88b60792009-03-03 19:28:42 -0800189
190HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
191HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
192HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
193HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
194HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
195HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
196
197TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
198TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
199TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
200TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
201
202TARGET_OUT := $(PRODUCT_OUT)/system
203TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
204TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
205TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
206TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
207TARGET_OUT_APPS:= $(TARGET_OUT)/app
208TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
209TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
210TARGET_OUT_ETC := $(TARGET_OUT)/etc
211TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
212TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
213
214TARGET_OUT_DATA := $(PRODUCT_OUT)/data
215TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
216TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
217TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
218TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
219TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
220TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
221TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
222TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
223
224TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
225TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
226TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
227TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
228TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
229TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
230
231TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
232TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
233TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
234TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
235TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
236
237TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
238TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
239
240TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
241TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
242TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
243
244TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
245TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
246TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
247TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
248
249COMMON_MODULE_CLASSES := JAVA_LIBRARIES NOTICE_FILES
250
251ifeq (,$(strip $(DIST_DIR)))
252 DIST_DIR := $(OUT_DIR)/dist
253endif
254
255ifeq ($(PRINT_BUILD_CONFIG),)
256PRINT_BUILD_CONFIG := true
257endif
258
259# ---------------------------------------------------------------
260# the setpath shell function in envsetup.sh uses this to figure out
261# what to add to the path given the config we have chosen.
262ifeq ($(CALLED_FROM_SETUP),true)
263
264ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
265
266ifeq ($(TARGET_SIMULATOR),true)
267 ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
268else
269 # this should be copied to HOST_OUT_EXECUTABLES instead
270 ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.2.1/bin
271endif
272ANDROID_BUILD_PATHS := $(ABP)
273ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
274
275# The "dumpvar" stuff lets you say something like
276#
277# CALLED_FROM_SETUP=true \
278# make -f config/envsetup.make dumpvar-TARGET_OUT
279# or
280# CALLED_FROM_SETUP=true \
281# make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
282#
283# The plain (non-abs) version just dumps the value of the named variable.
284# The "abs" version will treat the variable as a path, and dumps an
285# absolute path to it.
286#
287dumpvar_goals := \
288 $(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
289ifdef dumpvar_goals
290
291 ifneq ($(words $(dumpvar_goals)),1)
292 $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
293 endif
294
295 # If the goal is of the form "dumpvar-abs-VARNAME", then
296 # treat VARNAME as a path and return the absolute path to it.
297 absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
298 ifdef absolute_dumpvar
299 dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
300 DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
301 dumpvar_target := dumpvar-abs-$(dumpvar_goals)
302 else
303 DUMPVAR_VALUE := $($(dumpvar_goals))
304 dumpvar_target := dumpvar-$(dumpvar_goals)
305 endif
306
307.PHONY: $(dumpvar_target)
308$(dumpvar_target):
309 @echo $(DUMPVAR_VALUE)
310
311endif # dumpvar_goals
312
313ifneq ($(dumpvar_goals),report_config)
314PRINT_BUILD_CONFIG:=
315endif
316
317endif # CALLED_FROM_SETUP
318
319
320ifneq ($(PRINT_BUILD_CONFIG),)
321$(info ============================================)
322$(info TARGET_PRODUCT=$(TARGET_PRODUCT))
323$(info TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
324$(info TARGET_SIMULATOR=$(TARGET_SIMULATOR))
325$(info TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
326$(info TARGET_ARCH=$(TARGET_ARCH))
327$(info HOST_ARCH=$(HOST_ARCH))
328$(info HOST_OS=$(HOST_OS))
329$(info HOST_BUILD_TYPE=$(HOST_BUILD_TYPE))
330$(info BUILD_ID=$(BUILD_ID))
331$(info ============================================)
332endif
333
334