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