1########################################################### 2## Track NOTICE files 3########################################################### 4$(call record-module-type,NOTICE_FILE) 5 6ifneq ($(LOCAL_NOTICE_FILE),) 7notice_file:=$(strip $(LOCAL_NOTICE_FILE)) 8else 9notice_file:=$(strip $(wildcard $(LOCAL_PATH)/LICENSE $(LOCAL_PATH)/LICENCE $(LOCAL_PATH)/NOTICE)) 10endif 11 12ifneq (,$(strip $(LOCAL_LICENSE_PACKAGE_NAME))) 13license_package_name:=$(strip $(LOCAL_LICENSE_PACKAGE_NAME)) 14else ifdef my_register_name 15license_package_name:=$(my_register_name) 16else 17license_package_name:=$(strip $(LOCAL_MODULE)) 18endif 19 20ifneq (,$(strip $(LOCAL_LICENSE_INSTALL_MAP))) 21install_map:=$(strip $(LOCAL_LICENSE_INSTALL_MAP)) 22else 23install_map:= 24endif 25 26ifneq (,$(strip $(LOCAL_LICENSE_KINDS))) 27license_kinds:=$(strip $(LOCAL_LICENSE_KINDS)) 28else 29license_kinds:=legacy_by_exception_only 30endif 31 32ifneq (,$(strip $(LOCAL_LICENSE_CONDITIONS))) 33license_conditions:=$(strip $(LOCAL_LICENSE_CONDITIONS)) 34else 35license_conditions:=by_exception_only 36endif 37 38ifeq ($(LOCAL_MODULE_CLASS),GYP) 39 # We ignore NOTICE files for modules of type GYP. 40 notice_file := 41endif 42 43ifeq ($(LOCAL_MODULE_CLASS),FAKE) 44 # We ignore NOTICE files for modules of type FAKE. 45 notice_file := 46endif 47 48# Soong generates stub libraries that don't need NOTICE files 49ifdef LOCAL_NO_NOTICE_FILE 50 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 51 $(call pretty-error,LOCAL_NO_NOTICE_FILE should not be used by Android.mk files) 52 endif 53 notice_file := 54endif 55 56ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES) 57# If this is a NOTICE-only module, we don't include base_rule.mk, 58# so my_prefix is not set at this point. 59ifeq ($(LOCAL_IS_HOST_MODULE),true) 60 my_prefix := HOST_ 61 LOCAL_HOST_PREFIX := 62else 63 my_prefix := TARGET_ 64endif 65endif 66 67installed_notice_file := 68 69is_container:=$(strip $(LOCAL_MODULE_IS_CONTAINER)) 70ifeq (,$(is_container)) 71ifneq (,$(strip $(filter %.zip %.tar %.tgz %.tar.gz %.apk %.img %.srcszip %.apex, $(LOCAL_BUILT_MODULE)))) 72is_container:=true 73else 74is_container:=false 75endif 76else ifneq (,$(strip $(filter-out true false,$(is_container)))) 77$(error Unrecognized value '$(is_container)' for LOCAL_MODULE_IS_CONTAINER) 78endif 79 80ifeq (true,$(is_container)) 81# Include shared libraries' notices for "container" types, but not for binaries etc. 82notice_deps := \ 83 $(strip \ 84 $(LOCAL_REQUIRED_MODULES) \ 85 $(LOCAL_STATIC_LIBRARIES) \ 86 $(LOCAL_WHOLE_STATIC_LIBRARIES) \ 87 $(LOCAL_SHARED_LIBRARIES) \ 88 $(LOCAL_DYLIB_LIBRARIES) \ 89 $(LOCAL_RLIB_LIBRARIES) \ 90 $(LOCAL_PROC_MACRO_LIBRARIES) \ 91 $(LOCAL_HEADER_LIBRARIES) \ 92 $(LOCAL_STATIC_JAVA_LIBRARIES) \ 93 $(LOCAL_JAVA_LIBRARIES) \ 94 $(LOCAL_JNI_SHARED_LIBRARIES) \ 95 ) 96else 97notice_deps := \ 98 $(strip \ 99 $(LOCAL_REQUIRED_MODULES) \ 100 $(LOCAL_STATIC_LIBRARIES) \ 101 $(LOCAL_WHOLE_STATIC_LIBRARIES) \ 102 $(LOCAL_RLIB_LIBRARIES) \ 103 $(LOCAL_PROC_MACRO_LIBRARIES) \ 104 $(LOCAL_HEADER_LIBRARIES) \ 105 $(LOCAL_STATIC_JAVA_LIBRARIES) \ 106 ) 107endif 108ifeq ($(LOCAL_IS_HOST_MODULE),true) 109notice_deps := $(strip $(notice_deps) $(LOCAL_HOST_REQUIRED_MODULES)) 110else 111notice_deps := $(strip $(notice_deps) $(LOCAL_TARGET_REQUIRED_MODULES)) 112endif 113 114ifdef my_register_name 115ALL_MODULES.$(my_register_name).LICENSE_PACKAGE_NAME := $(strip $(license_package_name)) 116ALL_MODULES.$(my_register_name).LICENSE_KINDS := $(ALL_MODULES.$(my_register_name).LICENSE_KINDS) $(license_kinds) 117ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS := $(ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS) $(license_conditions) 118ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP := $(ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP) $(install_map) 119ALL_MODULES.$(my_register_name).NOTICE_DEPS := $(ALL_MODULES.$(my_register_name).NOTICE_DEPS) $(notice_deps) 120ALL_MODULES.$(my_register_name).IS_CONTAINER := $(strip $(filter-out false,$(ALL_MODULES.$(my_register_name).IS_CONTAINER) $(is_container))) 121endif 122 123ifdef notice_file 124 125ifdef my_register_name 126ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file) 127endif 128 129# This relies on the name of the directory in PRODUCT_OUT matching where 130# it's installed on the target - i.e. system, data, etc. This does 131# not work for root and isn't exact, but it's probably good enough for 132# compliance. 133# Includes the leading slash 134ifdef LOCAL_INSTALLED_MODULE 135 module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE)) 136else 137 # This module isn't installable 138 ifneq ($(filter STATIC_LIBRARIES RLIB_LIBRARIES PROC_MACRO_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 139 # Stick the static libraries with the dynamic libraries. 140 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into 141 # device-obj or host-obj. 142 module_installed_filename := \ 143 $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) 144 else ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) 145 # Shared modules may be uninstallable(e.g. TARGET_SKIP_CURRENT_VNDK=true) 146 module_installed_filename := 147 else 148 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 149 # Stick the static java libraries with the regular java libraries. 150 module_leaf := $(notdir $(LOCAL_BUILT_MODULE)) 151 # javalib.jar is the default name for the build module (and isn't meaningful) 152 # If that's what we have, substitute the module name instead. These files 153 # aren't included on the device, so this name is synthetic anyway. 154 # Extra path "static" is added to try to avoid name conflict between the notice file of 155 # this 'uninstallable' Java module and the notice file for another 'installable' Java module 156 # whose stem is the same as this module's name. 157 ifneq ($(filter javalib.jar,$(module_leaf)),) 158 module_leaf := static/$(LOCAL_MODULE).jar 159 endif 160 module_installed_filename := \ 161 $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf) 162 else ifneq ($(filter ETC DATA,$(LOCAL_MODULE_CLASS)),) 163 # ETC and DATA modules may be uninstallable, yet still have a NOTICE file. 164 # e.g. apex components 165 module_installed_filename := 166 else ifneq (,$(and $(filter %.sdk,$(LOCAL_MODULE)),$(filter $(patsubst %.sdk,%,$(LOCAL_MODULE)),$(SOONG_SDK_VARIANT_MODULES)))) 167 # Soong produces uninstallable *.sdk shared libraries for embedding in APKs. 168 module_installed_filename := \ 169 $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) 170 endif # JAVA_LIBRARIES 171 endif # STATIC_LIBRARIES 172endif 173 174ifdef module_installed_filename 175 176# In case it's actually a host file 177module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename)) 178module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename)) 179 180installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt 181 182ifdef my_register_name 183ALL_MODULES.$(my_register_name).INSTALLED_NOTICE_FILE := $(ALL_MODULES.$(my_register_name).INSTALLED_NOTICE_FILE) $(installed_notice_file) 184ALL_MODULES.$(my_register_name).MODULE_INSTALLED_FILENAMES := $(ALL_MODULES.$(my_register_name).MODULE_INSTALLED_FILENAMES) $(module_installed_filename) 185INSTALLED_NOTICE_FILES.$(installed_notice_file).MODULE := $(my_register_name) 186else 187$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) 188$(installed_notice_file) : PRIVATE_NOTICES := $(notice_file) 189 190$(installed_notice_file): $(notice_file) 191 @echo Notice file: $< -- $@ 192 $(hide) mkdir -p $(dir $@) 193 $(hide) awk 'FNR==1 && NR > 1 {print "\n"} {print}' $(PRIVATE_NOTICES) > $@ 194endif 195 196ifdef LOCAL_INSTALLED_MODULE 197# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist 198# libraries so they get installed along with it. Make it an order-only 199# dependency so we don't re-install a module when the NOTICE changes. 200$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) 201endif 202 203# To facilitate collecting NOTICE files for apps_only build, 204# we install the NOTICE file even if a module gets built but not installed, 205# because shared jni libraries won't be installed to the system image. 206ifdef TARGET_BUILD_APPS 207# for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE, 208# but just javalib.jar in the common intermediate dir. 209ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 210$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file) 211else 212$(LOCAL_BUILT_MODULE): | $(installed_notice_file) 213endif # JAVA_LIBRARIES 214endif # TARGET_BUILD_APPS 215 216endif # module_installed_filename 217endif # notice_file 218 219# Create a predictable, phony target to build this notice file. 220# Define it even if the notice file doesn't exist so that other 221# modules can depend on it. 222notice_target := NOTICE-$(if \ 223 $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE) 224.PHONY: $(notice_target) 225$(notice_target): $(installed_notice_file) 226