OSDN Git Service

b55760f8b49800969a537942616613adfc91a49b
[android-x86/build.git] / core / product_config.mk
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 _
36 define 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  )
50 endef
51
52
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
57
58 # ---------------------------------------------------------------
59 # Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
60 # a particular configuration without needing to set up the environment.
61 #
62 product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
63 ifdef product_goals
64   # Scrape the product and build names out of the goal,
65   # which should be of the form PRODUCT-<productname>-<buildname>.
66   #
67   ifneq ($(words $(product_goals)),1)
68     $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
69   endif
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)")
75   endif
76
77   # The product they want
78   TARGET_PRODUCT := $(word 1,$(product_goals))
79
80   # The variant they want
81   TARGET_BUILD_VARIANT := $(word 2,$(product_goals))
82
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 := 
89   else
90     default_goal_substitution := $(DEFAULT_GOAL)
91   endif
92
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
101   endif
102
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.
106   #
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").  
110   #
111   MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))
112
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
115   # want to force.
116   #
117 .PHONY: $(goal_name)
118 $(goal_name): $(MAKECMDGOALS)
119 endif
120 # else: Use the value set in the environment or buildspec.mk.
121
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.
126 #
127 include $(BUILD_SYSTEM)/node_fns.mk
128 include $(BUILD_SYSTEM)/product.mk
129 include $(BUILD_SYSTEM)/device.mk
130
131 # Read in all of the product definitions specified by the AndroidProducts.mk
132 # files in the tree.
133 #
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)
138 #$(dump-products)
139 #$(error done)
140
141 # Convert a short name like "sooner" into the path to the product
142 # file defining that product.
143 #
144 INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
145 #$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT))
146
147 # Find the device that this product maps to.
148 TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
149
150 # Figure out which resoure configuration options to use for this
151 # product.
152 PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
153 # TODO: also keep track of things like "port", "land" in product files.
154
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)
161   extra_locales :=
162 endif
163
164 # Assemble the list of options.
165 PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)
166
167 # Convert spaces to commas.
168 comma := ,
169 PRODUCT_AAPT_CONFIG := \
170         $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
171
172 PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))
173
174 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL))
175 ifndef PRODUCT_MODEL
176   PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME)) 
177 endif
178
179 PRODUCT_MANUFACTURER := \
180         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
181 ifndef PRODUCT_MANUFACTURER
182   PRODUCT_MANUFACTURER := unknown
183 endif
184
185 # Which policy should this product use
186 PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY))
187
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))
195
196 # The HTML file containing the contributors to the project.
197 PRODUCT_CONTRIBUTORS_FILE := \
198         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
199
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))
204
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))
210
211 # An list of whitespace-separated words.
212 PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS))
213
214 # Add the product-defined properties to the build properties.
215 ADDITIONAL_BUILD_PROPERTIES := \
216         $(ADDITIONAL_BUILD_PROPERTIES) \
217         $(PRODUCT_PROPERTY_OVERRIDES)
218
219 # Get the list of OTA public keys for the product.
220 OTA_PUBLIC_KEYS := \
221         $(sort \
222             $(OTA_PUBLIC_KEYS) \
223             $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \
224          )
225
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)
233   endif
234   OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
235 endif
236
237 # ---------------------------------------------------------------
238 # Force the simulator to be the simulator, and make BUILD_TYPE
239 # default to debug.
240 ifeq ($(TARGET_PRODUCT),sim)
241   TARGET_SIMULATOR := true
242   ifeq (,$(strip $(TARGET_BUILD_TYPE)))
243     TARGET_BUILD_TYPE := debug
244   endif
245   # dexpreopt doesn't work when building the simulator
246   DISABLE_DEXPREOPT := true
247 endif