OSDN Git Service

am 7ce7473f: am 5e12e60b: Merge "For the current MIPS compiler __builtin___clear_cach...
[android-x86/build.git] / core / prebuilt.mk
1 ###########################################################
2 ## Standard rules for copying files that are prebuilt
3 ##
4 ## Additional inputs from base_rules.make:
5 ## None.
6 ##
7 ###########################################################
8
9 ifneq ($(LOCAL_PREBUILT_LIBS),)
10 $(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
11 endif
12 ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
13 $(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
14 endif
15 ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
16 $(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
17 endif
18
19 ifdef LOCAL_PREBUILT_MODULE_FILE
20 my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
21 else
22 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
23 endif
24
25 ifdef LOCAL_IS_HOST_MODULE
26   my_prefix := HOST_
27 else
28   my_prefix := TARGET_
29 endif
30 ifeq (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)
34 endif
35
36 ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
37   prebuilt_module_is_a_library := true
38 else
39   prebuilt_module_is_a_library :=
40 endif
41
42 # Install the shared libraries if necessary
43 LOCAL_REQUIRED_MODULES += $(LOCAL_SHARED_LIBRARIES)
44
45 # Don't install static libraries by default.
46 ifndef LOCAL_UNINSTALLABLE_MODULE
47 ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
48   LOCAL_UNINSTALLABLE_MODULE := true
49 endif
50 endif
51
52 ifeq ($(LOCAL_STRIP_MODULE),true)
53   ifdef LOCAL_IS_HOST_MODULE
54     $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
55   endif
56   ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
57     $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
58   endif
59   ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
60     $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
61   endif
62   include $(BUILD_SYSTEM)/dynamic_binary.mk
63   built_module := $(linked_module)
64 else
65   include $(BUILD_SYSTEM)/base_rules.mk
66   built_module := $(LOCAL_BUILT_MODULE)
67
68 ifdef prebuilt_module_is_a_library
69 export_includes := $(intermediates)/export_includes
70 $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
71 $(export_includes) : $(LOCAL_MODULE_MAKEFILE)
72         @echo Export includes file: $< -- $@
73         $(hide) mkdir -p $(dir $@) && rm -f $@
74 ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
75         $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
76                 echo "-I $$d" >> $@; \
77                 done
78 else
79         $(hide) touch $@
80 endif
81
82 $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
83 endif  # prebuilt_module_is_a_library
84 endif
85
86 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
87
88 ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
89   # The magic string "EXTERNAL" means this package will be signed with
90   # the default dev key throughout the build process, but we expect
91   # the final package to be signed with a different key.
92   #
93   # This can be used for packages where we don't have access to the
94   # keys, but want the package to be predexopt'ed.
95   LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
96   PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
97
98   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
99   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
100 endif
101 ifeq ($(LOCAL_CERTIFICATE),)
102   ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
103     # It is now a build error to add a prebuilt .apk without
104     # specifying a key for it.
105     $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
106   endif
107 else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
108   # The magic string "PRESIGNED" means this package is already checked
109   # signed with its release key.
110   #
111   # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
112   # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
113   # but the dexpreopt process will not try to re-sign the app.
114   PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
115   PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
116 else
117   # If this is not an absolute certificate, assign it to a generic one.
118   ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
119       LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
120   endif
121
122   PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
123   PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
124   PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
125
126   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
127   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
128 endif
129
130 ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
131 ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
132 # Ensure that presigned .apks have been aligned.
133 $(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
134         $(transform-prebuilt-to-target-with-zipalign)
135 else
136 # Sign and align non-presigned .apks.
137 $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
138         $(transform-prebuilt-to-target)
139         $(sign-package)
140         $(align-package)
141 endif
142 else
143 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
144 $(built_module) : $(my_prebuilt_src_file)
145         $(transform-prebuilt-to-target-strip-comments)
146 else
147 $(built_module) : $(my_prebuilt_src_file) | $(ACP)
148         $(transform-prebuilt-to-target)
149 ifneq ($(prebuilt_module_is_a_library),)
150   ifneq ($(LOCAL_IS_HOST_MODULE),)
151         $(transform-host-ranlib-copy-hack)
152   else
153         $(transform-ranlib-copy-hack)
154   endif
155 endif
156 endif
157 endif
158
159 ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
160 # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
161 # while the deps should be in the common dir, so we make a copy in the common dir.
162 # For nonstatic library, $(common_javalib_jar) is the dependency file,
163 # while $(common_classes_jar) is used to link.
164 common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
165 common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
166
167 $(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
168         $(transform-prebuilt-to-target)
169
170 $(common_javalib_jar) : $(common_classes_jar) | $(ACP)
171         $(transform-prebuilt-to-target)
172
173 # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
174 $(built_module) : $(common_javalib_jar)
175 endif # TARGET JAVA_LIBRARIES