envsetup.mk revision b6c1cf6de79035f58b512f4400db458c8401379a
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# ---------------------------------------------------------------
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 := 8
17
18
19# ---------------------------------------------------------------
20# Set up configuration for host machine.  We don't do cross-
21# compiles except for arm, so the HOST is whatever we are
22# running on
23
24UNAME := $(shell uname -sm)
25
26# HOST_OS
27ifneq (,$(findstring Linux,$(UNAME)))
28	HOST_OS := linux
29endif
30ifneq (,$(findstring Darwin,$(UNAME)))
31	HOST_OS := darwin
32endif
33ifneq (,$(findstring Macintosh,$(UNAME)))
34	HOST_OS := darwin
35endif
36ifneq (,$(findstring CYGWIN,$(UNAME)))
37	HOST_OS := windows
38endif
39ifneq ($(USE_MINGW),)
40	HOST_OS := windows
41endif
42
43ifeq ($(HOST_OS),)
44$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
45endif
46
47
48# HOST_ARCH
49ifneq (,$(findstring 86,$(UNAME)))
50	HOST_ARCH := x86
51endif
52
53ifneq (,$(findstring Power,$(UNAME)))
54	HOST_ARCH := ppc
55endif
56
57ifeq ($(HOST_ARCH),)
58$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
59endif
60
61# the host build defaults to release, and it must be release or debug
62ifeq ($(HOST_BUILD_TYPE),)
63HOST_BUILD_TYPE := release
64endif
65
66ifneq ($(HOST_BUILD_TYPE),release)
67ifneq ($(HOST_BUILD_TYPE),debug)
68$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
69endif
70endif
71
72# This is the standard way to name a directory containing prebuilt host
73# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
74ifeq ($(HOST_OS),windows)
75  HOST_PREBUILT_TAG := windows
76else
77  HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
78endif
79
80
81# ---------------------------------------------------------------
82# Set up configuration for target machine.
83# The following must be set:
84# 		TARGET_OS = { linux }
85# 		TARGET_ARCH = { arm | x86 }
86# TARGET_ARCH==arm means that it's not the simulator, and the others
87# mean it is the simulator.
88
89# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
90# otherwise it's arm-linux
91ifeq ($(TARGET_SIMULATOR),true)
92ifneq ($(HOST_OS),linux)
93$(error TARGET_SIMULATOR=true is only supported under Linux)
94endif
95TARGET_ARCH := $(HOST_ARCH)
96TARGET_OS := $(HOST_OS)
97else
98TARGET_ARCH := arm
99TARGET_OS := linux
100endif
101
102# the target build type defaults to release
103ifneq ($(TARGET_BUILD_TYPE),debug)
104TARGET_BUILD_TYPE := release
105endif
106
107# This is the standard way to name a directory containing prebuilt target
108# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
109ifeq ($(TARGET_SIMULATOR),true)
110  TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
111else
112  TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
113endif
114
115# the product defaults to sooner on ARM and nothing on sim
116ifeq ($(TARGET_PRODUCT),)
117ifeq ($(TARGET_SIMULATOR),true)
118TARGET_PRODUCT := sim
119else
120TARGET_PRODUCT := sooner
121endif
122endif
123
124# ---------------------------------------------------------------
125# figure out the output directories
126
127ifeq (,$(strip $(OUT_DIR)))
128OUT_DIR := $(TOPDIR)out
129endif
130
131DEBUG_OUT_DIR := $(OUT_DIR)/debug
132
133# Move the host or target under the debug/ directory
134# if necessary.
135TARGET_OUT_ROOT_release := $(OUT_DIR)/target
136TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
137TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
138
139HOST_OUT_ROOT_release := $(OUT_DIR)/host
140HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
141HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
142
143HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
144HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
145HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
146
147ifeq ($(TARGET_SIMULATOR),true)
148  # Any arch- or os-specific parts of the simulator (everything
149  # under product/) are actually host-dependent.
150  # But, the debug type is controlled by TARGET_BUILD_TYPE and not
151  # HOST_BUILD_TYPE.
152  TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/product
153else
154  TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
155endif
156
157TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
158HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
159
160PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_PRODUCT)
161
162OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
163
164HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
165HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
166HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
167
168HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
169HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
170HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
171HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
172HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
173HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
174
175TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
176TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
177TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
178TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
179
180TARGET_OUT := $(PRODUCT_OUT)/system
181TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
182TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
183TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
184TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
185TARGET_OUT_APPS:= $(TARGET_OUT)/app
186TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
187TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
188TARGET_OUT_ETC := $(TARGET_OUT)/etc
189TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
190TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
191
192TARGET_OUT_DATA := $(PRODUCT_OUT)/data
193TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
194TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
195TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
196TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
197TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
198TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
199TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
200TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
201
202TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
203TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
204TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
205TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
206TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
207TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
208
209TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
210TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
211TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
212TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
213TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
214
215TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
216TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
217
218COMMON_MODULE_CLASSES := JAVA_LIBRARIES NOTICE_FILES
219
220ifeq (,$(strip $(DIST_DIR)))
221  DIST_DIR := $(OUT_DIR)/dist
222endif
223
224# ---------------------------------------------------------------
225# the setpath shell function in envsetup.sh uses this to figure out
226# what to add to the path given the config we have chosen.
227ifeq ($(CALLED_FROM_SETUP),true)
228
229ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
230
231ifeq ($(TARGET_SIMULATOR),true)
232	ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
233else
234	# this should be copied to HOST_OUT_EXECUTABLES instead
235	ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.2.1/bin
236endif
237ANDROID_BUILD_PATHS := $(ABP)
238ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
239
240# The "dumpvar" stuff lets you say something like
241#
242#     CALLED_FROM_SETUP=true \
243#       make -f config/envsetup.make dumpvar-TARGET_OUT
244# or
245#     CALLED_FROM_SETUP=true \
246#       make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
247#
248# The plain (non-abs) version just dumps the value of the named variable.
249# The "abs" version will treat the variable as a path, and dumps an
250# absolute path to it.
251#
252dumpvar_goals := \
253	$(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
254ifdef dumpvar_goals
255
256  ifneq ($(words $(dumpvar_goals)),1)
257    $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
258  endif
259
260  # If the goal is of the form "dumpvar-abs-VARNAME", then
261  # treat VARNAME as a path and return the absolute path to it.
262  absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
263  ifdef absolute_dumpvar
264    dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
265    DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
266    dumpvar_target := dumpvar-abs-$(dumpvar_goals)
267  else
268    DUMPVAR_VALUE := $($(dumpvar_goals))
269    dumpvar_target := dumpvar-$(dumpvar_goals)
270  endif
271
272.PHONY: $(dumpvar_target)
273$(dumpvar_target):
274	@echo $(DUMPVAR_VALUE)
275
276endif # dumpvar_goals
277
278endif # CALLED_FROM_SETUP
279