The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | |
Joe Onorato | eefd021 | 2009-05-13 00:45:23 -0400 | [diff] [blame] | 10 | # Set up version information. |
| 11 | include $(BUILD_SYSTEM)/version_defaults.mk |
| 12 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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. |
Jeff Hamilton | 77dfeae | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 19 | CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10 |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 |
Jean-Baptiste Queru | 0332f0a | 2010-10-22 09:52:09 -0700 | [diff] [blame] | 29 | TARGET_PRODUCT := full |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 |
Raphael | 9ca1628 | 2010-04-16 17:50:09 -0700 | [diff] [blame] | 71 | |
| 72 | # BUILD_OS is the real host doing the build. |
| 73 | BUILD_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. |
| 77 | ifeq ($(HOST_OS),linux) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 78 | ifneq ($(USE_MINGW),) |
| 79 | HOST_OS := windows |
| 80 | endif |
Raphael | 9ca1628 | 2010-04-16 17:50:09 -0700 | [diff] [blame] | 81 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 82 | |
| 83 | ifeq ($(HOST_OS),) |
| 84 | $(error Unable to determine HOST_OS from uname -sm: $(UNAME)!) |
| 85 | endif |
| 86 | |
| 87 | |
| 88 | # HOST_ARCH |
| 89 | ifneq (,$(findstring 86,$(UNAME))) |
| 90 | HOST_ARCH := x86 |
| 91 | endif |
| 92 | |
| 93 | ifneq (,$(findstring Power,$(UNAME))) |
| 94 | HOST_ARCH := ppc |
| 95 | endif |
| 96 | |
Raphael | 9ca1628 | 2010-04-16 17:50:09 -0700 | [diff] [blame] | 97 | BUILD_ARCH := $(HOST_ARCH) |
| 98 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 99 | ifeq ($(HOST_ARCH),) |
| 100 | $(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!) |
| 101 | endif |
| 102 | |
| 103 | # the host build defaults to release, and it must be release or debug |
| 104 | ifeq ($(HOST_BUILD_TYPE),) |
| 105 | HOST_BUILD_TYPE := release |
| 106 | endif |
| 107 | |
| 108 | ifneq ($(HOST_BUILD_TYPE),release) |
| 109 | ifneq ($(HOST_BUILD_TYPE),debug) |
| 110 | $(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)') |
| 111 | endif |
| 112 | endif |
| 113 | |
| 114 | # This is the standard way to name a directory containing prebuilt host |
| 115 | # objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc |
| 116 | ifeq ($(HOST_OS),windows) |
| 117 | HOST_PREBUILT_TAG := windows |
| 118 | else |
| 119 | HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH) |
| 120 | endif |
| 121 | |
Brian Carlstrom | e947865 | 2010-09-30 14:41:54 -0700 | [diff] [blame] | 122 | # Default to building dalvikvm on hosts that support it... |
Jesse Wilson | ce7d502 | 2010-09-22 10:59:10 -0700 | [diff] [blame] | 123 | ifeq ($(HOST_OS),linux) |
Brian Carlstrom | e947865 | 2010-09-30 14:41:54 -0700 | [diff] [blame] | 124 | # ... but not if we're building the sim... |
Andy McFadden | 6474811 | 2010-09-24 12:04:17 -0700 | [diff] [blame] | 125 | ifneq ($(TARGET_SIMULATOR),true) |
Brian Carlstrom | e947865 | 2010-09-30 14:41:54 -0700 | [diff] [blame] | 126 | # ... or if the if the option is already set |
| 127 | ifeq ($(WITH_HOST_DALVIK),) |
Jesse Wilson | ce7d502 | 2010-09-22 10:59:10 -0700 | [diff] [blame] | 128 | WITH_HOST_DALVIK := true |
| 129 | endif |
Andy McFadden | 6474811 | 2010-09-24 12:04:17 -0700 | [diff] [blame] | 130 | endif |
Brian Carlstrom | e947865 | 2010-09-30 14:41:54 -0700 | [diff] [blame] | 131 | endif |
Jesse Wilson | ce7d502 | 2010-09-22 10:59:10 -0700 | [diff] [blame] | 132 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 133 | |
| 134 | # --------------------------------------------------------------- |
| 135 | # Set up configuration for target machine. |
| 136 | # The following must be set: |
| 137 | # TARGET_OS = { linux } |
| 138 | # TARGET_ARCH = { arm | x86 } |
| 139 | |
| 140 | |
| 141 | # if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE) |
| 142 | # otherwise it's <arch>-linux |
| 143 | ifeq ($(TARGET_SIMULATOR),true) |
| 144 | ifneq ($(HOST_OS),linux) |
| 145 | $(error TARGET_SIMULATOR=true is only supported under Linux) |
| 146 | endif |
| 147 | TARGET_ARCH := $(HOST_ARCH) |
| 148 | TARGET_OS := $(HOST_OS) |
| 149 | else |
| 150 | ifeq ($(TARGET_ARCH),) |
| 151 | TARGET_ARCH := arm |
| 152 | endif |
| 153 | TARGET_OS := linux |
| 154 | endif |
| 155 | |
| 156 | # the target build type defaults to release |
| 157 | ifneq ($(TARGET_BUILD_TYPE),debug) |
| 158 | TARGET_BUILD_TYPE := release |
| 159 | endif |
| 160 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 161 | # --------------------------------------------------------------- |
| 162 | # figure out the output directories |
| 163 | |
| 164 | ifeq (,$(strip $(OUT_DIR))) |
| 165 | OUT_DIR := $(TOPDIR)out |
| 166 | endif |
| 167 | |
| 168 | DEBUG_OUT_DIR := $(OUT_DIR)/debug |
| 169 | |
| 170 | # Move the host or target under the debug/ directory |
| 171 | # if necessary. |
| 172 | TARGET_OUT_ROOT_release := $(OUT_DIR)/target |
| 173 | TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target |
| 174 | TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE)) |
| 175 | |
| 176 | HOST_OUT_ROOT_release := $(OUT_DIR)/host |
| 177 | HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host |
| 178 | HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE)) |
| 179 | |
| 180 | HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH) |
| 181 | HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH) |
| 182 | HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE)) |
| 183 | |
Raphael | 9ca1628 | 2010-04-16 17:50:09 -0700 | [diff] [blame] | 184 | BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH) |
| 185 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 186 | ifeq ($(TARGET_SIMULATOR),true) |
| 187 | # Any arch- or os-specific parts of the simulator (everything |
| 188 | # under product/) are actually host-dependent. |
| 189 | # But, the debug type is controlled by TARGET_BUILD_TYPE and not |
| 190 | # HOST_BUILD_TYPE. |
Andy McFadden | 2c86bfd | 2009-09-10 10:05:14 -0700 | [diff] [blame] | 191 | TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 192 | else |
| 193 | TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product |
| 194 | endif |
| 195 | |
| 196 | TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common |
| 197 | HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common |
| 198 | |
| 199 | PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE) |
| 200 | |
| 201 | OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs |
| 202 | |
Raphael | 9ca1628 | 2010-04-16 17:50:09 -0700 | [diff] [blame] | 203 | BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin |
| 204 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 205 | HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin |
| 206 | HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib |
| 207 | HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 208 | HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 209 | |
| 210 | HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj |
| 211 | HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include |
| 212 | HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib |
| 213 | HOST_OUT_STATIC_LIBRARIES := $(HOST_OUT_INTERMEDIATE_LIBRARIES) |
| 214 | HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES |
| 215 | HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj |
| 216 | |
| 217 | TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj |
| 218 | TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include |
| 219 | TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib |
| 220 | TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj |
| 221 | |
| 222 | TARGET_OUT := $(PRODUCT_OUT)/system |
| 223 | TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin |
| 224 | TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin |
| 225 | TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib |
| 226 | TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework |
| 227 | TARGET_OUT_APPS:= $(TARGET_OUT)/app |
| 228 | TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout |
| 229 | TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars |
| 230 | TARGET_OUT_ETC := $(TARGET_OUT)/etc |
| 231 | TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib |
| 232 | TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES |
Dima Zavin | 531f524 | 2010-09-27 17:37:17 -0700 | [diff] [blame] | 233 | TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 234 | |
| 235 | TARGET_OUT_DATA := $(PRODUCT_OUT)/data |
| 236 | TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES) |
| 237 | TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES) |
| 238 | TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_JAVA_LIBRARIES) |
| 239 | TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app |
| 240 | TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT) |
| 241 | TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS) |
| 242 | TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC) |
| 243 | TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES) |
Ying Wang | 4c68174 | 2010-07-20 11:08:47 -0700 | [diff] [blame] | 244 | TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 245 | |
| 246 | TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols |
| 247 | TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin |
| 248 | TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib |
| 249 | TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED) |
| 250 | TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin |
| 251 | TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin |
| 252 | |
| 253 | TARGET_ROOT_OUT := $(PRODUCT_OUT)/root |
| 254 | TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin |
| 255 | TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin |
| 256 | TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc |
| 257 | TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr |
| 258 | |
| 259 | TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/recovery |
| 260 | TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root |
| 261 | |
| 262 | TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader |
| 263 | TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root |
| 264 | TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system |
| 265 | |
| 266 | TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer |
| 267 | TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data |
| 268 | TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root |
| 269 | TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system |
| 270 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 271 | COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 272 | |
| 273 | ifeq (,$(strip $(DIST_DIR))) |
| 274 | DIST_DIR := $(OUT_DIR)/dist |
| 275 | endif |
| 276 | |
| 277 | ifeq ($(PRINT_BUILD_CONFIG),) |
| 278 | PRINT_BUILD_CONFIG := true |
| 279 | endif |