OSDN Git Service

auto import from //branches/cupcake/...@130745
[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 # ---------------------------------------------------------------
54 # Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
55 # a particular configuration without needing to set up the environment.
56 #
57 product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
58 ifdef product_goals
59   # Scrape the product and build names out of the goal,
60   # which should be of the form PRODUCT-<productname>-<buildname>.
61   #
62   ifneq ($(words $(product_goals)),1)
63     $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
64   endif
65   goal_name := $(product_goals)
66   product_goals := $(patsubst PRODUCT-%,%,$(product_goals))
67   product_goals := $(subst -, ,$(product_goals))
68   ifneq ($(words $(product_goals)),2)
69     $(error Bad PRODUCT-* goal "$(goal_name)")
70   endif
71
72   # The product they want
73   TARGET_PRODUCT := $(word 1,$(product_goals))
74
75   # The variant they want
76   TARGET_BUILD_VARIANT := $(word 2,$(product_goals))
77
78   # HACK HACK HACK
79   # The build server wants to do make PRODUCT-dream-installclean
80   # which really means TARGET_PRODUCT=dream make installclean.  
81   ifneq ($(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT)),)
82         MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
83         TARGET_BUILD_VARIANT := eng
84     default_goal_substitution := 
85   else
86     default_goal_substitution := $(DEFAULT_GOAL)
87   endif
88   # HACK HACK HACK
89
90   # Hack to make the linux build servers use dexpreopt.
91   # OSX is still a little flaky.  Most engineers don't use this
92   # type of target ("make PRODUCT-blah-user"), so this should
93   # only tend to happen when using buildbot.
94   # TODO: remove this and fix the matching lines in build/core/main.mk
95   # once dexpreopt works better on OSX.
96   ifeq ($(TARGET_BUILD_VARIANT),user)
97     WITH_DEXPREOPT_buildbot := true
98   endif
99
100   # Replace the PRODUCT-* goal with the build goal that it refers to.
101   # Note that this will ensure that it appears in the same relative
102   # position, in case it matters.
103   #
104   # Note that modifying this will not affect the goals that make will
105   # attempt to build, but it's important because we inspect this value
106   # in certain situations (like for "make sdk").  
107   #
108   MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))
109
110   # Define a rule for the PRODUCT-* goal, and make it depend on the
111   # patched-up command-line goals as well as any other goals that we
112   # want to force.
113   #
114 .PHONY: $(goal_name)
115 $(goal_name): $(MAKECMDGOALS)
116 endif
117 # else: Use the value set in the environment or buildspec.mk.
118
119 # ---------------------------------------------------------------
120 # Include the product definitions.
121 # We need to do this to translate TARGET_PRODUCT into its
122 # underlying TARGET_DEVICE before we start defining any rules.
123 #
124 include $(BUILD_SYSTEM)/node_fns.mk
125 include $(BUILD_SYSTEM)/product.mk
126 include $(BUILD_SYSTEM)/device.mk
127
128 # Read in all of the product definitions specified by the AndroidProducts.mk
129 # files in the tree.
130 #
131 #TODO: when we start allowing direct pointers to product files,
132 #    guarantee that they're in this list.
133 $(call import-products, $(get-all-product-makefiles))
134 $(check-all-products)
135 #$(dump-products)
136 #$(error done)
137
138 # Convert a short name like "sooner" into the path to the product
139 # file defining that product.
140 #
141 INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
142 #$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT))
143
144 # Find the device that this product maps to.
145 TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
146
147 # Figure out which resoure configuration options to use for this
148 # product.
149 PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
150 # TODO: also keep track of things like "port", "land" in product files.
151
152 # Assemble the list of options.
153 PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)
154
155 # Convert spaces to commas.
156 comma := ,
157 PRODUCT_AAPT_CONFIG := \
158         $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
159
160 PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))
161
162 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL))
163 ifndef PRODUCT_MODEL
164   PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME)) 
165 endif
166
167 PRODUCT_MANUFACTURER := \
168         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
169 ifndef PRODUCT_MANUFACTURER
170   PRODUCT_MANUFACTURER := unknown
171 endif
172
173 # Which policy should this product use
174 PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY))
175
176 # A list of words like <source path>:<destination path>.  The file at
177 # the source path should be copied to the destination path when building
178 # this product.  <destination path> is relative to $(PRODUCT_OUT), so
179 # it should look like, e.g., "system/etc/file.xml".  The rules
180 # for these copy steps are defined in config/Makefile.
181 PRODUCT_COPY_FILES := \
182         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
183
184 # The HTML file containing the contributors to the project.
185 PRODUCT_CONTRIBUTORS_FILE := \
186         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
187
188 # A list of property assignments, like "key = value", with zero or more
189 # whitespace characters on either side of the '='.
190 PRODUCT_PROPERTY_OVERRIDES := \
191         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
192
193 # Should we use the default resources or add any product specific overlays
194 PRODUCT_PACKAGE_OVERLAYS := \
195         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
196 DEVICE_PACKAGE_OVERLAYS := \
197         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
198
199 # An list of whitespace-separated words.
200 PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS))
201
202 # Add the product-defined properties to the build properties.
203 ADDITIONAL_BUILD_PROPERTIES := \
204         $(ADDITIONAL_BUILD_PROPERTIES) \
205         $(PRODUCT_PROPERTY_OVERRIDES)
206
207 # Get the list of OTA public keys for the product.
208 OTA_PUBLIC_KEYS := \
209         $(sort \
210             $(OTA_PUBLIC_KEYS) \
211             $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \
212          )
213
214 # HACK: Not all products define OTA keys yet, and the -user build
215 # will fail if no keys are defined.
216 # TODO: Let a product opt out of needing OTA keys, and stop defaulting to
217 #       the test key as soon as possible.
218 ifeq (,$(strip $(OTA_PUBLIC_KEYS)))
219   ifeq (,$(CALLED_FROM_SETUP))
220     $(warning WARNING: adding test OTA key)
221   endif
222   OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
223 endif
224
225 # ---------------------------------------------------------------
226 # Force the simulator to be the simulator, and make BUILD_TYPE
227 # default to debug.
228 ifeq ($(TARGET_PRODUCT),sim)
229   TARGET_SIMULATOR := true
230   ifeq (,$(strip $(TARGET_BUILD_TYPE)))
231     TARGET_BUILD_TYPE := debug
232   endif
233   # dexpreopt doesn't work when building the simulator
234   DISABLE_DEXPREOPT := true
235 endif