blob: b3eedc003c57973d4dc3a710a6d36b027193a43a [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Track NOTICE files
3###########################################################
Dan Willemsen3bf15e72016-07-25 16:03:53 -07004$(call record-module-type,NOTICE_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005
Narayan Kamath76c7d682015-12-22 14:34:09 +00006ifneq ($(LOCAL_NOTICE_FILE),)
7notice_file:=$(strip $(LOCAL_NOTICE_FILE))
8else
Bob Badour9da828c2020-02-13 12:37:33 -08009notice_file:=$(strip $(wildcard $(LOCAL_PATH)/LICENSE $(LOCAL_PATH)/LICENCE $(LOCAL_PATH)/NOTICE))
Narayan Kamath76c7d682015-12-22 14:34:09 +000010endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080011
Bob Badour21bd34f2021-01-07 03:34:31 +000012ifneq (,$(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
Torne (Richard Coles)63afdc12012-10-25 15:49:39 +010038ifeq ($(LOCAL_MODULE_CLASS),GYP)
39 # We ignore NOTICE files for modules of type GYP.
Steve Blockf55aeb02012-06-27 01:07:19 +010040 notice_file :=
41endif
42
John Muir58d96b12018-04-11 11:42:26 -070043ifeq ($(LOCAL_MODULE_CLASS),FAKE)
44 # We ignore NOTICE files for modules of type FAKE.
45 notice_file :=
46endif
47
Dan Willemsen2be55942017-04-03 16:06:00 -070048# 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
Ying Wang13d69502012-11-01 17:22:33 -070056ifeq ($(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_
Dan Willemsen057aaea2015-08-14 12:59:50 -070061 LOCAL_HOST_PREFIX :=
Ying Wang13d69502012-11-01 17:22:33 -070062else
63 my_prefix := TARGET_
64endif
65endif
66
Jaewoong Jungdca31862019-04-03 08:59:49 -070067installed_notice_file :=
68
Bob Badour21bd34f2021-01-07 03:34:31 +000069is_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 := \
Bob Badour3412a072021-02-18 17:17:49 -080083 $(strip \
Bob Badour879cfa82021-04-15 10:41:38 -070084 $(foreach d, \
85 $(LOCAL_REQUIRED_MODULES) \
86 $(LOCAL_STATIC_LIBRARIES) \
87 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
88 $(LOCAL_SHARED_LIBRARIES) \
89 $(LOCAL_DYLIB_LIBRARIES) \
90 $(LOCAL_RLIB_LIBRARIES) \
91 $(LOCAL_PROC_MACRO_LIBRARIES) \
92 $(LOCAL_HEADER_LIBRARIES) \
93 $(LOCAL_STATIC_JAVA_LIBRARIES) \
94 $(LOCAL_JAVA_LIBRARIES) \
95 $(LOCAL_JNI_SHARED_LIBRARIES) \
96 ,$(subst :,_,$(d)):static \
97 ) \
Bob Badour21bd34f2021-01-07 03:34:31 +000098 )
99else
100notice_deps := \
Bob Badour3412a072021-02-18 17:17:49 -0800101 $(strip \
Bob Badour879cfa82021-04-15 10:41:38 -0700102 $(foreach d, \
103 $(LOCAL_REQUIRED_MODULES) \
104 $(LOCAL_STATIC_LIBRARIES) \
105 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
106 $(LOCAL_RLIB_LIBRARIES) \
107 $(LOCAL_PROC_MACRO_LIBRARIES) \
108 $(LOCAL_HEADER_LIBRARIES) \
109 $(LOCAL_STATIC_JAVA_LIBRARIES) \
110 ,$(subst :,_,$(d)):static \
111 )$(foreach d, \
112 $(LOCAL_SHARED_LIBRARIES) \
113 $(LOCAL_DYLIB_LIBRARIES) \
114 $(LOCAL_JAVA_LIBRARIES) \
115 $(LOCAL_JNI_SHARED_LIBRARIES) \
116 ,$(subst :,_,$(d)):dynamic \
117 ) \
Bob Badour21bd34f2021-01-07 03:34:31 +0000118 )
119endif
120ifeq ($(LOCAL_IS_HOST_MODULE),true)
Bob Badour879cfa82021-04-15 10:41:38 -0700121notice_deps := $(strip $(notice_deps) $(foreach d,$(LOCAL_HOST_REQUIRED_MODULES),$(subst :,_,$(d)):static))
Bob Badour21bd34f2021-01-07 03:34:31 +0000122else
Bob Badour879cfa82021-04-15 10:41:38 -0700123notice_deps := $(strip $(notice_deps) $(foreach d,$(LOCAL_TARGET_REQUIRED_MODULES),$(subst :,_,$(d)):static))
Bob Badour21bd34f2021-01-07 03:34:31 +0000124endif
125
Bob Badour879cfa82021-04-15 10:41:38 -0700126local_path := $(LOCAL_PATH)
127
Colin Cross52a0c972021-12-03 22:46:20 +0000128
129module_license_metadata :=
130
Bob Badour21bd34f2021-01-07 03:34:31 +0000131ifdef my_register_name
Colin Cross52a0c972021-12-03 22:46:20 +0000132 module_license_metadata := $(call local-intermediates-dir)/$(my_register_name).meta_lic
133
134 $(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED),\
135 $(eval ALL_TARGETS.$(target).META_LIC := $(module_license_metadata)))
136
137 ALL_MODULES.$(my_register_name).META_LIC := $(strip $(ALL_MODULES.$(my_register_name).META_LIC) $(module_license_metadata))
138
Colin Cross81b16762021-12-10 22:52:43 +0000139 ALL_MODULES.$(my_register_name).DELAYED_META_LIC := $(strip $(ALL_MODULES.$(my_register_name).DELAYED_META_LIC) $(module_license_metadata))
140 ALL_MODULES.$(my_register_name).LICENSE_PACKAGE_NAME := $(strip $(license_package_name))
141 ALL_MODULES.$(my_register_name).MODULE_TYPE := $(strip $(ALL_MODULES.$(my_register_name).MODULE_TYPE) $(LOCAL_MODULE_TYPE))
142 ALL_MODULES.$(my_register_name).MODULE_CLASS := $(strip $(ALL_MODULES.$(my_register_name).MODULE_CLASS) $(LOCAL_MODULE_CLASS))
143 ALL_MODULES.$(my_register_name).LICENSE_KINDS := $(ALL_MODULES.$(my_register_name).LICENSE_KINDS) $(license_kinds)
144 ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS := $(ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS) $(license_conditions)
145 ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP := $(ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP) $(install_map)
146 ALL_MODULES.$(my_register_name).NOTICE_DEPS := $(ALL_MODULES.$(my_register_name).NOTICE_DEPS) $(notice_deps)
147 ALL_MODULES.$(my_register_name).IS_CONTAINER := $(strip $(filter-out false,$(ALL_MODULES.$(my_register_name).IS_CONTAINER) $(is_container)))
148 ALL_MODULES.$(my_register_name).PATH := $(strip $(ALL_MODULES.$(my_register_name).PATH) $(local_path))
Bob Badour21bd34f2021-01-07 03:34:31 +0000149endif
150
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +0200151ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152
Dan Willemsen64931182018-06-17 21:47:18 -0700153ifdef my_register_name
Bob Badour3412a072021-02-18 17:17:49 -0800154ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file)
Dan Willemsen64931182018-06-17 21:47:18 -0700155endif
156
The Android Open Source Project88b60792009-03-03 19:28:42 -0800157# This relies on the name of the directory in PRODUCT_OUT matching where
158# it's installed on the target - i.e. system, data, etc. This does
159# not work for root and isn't exact, but it's probably good enough for
160# compliance.
161# Includes the leading slash
162ifdef LOCAL_INSTALLED_MODULE
Dan Willemsene0bba6f2016-12-09 21:15:41 -0800163 module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800164else
165 # This module isn't installable
Ivan Lozanod62e7122019-08-27 11:23:35 -0700166 ifneq ($(filter STATIC_LIBRARIES RLIB_LIBRARIES PROC_MACRO_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800167 # Stick the static libraries with the dynamic libraries.
168 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
169 # device-obj or host-obj.
170 module_installed_filename := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -0800171 $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
Jooyung Han9340a672019-05-14 16:44:52 +0900172 else ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
173 # Shared modules may be uninstallable(e.g. TARGET_SKIP_CURRENT_VNDK=true)
174 module_installed_filename :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800175 else
176 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
177 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -0400178 module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
179 # javalib.jar is the default name for the build module (and isn't meaningful)
180 # If that's what we have, substitute the module name instead. These files
181 # aren't included on the device, so this name is synthetic anyway.
Jiyong Parke12c8622019-10-29 18:25:22 +0900182 # Extra path "static" is added to try to avoid name conflict between the notice file of
183 # this 'uninstallable' Java module and the notice file for another 'installable' Java module
184 # whose stem is the same as this module's name.
Colin Crossa6bc3a82017-09-27 14:28:41 -0700185 ifneq ($(filter javalib.jar,$(module_leaf)),)
Jiyong Parke12c8622019-10-29 18:25:22 +0900186 module_leaf := static/$(LOCAL_MODULE).jar
Joe Onorato68192562009-04-13 12:51:43 -0400187 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188 module_installed_filename := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -0800189 $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
Jesse Halla16690c2020-10-05 19:13:42 -0700190 else ifneq ($(filter ETC DATA,$(LOCAL_MODULE_CLASS)),)
191 # ETC and DATA modules may be uninstallable, yet still have a NOTICE file.
192 # e.g. apex components
Jaewoong Jungdca31862019-04-03 08:59:49 -0700193 module_installed_filename :=
Colin Crosse0c5e442020-04-07 16:50:32 +0000194 else ifneq (,$(and $(filter %.sdk,$(LOCAL_MODULE)),$(filter $(patsubst %.sdk,%,$(LOCAL_MODULE)),$(SOONG_SDK_VARIANT_MODULES))))
195 # Soong produces uninstallable *.sdk shared libraries for embedding in APKs.
196 module_installed_filename := \
197 $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800198 endif # JAVA_LIBRARIES
199 endif # STATIC_LIBRARIES
200endif
201
Jaewoong Jungdca31862019-04-03 08:59:49 -0700202ifdef module_installed_filename
203
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204# In case it's actually a host file
Dan Willemsene0bba6f2016-12-09 21:15:41 -0800205module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename))
206module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207
208installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
209
Colin Cross52a0c972021-12-03 22:46:20 +0000210$(installed_notice_file): $(module_license_metadata)
211
Bob Badour21bd34f2021-01-07 03:34:31 +0000212ifdef my_register_name
Bob Badour3412a072021-02-18 17:17:49 -0800213ALL_MODULES.$(my_register_name).INSTALLED_NOTICE_FILE := $(ALL_MODULES.$(my_register_name).INSTALLED_NOTICE_FILE) $(installed_notice_file)
214ALL_MODULES.$(my_register_name).MODULE_INSTALLED_FILENAMES := $(ALL_MODULES.$(my_register_name).MODULE_INSTALLED_FILENAMES) $(module_installed_filename)
215INSTALLED_NOTICE_FILES.$(installed_notice_file).MODULE := $(my_register_name)
216else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800217$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
Bob Badour879cfa82021-04-15 10:41:38 -0700218$(installed_notice_file) : PRIVATE_NOTICES := $(sort $(foreach n,$(notice_file),$(if $(filter %:%,$(n)), $(call word-colon,1,$(n)), $(n))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800219
Bob Badour879cfa82021-04-15 10:41:38 -0700220$(installed_notice_file): $(foreach n,$(notice_file),$(if $(filter %:%,$(n)), $(call word-colon,1,$(n)), $(n)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800221 @echo Notice file: $< -- $@
222 $(hide) mkdir -p $(dir $@)
Bob Badour7a958202021-01-07 03:34:31 +0000223 $(hide) awk 'FNR==1 && NR > 1 {print "\n"} {print}' $(PRIVATE_NOTICES) > $@
Bob Badour3412a072021-02-18 17:17:49 -0800224endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800225
226ifdef LOCAL_INSTALLED_MODULE
227# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
228# libraries so they get installed along with it. Make it an order-only
229# dependency so we don't re-install a module when the NOTICE changes.
230$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
231endif
232
Ying Wang62c81f82013-08-22 20:02:03 -0700233# To facilitate collecting NOTICE files for apps_only build,
234# we install the NOTICE file even if a module gets built but not installed,
235# because shared jni libraries won't be installed to the system image.
236ifdef TARGET_BUILD_APPS
237# for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE,
238# but just javalib.jar in the common intermediate dir.
239ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
240$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file)
241else
242$(LOCAL_BUILT_MODULE): | $(installed_notice_file)
243endif # JAVA_LIBRARIES
244endif # TARGET_BUILD_APPS
245
Jaewoong Jungdca31862019-04-03 08:59:49 -0700246endif # module_installed_filename
247endif # notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -0800248
249# Create a predictable, phony target to build this notice file.
250# Define it even if the notice file doesn't exist so that other
251# modules can depend on it.
252notice_target := NOTICE-$(if \
Jaewoong Junge8cb1952018-11-08 16:53:02 -0800253 $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800254.PHONY: $(notice_target)
255$(notice_target): $(installed_notice_file)