envsetup.mk revision f1582e549926e75a4edb194c4ff724df633299d4
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 := 10
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
71
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)
78ifneq ($(USE_MINGW),)
79	HOST_OS := windows
80endif
81endif
82
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
97BUILD_ARCH := $(HOST_ARCH)
98
99ifeq ($(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
122
123# ---------------------------------------------------------------
124# Set up configuration for target machine.
125# The following must be set:
126# 		TARGET_OS = { linux }
127# 		TARGET_ARCH = { arm | x86 }
128
129
130# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
131# otherwise  it's <arch>-linux
132ifeq ($(TARGET_SIMULATOR),true)
133ifneq ($(HOST_OS),linux)
134$(error TARGET_SIMULATOR=true is only supported under Linux)
135endif
136TARGET_ARCH := $(HOST_ARCH)
137TARGET_OS := $(HOST_OS)
138else
139ifeq ($(TARGET_ARCH),)
140TARGET_ARCH := arm
141endif
142TARGET_OS := linux
143endif
144
145# the target build type defaults to release
146ifneq ($(TARGET_BUILD_TYPE),debug)
147TARGET_BUILD_TYPE := release
148endif
149
150# ---------------------------------------------------------------
151# figure out the output directories
152
153ifeq (,$(strip $(OUT_DIR)))
154OUT_DIR := $(TOPDIR)out
155endif
156
157DEBUG_OUT_DIR := $(OUT_DIR)/debug
158
159# Move the host or target under the debug/ directory
160# if necessary.
161TARGET_OUT_ROOT_release := $(OUT_DIR)/target
162TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
163TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
164
165HOST_OUT_ROOT_release := $(OUT_DIR)/host
166HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
167HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
168
169HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
170HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
171HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
172
173BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
174
175ifeq ($(TARGET_SIMULATOR),true)
176  # Any arch- or os-specific parts of the simulator (everything
177  # under product/) are actually host-dependent.
178  # But, the debug type is controlled by TARGET_BUILD_TYPE and not
179  # HOST_BUILD_TYPE.
180  TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr
181else
182  TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
183endif
184
185TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
186HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
187
188PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
189
190OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
191
192BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin
193
194HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
195HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
196HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
197HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
198
199HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
200HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
201HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
202HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
203HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
204HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
205
206TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
207TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
208TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
209TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
210
211TARGET_OUT := $(PRODUCT_OUT)/system
212TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
213TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
214TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
215TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
216TARGET_OUT_APPS:= $(TARGET_OUT)/app
217TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
218TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
219TARGET_OUT_ETC := $(TARGET_OUT)/etc
220TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
221TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
222
223TARGET_OUT_DATA := $(PRODUCT_OUT)/data
224TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
225TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
226TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
227TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
228TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
229TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
230TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
231TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
232
233TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
234TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
235TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
236TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
237TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
238TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
239
240TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
241TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
242TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
243TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
244TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
245
246TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
247TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
248
249TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
250TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
251TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
252
253TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
254TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
255TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
256TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
257
258COMMON_MODULE_CLASSES := JAVA_LIBRARIES NOTICE_FILES
259
260ifeq (,$(strip $(DIST_DIR)))
261  DIST_DIR := $(OUT_DIR)/dist
262endif
263
264ifeq ($(PRINT_BUILD_CONFIG),)
265PRINT_BUILD_CONFIG := true
266endif
267