binary.mk revision 4c12c0303c705ee4cc87344adbd62087539c7729
1###########################################################
2## Standard rules for building binary object files from
3## asm/c/cpp/yacc/lex/etc source files.
4##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
8#######################################
9include $(BUILD_SYSTEM)/base_rules.mk
10#######################################
11
12my_ndk_sysroot :=
13my_ndk_sysroot_include :=
14my_ndk_sysroot_lib :=
15ifdef LOCAL_SDK_VERSION
16  ifdef LOCAL_NDK_VERSION
17    $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
18  endif
19  ifdef LOCAL_IS_HOST_MODULE
20    $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
21  endif
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
27  else
28    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
29  endif
30
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
41  endif
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))
44  endif
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
53    else
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
56    endif
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
64    else
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
67    endif
68    my_ndk_stl_cppflags := -std=c++11
69  else
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
74  endif
75  endif
76  endif
77endif
78
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.
86ifdef LOCAL_IS_HOST_MODULE
87  ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
88      my_system_shared_libraries :=
89  else
90      my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
91  endif
92else
93  ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
94      my_system_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
95  else
96      my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
97  endif
98endif
99
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.
103my_src_files := $(LOCAL_SRC_FILES)
104my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
105my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
106my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
107my_cflags := $(LOCAL_CFLAGS)
108my_cppflags := $(LOCAL_CPPFLAGS)
109my_ldflags := $(LOCAL_LDFLAGS)
110my_ldlibs := $(LOCAL_LDLIBS)
111my_asflags := $(LOCAL_ASFLAGS)
112my_cc := $(LOCAL_CC)
113my_cxx := $(LOCAL_CXX)
114my_c_includes := $(LOCAL_C_INCLUDES)
115my_generated_sources := $(LOCAL_GENERATED_SOURCES)
116my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
117
118# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
119# all code is position independent, and then those warnings get promoted to
120# errors.
121ifndef USE_MINGW
122ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
123my_cflags += -fpie
124else
125my_cflags += -fPIC
126endif
127endif
128
129my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
130my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
131my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
132my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
133my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
134my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
135my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
136my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
137
138my_clang := $(strip $(LOCAL_CLANG))
139ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
140my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
141endif
142ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
143my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
144endif
145
146# clang is enabled by default for host builds
147# enable it unless we've specifically disabled clang above
148ifdef LOCAL_IS_HOST_MODULE
149    ifneq ($(HOST_OS),windows)
150    ifeq ($(my_clang),)
151        my_clang := true
152    endif
153    endif
154endif
155
156# Add option to make clang the default for device build
157ifeq ($(USE_CLANG_PLATFORM_BUILD),true)
158    ifeq ($(my_clang),)
159        my_clang := true
160    endif
161endif
162
163# arch-specific static libraries go first so that generic ones can depend on them
164my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
165my_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)
166
167my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
168
169include $(BUILD_SYSTEM)/cxx_stl_setup.mk
170
171# Add static HAL libraries
172ifdef LOCAL_HAL_STATIC_LIBRARIES
173$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
174    $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
175    $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
176                   $(eval my_static_libraries += $(lib).default)))
177b_lib :=
178endif
179
180ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
181  my_clang := true
182  my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
183  my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
184  my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
185  my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
186endif
187
188ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
189  my_clang :=
190endif
191
192# Add in libcompiler_rt for all regular device builds
193ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
194  my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
195endif
196
197####################################################
198## Add FDO flags if FDO is turned on and supported
199####################################################
200ifneq ($(strip $(LOCAL_FDO_SUPPORT)),)
201  ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
202    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
203    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
204  endif
205endif
206
207###########################################################
208## Explicitly declare assembly-only __ASSEMBLY__ macro for
209## assembly source
210###########################################################
211my_asflags += -D__ASSEMBLY__
212
213
214##########################################################
215## Set up installed module dependency
216## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
217## they may cusomize their install path with LOCAL_MODULE_PATH
218##########################################################
219# Get the list of INSTALLED libraries as module names.
220ifdef LOCAL_SDK_VERSION
221  installed_shared_library_module_names := \
222      $(my_shared_libraries)
223else
224  installed_shared_library_module_names := \
225      $(my_system_shared_libraries) $(my_shared_libraries)
226endif
227installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
228
229# The real dependency will be added after all Android.mks are loaded and the install paths
230# of the shared libraries are determined.
231ifdef LOCAL_INSTALLED_MODULE
232ifdef installed_shared_library_module_names
233$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
234    $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
235endif
236endif
237
238###########################################################
239## Define PRIVATE_ variables from global vars
240###########################################################
241ifndef LOCAL_IS_HOST_MODULE
242ifdef LOCAL_SDK_VERSION
243my_target_project_includes :=
244my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
245my_target_global_cppflags := $(my_ndk_stl_cppflags)
246else
247my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
248my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
249my_target_global_cppflags :=
250endif # LOCAL_SDK_VERSION
251
252ifeq ($(my_clang),true)
253my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
254my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
255my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
256else
257my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
258my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
259my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
260endif # my_clang
261
262# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
263# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
264# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
265# clean build of your module after toggling it.
266ifeq ($(NATIVE_COVERAGE),true)
267    ifeq ($(my_native_coverage),true)
268        # We can't currently generate coverage for clang binaries for two
269        # reasons:
270        #
271        # 1) b/17574078 We currently don't have a prebuilt
272        #    libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if
273        #    --coverage is passed in the link stage. For now we manually link
274        #    libprofile_rt (which is the name it is built as from
275        #    external/compiler-rt).
276        #
277        # 2) b/17583330 Clang doesn't generate .gcno files when using
278        #    -no-integrated-as. Since most of the assembly in our tree is
279        #    incompatible with clang's assembler, we can't turn off this flag.
280        ifneq ($(my_clang),true)
281            my_cflags += --coverage -O0
282            my_ldflags += --coverage
283        endif
284    endif
285else
286    my_native_coverage := false
287endif
288
289$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
290$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
291$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
292$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
293$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
294
295else # LOCAL_IS_HOST_MODULE
296
297ifeq ($(my_clang),true)
298my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
299my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
300my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
301my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
302else
303my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
304my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
305my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
306my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
307endif # my_clang
308
309$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
310$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
311$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
312$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
313endif # LOCAL_IS_HOST_MODULE
314
315###########################################################
316## Define PRIVATE_ variables used by multiple module types
317###########################################################
318$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
319    $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
320
321ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
322  LOCAL_NO_SYNTAX_CHECK := true
323endif
324
325ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
326  LOCAL_NO_STATIC_ANALYZER := true
327endif
328
329ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
330  my_syntax_arch := host
331else
332  my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
333endif
334
335ifeq ($(strip $(my_cc)),)
336  ifeq ($(my_clang),true)
337    my_cc := $(CLANG)
338  else
339    my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
340  endif
341endif
342ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
343  my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
344else
345ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
346  my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
347endif
348endif
349$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
350
351ifeq ($(strip $(my_cxx)),)
352  ifeq ($(my_clang),true)
353    my_cxx := $(CLANG_CXX)
354  else
355    my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
356  endif
357endif
358ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
359  my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
360else
361ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
362  my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
363endif
364endif
365$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
366$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
367
368# TODO: support a mix of standard extensions so that this isn't necessary
369LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
370ifeq ($(LOCAL_CPP_EXTENSION),)
371  LOCAL_CPP_EXTENSION := .cpp
372endif
373$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
374
375# Certain modules like libdl have to have symbols resolved at runtime and blow
376# up if --no-undefined is passed to the linker.
377ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
378ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
379  my_ldflags +=  $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
380endif
381endif
382
383ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
384$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
385else
386$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
387endif
388
389###########################################################
390## Define arm-vs-thumb-mode flags.
391###########################################################
392LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
393ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
394arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
395normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
396
397# Read the values from something like TARGET_arm_CFLAGS or
398# TARGET_thumb_CFLAGS.  HOST_(arm|thumb)_CFLAGS values aren't
399# actually used (although they are usually empty).
400arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
401normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
402ifeq ($(my_clang),true)
403arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
404normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
405endif
406
407else
408arm_objects_mode :=
409normal_objects_mode :=
410arm_objects_cflags :=
411normal_objects_cflags :=
412endif
413
414###########################################################
415## Define per-module debugging flags.  Users can turn on
416## debugging for a particular module by setting DEBUG_MODULE_ModuleName
417## to a non-empty value in their environment or buildspec.mk,
418## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
419## debug flags that they want to use.
420###########################################################
421ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
422  debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
423else
424  debug_cflags :=
425endif
426
427####################################################
428## Compile RenderScript with reflected C++
429####################################################
430
431renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
432
433ifneq (,$(renderscript_sources))
434
435renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
436RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
437renderscript_intermediate := $(intermediates)/renderscript
438
439ifeq ($(LOCAL_RENDERSCRIPT_CC),)
440LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
441endif
442
443# Turn on all warnings and warnings as errors for RS compiles.
444# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
445renderscript_flags := -Wall -Werror
446renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
447
448renderscript_includes := \
449    $(TOPDIR)external/clang/lib/Headers \
450    $(TOPDIR)frameworks/rs/scriptc \
451    $(LOCAL_RENDERSCRIPT_INCLUDES)
452
453ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
454renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
455endif
456
457$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
458$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
459$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
460$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
461$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
462$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
463	$(transform-renderscripts-to-cpp-and-bc)
464
465# include the dependency files (.d) generated by llvm-rs-cc.
466renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
467    $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
468-include $(renderscript_generated_dep_files)
469
470LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
471
472rs_generated_cpps := $(addprefix \
473    $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
474    $(notdir $(renderscript_sources)))))
475
476# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
477$(rs_generated_cpps) : $(RenderScript_file_stamp)
478	@echo "Updated RS generated cpp file $@."
479
480my_c_includes += $(renderscript_intermediate)
481my_generated_sources += $(rs_generated_cpps)
482
483endif
484
485
486###########################################################
487## Stuff source generated from one-off tools
488###########################################################
489$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
490
491my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
492
493$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
494	@echo "Copy: $@"
495	$(copy-file-to-target)
496
497my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
498
499ALL_GENERATED_SOURCES += $(my_generated_sources)
500
501###########################################################
502## Compile the .proto files to .cc and then to .o
503###########################################################
504proto_sources := $(filter %.proto,$(my_src_files))
505proto_generated_objects :=
506proto_generated_headers :=
507ifneq ($(proto_sources),)
508proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
509proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
510proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
511    $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
512proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
513proto_generated_obj_dir := $(intermediates)/proto
514proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
515    $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
516
517# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
518ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
519$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
520$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
521$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
522$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
523	$(transform-proto-to-cc)
524
525# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
526$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
527	@echo "Updated header file $@."
528
529$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
530endif  # transform-proto-to-cc rule included only once
531
532$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
533$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
534$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
535	$(transform-$(PRIVATE_HOST)cpp-to-o)
536-include $(proto_generated_objects:%.o=%.P)
537
538my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
539my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
540ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
541my_static_libraries += libprotobuf-cpp-2.3.0-full
542else
543my_static_libraries += libprotobuf-cpp-2.3.0-lite
544endif
545endif  # $(proto_sources) non-empty
546
547
548###########################################################
549## YACC: Compile .y and .yy files to .cpp and the to .o.
550###########################################################
551
552y_yacc_sources := $(filter %.y,$(my_src_files))
553y_yacc_cpps := $(addprefix \
554    $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
555
556yy_yacc_sources := $(filter %.yy,$(my_src_files))
557yy_yacc_cpps := $(addprefix \
558    $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
559
560yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
561yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
562yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
563
564ifneq ($(strip $(y_yacc_cpps)),)
565$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
566    $(TOPDIR)$(LOCAL_PATH)/%.y \
567    $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
568	$(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
569$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
570endif
571
572ifneq ($(strip $(yy_yacc_cpps)),)
573$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
574    $(TOPDIR)$(LOCAL_PATH)/%.yy \
575    $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
576	$(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
577$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
578endif
579
580ifneq ($(strip $(yacc_cpps)),)
581$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
582$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
583$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
584	$(transform-$(PRIVATE_HOST)cpp-to-o)
585endif
586
587###########################################################
588## LEX: Compile .l and .ll files to .cpp and then to .o.
589###########################################################
590
591l_lex_sources := $(filter %.l,$(my_src_files))
592l_lex_cpps := $(addprefix \
593    $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
594
595ll_lex_sources := $(filter %.ll,$(my_src_files))
596ll_lex_cpps := $(addprefix \
597    $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
598
599lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
600lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
601
602ifneq ($(strip $(l_lex_cpps)),)
603$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
604    $(TOPDIR)$(LOCAL_PATH)/%.l
605	$(transform-l-to-cpp)
606endif
607
608ifneq ($(strip $(ll_lex_cpps)),)
609$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
610    $(TOPDIR)$(LOCAL_PATH)/%.ll
611	$(transform-l-to-cpp)
612endif
613
614ifneq ($(strip $(lex_cpps)),)
615$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
616$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
617$(lex_objects): $(intermediates)/%.o: \
618    $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
619    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
620    $(yacc_headers)
621	$(transform-$(PRIVATE_HOST)cpp-to-o)
622endif
623
624###########################################################
625## C++: Compile .cpp files to .o.
626###########################################################
627
628# we also do this on host modules, even though
629# it's not really arm, because there are files that are shared.
630cpp_arm_sources    := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
631cpp_arm_objects    := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
632
633cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
634cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
635
636$(cpp_arm_objects):    PRIVATE_ARM_MODE := $(arm_objects_mode)
637$(cpp_arm_objects):    PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
638$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
639$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
640
641cpp_objects        := $(cpp_arm_objects) $(cpp_normal_objects)
642
643ifneq ($(strip $(cpp_objects)),)
644$(cpp_objects): $(intermediates)/%.o: \
645    $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
646    $(yacc_cpps) $(proto_generated_headers) \
647    $(LOCAL_ADDITIONAL_DEPENDENCIES)
648	$(transform-$(PRIVATE_HOST)cpp-to-o)
649-include $(cpp_objects:%.o=%.P)
650endif
651
652###########################################################
653## C++: Compile generated .cpp files to .o.
654###########################################################
655
656gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
657gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
658
659ifneq ($(strip $(gen_cpp_objects)),)
660# Compile all generated files as thumb.
661# TODO: support compiling certain generated files as arm.
662$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
663$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
664$(gen_cpp_objects): $(intermediates)/%.o: \
665    $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
666    $(proto_generated_headers) \
667    $(LOCAL_ADDITIONAL_DEPENDENCIES)
668	$(transform-$(PRIVATE_HOST)cpp-to-o)
669-include $(gen_cpp_objects:%.o=%.P)
670endif
671
672###########################################################
673## S: Compile generated .S and .s files to .o.
674###########################################################
675
676gen_S_sources := $(filter %.S,$(my_generated_sources))
677gen_S_objects := $(gen_S_sources:%.S=%.o)
678
679ifneq ($(strip $(gen_S_sources)),)
680$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
681    $(LOCAL_ADDITIONAL_DEPENDENCIES)
682	$(transform-$(PRIVATE_HOST)s-to-o)
683-include $(gen_S_objects:%.o=%.P)
684endif
685
686gen_s_sources := $(filter %.s,$(my_generated_sources))
687gen_s_objects := $(gen_s_sources:%.s=%.o)
688
689ifneq ($(strip $(gen_s_objects)),)
690$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
691    $(LOCAL_ADDITIONAL_DEPENDENCIES)
692	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
693-include $(gen_s_objects:%.o=%.P)
694endif
695
696gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
697
698###########################################################
699## o: Include generated .o files in output.
700###########################################################
701
702gen_o_objects := $(filter %.o,$(my_generated_sources))
703
704###########################################################
705## C: Compile .c files to .o.
706###########################################################
707
708c_arm_sources    := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
709c_arm_objects    := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
710
711c_normal_sources := $(filter %.c,$(my_src_files))
712c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
713
714$(c_arm_objects):    PRIVATE_ARM_MODE := $(arm_objects_mode)
715$(c_arm_objects):    PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
716$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
717$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
718
719c_objects        := $(c_arm_objects) $(c_normal_objects)
720
721ifneq ($(strip $(c_objects)),)
722$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
723    $(LOCAL_ADDITIONAL_DEPENDENCIES)
724	$(transform-$(PRIVATE_HOST)c-to-o)
725-include $(c_objects:%.o=%.P)
726endif
727
728###########################################################
729## C: Compile generated .c files to .o.
730###########################################################
731
732gen_c_sources := $(filter %.c,$(my_generated_sources))
733gen_c_objects := $(gen_c_sources:%.c=%.o)
734
735ifneq ($(strip $(gen_c_objects)),)
736# Compile all generated files as thumb.
737# TODO: support compiling certain generated files as arm.
738$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
739$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
740$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
741    $(LOCAL_ADDITIONAL_DEPENDENCIES)
742	$(transform-$(PRIVATE_HOST)c-to-o)
743-include $(gen_c_objects:%.o=%.P)
744endif
745
746###########################################################
747## ObjC: Compile .m files to .o
748###########################################################
749
750objc_sources := $(filter %.m,$(my_src_files))
751objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
752
753ifneq ($(strip $(objc_objects)),)
754$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
755    $(LOCAL_ADDITIONAL_DEPENDENCIES)
756	$(transform-$(PRIVATE_HOST)m-to-o)
757-include $(objc_objects:%.o=%.P)
758endif
759
760###########################################################
761## AS: Compile .S files to .o.
762###########################################################
763
764asm_sources_S := $(filter %.S,$(my_src_files))
765asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
766
767ifneq ($(strip $(asm_objects_S)),)
768$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
769    $(LOCAL_ADDITIONAL_DEPENDENCIES)
770	$(transform-$(PRIVATE_HOST)s-to-o)
771-include $(asm_objects_S:%.o=%.P)
772endif
773
774asm_sources_s := $(filter %.s,$(my_src_files))
775asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
776
777ifneq ($(strip $(asm_objects_s)),)
778$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
779    $(LOCAL_ADDITIONAL_DEPENDENCIES)
780	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
781-include $(asm_objects_s:%.o=%.P)
782endif
783
784asm_objects := $(asm_objects_S) $(asm_objects_s)
785
786
787# .asm for x86 needs to be compiled with yasm.
788ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
789asm_sources_asm := $(filter %.asm,$(my_src_files))
790ifneq ($(strip $(asm_sources_asm)),)
791asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
792$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
793    $(LOCAL_ADDITIONAL_DEPENDENCIES)
794	$(transform-asm-to-o)
795
796asm_objects += $(asm_objects_asm)
797endif
798endif
799
800####################################################
801## Import includes
802####################################################
803import_includes := $(intermediates)/import_includes
804import_includes_deps := $(strip \
805    $(foreach l, $(installed_shared_library_module_names), \
806      $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \
807    $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
808      $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
809$(import_includes) : $(import_includes_deps)
810	@echo Import includes file: $@
811	$(hide) mkdir -p $(dir $@) && rm -f $@
812ifdef import_includes_deps
813	$(hide) for f in $^; do \
814	  cat $$f >> $@; \
815	done
816else
817	$(hide) touch $@
818endif
819
820###########################################################
821## Common object handling.
822###########################################################
823
824# some rules depend on asm_objects being first.  If your code depends on
825# being first, it's reasonable to require it to be assembly
826normal_objects := \
827    $(asm_objects) \
828    $(cpp_objects) \
829    $(gen_cpp_objects) \
830    $(gen_asm_objects) \
831    $(c_objects) \
832    $(gen_c_objects) \
833    $(objc_objects) \
834    $(yacc_objects) \
835    $(lex_objects) \
836    $(proto_generated_objects) \
837    $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
838
839all_objects := $(normal_objects) $(gen_o_objects)
840
841my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
842
843ifndef LOCAL_SDK_VERSION
844  my_c_includes += $(JNI_H_INCLUDE)
845endif
846
847# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
848# use normal_objects here to avoid creating circular dependencies. This assumes
849# that custom build rules which generate .o files don't consume other generated
850# sources as input (or if they do they take care of that dependency themselves).
851$(normal_objects) : | $(my_generated_sources)
852$(all_objects) : | $(import_includes)
853ALL_C_CPP_ETC_OBJECTS += $(all_objects)
854
855
856###########################################################
857# Standard library handling.
858###########################################################
859
860###########################################################
861# The list of libraries that this module will link against are in
862# these variables.  Each is a list of bare module names like "libc libm".
863#
864# LOCAL_SHARED_LIBRARIES
865# LOCAL_STATIC_LIBRARIES
866# LOCAL_WHOLE_STATIC_LIBRARIES
867#
868# We need to convert the bare names into the dependencies that
869# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
870# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
871# libraries, so that simply building this module doesn't force
872# an install of a library.  Similarly, LOCAL_INSTALLED_MODULE
873# should depend on the INSTALLED versions of the libraries so
874# that they get installed when this module does.
875###########################################################
876# NOTE:
877# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
878# module without leaving anything out, which is useful for turning
879# a collection of .a files into a .so file.  Linking against a
880# normal STATIC_LIBRARY will only pull in code/symbols that are
881# referenced by the module. (see gcc/ld's --whole-archive option)
882###########################################################
883
884# Get the list of BUILT libraries, which are under
885# various intermediates directories.
886so_suffix := $($(my_prefix)SHLIB_SUFFIX)
887a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
888
889ifdef LOCAL_SDK_VERSION
890built_shared_libraries := \
891    $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
892      $(addsuffix $(so_suffix), \
893        $(my_shared_libraries)))
894
895# Add the NDK libraries to the built module dependency
896my_system_shared_libraries_fullpath := \
897    $(my_ndk_stl_shared_lib_fullpath) \
898    $(addprefix $(my_ndk_sysroot_lib)/, \
899        $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
900
901built_shared_libraries += $(my_system_shared_libraries_fullpath)
902else
903built_shared_libraries := \
904    $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
905      $(addsuffix $(so_suffix), \
906        $(installed_shared_library_module_names)))
907endif
908
909built_static_libraries := \
910    $(foreach lib,$(my_static_libraries), \
911      $(call intermediates-dir-for, \
912        STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
913
914ifdef LOCAL_SDK_VERSION
915built_static_libraries += $(my_ndk_stl_static_lib)
916endif
917
918built_whole_libraries := \
919    $(foreach lib,$(my_whole_static_libraries), \
920      $(call intermediates-dir-for, \
921        STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
922
923# We don't care about installed static libraries, since the
924# libraries have already been linked into the module at that point.
925# We do, however, care about the NOTICE files for any static
926# libraries that we use. (see notice_files.mk)
927
928installed_static_library_notice_file_targets := \
929    $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
930      NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
931
932# Default is -fno-rtti.
933ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
934LOCAL_RTTI_FLAG := -fno-rtti
935endif
936
937###########################################################
938# Rule-specific variable definitions
939###########################################################
940
941ifeq ($(my_clang),true)
942my_cflags += $(LOCAL_CLANG_CFLAGS)
943my_cpplags += $(LOCAL_CLANG_CPPFLAGS)
944my_asflags += $(LOCAL_CLANG_ASFLAGS)
945my_ldflags += $(LOCAL_CLANG_LDFLAGS)
946my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
947my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
948my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
949my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
950my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
951my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
952my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
953my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
954endif
955
956$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
957$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
958$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
959$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
960$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
961$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
962$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
963$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
964$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
965$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
966$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
967$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
968$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
969
970# this is really the way to get the files onto the command line instead
971# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
972$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
973$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
974$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
975$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
976
977###########################################################
978# Define library dependencies.
979###########################################################
980# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
981all_libraries := \
982    $(built_shared_libraries) \
983    $(built_static_libraries) \
984    $(built_whole_libraries)
985
986# Also depend on the notice files for any static libraries that
987# are linked into this module.  This will force them to be installed
988# when this module is.
989$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
990
991###########################################################
992# Export includes
993###########################################################
994export_includes := $(intermediates)/export_includes
995$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
996$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
997	@echo Export includes file: $< -- $@
998	$(hide) mkdir -p $(dir $@) && rm -f $@
999ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
1000	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1001	        echo "-I $$d" >> $@; \
1002	        done
1003else
1004	$(hide) touch $@
1005endif
1006
1007# Make sure export_includes gets generated when you are running mm/mmm
1008$(LOCAL_BUILT_MODULE) : | $(export_includes)
1009