The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | ########################################################### |
| 2 | ## Standard rules for building binary object files from |
| 3 | ## asm/c/cpp/yacc/lex source files. |
| 4 | ## |
| 5 | ## The list of object files is exported in $(all_objects). |
| 6 | ########################################################### |
| 7 | |
| 8 | ####################################### |
| 9 | include $(BUILD_SYSTEM)/base_rules.mk |
| 10 | ####################################### |
| 11 | |
| 12 | ########################################################### |
| 13 | ## Define PRIVATE_ variables used by multiple module types |
| 14 | ########################################################### |
| 15 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ |
| 16 | $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) |
| 17 | |
| 18 | ifeq ($(strip $(LOCAL_CC)),) |
| 19 | LOCAL_CC := $($(my_prefix)CC) |
| 20 | endif |
| 21 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC) |
| 22 | |
| 23 | ifeq ($(strip $(LOCAL_CXX)),) |
| 24 | LOCAL_CXX := $($(my_prefix)CXX) |
| 25 | endif |
| 26 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX) |
| 27 | |
| 28 | # TODO: support a mix of standard extensions so that this isn't necessary |
| 29 | LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) |
| 30 | ifeq ($(LOCAL_CPP_EXTENSION),) |
| 31 | LOCAL_CPP_EXTENSION := .cpp |
| 32 | endif |
| 33 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) |
| 34 | |
| 35 | # Certain modules like libdl have to have symbols resolved at runtime and blow |
| 36 | # up if --no-undefined is passed to the linker. |
| 37 | ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) |
| 38 | ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) |
| 39 | LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS) |
| 40 | endif |
| 41 | endif |
| 42 | |
| 43 | ########################################################### |
| 44 | ## Define arm-vs-thumb-mode flags. |
| 45 | ########################################################### |
| 46 | LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) |
| 47 | arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) |
| 48 | normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) |
| 49 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 50 | # Read the values from something like TARGET_arm_CFLAGS or |
| 51 | # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't |
| 52 | # actually used (although they are usually empty). |
| 53 | arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS) |
| 54 | normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 55 | |
| 56 | ########################################################### |
| 57 | ## Define per-module debugging flags. Users can turn on |
| 58 | ## debugging for a particular module by setting DEBUG_MODULE_ModuleName |
| 59 | ## to a non-empty value in their environment or buildspec.mk, |
| 60 | ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the |
| 61 | ## debug flags that they want to use. |
| 62 | ########################################################### |
| 63 | ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) |
| 64 | debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) |
| 65 | else |
| 66 | debug_cflags := |
| 67 | endif |
| 68 | |
| 69 | ########################################################### |
| 70 | ## Stuff source generated from one-off tools |
| 71 | ########################################################### |
| 72 | $(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 73 | |
| 74 | ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES) |
| 75 | |
| 76 | |
| 77 | ########################################################### |
| 78 | ## YACC: Compile .y files to .cpp and the to .o. |
| 79 | ########################################################### |
| 80 | |
| 81 | yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES)) |
| 82 | yacc_cpps := $(addprefix \ |
| 83 | $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) |
| 84 | yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) |
| 85 | yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 86 | |
| 87 | ifneq ($(strip $(yacc_cpps)),) |
| 88 | $(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 89 | $(TOPDIR)$(LOCAL_PATH)/%.y \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 90 | $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 91 | $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) |
| 92 | $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 93 | |
| 94 | $(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 95 | $(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 96 | $(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 97 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 98 | endif |
| 99 | |
| 100 | ########################################################### |
| 101 | ## LEX: Compile .l files to .cpp and then to .o. |
| 102 | ########################################################### |
| 103 | |
| 104 | lex_sources := $(filter %.l,$(LOCAL_SRC_FILES)) |
| 105 | lex_cpps := $(addprefix \ |
| 106 | $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION))) |
| 107 | lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 108 | |
| 109 | ifneq ($(strip $(lex_cpps)),) |
| 110 | $(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 111 | $(TOPDIR)$(LOCAL_PATH)/%.l |
| 112 | $(transform-l-to-cpp) |
| 113 | |
| 114 | $(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 115 | $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 116 | $(lex_objects): $(intermediates)/%.o: \ |
| 117 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 118 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 119 | $(yacc_headers) |
| 120 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 121 | endif |
| 122 | |
| 123 | ########################################################### |
| 124 | ## C++: Compile .cpp files to .o. |
| 125 | ########################################################### |
| 126 | |
| 127 | # we also do this on host modules and sim builds, even though |
| 128 | # it's not really arm, because there are files that are shared. |
| 129 | cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES))) |
| 130 | cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 131 | |
| 132 | cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES)) |
| 133 | cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 134 | |
| 135 | $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 136 | $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 137 | $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 138 | $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 139 | |
| 140 | cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) |
| 141 | |
| 142 | ifneq ($(strip $(cpp_objects)),) |
| 143 | $(cpp_objects): $(intermediates)/%.o: \ |
| 144 | $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 145 | $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 146 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 147 | -include $(cpp_objects:%.o=%.P) |
| 148 | endif |
| 149 | |
| 150 | ########################################################### |
| 151 | ## C++: Compile generated .cpp files to .o. |
| 152 | ########################################################### |
| 153 | |
| 154 | gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES)) |
| 155 | gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) |
| 156 | |
| 157 | ifneq ($(strip $(gen_cpp_objects)),) |
| 158 | # Compile all generated files as thumb. |
| 159 | # TODO: support compiling certain generated files as arm. |
| 160 | $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 161 | $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 162 | $(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 163 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 164 | -include $(gen_cpp_objects:%.o=%.P) |
| 165 | endif |
| 166 | |
| 167 | ########################################################### |
| 168 | ## S: Compile generated .S and .s files to .o. |
| 169 | ########################################################### |
| 170 | |
| 171 | gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES)) |
| 172 | gen_S_objects := $(gen_S_sources:%.S=%.o) |
| 173 | |
| 174 | ifneq ($(strip $(gen_S_sources)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 175 | $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 176 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 177 | -include $(gen_S_objects:%.o=%.P) |
| 178 | endif |
| 179 | |
| 180 | gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES)) |
| 181 | gen_s_objects := $(gen_s_sources:%.s=%.o) |
| 182 | |
| 183 | ifneq ($(strip $(gen_s_objects)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 184 | $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 185 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 186 | -include $(gen_s_objects:%.o=%.P) |
| 187 | endif |
| 188 | |
| 189 | gen_asm_objects := $(gen_S_objects) $(gen_s_objects) |
| 190 | |
| 191 | ########################################################### |
| 192 | ## C: Compile .c files to .o. |
| 193 | ########################################################### |
| 194 | |
| 195 | c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES))) |
| 196 | c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) |
| 197 | |
| 198 | c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES)) |
| 199 | c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) |
| 200 | |
| 201 | $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 202 | $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 203 | $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 204 | $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 205 | |
| 206 | c_objects := $(c_arm_objects) $(c_normal_objects) |
| 207 | |
| 208 | ifneq ($(strip $(c_objects)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 209 | $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 210 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 211 | -include $(c_objects:%.o=%.P) |
| 212 | endif |
| 213 | |
| 214 | ########################################################### |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 215 | ## C: Compile generated .c files to .o. |
| 216 | ########################################################### |
| 217 | |
| 218 | gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES)) |
| 219 | gen_c_objects := $(gen_c_sources:%.c=%.o) |
| 220 | |
| 221 | ifneq ($(strip $(gen_c_objects)),) |
| 222 | # Compile all generated files as thumb. |
| 223 | # TODO: support compiling certain generated files as arm. |
| 224 | $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 225 | $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 226 | $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 227 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 228 | -include $(gen_c_objects:%.o=%.P) |
| 229 | endif |
| 230 | |
| 231 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 232 | ## ObjC: Compile .m files to .o |
| 233 | ########################################################### |
| 234 | |
| 235 | objc_sources := $(filter %.m,$(LOCAL_SRC_FILES)) |
| 236 | objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) |
| 237 | |
| 238 | ifneq ($(strip $(objc_objects)),) |
| 239 | $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(PRIVATE_ADDITIONAL_DEPENDENCIES) |
| 240 | $(transform-$(PRIVATE_HOST)m-to-o) |
| 241 | -include $(objc_objects:%.o=%.P) |
| 242 | endif |
| 243 | |
| 244 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 245 | ## AS: Compile .S files to .o. |
| 246 | ########################################################### |
| 247 | |
| 248 | asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES)) |
| 249 | asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) |
| 250 | |
| 251 | ifneq ($(strip $(asm_objects_S)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 252 | $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 253 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 254 | -include $(asm_objects_S:%.o=%.P) |
| 255 | endif |
| 256 | |
| 257 | asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES)) |
| 258 | asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) |
| 259 | |
| 260 | ifneq ($(strip $(asm_objects_s)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 261 | $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 262 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 263 | -include $(asm_objects_s:%.o=%.P) |
| 264 | endif |
| 265 | |
| 266 | asm_objects := $(asm_objects_S) $(asm_objects_s) |
| 267 | |
| 268 | |
| 269 | ########################################################### |
| 270 | ## Common object handling. |
| 271 | ########################################################### |
| 272 | |
| 273 | # some rules depend on asm_objects being first. If your code depends on |
| 274 | # being first, it's reasonable to require it to be assembly |
| 275 | all_objects := \ |
| 276 | $(asm_objects) \ |
| 277 | $(cpp_objects) \ |
| 278 | $(gen_cpp_objects) \ |
| 279 | $(gen_asm_objects) \ |
| 280 | $(c_objects) \ |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 281 | $(gen_c_objects) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 282 | $(yacc_objects) \ |
| 283 | $(lex_objects) \ |
| 284 | $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) |
| 285 | |
| 286 | LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates) |
| 287 | |
| 288 | $(all_objects) : | $(LOCAL_GENERATED_SOURCES) |
| 289 | ALL_C_CPP_ETC_OBJECTS += $(all_objects) |
| 290 | |
| 291 | ########################################################### |
| 292 | ## Copy headers to the install tree |
| 293 | ########################################################### |
| 294 | include $(BUILD_COPY_HEADERS) |
| 295 | |
| 296 | ########################################################### |
| 297 | # Standard library handling. |
| 298 | # |
| 299 | # On the target, we compile with -nostdlib, so we must add in the |
| 300 | # default system shared libraries, unless they have requested not |
| 301 | # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would |
| 302 | # supply that, for example, when building libc itself. |
| 303 | ########################################################### |
| 304 | ifndef LOCAL_IS_HOST_MODULE |
| 305 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
| 306 | LOCAL_SHARED_LIBRARIES += $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES) |
| 307 | else |
| 308 | LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
| 309 | endif |
| 310 | endif |
| 311 | |
| 312 | # Logging used to be part of libcutils (target) and libutils (sim); |
| 313 | # hack modules that use those other libs to also include liblog. |
| 314 | # All of this complexity is to make sure that liblog only appears |
| 315 | # once, and appears just before libcutils or libutils on the link |
| 316 | # line. |
| 317 | # TODO: remove this hack and change all modules to use liblog |
| 318 | # when necessary. |
| 319 | define insert-liblog |
| 320 | $(if $(filter liblog,$(1)),$(1), \ |
| 321 | $(if $(filter libcutils,$(1)), \ |
| 322 | $(patsubst libcutils,liblog libcutils,$(1)) \ |
| 323 | , \ |
| 324 | $(patsubst libutils,liblog libutils,$(1)) \ |
| 325 | ) \ |
| 326 | ) |
| 327 | endef |
| 328 | ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES))) |
| 329 | LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES)) |
| 330 | endif |
| 331 | ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES))) |
| 332 | LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES)) |
| 333 | endif |
| 334 | ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES))) |
| 335 | LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES)) |
| 336 | endif |
| 337 | |
| 338 | ########################################################### |
| 339 | # The list of libraries that this module will link against are in |
| 340 | # these variables. Each is a list of bare module names like "libc libm". |
| 341 | # |
| 342 | # LOCAL_SHARED_LIBRARIES |
| 343 | # LOCAL_STATIC_LIBRARIES |
| 344 | # LOCAL_WHOLE_STATIC_LIBRARIES |
| 345 | # |
| 346 | # We need to convert the bare names into the dependencies that |
| 347 | # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. |
| 348 | # LOCAL_BUILT_MODULE should depend on the BUILT versions of the |
| 349 | # libraries, so that simply building this module doesn't force |
| 350 | # an install of a library. Similarly, LOCAL_INSTALLED_MODULE |
| 351 | # should depend on the INSTALLED versions of the libraries so |
| 352 | # that they get installed when this module does. |
| 353 | ########################################################### |
| 354 | # NOTE: |
| 355 | # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the |
| 356 | # module without leaving anything out, which is useful for turning |
| 357 | # a collection of .a files into a .so file. Linking against a |
| 358 | # normal STATIC_LIBRARY will only pull in code/symbols that are |
| 359 | # referenced by the module. (see gcc/ld's --whole-archive option) |
| 360 | ########################################################### |
| 361 | |
| 362 | # Get the list of BUILT libraries, which are under |
| 363 | # various intermediates directories. |
| 364 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 365 | a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) |
| 366 | |
| 367 | built_shared_libraries := \ |
| 368 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 369 | $(addsuffix $(so_suffix), \ |
| 370 | $(LOCAL_SHARED_LIBRARIES))) |
| 371 | |
| 372 | built_static_libraries := \ |
| 373 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \ |
| 374 | $(call intermediates-dir-for, \ |
| 375 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 376 | |
| 377 | built_whole_libraries := \ |
| 378 | $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 379 | $(call intermediates-dir-for, \ |
| 380 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 381 | |
| 382 | # Get the list of INSTALLED libraries. Strip off the various |
| 383 | # intermediates directories and point to the common lib dirs. |
| 384 | installed_shared_libraries := \ |
| 385 | $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \ |
| 386 | $(notdir $(built_shared_libraries))) |
| 387 | |
| 388 | # We don't care about installed static libraries, since the |
| 389 | # libraries have already been linked into the module at that point. |
| 390 | # We do, however, care about the NOTICE files for any static |
| 391 | # libraries that we use. (see notice_files.make) |
| 392 | |
| 393 | installed_static_library_notice_file_targets := \ |
| 394 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 395 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) |
| 396 | |
| 397 | ########################################################### |
| 398 | # Rule-specific variable definitions |
| 399 | ########################################################### |
| 400 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) |
| 401 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS) |
| 402 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS) |
| 403 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS) |
| 404 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) |
| 405 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES) |
| 406 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS) |
| 407 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) |
| 408 | |
| 409 | # this is really the way to get the files onto the command line instead |
| 410 | # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work |
| 411 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) |
| 412 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) |
| 413 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) |
| 414 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) |
| 415 | |
| 416 | ########################################################### |
| 417 | # Define library dependencies. |
| 418 | ########################################################### |
| 419 | # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. |
| 420 | all_libraries := \ |
| 421 | $(built_shared_libraries) \ |
| 422 | $(built_static_libraries) \ |
| 423 | $(built_whole_libraries) |
| 424 | |
| 425 | # Make LOCAL_INSTALLED_MODULE depend on the installed versions of the |
| 426 | # libraries so they get installed along with it. We don't need to |
| 427 | # rebuild it when installing it, though, so this can be an order-only |
| 428 | # dependency. |
| 429 | $(LOCAL_INSTALLED_MODULE): | $(installed_shared_libraries) |
| 430 | |
| 431 | # Also depend on the notice files for any static libraries that |
| 432 | # are linked into this module. This will force them to be installed |
| 433 | # when this module is. |
| 434 | $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) |