notice_files.mk revision 63afdc12d50db1a96ac6d7e8ef6d9548cf95a420
1###########################################################
2## Track NOTICE files
3###########################################################
4
5notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
6
7ifeq ($(LOCAL_MODULE_CLASS),GYP)
8  # We ignore NOTICE files for modules of type GYP.
9  notice_file :=
10endif
11
12ifdef notice_file
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
19ifdef LOCAL_INSTALLED_MODULE
20  module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
21else
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 := \
28        $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
29  else
30    ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
31      # Stick the static java libraries with the regular java libraries.
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
39      module_installed_filename := \
40          $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
41    else
42      $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
43    endif # JAVA_LIBRARIES
44  endif # STATIC_LIBRARIES
45endif
46
47# In case it's actually a host file
48module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
49
50installed_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
59ifdef 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)
64endif
65
66else
67# NOTICE file does not exist
68installed_notice_file :=
69endif
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.
74notice_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)
78