blob: e7f89745b79adca25a88867c842485afbaae6478 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Track NOTICE files
3###########################################################
4
Narayan Kamath3026f4d2015-12-22 14:34:09 +00005ifneq ($(LOCAL_NOTICE_FILE),)
6notice_file:=$(strip $(LOCAL_NOTICE_FILE))
7else
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +02008notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
Narayan Kamath3026f4d2015-12-22 14:34:09 +00009endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080010
Torne (Richard Coles)63afdc12012-10-25 15:49:39 +010011ifeq ($(LOCAL_MODULE_CLASS),GYP)
12 # We ignore NOTICE files for modules of type GYP.
Steve Blockf55aeb02012-06-27 01:07:19 +010013 notice_file :=
14endif
15
Ying Wang13d69502012-11-01 17:22:33 -070016ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
17# If this is a NOTICE-only module, we don't include base_rule.mk,
18# so my_prefix is not set at this point.
19ifeq ($(LOCAL_IS_HOST_MODULE),true)
20 my_prefix := HOST_
Dan Willemsen057aaea2015-08-14 12:59:50 -070021 LOCAL_HOST_PREFIX :=
Ying Wang13d69502012-11-01 17:22:33 -070022else
23 my_prefix := TARGET_
24endif
25endif
26
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +020027ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -080028
29# This relies on the name of the directory in PRODUCT_OUT matching where
30# it's installed on the target - i.e. system, data, etc. This does
31# not work for root and isn't exact, but it's probably good enough for
32# compliance.
33# Includes the leading slash
34ifdef LOCAL_INSTALLED_MODULE
35 module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
36else
37 # This module isn't installable
38 ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
39 # Stick the static libraries with the dynamic libraries.
40 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
41 # device-obj or host-obj.
42 module_installed_filename := \
Ying Wang6ef65192014-01-15 16:02:16 -080043 $(patsubst $(PRODUCT_OUT)%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080044 else
45 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
46 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040047 module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
48 # javalib.jar is the default name for the build module (and isn't meaningful)
49 # If that's what we have, substitute the module name instead. These files
50 # aren't included on the device, so this name is synthetic anyway.
Yohann Rousself09e59e2014-09-08 14:45:14 +020051 ifneq ($(filter javalib.jar classes.jack,$(module_leaf)),)
Joe Onorato68192562009-04-13 12:51:43 -040052 module_leaf := $(LOCAL_MODULE).jar
53 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080054 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040055 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
The Android Open Source Project88b60792009-03-03 19:28:42 -080056 else
57 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
58 endif # JAVA_LIBRARIES
59 endif # STATIC_LIBRARIES
60endif
61
62# In case it's actually a host file
63module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
Dan Willemsen057aaea2015-08-14 12:59:50 -070064module_installed_filename := $(patsubst $(HOST_CROSS_OUT)%,%,$(module_installed_filename))
The Android Open Source Project88b60792009-03-03 19:28:42 -080065
66installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
67
68$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
69
70$(installed_notice_file): $(notice_file)
71 @echo Notice file: $< -- $@
72 $(hide) mkdir -p $(dir $@)
Torne (Richard Coles)278bbf12013-04-30 16:26:58 +010073 $(hide) cat $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080074
75ifdef LOCAL_INSTALLED_MODULE
76# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
77# libraries so they get installed along with it. Make it an order-only
78# dependency so we don't re-install a module when the NOTICE changes.
79$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
80endif
81
Ying Wang62c81f82013-08-22 20:02:03 -070082# To facilitate collecting NOTICE files for apps_only build,
83# we install the NOTICE file even if a module gets built but not installed,
84# because shared jni libraries won't be installed to the system image.
85ifdef TARGET_BUILD_APPS
86# for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE,
87# but just javalib.jar in the common intermediate dir.
88ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
89$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file)
90else
91$(LOCAL_BUILT_MODULE): | $(installed_notice_file)
92endif # JAVA_LIBRARIES
93endif # TARGET_BUILD_APPS
94
The Android Open Source Project88b60792009-03-03 19:28:42 -080095else
96# NOTICE file does not exist
97installed_notice_file :=
98endif
99
100# Create a predictable, phony target to build this notice file.
101# Define it even if the notice file doesn't exist so that other
102# modules can depend on it.
103notice_target := NOTICE-$(if \
104 $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
105.PHONY: $(notice_target)
106$(notice_target): $(installed_notice_file)