blob: 447e59ba6dfe08734e12ba17c0fa2206fa4ac0a3 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Track NOTICE files
3###########################################################
Dan Willemsen3bf15e72016-07-25 16:03:53 -07004$(call record-module-type,NOTICE_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005
Narayan Kamath76c7d682015-12-22 14:34:09 +00006ifneq ($(LOCAL_NOTICE_FILE),)
7notice_file:=$(strip $(LOCAL_NOTICE_FILE))
8else
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +02009notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
Narayan Kamath76c7d682015-12-22 14:34:09 +000010endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080011
Torne (Richard Coles)63afdc12012-10-25 15:49:39 +010012ifeq ($(LOCAL_MODULE_CLASS),GYP)
13 # We ignore NOTICE files for modules of type GYP.
Steve Blockf55aeb02012-06-27 01:07:19 +010014 notice_file :=
15endif
16
Ying Wang13d69502012-11-01 17:22:33 -070017ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
18# If this is a NOTICE-only module, we don't include base_rule.mk,
19# so my_prefix is not set at this point.
20ifeq ($(LOCAL_IS_HOST_MODULE),true)
21 my_prefix := HOST_
Dan Willemsen057aaea2015-08-14 12:59:50 -070022 LOCAL_HOST_PREFIX :=
Ying Wang13d69502012-11-01 17:22:33 -070023else
24 my_prefix := TARGET_
25endif
26endif
27
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +020028ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -080029
30# This relies on the name of the directory in PRODUCT_OUT matching where
31# it's installed on the target - i.e. system, data, etc. This does
32# not work for root and isn't exact, but it's probably good enough for
33# compliance.
34# Includes the leading slash
35ifdef LOCAL_INSTALLED_MODULE
Dan Willemsene0bba6f2016-12-09 21:15:41 -080036 module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080037else
38 # This module isn't installable
Dan Willemsen8dae49c2017-02-15 15:48:11 -080039 ifneq ($(filter STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -080040 # Stick the static libraries with the dynamic libraries.
41 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
42 # device-obj or host-obj.
43 module_installed_filename := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -080044 $(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 -080045 else
46 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
47 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040048 module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
49 # javalib.jar is the default name for the build module (and isn't meaningful)
50 # If that's what we have, substitute the module name instead. These files
51 # aren't included on the device, so this name is synthetic anyway.
Yohann Rousself09e59e2014-09-08 14:45:14 +020052 ifneq ($(filter javalib.jar classes.jack,$(module_leaf)),)
Joe Onorato68192562009-04-13 12:51:43 -040053 module_leaf := $(LOCAL_MODULE).jar
54 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080055 module_installed_filename := \
Dan Willemsene0bba6f2016-12-09 21:15:41 -080056 $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
The Android Open Source Project88b60792009-03-03 19:28:42 -080057 else
58 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
59 endif # JAVA_LIBRARIES
60 endif # STATIC_LIBRARIES
61endif
62
63# In case it's actually a host file
Dan Willemsene0bba6f2016-12-09 21:15:41 -080064module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename))
65module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename))
The Android Open Source Project88b60792009-03-03 19:28:42 -080066
67installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
68
69$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
70
71$(installed_notice_file): $(notice_file)
72 @echo Notice file: $< -- $@
73 $(hide) mkdir -p $(dir $@)
Torne (Richard Coles)278bbf12013-04-30 16:26:58 +010074 $(hide) cat $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080075
76ifdef LOCAL_INSTALLED_MODULE
77# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
78# libraries so they get installed along with it. Make it an order-only
79# dependency so we don't re-install a module when the NOTICE changes.
80$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
81endif
82
Ying Wang62c81f82013-08-22 20:02:03 -070083# To facilitate collecting NOTICE files for apps_only build,
84# we install the NOTICE file even if a module gets built but not installed,
85# because shared jni libraries won't be installed to the system image.
86ifdef TARGET_BUILD_APPS
87# for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE,
88# but just javalib.jar in the common intermediate dir.
89ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
90$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file)
91else
92$(LOCAL_BUILT_MODULE): | $(installed_notice_file)
93endif # JAVA_LIBRARIES
94endif # TARGET_BUILD_APPS
95
The Android Open Source Project88b60792009-03-03 19:28:42 -080096else
97# NOTICE file does not exist
98installed_notice_file :=
99endif
100
101# Create a predictable, phony target to build this notice file.
102# Define it even if the notice file doesn't exist so that other
103# modules can depend on it.
104notice_target := NOTICE-$(if \
105 $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
106.PHONY: $(notice_target)
107$(notice_target): $(installed_notice_file)