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