envsetup.mk revision cbb3266b4712fe0aa82d80d9d6db0974be9eea3f
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. 11include $(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. 19CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10 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. 25ifeq ($(TARGET_PRODUCT),) 26ifeq ($(TARGET_SIMULATOR),true) 27TARGET_PRODUCT := sim 28else 29TARGET_PRODUCT := full 30endif 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 39# --------------------------------------------------------------- 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 59 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) 66ifneq ($(USE_MINGW),) 67 HOST_OS := windows 68endif 69endif 70 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 85BUILD_ARCH := $(HOST_ARCH) 86 87ifeq ($(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 110# 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 113 114build_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 119 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 147# --------------------------------------------------------------- 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 170BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH) 171 172ifeq ($(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. 177 TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr 178else 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 189BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin 190 191HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin 192HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib 193HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework 194HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon 195 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 219TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages 220 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) 230TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest 231 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 257COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES 258 259ifeq (,$(strip $(DIST_DIR))) 260 DIST_DIR := $(OUT_DIR)/dist 261endif 262 263ifeq ($(PRINT_BUILD_CONFIG),) 264PRINT_BUILD_CONFIG := true 265endif 266