OSDN Git Service

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