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