OSDN Git Service

merge from open-source master
[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 #
20
21 #
22 # Returns the list of all AndroidProducts.mk files.
23 # $(call ) isn't necessary.
24 #
25 define _find-android-products-files
26 $(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk) \
27   $(SRC_TARGET_DIR)/product/AndroidProducts.mk
28 endef
29
30 #
31 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
32 # variables set in all AndroidProducts.mk files.
33 # $(call ) isn't necessary.
34 #
35 define get-all-product-makefiles
36 $(sort \
37   $(foreach f,$(_find-android-products-files), \
38     $(eval PRODUCT_MAKEFILES :=) \
39     $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
40     $(eval include $(f)) \
41     $(PRODUCT_MAKEFILES) \
42    ) \
43   $(eval PRODUCT_MAKEFILES :=) \
44   $(eval LOCAL_DIR :=) \
45  )
46 endef
47
48 #
49 # Functions for including product makefiles
50 #
51
52 _product_var_list := \
53     PRODUCT_NAME \
54     PRODUCT_MODEL \
55     PRODUCT_LOCALES \
56     PRODUCT_PACKAGES \
57     PRODUCT_DEVICE \
58     PRODUCT_MANUFACTURER \
59     PRODUCT_BRAND \
60     PRODUCT_PROPERTY_OVERRIDES \
61     PRODUCT_COPY_FILES \
62     PRODUCT_OTA_PUBLIC_KEYS \
63     PRODUCT_POLICY \
64     PRODUCT_PACKAGE_OVERLAYS \
65     DEVICE_PACKAGE_OVERLAYS \
66     PRODUCT_CONTRIBUTORS_FILE \
67     PRODUCT_TAGS \
68     PRODUCT_SDK_ADDON_NAME \
69     PRODUCT_SDK_ADDON_COPY_FILES \
70     PRODUCT_SDK_ADDON_COPY_MODULES \
71     PRODUCT_SDK_ADDON_DOC_MODULE \
72     PRODUCT_DEFAULT_WIFI_CHANNELS
73
74 define dump-product
75 $(info ==== $(1) ====)\
76 $(foreach v,$(_product_var_list),\
77 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
78 $(info --------)
79 endef
80
81 define dump-products
82 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
83 endef
84
85 #
86 # $(1): product to inherit
87 #
88 # Does three things:
89 #  1. Inherits all of the variables from $1.
90 #  2. Records the inheritance in the .INHERITS_FROM variable
91 #  3. Records that we've visited this node, in ALL_PRODUCTS
92 #
93 define inherit-product
94   $(foreach v,$(_product_var_list), \
95       $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \
96   $(eval inherit_var := \
97       PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
98   $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \
99   $(eval inherit_var:=) \
100   $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
101 endef
102
103 #
104 # $(1): product makefile list
105 #
106 #TODO: check to make sure that products have all the necessary vars defined
107 define import-products
108 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
109 endef
110
111
112 #
113 # Does various consistency checks on all of the known products.
114 # Takes no parameters, so $(call ) is not necessary.
115 #
116 define check-all-products
117 $(if ,, \
118   $(eval _cap_names :=) \
119   $(foreach p,$(PRODUCTS), \
120     $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
121     $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
122     $(if $(filter $(pn),$(_cap_names)), \
123       $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
124           $(foreach \
125             pp,$(PRODUCTS),
126               $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
127                 $(pp) \
128                ))) \
129        ) \
130      ) \
131     $(eval _cap_names += $(pn)) \
132     $(if $(call is-c-identifier,$(pn)),, \
133       $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
134      ) \
135     $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
136     $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
137     $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
138       $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \
139         $(error $(p): malformed COPY_FILE "$(cf)") \
140        ) \
141      ) \
142    ) \
143 )
144 endef
145
146
147 #
148 # Returns the product makefile path for the product with the provided name
149 #
150 # $(1): short product name like "generic"
151 #
152 define _resolve-short-product-name
153   $(eval pn := $(strip $(1)))
154   $(eval p := \
155       $(foreach p,$(PRODUCTS), \
156           $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
157             $(p) \
158        )) \
159    )
160   $(eval p := $(sort $(p)))
161   $(if $(filter 1,$(words $(p))), \
162     $(p), \
163     $(if $(filter 0,$(words $(p))), \
164       $(error No matches for product "$(pn)"), \
165       $(error Product "$(pn)" ambiguous: matches $(p)) \
166     ) \
167   )
168 endef
169 define resolve-short-product-name
170 $(strip $(call _resolve-short-product-name,$(1)))
171 endef