1 ########################################################### 2 ## Track NOTICE files 3 ########################################################### 4 $(call record-module-type,NOTICE_FILE) 5 6 ifneq ($(LOCAL_NOTICE_FILE),) 7 notice_file:=$(strip $(LOCAL_NOTICE_FILE)) 8 else 9 notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE)) 10 endif 11 12 ifeq ($(LOCAL_MODULE_CLASS),GYP) 13 # We ignore NOTICE files for modules of type GYP. 14 notice_file := 15 endif 16 17 ifeq ($(LOCAL_MODULE_CLASS),FAKE) 18 # We ignore NOTICE files for modules of type FAKE. 19 notice_file := 20 endif 21 22 # Soong generates stub libraries that don't need NOTICE files 23 ifdef LOCAL_NO_NOTICE_FILE 24 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 25 $(call pretty-error,LOCAL_NO_NOTICE_FILE should not be used by Android.mk files) 26 endif 27 notice_file := 28 endif 29 30 ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES) 31 # If this is a NOTICE-only module, we don't include base_rule.mk, 32 # so my_prefix is not set at this point. 33 ifeq ($(LOCAL_IS_HOST_MODULE),true) 34 my_prefix := HOST_ 35 LOCAL_HOST_PREFIX := 36 else 37 my_prefix := TARGET_ 38 endif 39 endif 40 41 installed_notice_file := 42 43 ifdef notice_file 44 45 ifdef my_register_name 46 ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file) 47 endif 48 49 # This relies on the name of the directory in PRODUCT_OUT matching where 50 # it's installed on the target - i.e. system, data, etc. This does 51 # not work for root and isn't exact, but it's probably good enough for 52 # compliance. 53 # Includes the leading slash 54 ifdef LOCAL_INSTALLED_MODULE 55 module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE)) 56 else 57 # This module isn't installable 58 ifneq ($(filter STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 59 # Stick the static libraries with the dynamic libraries. 60 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into 61 # device-obj or host-obj. 62 module_installed_filename := \ 63 $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) 64 else 65 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 66 # Stick the static java libraries with the regular java libraries. 67 module_leaf := $(notdir $(LOCAL_BUILT_MODULE)) 68 # javalib.jar is the default name for the build module (and isn't meaningful) 69 # If that's what we have, substitute the module name instead. These files 70 # aren't included on the device, so this name is synthetic anyway. 71 ifneq ($(filter javalib.jar,$(module_leaf)),) 72 module_leaf := $(LOCAL_MODULE).jar 73 endif 74 module_installed_filename := \ 75 $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf) 76 else ifeq ($(LOCAL_MODULE_CLASS),ETC) 77 # ETC modules may be uninstallable, yet still have a NOTICE file. e.g. apex components 78 module_installed_filename := 79 else 80 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE)) 81 endif # JAVA_LIBRARIES 82 endif # STATIC_LIBRARIES 83 endif 84 85 ifdef module_installed_filename 86 87 # In case it's actually a host file 88 module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename)) 89 module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename)) 90 91 installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt 92 93 $(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) 94 95 $(installed_notice_file): $(notice_file) 96 @echo Notice file: $< -- $@ 97 $(hide) mkdir -p $(dir $@) 98 $(hide) cat $< > $@ 99 100 ifdef LOCAL_INSTALLED_MODULE 101 # Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist 102 # libraries so they get installed along with it. Make it an order-only 103 # dependency so we don't re-install a module when the NOTICE changes. 104 $(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) 105 endif 106 107 # To facilitate collecting NOTICE files for apps_only build, 108 # we install the NOTICE file even if a module gets built but not installed, 109 # because shared jni libraries won't be installed to the system image. 110 ifdef TARGET_BUILD_APPS 111 # for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE, 112 # but just javalib.jar in the common intermediate dir. 113 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 114 $(intermediates.COMMON)/javalib.jar : | $(installed_notice_file) 115 else 116 $(LOCAL_BUILT_MODULE): | $(installed_notice_file) 117 endif # JAVA_LIBRARIES 118 endif # TARGET_BUILD_APPS 119 120 endif # module_installed_filename 121 endif # notice_file 122 123 # Create a predictable, phony target to build this notice file. 124 # Define it even if the notice file doesn't exist so that other 125 # modules can depend on it. 126 notice_target := NOTICE-$(if \ 127 $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE) 128 .PHONY: $(notice_target) 129 $(notice_target): $(installed_notice_file) 130