The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame^] | 1 | ########################################################### |
| 2 | ## Track NOTICE files |
| 3 | ########################################################### |
| 4 | |
| 5 | notice_file:=$(shell find $(LOCAL_PATH) -maxdepth 1 -name NOTICE) |
| 6 | |
| 7 | ifneq ($(strip $(notice_file)),) |
| 8 | |
| 9 | # This relies on the name of the directory in PRODUCT_OUT matching where |
| 10 | # it's installed on the target - i.e. system, data, etc. This does |
| 11 | # not work for root and isn't exact, but it's probably good enough for |
| 12 | # compliance. |
| 13 | # Includes the leading slash |
| 14 | ifdef LOCAL_INSTALLED_MODULE |
| 15 | module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 16 | else |
| 17 | # This module isn't installable |
| 18 | ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES) |
| 19 | # Stick the static libraries with the dynamic libraries. |
| 20 | # We can't use xxx_OUT_STATIC_LIBRARIES because it points into |
| 21 | # device-obj or host-obj. |
| 22 | module_installed_filename := \ |
| 23 | $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) |
| 24 | else |
| 25 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 26 | # Stick the static java libraries with the regular java libraries. |
| 27 | module_installed_filename := \ |
| 28 | $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE)) |
| 29 | else |
| 30 | $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE)) |
| 31 | endif # JAVA_LIBRARIES |
| 32 | endif # STATIC_LIBRARIES |
| 33 | endif |
| 34 | |
| 35 | # In case it's actually a host file |
| 36 | module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename)) |
| 37 | |
| 38 | installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt |
| 39 | |
| 40 | $(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename) |
| 41 | |
| 42 | $(installed_notice_file): $(notice_file) |
| 43 | @echo Notice file: $< -- $@ |
| 44 | $(hide) mkdir -p $(dir $@) |
| 45 | $(hide) cat $< >> $@ |
| 46 | |
| 47 | ifdef LOCAL_INSTALLED_MODULE |
| 48 | # Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist |
| 49 | # libraries so they get installed along with it. Make it an order-only |
| 50 | # dependency so we don't re-install a module when the NOTICE changes. |
| 51 | $(LOCAL_INSTALLED_MODULE): | $(installed_notice_file) |
| 52 | endif |
| 53 | |
| 54 | else |
| 55 | # NOTICE file does not exist |
| 56 | installed_notice_file := |
| 57 | endif |
| 58 | |
| 59 | # Create a predictable, phony target to build this notice file. |
| 60 | # Define it even if the notice file doesn't exist so that other |
| 61 | # modules can depend on it. |
| 62 | notice_target := NOTICE-$(if \ |
| 63 | $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE) |
| 64 | .PHONY: $(notice_target) |
| 65 | $(notice_target): $(installed_notice_file) |