blob: c3147341b45ebbda3fd988c61d02924d11bf950b [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
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +02009notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
Narayan Kamath76c7d682015-12-22 14:34:09 +000010endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080011
Torne (Richard Coles)63afdc12012-10-25 15:49:39 +010012ifeq ($(LOCAL_MODULE_CLASS),GYP)
13 # We ignore NOTICE files for modules of type GYP.
Steve Blockf55aeb02012-06-27 01:07:19 +010014 notice_file :=
15endif
16
John Muir58d96b12018-04-11 11:42:26 -070017ifeq ($(LOCAL_MODULE_CLASS),FAKE)
18 # We ignore NOTICE files for modules of type FAKE.
19 notice_file :=
20endif
21
Dan Willemsen2be55942017-04-03 16:06:00 -070022# Soong generates stub libraries that don't need NOTICE files
23ifdef 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 :=
28endif
29
Ying Wang13d69502012-11-01 17:22:33 -070030ifeq ($(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.
33ifeq ($(LOCAL_IS_HOST_MODULE),true)
34 my_prefix := HOST_
Dan Willemsen057aaea2015-08-14 12:59:50 -070035 LOCAL_HOST_PREFIX :=
Ying Wang13d69502012-11-01 17:22:33 -070036else
37 my_prefix := TARGET_
38endif
39endif
40
Jaewoong Jungdca31862019-04-03 08:59:49 -070041installed_notice_file :=
42
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +020043ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -080044
Dan Willemsen64931182018-06-17 21:47:18 -070045ifdef my_register_name
46ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file)
47endif
48
The Android Open Source Project88b60792009-03-03 19:28:42 -080049# 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
54ifdef LOCAL_INSTALLED_MODULE
Dan Willemsene0bba6f2016-12-09 21:15:41 -080055 module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080056else
57 # This module isn't installable
Dan Willemsen8dae49c2017-02-15 15:48:11 -080058 ifneq ($(filter STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -080059 # 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 := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -080063 $(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 -080064 else
65 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
66 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040067 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.
Colin Crossa6bc3a82017-09-27 14:28:41 -070071 ifneq ($(filter javalib.jar,$(module_leaf)),)
Joe Onorato68192562009-04-13 12:51:43 -040072 module_leaf := $(LOCAL_MODULE).jar
73 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080074 module_installed_filename := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -080075 $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
Jaewoong Jungdca31862019-04-03 08:59:49 -070076 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 :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080079 else
80 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
81 endif # JAVA_LIBRARIES
82 endif # STATIC_LIBRARIES
83endif
84
Jaewoong Jungdca31862019-04-03 08:59:49 -070085ifdef module_installed_filename
86
The Android Open Source Project88b60792009-03-03 19:28:42 -080087# In case it's actually a host file
Dan Willemsene0bba6f2016-12-09 21:15:41 -080088module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename))
89module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename))
The Android Open Source Project88b60792009-03-03 19:28:42 -080090
91installed_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 $@)
Torne (Richard Coles)278bbf12013-04-30 16:26:58 +010098 $(hide) cat $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080099
100ifdef 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)
105endif
106
Ying Wang62c81f82013-08-22 20:02:03 -0700107# 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.
110ifdef 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.
113ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
114$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file)
115else
116$(LOCAL_BUILT_MODULE): | $(installed_notice_file)
117endif # JAVA_LIBRARIES
118endif # TARGET_BUILD_APPS
119
Jaewoong Jungdca31862019-04-03 08:59:49 -0700120endif # module_installed_filename
121endif # notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -0800122
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.
126notice_target := NOTICE-$(if \
Jaewoong Junge8cb1952018-11-08 16:53:02 -0800127 $(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 -0800128.PHONY: $(notice_target)
129$(notice_target): $(installed_notice_file)