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 |
David 'Digit' Turner | 3e0e611 | 2011-03-29 14:27:27 +0200 | [diff] [blame] | 9 | notice_file:=$(strip $(wildcard $(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 | |
Torne (Richard Coles) | 63afdc1 | 2012-10-25 15:49:39 +0100 | [diff] [blame] | 12 | ifeq ($(LOCAL_MODULE_CLASS),GYP) |
| 13 | # We ignore NOTICE files for modules of type GYP. |
Steve Block | f55aeb0 | 2012-06-27 01:07:19 +0100 | [diff] [blame] | 14 | notice_file := |
| 15 | endif |
| 16 | |
John Muir | 58d96b1 | 2018-04-11 11:42:26 -0700 | [diff] [blame] | 17 | ifeq ($(LOCAL_MODULE_CLASS),FAKE) |
| 18 | # We ignore NOTICE files for modules of type FAKE. |
| 19 | notice_file := |
| 20 | endif |
| 21 | |
Dan Willemsen | 2be5594 | 2017-04-03 16:06:00 -0700 | [diff] [blame] | 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 | |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 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_ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 35 | LOCAL_HOST_PREFIX := |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 36 | else |
| 37 | my_prefix := TARGET_ |
| 38 | endif |
| 39 | endif |
| 40 | |
David 'Digit' Turner | 3e0e611 | 2011-03-29 14:27:27 +0200 | [diff] [blame] | 41 | ifdef notice_file |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 43 | ifdef my_register_name |
| 44 | ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file) |
| 45 | endif |
| 46 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 47 | # This relies on the name of the directory in PRODUCT_OUT matching where |
| 48 | # it's installed on the target - i.e. system, data, etc. This does |
| 49 | # not work for root and isn't exact, but it's probably good enough for |
| 50 | # compliance. |
| 51 | # Includes the leading slash |
| 52 | ifdef LOCAL_INSTALLED_MODULE |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 53 | module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 54 | else |
| 55 | # This module isn't installable |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 56 | ifneq ($(filter STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 57 | # Stick the static libraries with the dynamic libraries. |
| 58 | # We can't use xxx_OUT_STATIC_LIBRARIES because it points into |
| 59 | # device-obj or host-obj. |
| 60 | module_installed_filename := \ |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 61 | $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 62 | else |
| 63 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 64 | # Stick the static java libraries with the regular java libraries. |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 65 | module_leaf := $(notdir $(LOCAL_BUILT_MODULE)) |
| 66 | # javalib.jar is the default name for the build module (and isn't meaningful) |
| 67 | # If that's what we have, substitute the module name instead. These files |
| 68 | # aren't included on the device, so this name is synthetic anyway. |
Colin Cross | a6bc3a8 | 2017-09-27 14:28:41 -0700 | [diff] [blame] | 69 | ifneq ($(filter javalib.jar,$(module_leaf)),) |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 70 | module_leaf := $(LOCAL_MODULE).jar |
| 71 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 72 | module_installed_filename := \ |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 73 | $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 74 | else |
| 75 | $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE)) |
| 76 | endif # JAVA_LIBRARIES |
| 77 | endif # STATIC_LIBRARIES |
| 78 | endif |
| 79 | |
| 80 | # In case it's actually a host file |
Dan Willemsen | e0bba6f | 2016-12-09 21:15:41 -0800 | [diff] [blame] | 81 | module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename)) |
| 82 | 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] | 83 | |
| 84 | installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt |
| 85 | |
| 86 | $(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) |
| 87 | |
| 88 | $(installed_notice_file): $(notice_file) |
| 89 | @echo Notice file: $< -- $@ |
| 90 | $(hide) mkdir -p $(dir $@) |
Torne (Richard Coles) | 278bbf1 | 2013-04-30 16:26:58 +0100 | [diff] [blame] | 91 | $(hide) cat $< > $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 92 | |
| 93 | ifdef LOCAL_INSTALLED_MODULE |
| 94 | # Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist |
| 95 | # libraries so they get installed along with it. Make it an order-only |
| 96 | # dependency so we don't re-install a module when the NOTICE changes. |
| 97 | $(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) |
| 98 | endif |
| 99 | |
Ying Wang | 62c81f8 | 2013-08-22 20:02:03 -0700 | [diff] [blame] | 100 | # To facilitate collecting NOTICE files for apps_only build, |
| 101 | # we install the NOTICE file even if a module gets built but not installed, |
| 102 | # because shared jni libraries won't be installed to the system image. |
| 103 | ifdef TARGET_BUILD_APPS |
| 104 | # for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE, |
| 105 | # but just javalib.jar in the common intermediate dir. |
| 106 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 107 | $(intermediates.COMMON)/javalib.jar : | $(installed_notice_file) |
| 108 | else |
| 109 | $(LOCAL_BUILT_MODULE): | $(installed_notice_file) |
| 110 | endif # JAVA_LIBRARIES |
| 111 | endif # TARGET_BUILD_APPS |
| 112 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 113 | else |
| 114 | # NOTICE file does not exist |
| 115 | installed_notice_file := |
| 116 | endif |
| 117 | |
| 118 | # Create a predictable, phony target to build this notice file. |
| 119 | # Define it even if the notice file doesn't exist so that other |
| 120 | # modules can depend on it. |
| 121 | notice_target := NOTICE-$(if \ |
Jaewoong Jung | e8cb195 | 2018-11-08 16:53:02 -0800 | [diff] [blame] | 122 | $(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] | 123 | .PHONY: $(notice_target) |
| 124 | $(notice_target): $(installed_notice_file) |