blob: ee503946aff94797cb4eb381e4c16bbf54f69a6f [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Track NOTICE files
3###########################################################
4
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +02005notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08006
Steve Blockf55aeb02012-06-27 01:07:19 +01007ifeq ($(LOCAL_MODULE_CLASS),NONE)
8 # We ignore NOTICE files for modules of type NONE.
9 notice_file :=
10endif
11
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +020012ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -080013
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 := \
Joe Onorato68192562009-04-13 12:51:43 -040028 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080029 else
30 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
31 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040032 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 Project88b60792009-03-03 19:28:42 -080039 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040040 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
The Android Open Source Project88b60792009-03-03 19:28:42 -080041 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)