blob: 7e61c1e237ff8b40a91943e11efec150dfe5b413 [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
Torne (Richard Coles)63afdc12012-10-25 15:49:39 +01007ifeq ($(LOCAL_MODULE_CLASS),GYP)
8 # We ignore NOTICE files for modules of type GYP.
Steve Blockf55aeb02012-06-27 01:07:19 +01009 notice_file :=
10endif
11
Ying Wang13d69502012-11-01 17:22:33 -070012ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
13# If this is a NOTICE-only module, we don't include base_rule.mk,
14# so my_prefix is not set at this point.
15ifeq ($(LOCAL_IS_HOST_MODULE),true)
16 my_prefix := HOST_
17else
18 my_prefix := TARGET_
19endif
20endif
21
David 'Digit' Turner3e0e6112011-03-29 14:27:27 +020022ifdef notice_file
The Android Open Source Project88b60792009-03-03 19:28:42 -080023
24# This relies on the name of the directory in PRODUCT_OUT matching where
25# it's installed on the target - i.e. system, data, etc. This does
26# not work for root and isn't exact, but it's probably good enough for
27# compliance.
28# Includes the leading slash
29ifdef LOCAL_INSTALLED_MODULE
30 module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
31else
32 # This module isn't installable
33 ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
34 # Stick the static libraries with the dynamic libraries.
35 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
36 # device-obj or host-obj.
37 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040038 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080039 else
40 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
41 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040042 module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
43 # javalib.jar is the default name for the build module (and isn't meaningful)
44 # If that's what we have, substitute the module name instead. These files
45 # aren't included on the device, so this name is synthetic anyway.
46 ifeq ($(module_leaf),javalib.jar)
47 module_leaf := $(LOCAL_MODULE).jar
48 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080049 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040050 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
The Android Open Source Project88b60792009-03-03 19:28:42 -080051 else
52 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
53 endif # JAVA_LIBRARIES
54 endif # STATIC_LIBRARIES
55endif
56
57# In case it's actually a host file
58module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
59
60installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
61
62$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
63
64$(installed_notice_file): $(notice_file)
65 @echo Notice file: $< -- $@
66 $(hide) mkdir -p $(dir $@)
Torne (Richard Coles)278bbf12013-04-30 16:26:58 +010067 $(hide) cat $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080068
69ifdef LOCAL_INSTALLED_MODULE
70# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
71# libraries so they get installed along with it. Make it an order-only
72# dependency so we don't re-install a module when the NOTICE changes.
73$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
74endif
75
76else
77# NOTICE file does not exist
78installed_notice_file :=
79endif
80
81# Create a predictable, phony target to build this notice file.
82# Define it even if the notice file doesn't exist so that other
83# modules can depend on it.
84notice_target := NOTICE-$(if \
85 $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
86.PHONY: $(notice_target)
87$(notice_target): $(installed_notice_file)