envsetup.mk revision e6b4e5b20ac8a3b01f1a99dd877a98c92036ce5e
1# 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# Set up version information.
11include $(BUILD_SYSTEM)/version_defaults.mk
12
13# ---------------------------------------------------------------
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.
19CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 9
20
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
71ifneq ($(USE_MINGW),)
72	HOST_OS := windows
73endif
74
75ifeq ($(HOST_OS),)
76$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
77endif
78
79
80# HOST_ARCH
81ifneq (,$(findstring 86,$(UNAME)))
82	HOST_ARCH := x86
83endif
84
85ifneq (,$(findstring Power,$(UNAME)))
86	HOST_ARCH := ppc
87endif
88
89ifeq ($(HOST_ARCH),)
90$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
91endif
92
93# the host build defaults to release, and it must be release or debug
94ifeq ($(HOST_BUILD_TYPE),)
95HOST_BUILD_TYPE := release
96endif
97
98ifneq ($(HOST_BUILD_TYPE),release)
99ifneq ($(HOST_BUILD_TYPE),debug)
100$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
101endif
102endif
103
104# This is the standard way to name a directory containing prebuilt host
105# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
106ifeq ($(HOST_OS),windows)
107  HOST_PREBUILT_TAG := windows
108else
109  HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
110endif
111
112
113# ---------------------------------------------------------------
114# Set up configuration for target machine.
115# The following must be set:
116# 		TARGET_OS = { linux }
117# 		TARGET_ARCH = { arm | x86 }
118
119
120# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
121# otherwise  it's <arch>-linux
122ifeq ($(TARGET_SIMULATOR),true)
123ifneq ($(HOST_OS),linux)
124$(error TARGET_SIMULATOR=true is only supported under Linux)
125endif
126TARGET_ARCH := $(HOST_ARCH)
127TARGET_OS := $(HOST_OS)
128else
129ifeq ($(TARGET_ARCH),)
130TARGET_ARCH := arm
131endif
132TARGET_OS := linux
133endif
134
135# the target build type defaults to release
136ifneq ($(TARGET_BUILD_TYPE),debug)
137TARGET_BUILD_TYPE := release
138endif
139
140# This is the standard way to name a directory containing prebuilt target
141# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
142ifeq ($(TARGET_SIMULATOR),true)
143  TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
144else
145  TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
146endif
147
148# ---------------------------------------------------------------
149# figure out the output directories
150
151ifeq (,$(strip $(OUT_DIR)))
152OUT_DIR := $(TOPDIR)out
153endif
154
155DEBUG_OUT_DIR := $(OUT_DIR)/debug
156
157# Move the host or target under the debug/ directory
158# if necessary.
159TARGET_OUT_ROOT_release := $(OUT_DIR)/target
160TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
161TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
162
163HOST_OUT_ROOT_release := $(OUT_DIR)/host
164HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
165HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
166
167HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
168HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
169HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
170
171ifeq ($(TARGET_SIMULATOR),true)
172  # Any arch- or os-specific parts of the simulator (everything
173  # under product/) are actually host-dependent.
174  # But, the debug type is controlled by TARGET_BUILD_TYPE and not
175  # HOST_BUILD_TYPE.
176  TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr
177else
178  TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
179endif
180
181TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
182HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
183
184PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
185
186OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
187
188HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
189HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
190HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
191HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
192
193HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
194HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
195HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
196HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
197HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
198HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
199
200TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
201TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
202TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
203TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
204
205TARGET_OUT := $(PRODUCT_OUT)/system
206TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
207TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
208TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
209TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
210TARGET_OUT_APPS:= $(TARGET_OUT)/app
211TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
212TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
213TARGET_OUT_ETC := $(TARGET_OUT)/etc
214TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
215TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
216
217TARGET_OUT_DATA := $(PRODUCT_OUT)/data
218TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
219TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
220TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
221TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
222TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
223TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
224TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
225TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
226
227TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
228TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
229TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
230TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
231TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
232TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
233
234TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
235TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
236TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
237TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
238TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
239
240TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
241TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
242
243TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
244TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
245TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
246
247TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
248TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
249TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
250TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
251
252COMMON_MODULE_CLASSES := JAVA_LIBRARIES NOTICE_FILES
253
254ifeq (,$(strip $(DIST_DIR)))
255  DIST_DIR := $(OUT_DIR)/dist
256endif
257
258ifeq ($(PRINT_BUILD_CONFIG),)
259PRINT_BUILD_CONFIG := true
260endif
261
262# ---------------------------------------------------------------
263# the setpath shell function in envsetup.sh uses this to figure out
264# what to add to the path given the config we have chosen.
265ifeq ($(CALLED_FROM_SETUP),true)
266
267ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
268
269ifeq ($(TARGET_SIMULATOR),true)
270	ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
271else
272	# this should be copied to HOST_OUT_EXECUTABLES instead
273	ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin
274endif
275ANDROID_BUILD_PATHS := $(ABP)
276ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
277
278# The "dumpvar" stuff lets you say something like
279#
280#     CALLED_FROM_SETUP=true \
281#       make -f config/envsetup.make dumpvar-TARGET_OUT
282# or
283#     CALLED_FROM_SETUP=true \
284#       make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
285#
286# The plain (non-abs) version just dumps the value of the named variable.
287# The "abs" version will treat the variable as a path, and dumps an
288# absolute path to it.
289#
290dumpvar_goals := \
291	$(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
292ifdef dumpvar_goals
293
294  ifneq ($(words $(dumpvar_goals)),1)
295    $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
296  endif
297
298  # If the goal is of the form "dumpvar-abs-VARNAME", then
299  # treat VARNAME as a path and return the absolute path to it.
300  absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
301  ifdef absolute_dumpvar
302    dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
303    DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
304    dumpvar_target := dumpvar-abs-$(dumpvar_goals)
305  else
306    DUMPVAR_VALUE := $($(dumpvar_goals))
307    dumpvar_target := dumpvar-$(dumpvar_goals)
308  endif
309
310.PHONY: $(dumpvar_target)
311$(dumpvar_target):
312	@echo $(DUMPVAR_VALUE)
313
314endif # dumpvar_goals
315
316ifneq ($(dumpvar_goals),report_config)
317PRINT_BUILD_CONFIG:=
318endif
319
320endif # CALLED_FROM_SETUP
321
322
323ifneq ($(PRINT_BUILD_CONFIG),)
324$(info ============================================)
325$(info   PLATFORM_VERSION_CODENAME=$(PLATFORM_VERSION_CODENAME))
326$(info   PLATFORM_VERSION=$(PLATFORM_VERSION))
327$(info   TARGET_PRODUCT=$(TARGET_PRODUCT))
328$(info   TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
329$(info   TARGET_SIMULATOR=$(TARGET_SIMULATOR))
330$(info   TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
331$(info   TARGET_ARCH=$(TARGET_ARCH))
332$(info   HOST_ARCH=$(HOST_ARCH))
333$(info   HOST_OS=$(HOST_OS))
334$(info   HOST_BUILD_TYPE=$(HOST_BUILD_TYPE))
335$(info   BUILD_ID=$(BUILD_ID))
336$(info ============================================)
337endif
338