1 ###########################################################
2 ## Standard rules for building binary object files from
3 ## asm/c/cpp/yacc/lex/etc source files.
5 ## The list of object files is exported in $(all_objects).
6 ###########################################################
8 #######################################
9 include $(BUILD_SYSTEM)/base_rules.mk
10 #######################################
13 my_ndk_sysroot_include :=
15 ifdef LOCAL_SDK_VERSION
16 ifdef LOCAL_NDK_VERSION
17 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
19 ifdef LOCAL_IS_HOST_MODULE
20 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
22 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
23 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
24 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
25 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
26 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
28 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
31 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
32 # See ndk/docs/CPLUSPLUS-SUPPORT.html
33 my_ndk_stl_include_path :=
34 my_ndk_stl_shared_lib_fullpath :=
35 my_ndk_stl_shared_lib :=
36 my_ndk_stl_static_lib :=
37 my_ndk_stl_cppflags :=
38 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
39 ifeq (,$(LOCAL_NDK_STL_VARIANT))
40 LOCAL_NDK_STL_VARIANT := system
42 ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
43 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
45 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
46 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
47 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
48 else # LOCAL_NDK_STL_VARIANT is not system
49 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
50 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
51 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
52 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a
54 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so
55 my_ndk_stl_shared_lib := -lstlport_shared
57 else # LOCAL_NDK_STL_VARIANT is not stlport_* either
58 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
59 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
60 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
61 $(my_ndk_source_root)/android/support/include
62 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
63 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a
65 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so
66 my_ndk_stl_shared_lib := -lc++_shared
68 my_ndk_stl_cppflags := -std=c++11
70 # LOCAL_NDK_STL_VARIANT is gnustl_static
71 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \
72 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
73 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a
79 ##################################################
80 # Compute the dependency of the shared libraries
81 ##################################################
82 # On the target, we compile with -nostdlib, so we must add in the
83 # default system shared libraries, unless they have requested not
84 # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
85 # supply that, for example, when building libc itself.
86 ifdef LOCAL_IS_HOST_MODULE
87 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
88 my_system_shared_libraries :=
90 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
93 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
94 my_system_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
96 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
100 # The following LOCAL_ variables will be modified in this file.
101 # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
102 # we can't modify them in place.
103 my_src_files := $(LOCAL_SRC_FILES)
104 my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
105 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
106 my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
107 my_cflags := $(LOCAL_CFLAGS)
108 my_cppflags := $(LOCAL_CPPFLAGS)
109 my_ldflags := $(LOCAL_LDFLAGS)
110 my_asflags := $(LOCAL_ASFLAGS)
112 my_cxx := $(LOCAL_CXX)
113 my_c_includes := $(LOCAL_C_INCLUDES)
114 my_generated_sources := $(LOCAL_GENERATED_SOURCES)
116 # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
117 # all code is position independent, and then those warnings get promoted to
119 ifeq ($(strip $(USE_MINGW)),)
120 ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
127 my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
128 my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
129 my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
130 my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
131 my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
132 my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
133 my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
134 my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
136 my_clang := $(LOCAL_CLANG)
137 ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
138 my_clang := $(LOCAL_CLANG_$(my_32_64_bit_suffix))
140 ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
141 my_clang := $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
144 # arch-specific static libraries go first so that generic ones can depend on them
145 my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
146 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
148 my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
151 # Replace libstdc++ with libc++ if it's seen
152 my_libcxx := $(filter libc++, $(my_shared_libraries))
154 my_system_shared_libraries := $(filter-out libstdc++, $(my_system_shared_libraries))
157 # Add static HAL libraries
158 ifdef LOCAL_HAL_STATIC_LIBRARIES
159 $(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
160 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
161 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
162 $(eval my_static_libraries += $(lib).default)))
166 ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
168 # Frame pointer based unwinder in ASan requires ARM frame setup.
169 LOCAL_ARM_MODE := arm
170 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
171 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
172 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
173 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
176 ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
180 # Add in libcompiler_rt for all regular device builds
181 ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
182 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
185 my_compiler_dependencies :=
187 ##################################################################
188 ## Add FDO flags if FDO is turned on and supported
189 ## Please note that we will do option filtering during FDO build.
190 ## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
191 ##################################################################
192 ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
193 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
194 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
195 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
199 ###########################################################
200 ## Explicitly declare assembly-only __ASSEMBLY__ macro for
202 ###########################################################
203 my_asflags += -D__ASSEMBLY__
206 ##########################################################
207 ## Set up installed module dependency
208 ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
209 ## they may cusomize their install path with LOCAL_MODULE_PATH
210 ##########################################################
211 # Get the list of INSTALLED libraries as module names.
212 ifdef LOCAL_SDK_VERSION
213 installed_shared_library_module_names := \
214 $(my_shared_libraries)
216 installed_shared_library_module_names := \
217 $(my_system_shared_libraries) $(my_shared_libraries)
219 installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
221 # The real dependency will be added after all Android.mks are loaded and the install paths
222 # of the shared libraries are determined.
223 ifdef LOCAL_INSTALLED_MODULE
224 ifdef installed_shared_library_module_names
225 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
226 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
230 ###########################################################
231 ## Define PRIVATE_ variables from global vars
232 ###########################################################
233 ifndef LOCAL_IS_HOST_MODULE
234 ifdef LOCAL_SDK_VERSION
235 my_target_project_includes :=
236 my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
237 my_target_global_cppflags := $(my_ndk_stl_cppflags)
239 my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
240 my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
241 my_target_global_cppflags :=
242 endif # LOCAL_SDK_VERSION
244 ifeq ($(my_clang),true)
245 my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
246 my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
247 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
248 my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
250 my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
251 my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
252 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
255 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
256 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
257 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
258 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
259 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
261 else # LOCAL_IS_HOST_MODULE
263 ifeq ($(my_clang),true)
264 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
265 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
266 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
267 my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
269 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
270 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
271 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
272 my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
275 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
276 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
277 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
278 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
279 endif # LOCAL_IS_HOST_MODULE
281 ###########################################################
282 ## Define PRIVATE_ variables used by multiple module types
283 ###########################################################
284 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
285 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
287 ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
288 LOCAL_NO_SYNTAX_CHECK := true
291 ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
292 LOCAL_NO_STATIC_ANALYZER := true
295 ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
296 my_syntax_arch := host
298 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
301 ifeq ($(strip $(my_cc)),)
302 ifeq ($(strip $(my_clang)),true)
305 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
308 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
309 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
311 ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
312 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
315 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
317 ifeq ($(strip $(my_cxx)),)
318 ifeq ($(strip $(my_clang)),true)
319 my_cxx := $(CLANG_CXX)
321 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
324 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
325 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
327 ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
328 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
331 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
332 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
334 # TODO: support a mix of standard extensions so that this isn't necessary
335 LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
336 ifeq ($(LOCAL_CPP_EXTENSION),)
337 LOCAL_CPP_EXTENSION := .cpp
339 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
341 # Certain modules like libdl have to have symbols resolved at runtime and blow
342 # up if --no-undefined is passed to the linker.
343 ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
344 ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
345 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
349 ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
350 $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
352 $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
355 ###########################################################
356 ## Define arm-vs-thumb-mode flags.
357 ###########################################################
358 LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
359 ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
360 arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
361 normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
363 # Read the values from something like TARGET_arm_CFLAGS or
364 # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
365 # actually used (although they are usually empty).
366 arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
367 normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
368 ifeq ($(strip $(my_clang)),true)
369 arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
370 normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
375 normal_objects_mode :=
376 arm_objects_cflags :=
377 normal_objects_cflags :=
380 ###########################################################
381 ## Define per-module debugging flags. Users can turn on
382 ## debugging for a particular module by setting DEBUG_MODULE_ModuleName
383 ## to a non-empty value in their environment or buildspec.mk,
384 ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
385 ## debug flags that they want to use.
386 ###########################################################
387 ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
388 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
393 ####################################################
394 ## Compile RenderScript with reflected C++
395 ####################################################
397 renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
399 ifneq (,$(renderscript_sources))
401 renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
402 RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
403 renderscript_intermediate := $(intermediates)/renderscript
405 ifeq ($(LOCAL_RENDERSCRIPT_CC),)
406 LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
409 # Turn on all warnings and warnings as errors for RS compiles.
410 # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
411 renderscript_flags := -Wall -Werror
412 renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
414 renderscript_flags += -m$(my_32_64_bit_suffix)
416 renderscript_includes := \
417 $(TOPDIR)external/clang/lib/Headers \
418 $(TOPDIR)frameworks/rs/scriptc \
419 $(LOCAL_RENDERSCRIPT_INCLUDES)
421 ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
422 renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
425 $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
426 $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
427 $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
428 $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
429 $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
430 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
431 $(transform-renderscripts-to-cpp-and-bc)
433 # include the dependency files (.d) generated by llvm-rs-cc.
434 renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
435 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
436 -include $(renderscript_generated_dep_files)
438 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
440 rs_generated_cpps := $(addprefix \
441 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
442 $(notdir $(renderscript_sources)))))
444 # This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
445 $(rs_generated_cpps) : $(RenderScript_file_stamp)
446 @echo "Updated RS generated cpp file $@."
448 my_c_includes += $(renderscript_intermediate)
449 my_generated_sources += $(rs_generated_cpps)
454 ###########################################################
455 ## Stuff source generated from one-off tools
456 ###########################################################
457 $(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
459 my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
461 $(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
463 $(copy-file-to-target)
465 my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
467 ALL_GENERATED_SOURCES += $(my_generated_sources)
469 ###########################################################
470 ## Compile the .proto files to .cc and then to .o
471 ###########################################################
472 proto_sources := $(filter %.proto,$(my_src_files))
473 proto_generated_objects :=
474 proto_generated_headers :=
475 ifneq ($(proto_sources),)
476 proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
477 proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
478 proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
479 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
480 proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
481 proto_generated_obj_dir := $(intermediates)/proto
482 proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
483 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
485 # Auto-export the generated proto source dir.
486 LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir)
488 # Ensure the transform-proto-to-cc rule is only defined once in multilib build.
489 ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
490 $(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
491 $(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
492 $(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
493 $(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
494 $(transform-proto-to-cc)
496 # This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
497 $(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
498 @echo "Updated header file $@."
500 $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
501 endif # transform-proto-to-cc rule included only once
503 $(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
504 $(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
505 $(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
506 $(transform-$(PRIVATE_HOST)cpp-to-o)
507 -include $(proto_generated_objects:%.o=%.P)
509 my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
510 my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
511 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
512 my_static_libraries += libprotobuf-cpp-2.3.0-full
514 my_static_libraries += libprotobuf-cpp-2.3.0-lite
516 endif # $(proto_sources) non-empty
519 ###########################################################
520 ## YACC: Compile .y and .yy files to .cpp and the to .o.
521 ###########################################################
523 y_yacc_sources := $(filter %.y,$(my_src_files))
524 y_yacc_cpps := $(addprefix \
525 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
527 yy_yacc_sources := $(filter %.yy,$(my_src_files))
528 yy_yacc_cpps := $(addprefix \
529 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
531 yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
532 yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
533 yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
535 ifneq ($(strip $(y_yacc_cpps)),)
536 $(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
537 $(TOPDIR)$(LOCAL_PATH)/%.y \
538 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
539 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
540 $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
543 ifneq ($(strip $(yy_yacc_cpps)),)
544 $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
545 $(TOPDIR)$(LOCAL_PATH)/%.yy \
546 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
547 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
548 $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
551 ifneq ($(strip $(yacc_cpps)),)
552 $(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
553 $(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
554 $(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
555 $(transform-$(PRIVATE_HOST)cpp-to-o)
558 ###########################################################
559 ## LEX: Compile .l and .ll files to .cpp and then to .o.
560 ###########################################################
562 l_lex_sources := $(filter %.l,$(my_src_files))
563 l_lex_cpps := $(addprefix \
564 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
566 ll_lex_sources := $(filter %.ll,$(my_src_files))
567 ll_lex_cpps := $(addprefix \
568 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
570 lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
571 lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
573 ifneq ($(strip $(l_lex_cpps)),)
574 $(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
575 $(TOPDIR)$(LOCAL_PATH)/%.l
576 $(transform-l-to-cpp)
579 ifneq ($(strip $(ll_lex_cpps)),)
580 $(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
581 $(TOPDIR)$(LOCAL_PATH)/%.ll
582 $(transform-l-to-cpp)
585 ifneq ($(strip $(lex_cpps)),)
586 $(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
587 $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
588 $(lex_objects): $(intermediates)/%.o: \
589 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
590 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
592 $(transform-$(PRIVATE_HOST)cpp-to-o)
595 ###########################################################
596 ## C++: Compile .cpp files to .o.
597 ###########################################################
599 # we also do this on host modules, even though
600 # it's not really arm, because there are files that are shared.
601 cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
602 cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
604 cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
605 cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
607 $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
608 $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
609 $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
610 $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
612 cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
614 ifneq ($(strip $(cpp_objects)),)
615 $(cpp_objects): $(intermediates)/%.o: \
616 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
617 $(yacc_cpps) $(proto_generated_headers) \
618 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
619 | $(my_compiler_dependencies)
620 $(transform-$(PRIVATE_HOST)cpp-to-o)
621 -include $(cpp_objects:%.o=%.P)
624 ###########################################################
625 ## C++: Compile generated .cpp files to .o.
626 ###########################################################
628 gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
629 gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
631 ifneq ($(strip $(gen_cpp_objects)),)
632 # Compile all generated files as thumb.
633 # TODO: support compiling certain generated files as arm.
634 $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
635 $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
636 $(gen_cpp_objects): $(intermediates)/%.o: \
637 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
638 $(proto_generated_headers) \
639 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
640 | $(my_compiler_dependencies)
641 $(transform-$(PRIVATE_HOST)cpp-to-o)
642 -include $(gen_cpp_objects:%.o=%.P)
645 ###########################################################
646 ## S: Compile generated .S and .s files to .o.
647 ###########################################################
649 gen_S_sources := $(filter %.S,$(my_generated_sources))
650 gen_S_objects := $(gen_S_sources:%.S=%.o)
652 ifneq ($(strip $(gen_S_sources)),)
653 $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
654 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
655 | $(my_compiler_dependencies)
656 $(transform-$(PRIVATE_HOST)s-to-o)
657 -include $(gen_S_objects:%.o=%.P)
660 gen_s_sources := $(filter %.s,$(my_generated_sources))
661 gen_s_objects := $(gen_s_sources:%.s=%.o)
663 ifneq ($(strip $(gen_s_objects)),)
664 $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
665 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
666 | $(my_compiler_dependencies)
667 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
668 -include $(gen_s_objects:%.o=%.P)
671 gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
673 ###########################################################
674 ## o: Include generated .o files in output.
675 ###########################################################
677 gen_o_objects := $(filter %.o,$(my_generated_sources))
679 ###########################################################
680 ## C: Compile .c files to .o.
681 ###########################################################
683 c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
684 c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
686 c_normal_sources := $(filter %.c,$(my_src_files))
687 c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
689 $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
690 $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
691 $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
692 $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
694 c_objects := $(c_arm_objects) $(c_normal_objects)
696 ifneq ($(strip $(c_objects)),)
697 $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
698 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
699 | $(my_compiler_dependencies)
700 $(transform-$(PRIVATE_HOST)c-to-o)
701 -include $(c_objects:%.o=%.P)
704 ###########################################################
705 ## C: Compile generated .c files to .o.
706 ###########################################################
708 gen_c_sources := $(filter %.c,$(my_generated_sources))
709 gen_c_objects := $(gen_c_sources:%.c=%.o)
711 ifneq ($(strip $(gen_c_objects)),)
712 # Compile all generated files as thumb.
713 # TODO: support compiling certain generated files as arm.
714 $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
715 $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
716 $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
717 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
718 | $(my_compiler_dependencies)
719 $(transform-$(PRIVATE_HOST)c-to-o)
720 -include $(gen_c_objects:%.o=%.P)
723 ###########################################################
724 ## ObjC: Compile .m files to .o
725 ###########################################################
727 objc_sources := $(filter %.m,$(my_src_files))
728 objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
730 ifneq ($(strip $(objc_objects)),)
731 $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
732 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
733 | $(my_compiler_dependencies)
734 $(transform-$(PRIVATE_HOST)m-to-o)
735 -include $(objc_objects:%.o=%.P)
738 ###########################################################
739 ## AS: Compile .S files to .o.
740 ###########################################################
742 asm_sources_S := $(filter %.S,$(my_src_files))
743 asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
745 ifneq ($(strip $(asm_objects_S)),)
746 $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
747 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
748 | $(my_compiler_dependencies)
749 $(transform-$(PRIVATE_HOST)s-to-o)
750 -include $(asm_objects_S:%.o=%.P)
753 asm_sources_s := $(filter %.s,$(my_src_files))
754 asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
756 ifneq ($(strip $(asm_objects_s)),)
757 $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
758 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
759 | $(my_compiler_dependencies)
760 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
761 -include $(asm_objects_s:%.o=%.P)
764 asm_objects := $(asm_objects_S) $(asm_objects_s)
767 # .asm for x86 needs to be compiled with yasm.
768 ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
769 asm_sources_asm := $(filter %.asm,$(my_src_files))
770 ifneq ($(strip $(asm_sources_asm)),)
771 asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
772 $(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
773 $(LOCAL_ADDITIONAL_DEPENDENCIES)
774 $(transform-asm-to-o)
776 asm_objects += $(asm_objects_asm)
780 ####################################################
782 ####################################################
783 import_includes := $(intermediates)/import_includes
784 import_includes_deps := $(strip \
785 $(foreach l, $(installed_shared_library_module_names), \
786 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \
787 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
788 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
789 $(import_includes) : $(import_includes_deps)
790 @echo Import includes file: $@
791 $(hide) mkdir -p $(dir $@) && rm -f $@
792 ifdef import_includes_deps
793 $(hide) for f in $^; do \
800 ###########################################################
801 ## Common object handling.
802 ###########################################################
804 # some rules depend on asm_objects being first. If your code depends on
805 # being first, it's reasonable to require it to be assembly
816 $(proto_generated_objects) \
817 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
819 all_objects := $(normal_objects) $(gen_o_objects)
821 my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
823 ifndef LOCAL_SDK_VERSION
824 my_c_includes += $(JNI_H_INCLUDE)
827 # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
828 # use normal_objects here to avoid creating circular dependencies. This assumes
829 # that custom build rules which generate .o files don't consume other generated
830 # sources as input (or if they do they take care of that dependency themselves).
831 $(normal_objects) : | $(my_generated_sources)
832 $(all_objects) : | $(import_includes)
833 ALL_C_CPP_ETC_OBJECTS += $(all_objects)
836 ###########################################################
837 # Standard library handling.
838 ###########################################################
840 ###########################################################
841 # The list of libraries that this module will link against are in
842 # these variables. Each is a list of bare module names like "libc libm".
844 # LOCAL_SHARED_LIBRARIES
845 # LOCAL_STATIC_LIBRARIES
846 # LOCAL_WHOLE_STATIC_LIBRARIES
848 # We need to convert the bare names into the dependencies that
849 # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
850 # LOCAL_BUILT_MODULE should depend on the BUILT versions of the
851 # libraries, so that simply building this module doesn't force
852 # an install of a library. Similarly, LOCAL_INSTALLED_MODULE
853 # should depend on the INSTALLED versions of the libraries so
854 # that they get installed when this module does.
855 ###########################################################
857 # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
858 # module without leaving anything out, which is useful for turning
859 # a collection of .a files into a .so file. Linking against a
860 # normal STATIC_LIBRARY will only pull in code/symbols that are
861 # referenced by the module. (see gcc/ld's --whole-archive option)
862 ###########################################################
864 # Get the list of BUILT libraries, which are under
865 # various intermediates directories.
866 so_suffix := $($(my_prefix)SHLIB_SUFFIX)
867 a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
869 ifdef LOCAL_SDK_VERSION
870 built_shared_libraries := \
871 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
872 $(addsuffix $(so_suffix), \
873 $(my_shared_libraries)))
875 # Add the NDK libraries to the built module dependency
876 my_system_shared_libraries_fullpath := \
877 $(my_ndk_stl_shared_lib_fullpath) \
878 $(addprefix $(my_ndk_sysroot_lib)/, \
879 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
881 built_shared_libraries += $(my_system_shared_libraries_fullpath)
883 built_shared_libraries := \
884 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
885 $(addsuffix $(so_suffix), \
886 $(installed_shared_library_module_names)))
889 built_static_libraries := \
890 $(foreach lib,$(my_static_libraries), \
891 $(call intermediates-dir-for, \
892 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
894 ifdef LOCAL_SDK_VERSION
895 built_static_libraries += $(my_ndk_stl_static_lib)
898 built_whole_libraries := \
899 $(foreach lib,$(my_whole_static_libraries), \
900 $(call intermediates-dir-for, \
901 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
903 # We don't care about installed static libraries, since the
904 # libraries have already been linked into the module at that point.
905 # We do, however, care about the NOTICE files for any static
906 # libraries that we use. (see notice_files.mk)
908 installed_static_library_notice_file_targets := \
909 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
910 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
912 # Default is -fno-rtti.
913 ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
914 LOCAL_RTTI_FLAG := -fno-rtti
917 ###########################################################
918 # Rule-specific variable definitions
919 ###########################################################
921 ifeq ($(my_clang),true)
922 my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
923 my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
924 my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
925 my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
928 ifeq ($(LOCAL_FDO_SUPPORT), true)
929 build_with_fdo := false
930 ifeq ($(BUILD_FDO_INSTRUMENT), true)
931 build_with_fdo := true
933 ifeq ($(BUILD_FDO_OPTIMIZE), true)
934 build_with_fdo := true
936 ifeq ($(build_with_fdo), true)
937 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
938 fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
939 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
943 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
944 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
945 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
946 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
947 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
948 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
949 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
950 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
951 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
952 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
953 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
954 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
955 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
957 # this is really the way to get the files onto the command line instead
958 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
959 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
960 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
961 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
962 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
964 ###########################################################
965 # Define library dependencies.
966 ###########################################################
967 # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
969 $(built_shared_libraries) \
970 $(built_static_libraries) \
971 $(built_whole_libraries)
973 # Also depend on the notice files for any static libraries that
974 # are linked into this module. This will force them to be installed
975 # when this module is.
976 $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
978 ###########################################################
980 ###########################################################
981 export_includes := $(intermediates)/export_includes
982 $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
983 # Make sure .pb.h are already generated before any dependent source files get compiled.
984 $(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
985 @echo Export includes file: $< -- $@
986 $(hide) mkdir -p $(dir $@) && rm -f $@
987 ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
988 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
989 echo "-I $$d" >> $@; \
995 # Make sure export_includes gets generated when you are running mm/mmm
996 $(LOCAL_BUILT_MODULE) : | $(export_includes)