blob: ed09a2433c5eea20171b8915eb559eed3dcde2ae [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building binary object files from
Ying Wangd8d37212014-03-21 16:17:04 -07003## asm/c/cpp/yacc/lex/etc source files.
The Android Open Source Project88b60792009-03-03 19:28:42 -08004##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
Ying Wangd8d37212014-03-21 16:17:04 -07008#######################################
9include $(BUILD_SYSTEM)/base_rules.mk
10#######################################
11
Andrew Hsieh140761af02014-04-25 23:47:10 -070012my_ndk_sysroot :=
13my_ndk_sysroot_include :=
14my_ndk_sysroot_lib :=
Ying Wang848020f2012-08-14 10:13:16 -070015ifdef LOCAL_SDK_VERSION
Ying Wangfe1bfe72012-08-14 11:08:03 -070016 ifdef LOCAL_NDK_VERSION
17 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
18 endif
Ying Wang1a081002010-07-13 14:55:47 -070019 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070020 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070021 endif
Ying Wang848020f2012-08-14 10:13:16 -070022 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
Andrew Hsieh140761af02014-04-25 23:47:10 -070023 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
Ying Wangcce4c972011-03-03 18:53:53 -080030
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 :=
Andrew Hsieh73d800e2014-03-04 17:11:52 +080037 my_ndk_stl_cppflags :=
38 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -080039 ifeq (,$(LOCAL_NDK_STL_VARIANT))
40 LOCAL_NDK_STL_VARIANT := system
41 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080042 ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -070043 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -080044 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))
Ying Wang6ef65192014-01-15 16:02:16 -080052 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a
Ying Wangcce4c972011-03-03 18:53:53 -080053 else
Ying Wang6ef65192014-01-15 16:02:16 -080054 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
Ying Wangcce4c972011-03-03 18:53:53 -080055 my_ndk_stl_shared_lib := -lstlport_shared
56 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080057 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
Ying Wangcce4c972011-03-03 18:53:53 -080069 else
70 # LOCAL_NDK_STL_VARIANT is gnustl_static
Ben Cheng4de6fa42014-04-10 22:46:26 -070071 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
Ying Wangcce4c972011-03-03 18:53:53 -080074 endif
75 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080076 endif
Ying Wang1a081002010-07-13 14:55:47 -070077endif
78
Ying Wang704c0c92011-09-15 13:50:52 -070079##################################################
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)
Ying Wangd8d37212014-03-21 16:17:04 -070088 my_system_shared_libraries :=
89 else
90 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang704c0c92011-09-15 13:50:52 -070091 endif
92else
93 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wangd8d37212014-03-21 16:17:04 -070094 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)
Ying Wang704c0c92011-09-15 13:50:52 -070097 endif
98endif
99
Ying Wang6ef65192014-01-15 16:02:16 -0800100# 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.
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800103my_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)
Ying Wang6ef65192014-01-15 16:02:16 -0800108my_cppflags := $(LOCAL_CPPFLAGS)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800109my_ldflags := $(LOCAL_LDFLAGS)
Dan Albertb05f2ca2014-09-12 14:46:57 -0700110my_ldlibs := $(LOCAL_LDLIBS)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800111my_asflags := $(LOCAL_ASFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800112my_cc := $(LOCAL_CC)
113my_cxx := $(LOCAL_CXX)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800114my_c_includes := $(LOCAL_C_INCLUDES)
115my_generated_sources := $(LOCAL_GENERATED_SOURCES)
Dan Albert4bbc6c72014-09-19 14:25:57 -0700116my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800117
Dan Albert95994de2014-08-07 18:29:11 -0700118# 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.
Ying Wang594a10a2014-08-07 20:08:04 -0700121ifndef USE_MINGW
Dan Albert4803ce22014-08-06 12:36:46 -0700122ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
123my_cflags += -fpie
124else
125my_cflags += -fPIC
126endif
Dan Albert95994de2014-08-07 18:29:11 -0700127endif
Dan Albert4803ce22014-08-06 12:36:46 -0700128
Ying Wang6feb6d52014-04-17 10:03:35 -0700129my_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))
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800137
Dan Albertdb905e72014-08-18 11:14:38 -0700138my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700139ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700140my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700141endif
142ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700143my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700144endif
145
Tim Murray92d79cb2014-04-04 14:38:29 -0700146# clang is enabled by default for host builds
147# enable it unless we've specifically disabled clang above
148ifdef LOCAL_IS_HOST_MODULE
Tim Murrayf3ca3d52014-07-24 15:20:18 -0700149 ifneq ($(HOST_OS),windows)
Tim Murray5ca1dc12014-07-24 14:42:53 -0700150 ifeq ($(my_clang),)
151 my_clang := true
152 endif
153 endif
Tim Murray92d79cb2014-04-04 14:38:29 -0700154endif
155
Tim Murray06659bc2014-08-13 11:53:07 -0700156# 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
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800163# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700164my_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)
Ying Wang6ef65192014-01-15 16:02:16 -0800166
Ying Wang6feb6d52014-04-17 10:03:35 -0700167my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
Ying Wang6ef65192014-01-15 16:02:16 -0800168
Ying Wang75e8fcb2014-10-07 13:03:29 -0700169include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700170
Ying Wang285045b2013-08-13 12:35:10 -0700171# 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)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800175 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
176 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700177b_lib :=
178endif
179
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400180ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700181 my_clang := true
Evgeniy Stepanov5d8029f2014-02-21 18:10:53 +0400182 # Frame pointer based unwinder in ASan requires ARM frame setup.
183 LOCAL_ARM_MODE := arm
Ying Wang6ef65192014-01-15 16:02:16 -0800184 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
185 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
186 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
187 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400188endif
189
Ying Wangba8b3772014-03-10 18:23:08 -0700190ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700191 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700192endif
193
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800194# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700195ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800196 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700197endif
198
Jing Yu2dcc8062009-09-21 16:31:50 -0700199####################################################
200## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700201## Please note that we will do option filtering during FDO build.
202## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
203##################################################################
Dehao Chenf7a909d2014-08-07 16:53:18 -0700204ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
synergydev4a605762013-08-05 02:44:37 -0700205 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800206 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
Dehao Chenf4294cd2014-08-20 16:48:17 -0700207 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700208 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700209endif
210
The Android Open Source Project88b60792009-03-03 19:28:42 -0800211###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800212## Explicitly declare assembly-only __ASSEMBLY__ macro for
213## assembly source
214###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800215my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800216
Ying Wangd8d37212014-03-21 16:17:04 -0700217
218##########################################################
219## Set up installed module dependency
220## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
221## they may cusomize their install path with LOCAL_MODULE_PATH
222##########################################################
223# Get the list of INSTALLED libraries as module names.
224ifdef LOCAL_SDK_VERSION
225 installed_shared_library_module_names := \
226 $(my_shared_libraries)
227else
228 installed_shared_library_module_names := \
229 $(my_system_shared_libraries) $(my_shared_libraries)
230endif
231installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
232
233# The real dependency will be added after all Android.mks are loaded and the install paths
234# of the shared libraries are determined.
235ifdef LOCAL_INSTALLED_MODULE
236ifdef installed_shared_library_module_names
237$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wange1b867d2014-06-10 14:21:20 -0700238 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wangd8d37212014-03-21 16:17:04 -0700239endif
240endif
241
Jim Huang20d1ba62010-10-14 16:15:56 +0800242###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700243## Define PRIVATE_ variables from global vars
244###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800245ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700246ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700247my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700248my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800249my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700250else
Ying Wang6ef65192014-01-15 16:02:16 -0800251my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
252my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800253my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700254endif # LOCAL_SDK_VERSION
255
Ying Wang824344a2014-05-27 13:03:36 -0700256ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800257my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800258my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800259my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700260else
Ying Wang6ef65192014-01-15 16:02:16 -0800261my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800262my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800263my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700264endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700265
Dan Albert4c12c032014-10-07 23:37:53 -0700266# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
267# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
268# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
269# clean build of your module after toggling it.
Dan Albert4bbc6c72014-09-19 14:25:57 -0700270ifeq ($(NATIVE_COVERAGE),true)
271 ifeq ($(my_native_coverage),true)
272 # We can't currently generate coverage for clang binaries for two
273 # reasons:
274 #
275 # 1) b/17574078 We currently don't have a prebuilt
276 # libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if
277 # --coverage is passed in the link stage. For now we manually link
278 # libprofile_rt (which is the name it is built as from
279 # external/compiler-rt).
280 #
281 # 2) b/17583330 Clang doesn't generate .gcno files when using
282 # -no-integrated-as. Since most of the assembly in our tree is
283 # incompatible with clang's assembler, we can't turn off this flag.
284 ifneq ($(my_clang),true)
Dan Albert4c12c032014-10-07 23:37:53 -0700285 my_cflags += --coverage -O0
286 my_ldflags += --coverage
Dan Albert4bbc6c72014-09-19 14:25:57 -0700287 endif
288 endif
289else
290 my_native_coverage := false
291endif
292
Ying Wang1a081002010-07-13 14:55:47 -0700293$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400294$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700295$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800296$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
297$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
298
Ying Wang7fff9a12014-01-09 14:39:41 -0800299else # LOCAL_IS_HOST_MODULE
300
Ying Wang824344a2014-05-27 13:03:36 -0700301ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700302my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
303my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
304my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
Stephen Hinesf0089662014-09-25 22:35:16 -0700305my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800306else
Ying Wang6feb6d52014-04-17 10:03:35 -0700307my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
308my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
309my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
310my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700311endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800312
313$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
314$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
315$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
316$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
317endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700318
319###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800320## Define PRIVATE_ variables used by multiple module types
321###########################################################
322$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700323 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800324
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800325ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
326 LOCAL_NO_SYNTAX_CHECK := true
327endif
328
Andrew Hsieh906cb782013-09-10 17:37:14 +0800329ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
330 LOCAL_NO_STATIC_ANALYZER := true
331endif
332
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800333ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
334 my_syntax_arch := host
335else
Ying Wang6ef65192014-01-15 16:02:16 -0800336 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800337endif
338
Ying Wang6ef65192014-01-15 16:02:16 -0800339ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700340 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800341 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400342 else
Ying Wang6ef65192014-01-15 16:02:16 -0800343 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400344 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800345endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800346ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800347 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800348else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800349ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800350 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800351endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800352endif
Ying Wang6ef65192014-01-15 16:02:16 -0800353$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800354
Ying Wang6ef65192014-01-15 16:02:16 -0800355ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700356 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800357 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400358 else
Ying Wang6ef65192014-01-15 16:02:16 -0800359 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400360 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800361endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800362ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800363 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800364else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800365ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800366 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800367endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800368endif
Ying Wang6ef65192014-01-15 16:02:16 -0800369$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700370$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800371
372# TODO: support a mix of standard extensions so that this isn't necessary
373LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
374ifeq ($(LOCAL_CPP_EXTENSION),)
375 LOCAL_CPP_EXTENSION := .cpp
376endif
377$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
378
379# Certain modules like libdl have to have symbols resolved at runtime and blow
380# up if --no-undefined is passed to the linker.
381ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
382ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800383 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800384endif
385endif
386
Ying Wangfcdabd42011-04-25 14:22:41 -0700387ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
388$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
389else
390$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
391endif
392
The Android Open Source Project88b60792009-03-03 19:28:42 -0800393###########################################################
394## Define arm-vs-thumb-mode flags.
395###########################################################
396LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800397ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800398arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
399normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
400
Dave Bort95282482009-04-23 18:44:55 -0700401# Read the values from something like TARGET_arm_CFLAGS or
402# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
403# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800404arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
405normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700406ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800407arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
408normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400409endif
410
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800411else
412arm_objects_mode :=
413normal_objects_mode :=
414arm_objects_cflags :=
415normal_objects_cflags :=
416endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800417
418###########################################################
419## Define per-module debugging flags. Users can turn on
420## debugging for a particular module by setting DEBUG_MODULE_ModuleName
421## to a non-empty value in their environment or buildspec.mk,
422## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
423## debug flags that they want to use.
424###########################################################
425ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
426 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
427else
428 debug_cflags :=
429endif
430
Tim Murraya7aa8002012-10-29 16:06:00 -0700431####################################################
432## Compile RenderScript with reflected C++
433####################################################
434
Ying Wangb8e01852014-01-23 15:09:04 -0800435renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700436
437ifneq (,$(renderscript_sources))
438
439renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
440RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
441renderscript_intermediate := $(intermediates)/renderscript
442
443ifeq ($(LOCAL_RENDERSCRIPT_CC),)
444LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
445endif
446
447# Turn on all warnings and warnings as errors for RS compiles.
448# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
449renderscript_flags := -Wall -Werror
450renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700451# -m32 or -m64
452renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700453
Ying Wang6ef65192014-01-15 16:02:16 -0800454renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700455 $(TOPDIR)external/clang/lib/Headers \
456 $(TOPDIR)frameworks/rs/scriptc \
457 $(LOCAL_RENDERSCRIPT_INCLUDES)
458
459ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800460renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700461endif
462
Ying Wang6ef65192014-01-15 16:02:16 -0800463$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700464$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
465$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
466$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
467$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
468$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
469 $(transform-renderscripts-to-cpp-and-bc)
470
471# include the dependency files (.d) generated by llvm-rs-cc.
472renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
473 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
474-include $(renderscript_generated_dep_files)
475
476LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
477
478rs_generated_cpps := $(addprefix \
479 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
480 $(notdir $(renderscript_sources)))))
481
Stephen Hines8ff92522014-06-06 12:51:47 -0700482# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700483$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700484 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700485
Ying Wang6ef65192014-01-15 16:02:16 -0800486my_c_includes += $(renderscript_intermediate)
487my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700488
489endif
490
491
The Android Open Source Project88b60792009-03-03 19:28:42 -0800492###########################################################
493## Stuff source generated from one-off tools
494###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800495$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800496
Colin Crossd8262642014-01-24 23:17:21 -0800497my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800498
Colin Crossd8262642014-01-24 23:17:21 -0800499$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
500 @echo "Copy: $@"
501 $(copy-file-to-target)
502
503my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
504
505ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800506
507###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700508## Compile the .proto files to .cc and then to .o
509###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800510proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700511proto_generated_objects :=
512proto_generated_headers :=
513ifneq ($(proto_sources),)
514proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangead89442014-02-25 11:18:40 -0800515proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
Ying Wanga5fc87a2010-11-02 18:43:16 -0700516proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700517 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wangead89442014-02-25 11:18:40 -0800518proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
519proto_generated_obj_dir := $(intermediates)/proto
520proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
521 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700522
Ying Wang49085952014-05-06 13:03:32 -0700523# Auto-export the generated proto source dir.
524LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir)
525
Ying Wangead89442014-02-25 11:18:40 -0800526# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
527ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wanga5fc87a2010-11-02 18:43:16 -0700528$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
529$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700530$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700531$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
532 $(transform-proto-to-cc)
533
Stephen Hines8ff92522014-06-06 12:51:47 -0700534# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wanga5fc87a2010-11-02 18:43:16 -0700535$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
Ying Wang81ab8332014-05-28 16:17:09 -0700536 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700537
Ying Wangead89442014-02-25 11:18:40 -0800538$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
539endif # transform-proto-to-cc rule included only once
540
Ying Wang022a7b32012-06-13 11:38:10 -0700541$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
542$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wangead89442014-02-25 11:18:40 -0800543$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700544 $(transform-$(PRIVATE_HOST)cpp-to-o)
545-include $(proto_generated_objects:%.o=%.P)
546
Ying Wang6ef65192014-01-15 16:02:16 -0800547my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
548my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700549ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800550my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700551else
Ying Wang6ef65192014-01-15 16:02:16 -0800552my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700553endif
Ying Wangead89442014-02-25 11:18:40 -0800554endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700555
556
557###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000558## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800559###########################################################
560
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000561y_yacc_sources := $(filter %.y,$(my_src_files))
562y_yacc_cpps := $(addprefix \
563 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
564
565yy_yacc_sources := $(filter %.yy,$(my_src_files))
566yy_yacc_cpps := $(addprefix \
567 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
568
569yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800570yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
571yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
572
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000573ifneq ($(strip $(y_yacc_cpps)),)
574$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700575 $(TOPDIR)$(LOCAL_PATH)/%.y \
576 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800577 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
578$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000579endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000581ifneq ($(strip $(yy_yacc_cpps)),)
582$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
583 $(TOPDIR)$(LOCAL_PATH)/%.yy \
584 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
585 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
586$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
587endif
588
589ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800590$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
591$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
592$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
593 $(transform-$(PRIVATE_HOST)cpp-to-o)
594endif
595
596###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000597## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800598###########################################################
599
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000600l_lex_sources := $(filter %.l,$(my_src_files))
601l_lex_cpps := $(addprefix \
602 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
603
604ll_lex_sources := $(filter %.ll,$(my_src_files))
605ll_lex_cpps := $(addprefix \
606 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
607
608lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800609lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
610
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000611ifneq ($(strip $(l_lex_cpps)),)
612$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700613 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800614 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000615endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800616
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000617ifneq ($(strip $(ll_lex_cpps)),)
618$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
619 $(TOPDIR)$(LOCAL_PATH)/%.ll
620 $(transform-l-to-cpp)
621endif
622
623ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800624$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
625$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
626$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700627 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
628 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
629 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630 $(transform-$(PRIVATE_HOST)cpp-to-o)
631endif
632
633###########################################################
634## C++: Compile .cpp files to .o.
635###########################################################
636
Jeff Browne33ba4c2011-07-11 22:11:46 -0700637# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800638# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800639cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800640cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
641
Ying Wangb8e01852014-01-23 15:09:04 -0800642cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800643cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
644
645$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
646$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
647$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
648$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
649
650cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
651
652ifneq ($(strip $(cpp_objects)),)
653$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700654 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800655 $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700656 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800657 $(transform-$(PRIVATE_HOST)cpp-to-o)
658-include $(cpp_objects:%.o=%.P)
659endif
660
661###########################################################
662## C++: Compile generated .cpp files to .o.
663###########################################################
664
Ying Wangec6d6262014-01-16 16:21:03 -0800665gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800666gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
667
668ifneq ($(strip $(gen_cpp_objects)),)
669# Compile all generated files as thumb.
670# TODO: support compiling certain generated files as arm.
671$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
672$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400673$(gen_cpp_objects): $(intermediates)/%.o: \
674 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800675 $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700676 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800677 $(transform-$(PRIVATE_HOST)cpp-to-o)
678-include $(gen_cpp_objects:%.o=%.P)
679endif
680
681###########################################################
682## S: Compile generated .S and .s files to .o.
683###########################################################
684
Ying Wangec6d6262014-01-16 16:21:03 -0800685gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686gen_S_objects := $(gen_S_sources:%.S=%.o)
687
688ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400689$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Alberta8fd6682014-10-03 13:29:42 -0700690 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800691 $(transform-$(PRIVATE_HOST)s-to-o)
692-include $(gen_S_objects:%.o=%.P)
693endif
694
Ying Wangec6d6262014-01-16 16:21:03 -0800695gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800696gen_s_objects := $(gen_s_sources:%.s=%.o)
697
698ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400699$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Alberta8fd6682014-10-03 13:29:42 -0700700 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800701 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
702-include $(gen_s_objects:%.o=%.P)
703endif
704
705gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
706
707###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000708## o: Include generated .o files in output.
709###########################################################
710
Ying Wangec6d6262014-01-16 16:21:03 -0800711gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000712
713###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714## C: Compile .c files to .o.
715###########################################################
716
Ying Wangb8e01852014-01-23 15:09:04 -0800717c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800718c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
719
Ying Wangb8e01852014-01-23 15:09:04 -0800720c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800721c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
722
723$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
724$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
725$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
726$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
727
728c_objects := $(c_arm_objects) $(c_normal_objects)
729
730ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400731$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700732 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733 $(transform-$(PRIVATE_HOST)c-to-o)
734-include $(c_objects:%.o=%.P)
735endif
736
737###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700738## C: Compile generated .c files to .o.
739###########################################################
740
Ying Wangec6d6262014-01-16 16:21:03 -0800741gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700742gen_c_objects := $(gen_c_sources:%.c=%.o)
743
744ifneq ($(strip $(gen_c_objects)),)
745# Compile all generated files as thumb.
746# TODO: support compiling certain generated files as arm.
747$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
748$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400749$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700750 $(LOCAL_ADDITIONAL_DEPENDENCIES)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700751 $(transform-$(PRIVATE_HOST)c-to-o)
752-include $(gen_c_objects:%.o=%.P)
753endif
754
755###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200756## ObjC: Compile .m files to .o
757###########################################################
758
Ying Wangb8e01852014-01-23 15:09:04 -0800759objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200760objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
761
762ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400763$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700764 $(LOCAL_ADDITIONAL_DEPENDENCIES)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200765 $(transform-$(PRIVATE_HOST)m-to-o)
766-include $(objc_objects:%.o=%.P)
767endif
768
769###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770## AS: Compile .S files to .o.
771###########################################################
772
Ying Wangb8e01852014-01-23 15:09:04 -0800773asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
775
776ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400777$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Alberta8fd6682014-10-03 13:29:42 -0700778 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800779 $(transform-$(PRIVATE_HOST)s-to-o)
780-include $(asm_objects_S:%.o=%.P)
781endif
782
Ying Wangb8e01852014-01-23 15:09:04 -0800783asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800784asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
785
786ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400787$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Alberta8fd6682014-10-03 13:29:42 -0700788 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800789 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
790-include $(asm_objects_s:%.o=%.P)
791endif
792
793asm_objects := $(asm_objects_S) $(asm_objects_s)
794
795
Ying Wang7b913ce2014-06-05 19:05:47 -0700796# .asm for x86 needs to be compiled with yasm.
797ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
798asm_sources_asm := $(filter %.asm,$(my_src_files))
799ifneq ($(strip $(asm_sources_asm)),)
800asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
801$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
802 $(LOCAL_ADDITIONAL_DEPENDENCIES)
803 $(transform-asm-to-o)
804
805asm_objects += $(asm_objects_asm)
806endif
807endif
808
Ying Wang5f074802011-11-08 09:31:21 -0800809####################################################
810## Import includes
811####################################################
812import_includes := $(intermediates)/import_includes
813import_includes_deps := $(strip \
814 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800815 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \
Colin Cross90353fe2014-02-04 14:53:25 -0800816 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800817 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
Ying Wang5f074802011-11-08 09:31:21 -0800818$(import_includes) : $(import_includes_deps)
819 @echo Import includes file: $@
820 $(hide) mkdir -p $(dir $@) && rm -f $@
821ifdef import_includes_deps
822 $(hide) for f in $^; do \
823 cat $$f >> $@; \
824 done
825else
826 $(hide) touch $@
827endif
828
The Android Open Source Project88b60792009-03-03 19:28:42 -0800829###########################################################
830## Common object handling.
831###########################################################
832
833# some rules depend on asm_objects being first. If your code depends on
834# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100835normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700836 $(asm_objects) \
837 $(cpp_objects) \
838 $(gen_cpp_objects) \
839 $(gen_asm_objects) \
840 $(c_objects) \
841 $(gen_c_objects) \
842 $(objc_objects) \
843 $(yacc_objects) \
844 $(lex_objects) \
845 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100846 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
847
848all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849
Colin Cross2d206702014-02-13 13:41:52 -0800850my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800851
Ying Wang848020f2012-08-14 10:13:16 -0700852ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800853 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700854endif
855
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100856# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
857# use normal_objects here to avoid creating circular dependencies. This assumes
858# that custom build rules which generate .o files don't consume other generated
859# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800860$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100861$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800862ALL_C_CPP_ETC_OBJECTS += $(all_objects)
863
The Android Open Source Project88b60792009-03-03 19:28:42 -0800864
865###########################################################
866# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800867###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800868
869###########################################################
870# The list of libraries that this module will link against are in
871# these variables. Each is a list of bare module names like "libc libm".
872#
873# LOCAL_SHARED_LIBRARIES
874# LOCAL_STATIC_LIBRARIES
875# LOCAL_WHOLE_STATIC_LIBRARIES
876#
877# We need to convert the bare names into the dependencies that
878# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
879# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
880# libraries, so that simply building this module doesn't force
881# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
882# should depend on the INSTALLED versions of the libraries so
883# that they get installed when this module does.
884###########################################################
885# NOTE:
886# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
887# module without leaving anything out, which is useful for turning
888# a collection of .a files into a .so file. Linking against a
889# normal STATIC_LIBRARY will only pull in code/symbols that are
890# referenced by the module. (see gcc/ld's --whole-archive option)
891###########################################################
892
893# Get the list of BUILT libraries, which are under
894# various intermediates directories.
895so_suffix := $($(my_prefix)SHLIB_SUFFIX)
896a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
897
Ying Wang848020f2012-08-14 10:13:16 -0700898ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800900 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800902 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800903
Ying Wangd8d37212014-03-21 16:17:04 -0700904# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -0800905my_system_shared_libraries_fullpath := \
906 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -0700907 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -0700908 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700909
910built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -0700911else
Ying Wang1a081002010-07-13 14:55:47 -0700912built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800913 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700914 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -0700915 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -0700916endif
917
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800919 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800920 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800921 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800922
Ying Wang848020f2012-08-14 10:13:16 -0700923ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800924built_static_libraries += $(my_ndk_stl_static_lib)
925endif
926
The Android Open Source Project88b60792009-03-03 19:28:42 -0800927built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -0800928 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800930 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800931
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932# We don't care about installed static libraries, since the
933# libraries have already been linked into the module at that point.
934# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000935# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800936
937installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -0800938 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800939 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
940
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700941# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -0700942ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
943LOCAL_RTTI_FLAG := -fno-rtti
944endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700945
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946###########################################################
947# Rule-specific variable definitions
948###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +0800949
Ying Wang824344a2014-05-27 13:03:36 -0700950ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -0700951my_cflags += $(LOCAL_CLANG_CFLAGS)
952my_cpplags += $(LOCAL_CLANG_CPPFLAGS)
953my_asflags += $(LOCAL_CLANG_ASFLAGS)
954my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -0700955my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
956my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
957my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
958my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
Ying Wang1f982832014-02-06 18:08:44 -0800959my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
960my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
961my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
962my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +0800963endif
964
Dehao Chen295a6d22014-09-19 10:18:12 -0700965ifeq ($(LOCAL_FDO_SUPPORT), true)
966 build_with_fdo := false
967 ifeq ($(BUILD_FDO_INSTRUMENT), true)
968 build_with_fdo := true
969 endif
970 ifeq ($(BUILD_FDO_OPTIMIZE), true)
971 build_with_fdo := true
972 endif
973 ifeq ($(build_with_fdo), true)
974 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
975 fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
976 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
977 endif
978endif
979
The Android Open Source Project88b60792009-03-03 19:28:42 -0800980$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800981$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -0700982$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800983$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
984$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700985$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800986$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -0800987$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -0800988$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -0800989$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -0700990$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Ying Wangb8e01852014-01-23 15:09:04 -0800991$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wangd90de322014-05-23 16:42:37 -0700992$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993
994# this is really the way to get the files onto the command line instead
995# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
996$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
997$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
998$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
999$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
1000
1001###########################################################
1002# Define library dependencies.
1003###########################################################
1004# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1005all_libraries := \
1006 $(built_shared_libraries) \
1007 $(built_static_libraries) \
1008 $(built_whole_libraries)
1009
The Android Open Source Project88b60792009-03-03 19:28:42 -08001010# Also depend on the notice files for any static libraries that
1011# are linked into this module. This will force them to be installed
1012# when this module is.
1013$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001014
1015###########################################################
1016# Export includes
1017###########################################################
1018export_includes := $(intermediates)/export_includes
1019$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang49085952014-05-06 13:03:32 -07001020# Make sure .pb.h are already generated before any dependent source files get compiled.
1021$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
Ying Wang5f074802011-11-08 09:31:21 -08001022 @echo Export includes file: $< -- $@
1023 $(hide) mkdir -p $(dir $@) && rm -f $@
1024ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
1025 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1026 echo "-I $$d" >> $@; \
1027 done
1028else
1029 $(hide) touch $@
1030endif
Ying Wang616e5962012-04-18 17:35:55 -07001031
1032# Make sure export_includes gets generated when you are running mm/mmm
1033$(LOCAL_BUILT_MODULE) : | $(export_includes)