blob: fd76d5159ce435bc6c108667d76e8e4c499a4518 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Track NOTICE files
3###########################################################
4
5notice_file:=$(shell find $(LOCAL_PATH) -maxdepth 1 -name NOTICE)
6
7ifneq ($(strip $(notice_file)),)
8
9# This relies on the name of the directory in PRODUCT_OUT matching where
10# it's installed on the target - i.e. system, data, etc. This does
11# not work for root and isn't exact, but it's probably good enough for
12# compliance.
13# Includes the leading slash
14ifdef LOCAL_INSTALLED_MODULE
15 module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
16else
17 # This module isn't installable
18 ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
19 # Stick the static libraries with the dynamic libraries.
20 # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
21 # device-obj or host-obj.
22 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040023 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080024 else
25 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
26 # Stick the static java libraries with the regular java libraries.
Joe Onorato68192562009-04-13 12:51:43 -040027 module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
28 # javalib.jar is the default name for the build module (and isn't meaningful)
29 # If that's what we have, substitute the module name instead. These files
30 # aren't included on the device, so this name is synthetic anyway.
31 ifeq ($(module_leaf),javalib.jar)
32 module_leaf := $(LOCAL_MODULE).jar
33 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080034 module_installed_filename := \
Joe Onorato68192562009-04-13 12:51:43 -040035 $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
The Android Open Source Project88b60792009-03-03 19:28:42 -080036 else
37 $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
38 endif # JAVA_LIBRARIES
39 endif # STATIC_LIBRARIES
40endif
41
42# In case it's actually a host file
43module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
44
45installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
46
47$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
48
49$(installed_notice_file): $(notice_file)
50 @echo Notice file: $< -- $@
51 $(hide) mkdir -p $(dir $@)
52 $(hide) cat $< >> $@
53
54ifdef LOCAL_INSTALLED_MODULE
55# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
56# libraries so they get installed along with it. Make it an order-only
57# dependency so we don't re-install a module when the NOTICE changes.
58$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
59endif
60
61else
62# NOTICE file does not exist
63installed_notice_file :=
64endif
65
66# Create a predictable, phony target to build this notice file.
67# Define it even if the notice file doesn't exist so that other
68# modules can depend on it.
69notice_target := NOTICE-$(if \
70 $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
71.PHONY: $(notice_target)
72$(notice_target): $(installed_notice_file)