blob: fd8e0f52f0b42b4b0de4ce1bb19b33813a167417 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for copying files that are prebuilt
3##
4## Additional inputs from base_rules.make:
5## None.
Doug Zongker1046d202009-08-06 13:02:19 -07006##
The Android Open Source Project88b60792009-03-03 19:28:42 -08007###########################################################
8
9ifneq ($(LOCAL_PREBUILT_LIBS),)
10$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
11endif
12ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
13$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
14endif
15ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
16$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
17endif
18
Ying Wang63d94fa2012-12-13 18:23:01 -080019ifdef LOCAL_PREBUILT_MODULE_FILE
20my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
21else
22my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
23endif
24
Ying Wangc36b4502011-09-15 12:00:52 -070025ifdef LOCAL_IS_HOST_MODULE
Ying Wang13d69502012-11-01 17:22:33 -070026 my_prefix := HOST_
Ying Wangc36b4502011-09-15 12:00:52 -070027else
Ying Wang13d69502012-11-01 17:22:33 -070028 my_prefix := TARGET_
Ying Wangc36b4502011-09-15 12:00:52 -070029endif
30ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
31 # Put the built targets of all shared libraries in a common directory
32 # to simplify the link line.
33 OVERRIDE_BUILT_MODULE_PATH := $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
34endif
35
Ying Wang5f074802011-11-08 09:31:21 -080036ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
37 prebuilt_module_is_a_library := true
38else
39 prebuilt_module_is_a_library :=
40endif
41
Ying Wangb1a4e4e2012-05-15 15:31:41 -070042# Don't install static libraries by default.
43ifndef LOCAL_UNINSTALLABLE_MODULE
44ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
45 LOCAL_UNINSTALLABLE_MODULE := true
46endif
47endif
48
Ji-Hwan Lee0219e922011-07-07 03:10:14 +090049ifeq ($(LOCAL_STRIP_MODULE),true)
50 ifdef LOCAL_IS_HOST_MODULE
51 $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
52 endif
53 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
54 $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
55 endif
56 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
57 $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
58 endif
59 include $(BUILD_SYSTEM)/dynamic_binary.mk
60 built_module := $(linked_module)
Ying Wang6c86a132013-02-25 18:12:11 -080061else # LOCAL_STRIP_MODULE not true
Ji-Hwan Lee0219e922011-07-07 03:10:14 +090062 include $(BUILD_SYSTEM)/base_rules.mk
63 built_module := $(LOCAL_BUILT_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -080064
Ying Wang5f074802011-11-08 09:31:21 -080065ifdef prebuilt_module_is_a_library
Ying Wangfe3f62d2012-12-03 18:24:55 -080066export_includes := $(intermediates)/export_includes
67$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
68$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
69 @echo Export includes file: $< -- $@
Ying Wang5f074802011-11-08 09:31:21 -080070 $(hide) mkdir -p $(dir $@) && rm -f $@
Ying Wangfe3f62d2012-12-03 18:24:55 -080071ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
72 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
73 echo "-I $$d" >> $@; \
74 done
75else
Ying Wang5f074802011-11-08 09:31:21 -080076 $(hide) touch $@
Ying Wangfe3f62d2012-12-03 18:24:55 -080077endif
Ying Wang616e5962012-04-18 17:35:55 -070078
79$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
Ying Wang63d94fa2012-12-13 18:23:01 -080080endif # prebuilt_module_is_a_library
Ying Wang6c86a132013-02-25 18:12:11 -080081
82# The real dependency will be added after all Android.mks are loaded and the install paths
83# of the shared libraries are determined.
84ifdef LOCAL_INSTALLED_MODULE
85ifdef LOCAL_SHARED_LIBRARIES
Ying Wangd6b1d612013-04-15 17:32:21 -070086$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
Ying Wangba9636d2013-07-12 22:05:14 -070087
88# We also need the LOCAL_BUILT_MODULE dependency,
89# since we use -rpath-link which points to the built module's path.
90built_shared_libraries := \
91 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang988251c2013-07-15 08:47:33 -070092 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
Ying Wangba9636d2013-07-12 22:05:14 -070093 $(LOCAL_SHARED_LIBRARIES)))
94$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
The Android Open Source Project88b60792009-03-03 19:28:42 -080095endif
Ying Wang6c86a132013-02-25 18:12:11 -080096endif
97
98endif # LOCAL_STRIP_MODULE not true
The Android Open Source Project88b60792009-03-03 19:28:42 -080099
Owen Lin64d5a802009-10-16 02:43:05 -0700100PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
101
Doug Zongker08d79c12011-10-05 08:16:30 -0700102ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
103 # The magic string "EXTERNAL" means this package will be signed with
104 # the default dev key throughout the build process, but we expect
105 # the final package to be signed with a different key.
106 #
107 # This can be used for packages where we don't have access to the
108 # keys, but want the package to be predexopt'ed.
109 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
110 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
111
112 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
113 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
114endif
115ifeq ($(LOCAL_CERTIFICATE),)
116 ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
117 # It is now a build error to add a prebuilt .apk without
118 # specifying a key for it.
Ying Wang63d94fa2012-12-13 18:23:01 -0800119 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Doug Zongker08d79c12011-10-05 08:16:30 -0700120 endif
121else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
122 # The magic string "PRESIGNED" means this package is already checked
123 # signed with its release key.
124 #
125 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
126 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
127 # but the dexpreopt process will not try to re-sign the app.
128 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
129 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
130else
131 # If this is not an absolute certificate, assign it to a generic one.
132 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
133 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
134 endif
135
136 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
137 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
138 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
139
140 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
141 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
142endif
143
Dianne Hackborn9c0c4b72009-08-11 19:16:46 -0700144ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
Doug Zongker08d79c12011-10-05 08:16:30 -0700145ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
146# Ensure that presigned .apks have been aligned.
Ying Wang63d94fa2012-12-13 18:23:01 -0800147$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
Dianne Hackborn9c0c4b72009-08-11 19:16:46 -0700148 $(transform-prebuilt-to-target-with-zipalign)
149else
Doug Zongker08d79c12011-10-05 08:16:30 -0700150# Sign and align non-presigned .apks.
Ying Wang63d94fa2012-12-13 18:23:01 -0800151$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
Doug Zongker08d79c12011-10-05 08:16:30 -0700152 $(transform-prebuilt-to-target)
153 $(sign-package)
154 $(align-package)
155endif
156else
Doug Zongker1046d202009-08-06 13:02:19 -0700157ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Ying Wang63d94fa2012-12-13 18:23:01 -0800158$(built_module) : $(my_prebuilt_src_file)
Doug Zongker1046d202009-08-06 13:02:19 -0700159 $(transform-prebuilt-to-target-strip-comments)
160else
Ying Wang63d94fa2012-12-13 18:23:01 -0800161$(built_module) : $(my_prebuilt_src_file) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800162 $(transform-prebuilt-to-target)
Ying Wang5f074802011-11-08 09:31:21 -0800163ifneq ($(prebuilt_module_is_a_library),)
164 ifneq ($(LOCAL_IS_HOST_MODULE),)
165 $(transform-host-ranlib-copy-hack)
166 else
167 $(transform-ranlib-copy-hack)
168 endif
169endif
Doug Zongker1046d202009-08-06 13:02:19 -0700170endif
Dianne Hackborn9c0c4b72009-08-11 19:16:46 -0700171endif
172
Ying Wanga83940f2010-09-24 18:09:04 -0700173ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
174# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
175# while the deps should be in the common dir, so we make a copy in the common dir.
Ying Wang5b316b62011-02-01 12:57:45 -0800176# For nonstatic library, $(common_javalib_jar) is the dependency file,
177# while $(common_classes_jar) is used to link.
178common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
179common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
180
Ying Wang63d94fa2012-12-13 18:23:01 -0800181$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
Ying Wanga83940f2010-09-24 18:09:04 -0700182 $(transform-prebuilt-to-target)
Ying Wang5b316b62011-02-01 12:57:45 -0800183
184$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
185 $(transform-prebuilt-to-target)
186
187# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
Ji-Hwan Lee0219e922011-07-07 03:10:14 +0900188$(built_module) : $(common_javalib_jar)
Ying Wang5b316b62011-02-01 12:57:45 -0800189endif # TARGET JAVA_LIBRARIES