product_config.mk revision b6c1cf6de79035f58b512f4400db458c8401379a
1# 2# Copyright (C) 2008 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# --------------------------------------------------------------- 18# Generic functions 19# TODO: Move these to definitions.make once we're able to include 20# definitions.make before config.make. 21 22########################################################### 23## Return non-empty if $(1) is a C identifier; i.e., if it 24## matches /^[a-zA-Z_][a-zA-Z0-9_]*$/. We do this by first 25## making sure that it isn't empty and doesn't start with 26## a digit, then by removing each valid character. If the 27## final result is empty, then it was a valid C identifier. 28## 29## $(1): word to check 30########################################################### 31 32_ici_digits := 0 1 2 3 4 5 6 7 8 9 33_ici_alphaunderscore := \ 34 a b c d e f g h i j k l m n o p q r s t u v w x y z \ 35 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ 36define is-c-identifier 37$(strip \ 38 $(if $(1), \ 39 $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \ 40 , \ 41 $(eval w := $(1)) \ 42 $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \ 43 $(eval w := $(subst $(c),,$(w))) \ 44 ) \ 45 $(if $(w),,TRUE) \ 46 $(eval w :=) \ 47 ) \ 48 ) \ 49 ) 50endef 51 52 53# --------------------------------------------------------------- 54# if TARGET_PRODUCT isn't set, fall back to the hardware- and 55# vendor-agnostic "generic" product. 56# 57ifeq ($(strip $(TARGET_PRODUCT)),) 58TARGET_PRODUCT := generic 59endif 60 61 62# --------------------------------------------------------------- 63# Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build 64# a particular configuration without needing to set up the environment. 65# 66product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS))) 67ifdef product_goals 68 # Scrape the product and build names out of the goal, 69 # which should be of the form PRODUCT-<productname>-<buildname>. 70 # 71 ifneq ($(words $(product_goals)),1) 72 $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)") 73 endif 74 goal_name := $(product_goals) 75 product_goals := $(patsubst PRODUCT-%,%,$(product_goals)) 76 product_goals := $(subst -, ,$(product_goals)) 77 ifneq ($(words $(product_goals)),2) 78 $(error Bad PRODUCT-* goal "$(goal_name)") 79 endif 80 product_name := $(word 1,$(product_goals)) 81 product_build := $(word 2,$(product_goals)) 82 ifeq ($(product_build),eng) 83 product_build := droid 84 endif 85 86 # Hack to make the linux build servers use dexpreopt. 87 # OSX is still a little flaky. Most engineers don't use this 88 # type of target ("make PRODUCT-blah-user"), so this should 89 # only tend to happen when using buildbot. 90 # TODO: remove this and fix the matching lines in //device/Makefile 91 # once dexpreopt works better on OSX. 92 ifeq ($(product_build),user) 93 WITH_DEXPREOPT_buildbot := true 94 endif 95 96 # Replace the PRODUCT-* goal with the build goal that it refers to. 97 # Note that this will ensure that it appears in the same relative 98 # position, in case it matters. 99 # 100 # Note that modifying this will not affect the goals that make will 101 # attempt to build, but it's important because we inspect this value 102 # in certain situations (like for "make user"). 103 # 104 MAKECMDGOALS := $(patsubst $(goal_name),$(product_build),$(MAKECMDGOALS)) 105 106 # Keep track of the requested product. 107 REQUESTED_PRODUCT := $(product_name) 108 109 # Define a rule for the PRODUCT-* goal, and make it depend on the 110 # patched-up command-line goals as well as any other goals that we 111 # want to force. 112 # 113.PHONY: $(goal_name) 114$(goal_name): $(MAKECMDGOALS) 115 116else 117 # Use the value set in the environment or buildspec.mk. 118 # 119 REQUESTED_PRODUCT := $(TARGET_PRODUCT) 120endif 121 122# --------------------------------------------------------------- 123# Make the SDK build against generic by default. 124ifneq (,$(filter sdk,$(MAKECMDGOALS))) 125 ifeq (,$(strip $(REQUESTED_PRODUCT))) 126 REQUESTED_PRODUCT := generic 127 endif 128endif 129 130# --------------------------------------------------------------- 131# Make the PDK build against generic by default. 132ifneq (,$(filter pdk,$(MAKECMDGOALS))) 133 ifeq (,$(strip $(REQUESTED_PRODUCT))) 134 REQUESTED_PRODUCT := generic 135 endif 136endif 137 138 139# --------------------------------------------------------------- 140# Include the product definitions. 141# We need to do this to translate TARGET_PRODUCT into its 142# underlying TARGET_DEVICE before we start defining any rules. 143# 144include $(BUILD_SYSTEM)/node_fns.mk 145include $(BUILD_SYSTEM)/product.mk 146include $(BUILD_SYSTEM)/device.mk 147 148# Read in all of the product definitions specified by the AndroidProducts.mk 149# files in the tree. 150# 151#TODO: when we start allowing direct pointers to product files, 152# guarantee that they're in this list. 153$(call import-products, $(get-all-product-makefiles)) 154$(check-all-products) 155#$(dump-products) 156#$(error done) 157 158# Convert a short name like "sooner" into the path to the product 159# file defining that product. 160# 161INTERNAL_PRODUCT := $(call resolve-short-product-name, $(REQUESTED_PRODUCT)) 162#$(error REQUESTED_PRODUCT $(REQUESTED_PRODUCT) --> $(INTERNAL_PRODUCT)) 163 164# Convert from the real product (which represents everything about a 165# build) to the old product (which represents a board/device/sku). 166# 167# Use "override" in case make was invoked like "make TARGET_PRODUCT=xyz" 168# TODO: get rid of the old meaning of "product" in favor of 169# device/board. 170# 171override TARGET_PRODUCT := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE) 172 173# Figure out which resoure configuration options to use for this 174# product. 175PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES)) 176# TODO: also keep track of things like "port", "land" in product files. 177 178# Assemble the list of options. 179PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) 180 181# Convert spaces to commas. 182comma := , 183PRODUCT_AAPT_CONFIG := \ 184 $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG))) 185 186PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND)) 187 188PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL)) 189ifndef PRODUCT_MODEL 190 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME)) 191endif 192 193PRODUCT_MANUFACTURER := \ 194 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER)) 195ifndef PRODUCT_MANUFACTURER 196 PRODUCT_MANUFACTURER := unknown 197endif 198 199# A list of words like <source path>:<destination path>. The file at 200# the source path should be copied to the destination path when building 201# this product. <destination path> is relative to $(PRODUCT_OUT), so 202# it should look like, e.g., "system/etc/file.xml". The rules 203# for these copy steps are defined in config/Makefile. 204PRODUCT_COPY_FILES := \ 205 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES)) 206 207# A list of property assignments, like "key = value", with zero or more 208# whitespace characters on either side of the '='. 209PRODUCT_PROPERTY_OVERRIDES := \ 210 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES)) 211 212# Add the product-defined properties to the build properties. 213ADDITIONAL_BUILD_PROPERTIES := \ 214 $(ADDITIONAL_BUILD_PROPERTIES) \ 215 $(PRODUCT_PROPERTY_OVERRIDES) 216 217# Get the list of OTA public keys for the product. 218OTA_PUBLIC_KEYS := \ 219 $(sort \ 220 $(OTA_PUBLIC_KEYS) \ 221 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \ 222 ) 223 224# HACK: Not all products define OTA keys yet, and the -user build 225# will fail if no keys are defined. 226# TODO: Let a product opt out of needing OTA keys, and stop defaulting to 227# the test key as soon as possible. 228ifeq (,$(strip $(OTA_PUBLIC_KEYS))) 229 $(warning WARNING: adding test OTA key) 230 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 231endif 232 233# --------------------------------------------------------------- 234# Force the simulator to be the simulator, and make BUILD_TYPE 235# default to debug. 236ifeq ($(TARGET_PRODUCT),sim) 237 TARGET_SIMULATOR := true 238 ifeq (,$(strip $(TARGET_BUILD_TYPE))) 239 TARGET_BUILD_TYPE := debug 240 endif 241 # dexpreopt doesn't work when building the simulator 242 DISABLE_DEXPREOPT := true 243endif 244