OSDN Git Service

Makefile: Add the missing dependency on FUTILITY.
[android-x86/build.git] / core / product.mk
1 #
2 # Copyright (C) 2007 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 # Functions for including AndroidProducts.mk files
19 # PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
20 # Format of PRODUCT_MAKEFILES:
21 # <product_name>:<path_to_the_product_makefile>
22 # If the <product_name> is the same as the base file name (without dir
23 # and the .mk suffix) of the product makefile, "<product_name>:" can be
24 # omitted.
25
26 # Search for AndroidProducts.mks in the given dir.
27 # $(1): the path to the dir
28 define _search-android-products-files-in-dir
29 $(sort $(shell test -d $(1) && find -L $(1) \
30   -maxdepth 6 \
31   -name .git -prune \
32   -o -name AndroidProducts.mk -print))
33 endef
34
35 #
36 # Returns the list of all AndroidProducts.mk files.
37 # $(call ) isn't necessary.
38 #
39 define _find-android-products-files
40 $(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
41   $(SRC_TARGET_DIR)/product/AndroidProducts.mk
42 endef
43
44 #
45 # Returns the sorted concatenation of PRODUCT_MAKEFILES
46 # variables set in the given AndroidProducts.mk files.
47 # $(1): the list of AndroidProducts.mk files.
48 #
49 define get-product-makefiles
50 $(sort \
51   $(foreach f,$(1), \
52     $(eval PRODUCT_MAKEFILES :=) \
53     $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
54     $(eval include $(f)) \
55     $(PRODUCT_MAKEFILES) \
56    ) \
57   $(eval PRODUCT_MAKEFILES :=) \
58   $(eval LOCAL_DIR :=) \
59  )
60 endef
61
62 #
63 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
64 # variables set in all AndroidProducts.mk files.
65 # $(call ) isn't necessary.
66 #
67 define get-all-product-makefiles
68 $(call get-product-makefiles,$(_find-android-products-files))
69 endef
70
71 #
72 # Functions for including product makefiles
73 #
74
75 _product_var_list := \
76     PRODUCT_BUILD_PROP_OVERRIDES \
77     PRODUCT_NAME \
78     PRODUCT_MODEL \
79     PRODUCT_LOCALES \
80     PRODUCT_AAPT_CONFIG \
81     PRODUCT_AAPT_PREF_CONFIG \
82     PRODUCT_AAPT_PREBUILT_DPI \
83     PRODUCT_PACKAGES \
84     PRODUCT_PACKAGES_DEBUG \
85     PRODUCT_PACKAGES_ENG \
86     PRODUCT_PACKAGES_TESTS \
87     PRODUCT_DEVICE \
88     PRODUCT_MANUFACTURER \
89     PRODUCT_BRAND \
90     PRODUCT_PROPERTY_OVERRIDES \
91     PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
92     PRODUCT_CHARACTERISTICS \
93     PRODUCT_COPY_FILES \
94     PRODUCT_COPY_FILES_OVERRIDES \
95     PRODUCT_OTA_PUBLIC_KEYS \
96     PRODUCT_EXTRA_RECOVERY_KEYS \
97     PRODUCT_PACKAGE_OVERLAYS \
98     DEVICE_PACKAGE_OVERLAYS \
99     PRODUCT_SDK_ATREE_FILES \
100     PRODUCT_SDK_ADDON_NAME \
101     PRODUCT_SDK_ADDON_COPY_FILES \
102     PRODUCT_SDK_ADDON_COPY_MODULES \
103     PRODUCT_SDK_ADDON_DOC_MODULES \
104     PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
105     PRODUCT_DEFAULT_WIFI_CHANNELS \
106     PRODUCT_DEFAULT_DEV_CERTIFICATE \
107     PRODUCT_RESTRICT_VENDOR_FILES \
108     PRODUCT_VENDOR_KERNEL_HEADERS \
109     PRODUCT_BOOT_JARS \
110     PRODUCT_SUPPORTS_BOOT_SIGNER \
111     PRODUCT_SUPPORTS_VBOOT \
112     PRODUCT_SUPPORTS_VERITY \
113     PRODUCT_SUPPORTS_VERITY_FEC \
114     PRODUCT_OEM_PROPERTIES \
115     PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
116     PRODUCT_SYSTEM_SERVER_JARS \
117     PRODUCT_VBOOT_SIGNING_KEY \
118     PRODUCT_VBOOT_SIGNING_SUBKEY \
119     PRODUCT_VERITY_SIGNING_KEY \
120     PRODUCT_SYSTEM_VERITY_PARTITION \
121     PRODUCT_VENDOR_VERITY_PARTITION \
122     PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
123     PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
124     PRODUCT_DEX_PREOPT_BOOT_FLAGS \
125     PRODUCT_SANITIZER_MODULE_CONFIGS \
126     PRODUCT_SYSTEM_BASE_FS_PATH \
127     PRODUCT_VENDOR_BASE_FS_PATH \
128     PRODUCT_SHIPPING_API_LEVEL \
129
130
131
132 define dump-product
133 $(info ==== $(1) ====)\
134 $(foreach v,$(_product_var_list),\
135 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
136 $(info --------)
137 endef
138
139 define dump-products
140 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
141 endef
142
143 #
144 # Internal function. Appends inherited product variables to an existing one.
145 #
146 # $(1): Product variable to operate on
147 # $(2): Value to append
148 #
149 define inherit-product_append-var
150   $(if $(findstring ../,$(2)),\
151     $(eval np := $(call normalize-paths,$(2))),\
152     $(eval np := $(strip $(2))))\
153   $(eval $(1) := $($(1)) $(INHERIT_TAG)$(np))
154 endef
155
156 #
157 # Internal function. Prepends inherited product variables to an existing one.
158 #
159 # $(1): Product variable to operate on
160 # $(2): Value to prepend
161 #
162 define inherit-product_prepend-var
163   $(eval $(1) := $(INHERIT_TAG)$(strip $(2)) $($(1)))
164 endef
165
166 #
167 # Internal function. Tracks visited notes during inheritance resolution.
168 #
169 # $(1): Product being inherited
170 #
171 define inherit-product_track-node
172   $(if $(findstring ../,$(1)),\
173     $(eval np := $(call normalize-paths,$(1))),\
174     $(eval np := $(strip $(1))))\
175   $(eval inherit_var := \
176       PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
177   $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
178   $(eval inherit_var:=) \
179   $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
180 endef
181
182 #
183 # $(1): product to inherit
184 #
185 # Does three things:
186 #  1. Inherits all of the variables from $1, prioritizing existing settings.
187 #  2. Records the inheritance in the .INHERITS_FROM variable
188 #  3. Records that we've visited this node, in ALL_PRODUCTS
189 #
190
191 define inherit-product
192   $(foreach v,$(_product_var_list), \
193       $(call inherit-product_append-var,$(v),$(1))) \
194   $(call inherit-product_track-node,$(1))
195 endef
196
197 #
198 # $(1): product to inherit
199 #
200 # Does three things:
201 #  1. Inherits all of the variables from $1, prioritizing inherited settings.
202 #  2. Records the inheritance in the .INHERITS_FROM variable
203 #  3. Records that we've visited this node, in ALL_PRODUCTS
204 #
205 define prepend-product
206   $(foreach v,$(_product_var_list), \
207       $(call inherit-product_prepend-var,$(v),$(1))) \
208   $(call inherit-product_track-node,$(1))
209 endef
210
211 #
212 # Do inherit-product only if $(1) exists
213 #
214 define inherit-product-if-exists
215   $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
216 endef
217
218 #
219 # Do inherit-product-prepend only if $(1) exists
220 #
221 define prepend-product-if-exists
222   $(if $(wildcard $(1)),$(call prepend-product,$(1)),)
223 endef
224
225 #
226 # $(1): product makefile list
227 #
228 #TODO: check to make sure that products have all the necessary vars defined
229 define import-products
230 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
231 endef
232
233
234 #
235 # Does various consistency checks on all of the known products.
236 # Takes no parameters, so $(call ) is not necessary.
237 #
238 define check-all-products
239 $(if ,, \
240   $(eval _cap_names :=) \
241   $(foreach p,$(PRODUCTS), \
242     $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
243     $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
244     $(if $(filter $(pn),$(_cap_names)), \
245       $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
246           $(foreach \
247             pp,$(PRODUCTS),
248               $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
249                 $(pp) \
250                ))) \
251        ) \
252      ) \
253     $(eval _cap_names += $(pn)) \
254     $(if $(call is-c-identifier,$(pn)),, \
255       $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
256      ) \
257     $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
258     $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
259     $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
260       $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
261         $(error $(p): malformed COPY_FILE "$(cf)") \
262        ) \
263      ) \
264    ) \
265 )
266 endef
267
268
269 #
270 # Returns the product makefile path for the product with the provided name
271 #
272 # $(1): short product name like "generic"
273 #
274 define _resolve-short-product-name
275   $(eval pn := $(strip $(1)))
276   $(eval p := \
277       $(foreach p,$(PRODUCTS), \
278           $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
279             $(p) \
280        )) \
281    )
282   $(eval p := $(sort $(p)))
283   $(if $(filter 1,$(words $(p))), \
284     $(p), \
285     $(if $(filter 0,$(words $(p))), \
286       $(error No matches for product "$(pn)"), \
287       $(error Product "$(pn)" ambiguous: matches $(p)) \
288     ) \
289   )
290 endef
291 define resolve-short-product-name
292 $(strip $(call _resolve-short-product-name,$(1)))
293 endef
294
295
296 _product_stash_var_list := $(_product_var_list) \
297         PRODUCT_BOOTCLASSPATH \
298         PRODUCT_SYSTEM_SERVER_CLASSPATH \
299         TARGET_ARCH \
300         TARGET_ARCH_VARIANT \
301         TARGET_CPU_VARIANT \
302         TARGET_BOARD_PLATFORM \
303         TARGET_BOARD_PLATFORM_GPU \
304         TARGET_BOARD_KERNEL_HEADERS \
305         TARGET_DEVICE_KERNEL_HEADERS \
306         TARGET_PRODUCT_KERNEL_HEADERS \
307         TARGET_BOOTLOADER_BOARD_NAME \
308         TARGET_NO_BOOTLOADER \
309         TARGET_NO_KERNEL \
310         TARGET_NO_RECOVERY \
311         TARGET_NO_RADIOIMAGE \
312         TARGET_HARDWARE_3D \
313         TARGET_CPU_ABI \
314         TARGET_CPU_ABI2 \
315
316
317 _product_stash_var_list += \
318         BOARD_WPA_SUPPLICANT_DRIVER \
319         BOARD_WLAN_DEVICE \
320         BOARD_USES_GENERIC_AUDIO \
321         BOARD_KERNEL_CMDLINE \
322         BOARD_KERNEL_BASE \
323         BOARD_HAVE_BLUETOOTH \
324         BOARD_VENDOR_USE_AKMD \
325         BOARD_EGL_CFG \
326         BOARD_BOOTIMAGE_PARTITION_SIZE \
327         BOARD_RECOVERYIMAGE_PARTITION_SIZE \
328         BOARD_SYSTEMIMAGE_PARTITION_SIZE \
329         BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
330         BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
331         BOARD_USERDATAIMAGE_PARTITION_SIZE \
332         BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
333         BOARD_CACHEIMAGE_PARTITION_SIZE \
334         BOARD_FLASH_BLOCK_SIZE \
335         BOARD_VENDORIMAGE_PARTITION_SIZE \
336         BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
337         BOARD_INSTALLER_CMDLINE \
338
339
340 _product_stash_var_list += \
341         DEFAULT_SYSTEM_DEV_CERTIFICATE \
342         WITH_DEXPREOPT \
343         WITH_DEXPREOPT_BOOT_IMG_ONLY
344
345 _product_stash_var_list += \
346         GLOBAL_CFLAGS_NO_OVERRIDE \
347         GLOBAL_CPPFLAGS_NO_OVERRIDE \
348         GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
349
350 _product_stash_var_list += \
351         TARGET_SKIP_DEFAULT_LOCALE \
352         TARGET_SKIP_PRODUCT_DEVICE \
353
354 #
355 # Stash values of the variables in _product_stash_var_list.
356 # $(1): Renamed prefix
357 #
358 define stash-product-vars
359 $(foreach v,$(_product_stash_var_list), \
360         $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
361  )
362 endef
363
364 #
365 # Assert that the the variable stashed by stash-product-vars remains untouched.
366 # $(1): The prefix as supplied to stash-product-vars
367 #
368 define assert-product-vars
369 $(strip \
370   $(eval changed_variables:=)
371   $(foreach v,$(_product_stash_var_list), \
372     $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
373         $(eval $(warning $(v) has been modified: $($(v)))) \
374         $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
375         $(eval changed_variables := $(changed_variables) $(v))) \
376    ) \
377   $(if $(changed_variables),\
378     $(eval $(error The following variables have been changed: $(changed_variables))),)
379 )
380 endef
381
382 define add-to-product-copy-files-if-exists
383 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
384 endef
385
386 # whitespace placeholder when we record module's dex-preopt config.
387 _PDPMC_SP_PLACE_HOLDER := |@SP@|
388 # Set up dex-preopt config for a module.
389 # $(1) list of module names
390 # $(2) the modules' dex-preopt config
391 define add-product-dex-preopt-module-config
392 $(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
393 $(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
394   $(foreach m,$(1),$(m)=$(_c)))
395 endef
396
397 # whitespace placeholder when we record module's sanitizer config.
398 _PSMC_SP_PLACE_HOLDER := |@SP@|
399 # Set up sanitizer config for a module.
400 # $(1) list of module names
401 # $(2) the modules' sanitizer config
402 define add-product-sanitizer-module-config
403 $(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
404 $(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
405   $(foreach m,$(1),$(m)=$(_c)))
406 endef