Home | History | Annotate | Download | only in core
      1 # Variables we check:
      2 #     HOST_BUILD_TYPE = { release debug }
      3 #     TARGET_BUILD_TYPE = { release debug }
      4 # and we output a bunch of variables, see the case statement at
      5 # the bottom for the full list
      6 #     OUT_DIR is also set to "out" if it's not already set.
      7 #         this allows you to set it to somewhere else if you like
      8 
      9 # Set up version information.
     10 include $(BUILD_SYSTEM)/version_defaults.mk
     11 
     12 # ---------------------------------------------------------------
     13 # If you update the build system such that the environment setup
     14 # or buildspec.mk need to be updated, increment this number, and
     15 # people who haven't re-run those will have to do so before they
     16 # can build.  Make sure to also update the corresponding value in
     17 # buildspec.mk.default and envsetup.sh.
     18 CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
     19 
     20 # ---------------------------------------------------------------
     21 # The product defaults to generic on hardware
     22 # NOTE: This will be overridden in product_config.mk if make
     23 # was invoked with a PRODUCT-xxx-yyy goal.
     24 ifeq ($(TARGET_PRODUCT),)
     25 TARGET_PRODUCT := full
     26 endif
     27 
     28 
     29 # the variant -- the set of files that are included for a build
     30 ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
     31 TARGET_BUILD_VARIANT := eng
     32 endif
     33 
     34 # ---------------------------------------------------------------
     35 # Set up configuration for host machine.  We don't do cross-
     36 # compiles except for arm/mips, so the HOST is whatever we are
     37 # running on
     38 
     39 UNAME := $(shell uname -sm)
     40 
     41 # HOST_OS
     42 ifneq (,$(findstring Linux,$(UNAME)))
     43 	HOST_OS := linux
     44 endif
     45 ifneq (,$(findstring Darwin,$(UNAME)))
     46 	HOST_OS := darwin
     47 endif
     48 ifneq (,$(findstring Macintosh,$(UNAME)))
     49 	HOST_OS := darwin
     50 endif
     51 ifneq (,$(findstring CYGWIN,$(UNAME)))
     52 	HOST_OS := windows
     53 endif
     54 
     55 # BUILD_OS is the real host doing the build.
     56 BUILD_OS := $(HOST_OS)
     57 
     58 # Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the
     59 # Windows SDK. Only a subset of tools and SDK will manage to build properly.
     60 ifeq ($(HOST_OS),linux)
     61 ifneq ($(USE_MINGW),)
     62 	HOST_OS := windows
     63 endif
     64 endif
     65 
     66 ifeq ($(HOST_OS),)
     67 $(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
     68 endif
     69 
     70 
     71 # HOST_ARCH
     72 ifneq (,$(findstring 86,$(UNAME)))
     73 	HOST_ARCH := x86
     74 endif
     75 
     76 ifneq (,$(findstring Power,$(UNAME)))
     77 	HOST_ARCH := ppc
     78 endif
     79 
     80 BUILD_ARCH := $(HOST_ARCH)
     81 
     82 ifeq ($(HOST_ARCH),)
     83 $(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
     84 endif
     85 
     86 # the host build defaults to release, and it must be release or debug
     87 ifeq ($(HOST_BUILD_TYPE),)
     88 HOST_BUILD_TYPE := release
     89 endif
     90 
     91 ifneq ($(HOST_BUILD_TYPE),release)
     92 ifneq ($(HOST_BUILD_TYPE),debug)
     93 $(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
     94 endif
     95 endif
     96 
     97 # This is the standard way to name a directory containing prebuilt host
     98 # objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
     99 ifeq ($(HOST_OS),windows)
    100   HOST_PREBUILT_TAG := windows
    101 else
    102   HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
    103 endif
    104 
    105 # TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT.
    106 # Define them here so they can be used in product config files.
    107 TARGET_COPY_OUT_SYSTEM := system
    108 TARGET_COPY_OUT_DATA := data
    109 TARGET_COPY_OUT_VENDOR := system/vendor
    110 TARGET_COPY_OUT_ROOT := root
    111 TARGET_COPY_OUT_RECOVERY := recovery
    112 
    113 # Read the product specs so we an get TARGET_DEVICE and other
    114 # variables that we need in order to locate the output files.
    115 include $(BUILD_SYSTEM)/product_config.mk
    116 
    117 build_variant := $(filter-out eng user userdebug,$(TARGET_BUILD_VARIANT))
    118 ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
    119 $(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
    120 $(error must be empty or one of: eng user userdebug)
    121 endif
    122 
    123 # ---------------------------------------------------------------
    124 # Set up configuration for target machine.
    125 # The following must be set:
    126 # 		TARGET_OS = { linux }
    127 # 		TARGET_ARCH = { arm | x86 | mips }
    128 
    129 TARGET_OS := linux
    130 # TARGET_ARCH should be set by BoardConfig.mk and will be checked later
    131 
    132 # the target build type defaults to release
    133 ifneq ($(TARGET_BUILD_TYPE),debug)
    134 TARGET_BUILD_TYPE := release
    135 endif
    136 
    137 # ---------------------------------------------------------------
    138 # figure out the output directories
    139 
    140 ifeq (,$(strip $(OUT_DIR)))
    141 ifeq (,$(strip $(OUT_DIR_COMMON_BASE)))
    142 OUT_DIR := $(TOPDIR)out
    143 else
    144 OUT_DIR := $(OUT_DIR_COMMON_BASE)/$(notdir $(PWD))
    145 endif
    146 endif
    147 
    148 DEBUG_OUT_DIR := $(OUT_DIR)/debug
    149 
    150 # Move the host or target under the debug/ directory
    151 # if necessary.
    152 TARGET_OUT_ROOT_release := $(OUT_DIR)/target
    153 TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
    154 TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
    155 
    156 HOST_OUT_ROOT_release := $(OUT_DIR)/host
    157 HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
    158 HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
    159 
    160 HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_ARCH)
    161 HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_ARCH)
    162 HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
    163 
    164 BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
    165 
    166 TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
    167 
    168 TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
    169 HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
    170 
    171 PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
    172 
    173 OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
    174 
    175 BUILD_OUT_EXECUTABLES:= $(BUILD_OUT)/bin
    176 
    177 HOST_OUT_EXECUTABLES:= $(HOST_OUT)/bin
    178 HOST_OUT_SHARED_LIBRARIES:= $(HOST_OUT)/lib
    179 HOST_OUT_JAVA_LIBRARIES:= $(HOST_OUT)/framework
    180 HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
    181 
    182 HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
    183 HOST_OUT_HEADERS:= $(HOST_OUT_INTERMEDIATES)/include
    184 HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
    185 HOST_OUT_NOTICE_FILES:=$(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
    186 HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
    187 
    188 TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
    189 TARGET_OUT_HEADERS:= $(TARGET_OUT_INTERMEDIATES)/include
    190 TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
    191 TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
    192 
    193 TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
    194 TARGET_OUT_EXECUTABLES:= $(TARGET_OUT)/bin
    195 TARGET_OUT_OPTIONAL_EXECUTABLES:= $(TARGET_OUT)/xbin
    196 TARGET_OUT_SHARED_LIBRARIES:= $(TARGET_OUT)/lib
    197 TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework
    198 TARGET_OUT_APPS:= $(TARGET_OUT)/app
    199 TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT)/priv-app
    200 TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
    201 TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
    202 TARGET_OUT_ETC := $(TARGET_OUT)/etc
    203 TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
    204 TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
    205 
    206 TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
    207 TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
    208 TARGET_OUT_DATA_SHARED_LIBRARIES:= $(TARGET_OUT_SHARED_LIBRARIES)
    209 TARGET_OUT_DATA_JAVA_LIBRARIES:= $(TARGET_OUT_DATA)/framework
    210 TARGET_OUT_DATA_APPS:= $(TARGET_OUT_DATA)/app
    211 TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
    212 TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
    213 TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
    214 TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
    215 TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
    216 
    217 TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
    218 
    219 TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
    220 TARGET_OUT_VENDOR_EXECUTABLES:= $(TARGET_OUT_VENDOR)/bin
    221 TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES:= $(TARGET_OUT_VENDOR)/xbin
    222 TARGET_OUT_VENDOR_SHARED_LIBRARIES:= $(TARGET_OUT_VENDOR)/lib
    223 TARGET_OUT_VENDOR_JAVA_LIBRARIES:= $(TARGET_OUT_VENDOR)/framework
    224 TARGET_OUT_VENDOR_APPS:= $(TARGET_OUT_VENDOR)/app
    225 TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
    226 
    227 TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
    228 TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
    229 TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
    230 TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
    231 TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
    232 TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
    233 
    234 TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
    235 TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
    236 TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
    237 TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
    238 TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
    239 
    240 TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RECOVERY)
    241 TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
    242 
    243 TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
    244 TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
    245 TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
    246 
    247 TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
    248 TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
    249 TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
    250 TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
    251 
    252 TARGET_FACTORY_RAMDISK_OUT := $(PRODUCT_OUT)/factory_ramdisk
    253 
    254 COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
    255 
    256 ifeq (,$(strip $(DIST_DIR)))
    257   DIST_DIR := $(OUT_DIR)/dist
    258 endif
    259 
    260 ifeq ($(PRINT_BUILD_CONFIG),)
    261 PRINT_BUILD_CONFIG := true
    262 endif
    263