2 # Copyright (C) 2008 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # ---------------------------------------------------------------
19 # TODO: Move these to definitions.make once we're able to include
20 # definitions.make before config.make.
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.
29 ## $(1): word to check
30 ###########################################################
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 _
36 define is-c-identifier
39 $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \
42 $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \
43 $(eval w := $(subst $(c),,$(w))) \
53 # These are the valid values of TARGET_BUILD_VARIANT. Also, if anything else is passed
54 # as the variant in the PRODUCT-$TARGET_BUILD_PRODUCT-$TARGET_BUILD_VARIANT form,
55 # it will be treated as a goal, and the eng variant will be used.
56 INTERNAL_VALID_VARIANTS := user userdebug eng tests
58 # ---------------------------------------------------------------
59 # Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
60 # a particular configuration without needing to set up the environment.
62 product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
64 # Scrape the product and build names out of the goal,
65 # which should be of the form PRODUCT-<productname>-<buildname>.
67 ifneq ($(words $(product_goals)),1)
68 $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
70 goal_name := $(product_goals)
71 product_goals := $(patsubst PRODUCT-%,%,$(product_goals))
72 product_goals := $(subst -, ,$(product_goals))
73 ifneq ($(words $(product_goals)),2)
74 $(error Bad PRODUCT-* goal "$(goal_name)")
77 # The product they want
78 TARGET_PRODUCT := $(word 1,$(product_goals))
80 # The variant they want
81 TARGET_BUILD_VARIANT := $(word 2,$(product_goals))
83 # The build server wants to do make PRODUCT-dream-installclean
84 # which really means TARGET_PRODUCT=dream make installclean.
85 ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
86 MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
87 TARGET_BUILD_VARIANT := eng
88 default_goal_substitution :=
90 default_goal_substitution := $(DEFAULT_GOAL)
93 # Hack to make the linux build servers use dexpreopt.
94 # OSX is still a little flaky. Most engineers don't use this
95 # type of target ("make PRODUCT-blah-user"), so this should
96 # only tend to happen when using buildbot.
97 # TODO: remove this and fix the matching lines in build/core/main.mk
98 # once dexpreopt works better on OSX.
99 ifeq ($(TARGET_BUILD_VARIANT),user)
100 WITH_DEXPREOPT_buildbot := true
103 # Replace the PRODUCT-* goal with the build goal that it refers to.
104 # Note that this will ensure that it appears in the same relative
105 # position, in case it matters.
107 # Note that modifying this will not affect the goals that make will
108 # attempt to build, but it's important because we inspect this value
109 # in certain situations (like for "make sdk").
111 MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))
113 # Define a rule for the PRODUCT-* goal, and make it depend on the
114 # patched-up command-line goals as well as any other goals that we
118 $(goal_name): $(MAKECMDGOALS)
120 # else: Use the value set in the environment or buildspec.mk.
122 # ---------------------------------------------------------------
123 # Include the product definitions.
124 # We need to do this to translate TARGET_PRODUCT into its
125 # underlying TARGET_DEVICE before we start defining any rules.
127 include $(BUILD_SYSTEM)/node_fns.mk
128 include $(BUILD_SYSTEM)/product.mk
129 include $(BUILD_SYSTEM)/device.mk
131 # Read in all of the product definitions specified by the AndroidProducts.mk
134 #TODO: when we start allowing direct pointers to product files,
135 # guarantee that they're in this list.
136 $(call import-products, $(get-all-product-makefiles))
137 $(check-all-products)
141 # Convert a short name like "sooner" into the path to the product
142 # file defining that product.
144 INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
145 #$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT))
147 # Find the device that this product maps to.
148 TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
150 # Figure out which resoure configuration options to use for this
152 PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
153 # TODO: also keep track of things like "port", "land" in product files.
155 # If CUSTOM_LOCALES contains any locales not already included
156 # in PRODUCT_LOCALES, add them to PRODUCT_LOCALES.
157 extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES))
158 ifneq (,$(extra_locales))
159 $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)])
160 PRODUCT_LOCALES += $(extra_locales)
164 # Assemble the list of options.
165 PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)
167 # Convert spaces to commas.
169 PRODUCT_AAPT_CONFIG := \
170 $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
172 PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))
174 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL))
176 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME))
179 PRODUCT_MANUFACTURER := \
180 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
181 ifndef PRODUCT_MANUFACTURER
182 PRODUCT_MANUFACTURER := unknown
185 # Which policy should this product use
186 PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY))
188 # A list of words like <source path>:<destination path>. The file at
189 # the source path should be copied to the destination path when building
190 # this product. <destination path> is relative to $(PRODUCT_OUT), so
191 # it should look like, e.g., "system/etc/file.xml". The rules
192 # for these copy steps are defined in config/Makefile.
193 PRODUCT_COPY_FILES := \
194 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
196 # The HTML file containing the contributors to the project.
197 PRODUCT_CONTRIBUTORS_FILE := \
198 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
200 # A list of property assignments, like "key = value", with zero or more
201 # whitespace characters on either side of the '='.
202 PRODUCT_PROPERTY_OVERRIDES := \
203 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
205 # Should we use the default resources or add any product specific overlays
206 PRODUCT_PACKAGE_OVERLAYS := \
207 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
208 DEVICE_PACKAGE_OVERLAYS := \
209 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
211 # An list of whitespace-separated words.
212 PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS))
214 # Add the product-defined properties to the build properties.
215 ADDITIONAL_BUILD_PROPERTIES := \
216 $(ADDITIONAL_BUILD_PROPERTIES) \
217 $(PRODUCT_PROPERTY_OVERRIDES)
219 # Get the list of OTA public keys for the product.
223 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \
226 # HACK: Not all products define OTA keys yet, and the -user build
227 # will fail if no keys are defined.
228 # TODO: Let a product opt out of needing OTA keys, and stop defaulting to
229 # the test key as soon as possible.
230 ifeq (,$(strip $(OTA_PUBLIC_KEYS)))
231 ifeq (,$(CALLED_FROM_SETUP))
232 $(warning WARNING: adding test OTA key)
234 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
237 # ---------------------------------------------------------------
238 # Force the simulator to be the simulator, and make BUILD_TYPE
240 ifeq ($(TARGET_PRODUCT),sim)
241 TARGET_SIMULATOR := true
242 ifeq (,$(strip $(TARGET_BUILD_TYPE)))
243 TARGET_BUILD_TYPE := debug
245 # dexpreopt doesn't work when building the simulator
246 DISABLE_DEXPREOPT := true