blob: b02d8c6758fa6c4e272d86cd878ccc96652de932 [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
Joe Onoratoeefd0212009-05-13 00:45:23 -040010# Set up version information.
11include $(BUILD_SYSTEM)/version_defaults.mk
12
The Android Open Source Project88b60792009-03-03 19:28:42 -080013# ---------------------------------------------------------------
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.
Jeff Hamilton77dfeae2010-06-21 18:26:38 -050019CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
The Android Open Source Project88b60792009-03-03 19:28:42 -080020
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
Jean-Baptiste Queru0332f0a2010-10-22 09:52:09 -070029TARGET_PRODUCT := full
The Android Open Source Project88b60792009-03-03 19:28:42 -080030endif
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
The Android Open Source Project88b60792009-03-03 19:28:42 -080039# ---------------------------------------------------------------
40# Set up configuration for host machine. We don't do cross-
41# compiles except for arm, so the HOST is whatever we are
42# running on
43
44UNAME := $(shell uname -sm)
45
46# HOST_OS
47ifneq (,$(findstring Linux,$(UNAME)))
48 HOST_OS := linux
49endif
50ifneq (,$(findstring Darwin,$(UNAME)))
51 HOST_OS := darwin
52endif
53ifneq (,$(findstring Macintosh,$(UNAME)))
54 HOST_OS := darwin
55endif
56ifneq (,$(findstring CYGWIN,$(UNAME)))
57 HOST_OS := windows
58endif
Raphael9ca16282010-04-16 17:50:09 -070059
60# BUILD_OS is the real host doing the build.
61BUILD_OS := $(HOST_OS)
62
63# Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the
64# Windows SDK. Only a subset of tools and SDK will manage to build properly.
65ifeq ($(HOST_OS),linux)
The Android Open Source Project88b60792009-03-03 19:28:42 -080066ifneq ($(USE_MINGW),)
67 HOST_OS := windows
68endif
Raphael9ca16282010-04-16 17:50:09 -070069endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080070
71ifeq ($(HOST_OS),)
72$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
73endif
74
75
76# HOST_ARCH
77ifneq (,$(findstring 86,$(UNAME)))
78 HOST_ARCH := x86
79endif
80
81ifneq (,$(findstring Power,$(UNAME)))
82 HOST_ARCH := ppc
83endif
84
Raphael9ca16282010-04-16 17:50:09 -070085BUILD_ARCH := $(HOST_ARCH)
86
The Android Open Source Project88b60792009-03-03 19:28:42 -080087ifeq ($(HOST_ARCH),)
88$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
89endif
90
91# the host build defaults to release, and it must be release or debug
92ifeq ($(HOST_BUILD_TYPE),)
93HOST_BUILD_TYPE := release
94endif
95
96ifneq ($(HOST_BUILD_TYPE),release)
97ifneq ($(HOST_BUILD_TYPE),debug)
98$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
99endif
100endif
101
102# This is the standard way to name a directory containing prebuilt host
103# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
104ifeq ($(HOST_OS),windows)
105 HOST_PREBUILT_TAG := windows
106else
107 HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
108endif
109
Ryo Fujiicbb32662011-06-16 16:58:11 -0700110# Read the product specs so we an get TARGET_DEVICE and other
111# variables that we need in order to locate the output files.
112include $(BUILD_SYSTEM)/product_config.mk
Jesse Wilsonce7d5022010-09-22 10:59:10 -0700113
Ryo Fujiicbb32662011-06-16 16:58:11 -0700114build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
115ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
116$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
117$(error must be empty or one of: eng user userdebug tests)
118endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800119
120# ---------------------------------------------------------------
121# Set up configuration for target machine.
122# The following must be set:
123# TARGET_OS = { linux }
124# TARGET_ARCH = { arm | x86 }
125
126
127# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
128# otherwise it's <arch>-linux
129ifeq ($(TARGET_SIMULATOR),true)
130ifneq ($(HOST_OS),linux)
131$(error TARGET_SIMULATOR=true is only supported under Linux)
132endif
133TARGET_ARCH := $(HOST_ARCH)
134TARGET_OS := $(HOST_OS)
135else
136ifeq ($(TARGET_ARCH),)
137TARGET_ARCH := arm
138endif
139TARGET_OS := linux
140endif
141
142# the target build type defaults to release
143ifneq ($(TARGET_BUILD_TYPE),debug)
144TARGET_BUILD_TYPE := release
145endif
146
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147# ---------------------------------------------------------------
148# figure out the output directories
149
150ifeq (,$(strip $(OUT_DIR)))
151OUT_DIR := $(TOPDIR)out
152endif
153
154DEBUG_OUT_DIR := $(OUT_DIR)/debug
155
156# Move the host or target under the debug/ directory
157# if necessary.
158TARGET_OUT_ROOT_release := $(OUT_DIR)/target
159TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
160TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
161
162HOST_OUT_ROOT_release := $(OUT_DIR)/host
163HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
164HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
165
166HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
167HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
168HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
169
Raphael9ca16282010-04-16 17:50:09 -0700170BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
171
The Android Open Source Project88b60792009-03-03 19:28:42 -0800172ifeq ($(TARGET_SIMULATOR),true)
173 # Any arch- or os-specific parts of the simulator (everything
174 # under product/) are actually host-dependent.
175 # But, the debug type is controlled by TARGET_BUILD_TYPE and not
176 # HOST_BUILD_TYPE.
Andy McFadden2c86bfd2009-09-10 10:05:14 -0700177 TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178else
179 TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
180endif
181
182TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
183HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
184
185PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
186
187OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
188
Raphael9ca16282010-04-16 17:50:09 -0700189BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin
190
The Android Open Source Project88b60792009-03-03 19:28:42 -0800191HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
192HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
193HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
Joe Onorato64d85d02009-04-09 19:31:12 -0700194HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
The Android Open Source Project88b60792009-03-03 19:28:42 -0800195
196HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
197HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
198HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
199HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
200HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
201HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
202
203TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
204TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
205TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
206TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
207
208TARGET_OUT := $(PRODUCT_OUT)/system
209TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
210TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
211TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
212TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
213TARGET_OUT_APPS:= $(TARGET_OUT)/app
214TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
215TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
216TARGET_OUT_ETC := $(TARGET_OUT)/etc
217TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
218TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
Dima Zavin531f5242010-09-27 17:37:17 -0700219TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800220
221TARGET_OUT_DATA := $(PRODUCT_OUT)/data
222TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
223TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
224TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES)
225TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
226TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
227TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
228TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
229TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
Ying Wang4c681742010-07-20 11:08:47 -0700230TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
The Android Open Source Project88b60792009-03-03 19:28:42 -0800231
232TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
233TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
234TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
235TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
236TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
237TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
238
239TARGET_ROOT_OUT := $(PRODUCT_OUT)/root
240TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
241TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
242TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
243TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
244
245TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery
246TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
247
248TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
249TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
250TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
251
252TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
253TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
254TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
255TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
256
Ying Wanga83940f2010-09-24 18:09:04 -0700257COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258
259ifeq (,$(strip $(DIST_DIR)))
260 DIST_DIR := $(OUT_DIR)/dist
261endif
262
263ifeq ($(PRINT_BUILD_CONFIG),)
264PRINT_BUILD_CONFIG := true
265endif