The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | ########################################################### |
| 2 | ## Track NOTICE files |
| 3 | ########################################################### |
Dan Willemsen | 3bf15e7 | 2016-07-25 16:03:53 -0700 | [diff] [blame] | 4 | $(call record-module-type,NOTICE_FILE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 5 | |
Narayan Kamath | 76c7d68 | 2015-12-22 14:34:09 +0000 | [diff] [blame] | 6 | ifneq ($(LOCAL_NOTICE_FILE),) |
| 7 | notice_file:=$(strip $(LOCAL_NOTICE_FILE)) |
| 8 | else |
Bob Badour | 9da828c | 2020-02-13 12:37:33 -0800 | [diff] [blame] | 9 | notice_file:=$(strip $(wildcard $(LOCAL_PATH)/LICENSE $(LOCAL_PATH)/LICENCE $(LOCAL_PATH)/NOTICE)) |
Narayan Kamath | 76c7d68 | 2015-12-22 14:34:09 +0000 | [diff] [blame] | 10 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 11 | |
Bob Badour | 21bd34f | 2021-01-07 03:34:31 +0000 | [diff] [blame^] | 12 | ifneq (,$(strip $(LOCAL_LICENSE_PACKAGE_NAME))) |
| 13 | license_package_name:=$(strip $(LOCAL_LICENSE_PACKAGE_NAME)) |
| 14 | else ifdef my_register_name |
| 15 | license_package_name:=$(my_register_name) |
| 16 | else |
| 17 | license_package_name:=$(strip $(LOCAL_MODULE)) |
| 18 | endif |
| 19 | |
| 20 | ifneq (,$(strip $(LOCAL_LICENSE_INSTALL_MAP))) |
| 21 | install_map:=$(strip $(LOCAL_LICENSE_INSTALL_MAP)) |
| 22 | else |
| 23 | install_map:= |
| 24 | endif |
| 25 | |
| 26 | ifneq (,$(strip $(LOCAL_LICENSE_KINDS))) |
| 27 | license_kinds:=$(strip $(LOCAL_LICENSE_KINDS)) |
| 28 | else |
| 29 | license_kinds:=legacy_by_exception_only |
| 30 | endif |
| 31 | |
| 32 | ifneq (,$(strip $(LOCAL_LICENSE_CONDITIONS))) |
| 33 | license_conditions:=$(strip $(LOCAL_LICENSE_CONDITIONS)) |
| 34 | else |
| 35 | license_conditions:=by_exception_only |
| 36 | endif |
| 37 | |
Torne (Richard Coles) | 63afdc1 | 2012-10-25 15:49:39 +0100 | [diff] [blame] | 38 | ifeq ($(LOCAL_MODULE_CLASS),GYP) |
| 39 | # We ignore NOTICE files for modules of type GYP. |
Steve Block | f55aeb0 | 2012-06-27 01:07:19 +0100 | [diff] [blame] | 40 | notice_file := |
| 41 | endif |
| 42 | |
John Muir | 58d96b1 | 2018-04-11 11:42:26 -0700 | [diff] [blame] | 43 | ifeq ($(LOCAL_MODULE_CLASS),FAKE) |
| 44 | # We ignore NOTICE files for modules of type FAKE. |
| 45 | notice_file := |
| 46 | endif |
| 47 | |
Dan Willemsen | 2be5594 | 2017-04-03 16:06:00 -0700 | [diff] [blame] | 48 | # Soong generates stub libraries that don't need NOTICE files |
| 49 | ifdef 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 := |
| 54 | endif |
| 55 | |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 56 | ifeq ($(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. |
| 59 | ifeq ($(LOCAL_IS_HOST_MODULE),true) |
| 60 | my_prefix := HOST_ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 61 | LOCAL_HOST_PREFIX := |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 62 | else |
| 63 | my_prefix := TARGET_ |
| 64 | endif |
| 65 | endif |
| 66 | |
Jaewoong Jung | dca3186 | 2019-04-03 08:59:49 -0700 | [diff] [blame] | 67 | installed_notice_file := |
| 68 | |
Bob Badour | 21bd34f | 2021-01-07 03:34:31 +0000 | [diff] [blame^] | 69 | is_container:=$(strip $(LOCAL_MODULE_IS_CONTAINER)) |
| 70 | ifeq (,$(is_container)) |
| 71 | ifneq (,$(strip $(filter %.zip %.tar %.tgz %.tar.gz %.apk %.img %.srcszip %.apex, $(LOCAL_BUILT_MODULE)))) |
| 72 | is_container:=true |
| 73 | else |
| 74 | is_container:=false |
| 75 | endif |
| 76 | else ifneq (,$(strip $(filter-out true false,$(is_container)))) |
| 77 | $(error Unrecognized value '$(is_container)' for LOCAL_MODULE_IS_CONTAINER) |
| 78 | endif |
| 79 | |
| 80 | ifeq (true,$(is_container)) |
| 81 | # Include shared libraries' notices for "container" types, but not for binaries etc. |
| 82 | notice_deps := \ |
| 83 | $(sort \ |
| 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 | ) |
| 96 | else |
| 97 | notice_deps := \ |
| 98 | $(sort \ |
| 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 | ) |
| 107 | endif |
| 108 | ifeq ($(LOCAL_IS_HOST_MODULE),true) |
| 109 | notice_deps := $(sort $(notice_deps) $(LOCAL_HOST_REQUIRED_MODULES)) |
| 110 | else |
| 111 | notice_deps := $(sort $(notice_deps) $(LOCAL_TARGET_REQUIRED_MODULES)) |
| 112 | endif |
| 113 | |
| 114 | ifdef my_register_name |
| 115 | ALL_MODULES.$(my_register_name).LICENSE_PACKAGE_NAME := $(strip $(license_package_name)) |
| 116 | ALL_MODULES.$(my_register_name).LICENSE_KINDS := $(sort $(ALL_MODULES.$(my_register_name).LICENSE_KINDS) $(license_kinds)) |
| 117 | ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS := $(sort $(ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS) $(license_conditions)) |
| 118 | ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP := $(sort $(ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP) $(install_map)) |
| 119 | ALL_MODULES.$(my_register_name).NOTICE_DEPS := $(sort $(ALL_MODULES.$(my_register_name).NOTICE_DEPS) $(notice_deps)) |
| 120 | ALL_MODULES.$(my_register_name).IS_CONTAINER := $(sort $(ALL_MODULES.$(my_register_name).IS_CONTAINER) $(is_container)) |
| 121 | endif |
| 122 | |
David 'Digit' Turner | 3e0e611 | 2011-03-29 14:27:27 +0200 | [diff] [blame] | 123 | ifdef notice_file |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 124 | |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 125 | ifdef my_register_name |
Bob Badour | 21bd34f | 2021-01-07 03:34:31 +0000 | [diff] [blame^] | 126 | ALL_MODULES.$(my_register_name).NOTICES := $(sort $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file)) |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 127 | endif |
| 128 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 |
| 134 | ifdef LOCAL_INSTALLED_MODULE |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 135 | module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 136 | else |
| 137 | # This module isn't installable |
Ivan Lozano | d62e712 | 2019-08-27 11:23:35 -0700 | [diff] [blame] | 138 | ifneq ($(filter STATIC_LIBRARIES RLIB_LIBRARIES PROC_MACRO_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 := \ |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 143 | $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) |
Jooyung Han | 9340a67 | 2019-05-14 16:44:52 +0900 | [diff] [blame] | 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 := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 147 | else |
| 148 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 149 | # Stick the static java libraries with the regular java libraries. |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 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. |
Jiyong Park | e12c862 | 2019-10-29 18:25:22 +0900 | [diff] [blame] | 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. |
Colin Cross | a6bc3a8 | 2017-09-27 14:28:41 -0700 | [diff] [blame] | 157 | ifneq ($(filter javalib.jar,$(module_leaf)),) |
Jiyong Park | e12c862 | 2019-10-29 18:25:22 +0900 | [diff] [blame] | 158 | module_leaf := static/$(LOCAL_MODULE).jar |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 159 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 160 | module_installed_filename := \ |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 161 | $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf) |
Jesse Hall | a16690c | 2020-10-05 19:13:42 -0700 | [diff] [blame] | 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 |
Jaewoong Jung | dca3186 | 2019-04-03 08:59:49 -0700 | [diff] [blame] | 165 | module_installed_filename := |
Colin Cross | e0c5e44 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 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)) |
Jerome Gaillard | 5406674 | 2021-01-06 19:00:05 +0000 | [diff] [blame] | 170 | else |
| 171 | $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 172 | endif # JAVA_LIBRARIES |
| 173 | endif # STATIC_LIBRARIES |
| 174 | endif |
| 175 | |
Jaewoong Jung | dca3186 | 2019-04-03 08:59:49 -0700 | [diff] [blame] | 176 | ifdef module_installed_filename |
| 177 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 178 | # In case it's actually a host file |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 179 | module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename)) |
| 180 | module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 181 | |
| 182 | installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt |
| 183 | |
Bob Badour | 21bd34f | 2021-01-07 03:34:31 +0000 | [diff] [blame^] | 184 | ifdef my_register_name |
| 185 | ALL_MODULES.$(my_register_name).INSTALLED_NOTICE_FILE := $(installed_notice_file) |
| 186 | endif |
| 187 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 188 | $(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) |
| 189 | |
| 190 | $(installed_notice_file): $(notice_file) |
| 191 | @echo Notice file: $< -- $@ |
| 192 | $(hide) mkdir -p $(dir $@) |
Jerome Gaillard | 5406674 | 2021-01-06 19:00:05 +0000 | [diff] [blame] | 193 | $(hide) awk 'FNR==1 && NR > 1 {print "\n"} {print}' $^ > $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 194 | |
| 195 | ifdef LOCAL_INSTALLED_MODULE |
| 196 | # Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist |
| 197 | # libraries so they get installed along with it. Make it an order-only |
| 198 | # dependency so we don't re-install a module when the NOTICE changes. |
| 199 | $(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) |
| 200 | endif |
| 201 | |
Ying Wang | 62c81f8 | 2013-08-22 20:02:03 -0700 | [diff] [blame] | 202 | # To facilitate collecting NOTICE files for apps_only build, |
| 203 | # we install the NOTICE file even if a module gets built but not installed, |
| 204 | # because shared jni libraries won't be installed to the system image. |
| 205 | ifdef TARGET_BUILD_APPS |
| 206 | # for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE, |
| 207 | # but just javalib.jar in the common intermediate dir. |
| 208 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 209 | $(intermediates.COMMON)/javalib.jar : | $(installed_notice_file) |
| 210 | else |
| 211 | $(LOCAL_BUILT_MODULE): | $(installed_notice_file) |
| 212 | endif # JAVA_LIBRARIES |
| 213 | endif # TARGET_BUILD_APPS |
| 214 | |
Jaewoong Jung | dca3186 | 2019-04-03 08:59:49 -0700 | [diff] [blame] | 215 | endif # module_installed_filename |
| 216 | endif # notice_file |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 217 | |
| 218 | # Create a predictable, phony target to build this notice file. |
| 219 | # Define it even if the notice file doesn't exist so that other |
| 220 | # modules can depend on it. |
| 221 | notice_target := NOTICE-$(if \ |
Jaewoong Jung | e8cb195 | 2018-11-08 16:53:02 -0800 | [diff] [blame] | 222 | $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 223 | .PHONY: $(notice_target) |
| 224 | $(notice_target): $(installed_notice_file) |