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 | |
Steve Block | f55aeb0 | 2012-06-27 01:07:19 +0100 | [diff] [blame] | 7 | ifeq ($(LOCAL_MODULE_CLASS),NONE) |
| 8 | # We ignore NOTICE files for modules of type NONE. |
| 9 | notice_file := |
| 10 | endif |
| 11 | |
David 'Digit' Turner | 3e0e611 | 2011-03-29 14:27:27 +0200 | [diff] [blame] | 12 | ifdef notice_file |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 13 | |
| 14 | # This relies on the name of the directory in PRODUCT_OUT matching where |
| 15 | # it's installed on the target - i.e. system, data, etc. This does |
| 16 | # not work for root and isn't exact, but it's probably good enough for |
| 17 | # compliance. |
| 18 | # Includes the leading slash |
| 19 | ifdef LOCAL_INSTALLED_MODULE |
| 20 | module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 21 | else |
| 22 | # This module isn't installable |
| 23 | ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES) |
| 24 | # Stick the static libraries with the dynamic libraries. |
| 25 | # We can't use xxx_OUT_STATIC_LIBRARIES because it points into |
| 26 | # device-obj or host-obj. |
| 27 | module_installed_filename := \ |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 28 | $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 29 | else |
| 30 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 31 | # Stick the static java libraries with the regular java libraries. |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 32 | module_leaf := $(notdir $(LOCAL_BUILT_MODULE)) |
| 33 | # javalib.jar is the default name for the build module (and isn't meaningful) |
| 34 | # If that's what we have, substitute the module name instead. These files |
| 35 | # aren't included on the device, so this name is synthetic anyway. |
| 36 | ifeq ($(module_leaf),javalib.jar) |
| 37 | module_leaf := $(LOCAL_MODULE).jar |
| 38 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 39 | module_installed_filename := \ |
Joe Onorato | 6819256 | 2009-04-13 12:51:43 -0400 | [diff] [blame] | 40 | $(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] | 41 | else |
| 42 | $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE)) |
| 43 | endif # JAVA_LIBRARIES |
| 44 | endif # STATIC_LIBRARIES |
| 45 | endif |
| 46 | |
| 47 | # In case it's actually a host file |
| 48 | module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename)) |
| 49 | |
| 50 | installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt |
| 51 | |
| 52 | $(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) |
| 53 | |
| 54 | $(installed_notice_file): $(notice_file) |
| 55 | @echo Notice file: $< -- $@ |
| 56 | $(hide) mkdir -p $(dir $@) |
| 57 | $(hide) cat $< >> $@ |
| 58 | |
| 59 | ifdef LOCAL_INSTALLED_MODULE |
| 60 | # Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist |
| 61 | # libraries so they get installed along with it. Make it an order-only |
| 62 | # dependency so we don't re-install a module when the NOTICE changes. |
| 63 | $(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) |
| 64 | endif |
| 65 | |
| 66 | else |
| 67 | # NOTICE file does not exist |
| 68 | installed_notice_file := |
| 69 | endif |
| 70 | |
| 71 | # Create a predictable, phony target to build this notice file. |
| 72 | # Define it even if the notice file doesn't exist so that other |
| 73 | # modules can depend on it. |
| 74 | notice_target := NOTICE-$(if \ |
| 75 | $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE) |
| 76 | .PHONY: $(notice_target) |
| 77 | $(notice_target): $(installed_notice_file) |