blob: 7b629d80a09993aaf1d7bb7fc82f654e47d5c738 [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
Dan Albertd3d894d2014-11-14 15:28:49 -080012##################################################
13# Compute the dependency of the shared libraries
14##################################################
15# On the target, we compile with -nostdlib, so we must add in the
16# default system shared libraries, unless they have requested not
17# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
18# supply that, for example, when building libc itself.
19ifdef LOCAL_IS_HOST_MODULE
20 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
21 my_system_shared_libraries :=
22 else
23 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
24 endif
25else
26 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Dan Albert7ba582a2015-08-06 12:22:40 -070027 my_system_shared_libraries := libc libm
Dan Albertd3d894d2014-11-14 15:28:49 -080028 else
29 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
30 endif
31endif
32
33# The following LOCAL_ variables will be modified in this file.
34# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
35# we can't modify them in place.
36my_src_files := $(LOCAL_SRC_FILES)
37my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
38my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
39my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
40my_cflags := $(LOCAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -080041my_conlyflags := $(LOCAL_CONLYFLAGS)
Dan Albertd3d894d2014-11-14 15:28:49 -080042my_cppflags := $(LOCAL_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -070043my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE)
44my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080045my_ldflags := $(LOCAL_LDFLAGS)
46my_ldlibs := $(LOCAL_LDLIBS)
47my_asflags := $(LOCAL_ASFLAGS)
48my_cc := $(LOCAL_CC)
Ying Wang57d90602015-07-20 18:40:18 -070049my_cc_wrapper := $(CC_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080050my_cxx := $(LOCAL_CXX)
Ying Wang57d90602015-07-20 18:40:18 -070051my_cxx_wrapper := $(CXX_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080052my_c_includes := $(LOCAL_C_INCLUDES)
53my_generated_sources := $(LOCAL_GENERATED_SOURCES)
54my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
55my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
Ying Wangb28ed232015-04-07 11:59:34 -070056my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Albertd3d894d2014-11-14 15:28:49 -080057
Dan Albertb58fb4a2014-11-14 17:15:00 -080058ifdef LOCAL_IS_HOST_MODULE
59my_allow_undefined_symbols := true
60else
61my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
62endif
63
Andrew Hsieh140761af02014-04-25 23:47:10 -070064my_ndk_sysroot :=
65my_ndk_sysroot_include :=
66my_ndk_sysroot_lib :=
Ying Wang848020f2012-08-14 10:13:16 -070067ifdef LOCAL_SDK_VERSION
Ying Wangfe1bfe72012-08-14 11:08:03 -070068 ifdef LOCAL_NDK_VERSION
69 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
70 endif
Ying Wang1a081002010-07-13 14:55:47 -070071 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070072 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070073 endif
Ying Wang848020f2012-08-14 10:13:16 -070074 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
Andrew Hsieh140761af02014-04-25 23:47:10 -070075 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
76 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
77 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
78 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
Duane Sand1a074872014-11-08 15:25:18 -080079 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
80 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6
Andrew Hsieh140761af02014-04-25 23:47:10 -070081 else
82 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
83 endif
Ying Wangcce4c972011-03-03 18:53:53 -080084
Dmitriy Ivanov3b51f202015-04-23 18:48:52 -070085 # The bionic linker now has support for packed relocations and gnu style
86 # hashes (which are much faster!), but shipping to older devices requires
87 # the old style hash and disabling packed relocations.
Dan Albertd3d894d2014-11-14 15:28:49 -080088 #ifeq ($(shell expr $(LOCAL_SDK_VERSION) >= FIRST_SUPPORTED_VERSION),0)
89 my_ldflags += -Wl,--hash-style=sysv
Dmitriy Ivanov3b51f202015-04-23 18:48:52 -070090 LOCAL_PACK_MODULE_RELOCATIONS := false
Dan Albertd3d894d2014-11-14 15:28:49 -080091 #endif
92
Ying Wangcce4c972011-03-03 18:53:53 -080093 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
94 # See ndk/docs/CPLUSPLUS-SUPPORT.html
95 my_ndk_stl_include_path :=
96 my_ndk_stl_shared_lib_fullpath :=
97 my_ndk_stl_shared_lib :=
98 my_ndk_stl_static_lib :=
Andrew Hsieh73d800e2014-03-04 17:11:52 +080099 my_ndk_stl_cppflags :=
Duane Sand1a074872014-11-08 15:25:18 -0800100 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
101 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
102 my_cpu_variant := mips32r6
103 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800104 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800105 ifeq (,$(LOCAL_NDK_STL_VARIANT))
106 LOCAL_NDK_STL_VARIANT := system
107 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800108 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 -0700109 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800110 endif
111 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
112 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
113 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
114 else # LOCAL_NDK_STL_VARIANT is not system
115 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
116 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
117 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
Duane Sand1a074872014-11-08 15:25:18 -0800118 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a
Ying Wangcce4c972011-03-03 18:53:53 -0800119 else
Duane Sand1a074872014-11-08 15:25:18 -0800120 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so
Ying Wangcce4c972011-03-03 18:53:53 -0800121 my_ndk_stl_shared_lib := -lstlport_shared
122 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800123 else # LOCAL_NDK_STL_VARIANT is not stlport_* either
124 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
125 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
126 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
127 $(my_ndk_source_root)/android/support/include
128 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
Duane Sand1a074872014-11-08 15:25:18 -0800129 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_static.a
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800130 else
Duane Sand1a074872014-11-08 15:25:18 -0800131 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_shared.so
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800132 my_ndk_stl_shared_lib := -lc++_shared
133 endif
134 my_ndk_stl_cppflags := -std=c++11
Ying Wangcce4c972011-03-03 18:53:53 -0800135 else
136 # LOCAL_NDK_STL_VARIANT is gnustl_static
Duane Sand1a074872014-11-08 15:25:18 -0800137 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \
Ben Cheng4de6fa42014-04-10 22:46:26 -0700138 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
Duane Sand1a074872014-11-08 15:25:18 -0800139 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a
Ying Wangcce4c972011-03-03 18:53:53 -0800140 endif
141 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800142 endif
Ying Wang1a081002010-07-13 14:55:47 -0700143endif
144
Dan Albert95994de2014-08-07 18:29:11 -0700145# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
146# all code is position independent, and then those warnings get promoted to
147# errors.
Ying Wang594a10a2014-08-07 20:08:04 -0700148ifndef USE_MINGW
Dan Albert4803ce22014-08-06 12:36:46 -0700149ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
150my_cflags += -fpie
151else
152my_cflags += -fPIC
153endif
Dan Albert95994de2014-08-07 18:29:11 -0700154endif
Dan Albert4803ce22014-08-06 12:36:46 -0700155
Dan Willemsen7a549852015-08-13 17:51:40 -0700156ifdef LOCAL_IS_HOST_MODULE
157my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS))
158my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
159my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
160my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
161my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
162my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
163my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS))
164my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS))
165my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS))
166my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS))
167endif
168
Ying Wang6feb6d52014-04-17 10:03:35 -0700169my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
170my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
171my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
172my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
173my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
174my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
175my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
176my_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 -0800177
Dan Albertdb905e72014-08-18 11:14:38 -0700178my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700179ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700180my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700181endif
182ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700183my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700184endif
185
Tim Murray92d79cb2014-04-04 14:38:29 -0700186# clang is enabled by default for host builds
187# enable it unless we've specifically disabled clang above
188ifdef LOCAL_IS_HOST_MODULE
Tim Murrayf3ca3d52014-07-24 15:20:18 -0700189 ifneq ($(HOST_OS),windows)
Tim Murray5ca1dc12014-07-24 14:42:53 -0700190 ifeq ($(my_clang),)
191 my_clang := true
192 endif
193 endif
Tim Murray92d79cb2014-04-04 14:38:29 -0700194endif
195
Dan Albertc7d307d2015-07-29 15:13:57 -0700196my_cpp_std_version := -std=gnu++14
197ifdef LOCAL_SDK_VERSION
198 # The NDK handles this itself.
199 my_cpp_std_version :=
200endif
201
202ifdef LOCAL_IS_HOST_MODULE
203 ifneq ($(my_clang),true)
204 # The host GCC doesn't support C++14 (and is deprecated, so likely
205 # never will). Build these modules with C++11.
206 my_cpp_std_version := -std=gnu++11
207 endif
208endif
209
210my_cppflags := $(my_cpp_std_version) $(my_cppflags)
211
Tim Murray06659bc2014-08-13 11:53:07 -0700212# Add option to make clang the default for device build
213ifeq ($(USE_CLANG_PLATFORM_BUILD),true)
214 ifeq ($(my_clang),)
215 my_clang := true
216 endif
217endif
218
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800219# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700220my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
221my_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 -0800222
Ying Wang75e8fcb2014-10-07 13:03:29 -0700223include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700224
Ying Wang285045b2013-08-13 12:35:10 -0700225# Add static HAL libraries
226ifdef LOCAL_HAL_STATIC_LIBRARIES
227$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
228 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800229 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
230 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700231b_lib :=
232endif
233
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700234my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER)
235
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700236include $(BUILD_SYSTEM)/config_sanitizers.mk
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400237
Ying Wangba8b3772014-03-10 18:23:08 -0700238ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700239 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700240endif
241
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800242# Add in libcompiler_rt for all regular device builds
Dan Albert30a9c352015-04-09 14:41:06 -0700243ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800244 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700245endif
246
Jing Yu2dcc8062009-09-21 16:31:50 -0700247####################################################
248## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700249## Please note that we will do option filtering during FDO build.
250## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
251##################################################################
Ying Wangd7914632014-10-28 14:50:59 -0700252my_fdo_build :=
253ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
254 ifeq ($(BUILD_FDO_INSTRUMENT),true)
255 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
256 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
257 my_fdo_build := true
258 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
259 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
260 my_fdo_build := true
synergydev4a605762013-08-05 02:44:37 -0700261 endif
Ying Wang57d90602015-07-20 18:40:18 -0700262 # Disable ccache (or other compiler wrapper).
263 my_cc_wrapper :=
264 my_cxx_wrapper :=
Jing Yu2dcc8062009-09-21 16:31:50 -0700265endif
266
The Android Open Source Project88b60792009-03-03 19:28:42 -0800267###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800268## Explicitly declare assembly-only __ASSEMBLY__ macro for
269## assembly source
270###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800271my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800272
Ying Wangd8d37212014-03-21 16:17:04 -0700273
Jim Huang20d1ba62010-10-14 16:15:56 +0800274###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700275## Define PRIVATE_ variables from global vars
276###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800277ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700278ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700279my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700280my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800281my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700282else
Ying Wang6ef65192014-01-15 16:02:16 -0800283my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
284my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800285my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700286endif # LOCAL_SDK_VERSION
287
Ying Wang824344a2014-05-27 13:03:36 -0700288ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800289my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800290my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800291my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800292my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700293else
Ying Wang6ef65192014-01-15 16:02:16 -0800294my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800295my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800296my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800297my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700298endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700299
Ying Wang1a081002010-07-13 14:55:47 -0700300$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400301$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700302$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800303$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800304$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
305$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
306
Ying Wang7fff9a12014-01-09 14:39:41 -0800307else # LOCAL_IS_HOST_MODULE
308
Ying Wang824344a2014-05-27 13:03:36 -0700309ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700310my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800311my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CONLYFLAGS)
Ying Wang6feb6d52014-04-17 10:03:35 -0700312my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
313my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
Stephen Hinesf0089662014-09-25 22:35:16 -0700314my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800315else
Ying Wang6feb6d52014-04-17 10:03:35 -0700316my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800317my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CONLYFLAGS)
Ying Wang6feb6d52014-04-17 10:03:35 -0700318my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
319my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
320my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700321endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800322
323$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
324$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800325$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800326$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
327$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
328endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700329
Dan Albert43e128a2015-01-23 16:12:57 -0800330# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
331# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
332# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
333# clean build of your module after toggling it.
334ifeq ($(NATIVE_COVERAGE),true)
335 ifeq ($(my_native_coverage),true)
Dan Albert343ed672015-01-25 16:20:57 -0800336 # Note that clang coverage doesn't play nicely with acov out of the box.
337 # Clang apparently generates .gcno files that aren't compatible with
338 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
339 # with `--gcov-tool /usr/bin/gcov-4.6`.
340 #
341 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
Dan Albert2c03e042015-01-24 15:14:35 -0800342 my_cflags += --coverage -O0
Dan Albert343ed672015-01-25 16:20:57 -0800343 my_ldflags += --coverage
Dan Albert43e128a2015-01-23 16:12:57 -0800344 endif
345else
346 my_native_coverage := false
347endif
348
Ying Wang1a081002010-07-13 14:55:47 -0700349###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800350## Define PRIVATE_ variables used by multiple module types
351###########################################################
352$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700353 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800354
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800355ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
356 LOCAL_NO_SYNTAX_CHECK := true
357endif
358
Andrew Hsieh906cb782013-09-10 17:37:14 +0800359ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
360 LOCAL_NO_STATIC_ANALYZER := true
361endif
362
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800363ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
364 my_syntax_arch := host
365else
Ying Wang6ef65192014-01-15 16:02:16 -0800366 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800367endif
368
Ying Wang6ef65192014-01-15 16:02:16 -0800369ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700370 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800371 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400372 else
Ying Wang6ef65192014-01-15 16:02:16 -0800373 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400374 endif
Ying Wang57d90602015-07-20 18:40:18 -0700375 my_cc := $(my_cc_wrapper) $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800376endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800377ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800378 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800379else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800380ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800381 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800382endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800383endif
Ying Wang6ef65192014-01-15 16:02:16 -0800384$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800385
Ying Wang6ef65192014-01-15 16:02:16 -0800386ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700387 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800388 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400389 else
Ying Wang6ef65192014-01-15 16:02:16 -0800390 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400391 endif
Ying Wang57d90602015-07-20 18:40:18 -0700392 my_cxx := $(my_cxx_wrapper) $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800393endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800394ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800395 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800396else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800397ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800398 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800399endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800400endif
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700401$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
Ying Wang6ef65192014-01-15 16:02:16 -0800402$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700403$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800404
405# TODO: support a mix of standard extensions so that this isn't necessary
406LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
407ifeq ($(LOCAL_CPP_EXTENSION),)
408 LOCAL_CPP_EXTENSION := .cpp
409endif
410$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
411
412# Certain modules like libdl have to have symbols resolved at runtime and blow
413# up if --no-undefined is passed to the linker.
414ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
Dan Albertb58fb4a2014-11-14 17:15:00 -0800415ifeq ($(my_allow_undefined_symbols),)
Ying Wang6ef65192014-01-15 16:02:16 -0800416 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800417endif
418endif
419
Ying Wangfcdabd42011-04-25 14:22:41 -0700420ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
421$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
422else
423$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
424endif
425
The Android Open Source Project88b60792009-03-03 19:28:42 -0800426###########################################################
427## Define arm-vs-thumb-mode flags.
428###########################################################
429LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Ying Wangb28ed232015-04-07 11:59:34 -0700430ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800431arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
432normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
433
Dave Bort95282482009-04-23 18:44:55 -0700434# Read the values from something like TARGET_arm_CFLAGS or
435# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
436# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800437arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
438normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700439ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800440arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
441normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400442endif
443
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800444else
445arm_objects_mode :=
446normal_objects_mode :=
447arm_objects_cflags :=
448normal_objects_cflags :=
449endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800450
451###########################################################
452## Define per-module debugging flags. Users can turn on
453## debugging for a particular module by setting DEBUG_MODULE_ModuleName
454## to a non-empty value in their environment or buildspec.mk,
455## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
456## debug flags that they want to use.
457###########################################################
458ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
459 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
460else
461 debug_cflags :=
462endif
463
Tim Murraya7aa8002012-10-29 16:06:00 -0700464####################################################
465## Compile RenderScript with reflected C++
466####################################################
467
Ying Wangb8e01852014-01-23 15:09:04 -0800468renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700469
470ifneq (,$(renderscript_sources))
471
472renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
473RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
474renderscript_intermediate := $(intermediates)/renderscript
475
Noah Presler4796a8c2015-08-13 17:04:10 -0700476renderscript_target_api :=
477
478ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
479renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
480else
481ifneq (,$(LOCAL_SDK_VERSION))
482# Set target-api for LOCAL_SDK_VERSIONs other than current.
483ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION)))
484renderscript_target_api := $(LOCAL_SDK_VERSION)
485endif
486endif # LOCAL_SDK_VERSION is set
487endif # LOCAL_RENDERSCRIPT_TARGET_API is set
488
489
Tim Murraya7aa8002012-10-29 16:06:00 -0700490ifeq ($(LOCAL_RENDERSCRIPT_CC),)
491LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
492endif
493
494# Turn on all warnings and warnings as errors for RS compiles.
495# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
496renderscript_flags := -Wall -Werror
497renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700498# -m32 or -m64
499renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700500
Ying Wang6ef65192014-01-15 16:02:16 -0800501renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700502 $(TOPDIR)external/clang/lib/Headers \
503 $(TOPDIR)frameworks/rs/scriptc \
504 $(LOCAL_RENDERSCRIPT_INCLUDES)
505
506ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800507renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700508endif
509
Ying Wangb9319562015-04-03 16:15:28 -0700510bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
511 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
512
Ying Wang6ef65192014-01-15 16:02:16 -0800513$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700514$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
515$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
516$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
517$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
Noah Presler4796a8c2015-08-13 17:04:10 -0700518$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api)
Ying Wangb9319562015-04-03 16:15:28 -0700519$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
Tim Murraya7aa8002012-10-29 16:06:00 -0700520$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
521 $(transform-renderscripts-to-cpp-and-bc)
522
Ying Wangb9319562015-04-03 16:15:28 -0700523# include the dependency files (.d/.P) generated by llvm-rs-cc.
524-include $(bc_dep_files:%.d=%.P)
Tim Murraya7aa8002012-10-29 16:06:00 -0700525
526LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
527
528rs_generated_cpps := $(addprefix \
529 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
530 $(notdir $(renderscript_sources)))))
531
Stephen Hines8ff92522014-06-06 12:51:47 -0700532# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700533$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700534 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700535
Ying Wang6ef65192014-01-15 16:02:16 -0800536my_c_includes += $(renderscript_intermediate)
537my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700538
539endif
540
541
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542###########################################################
543## Stuff source generated from one-off tools
544###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800545$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800546
Colin Crossd8262642014-01-24 23:17:21 -0800547my_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 -0800548
Colin Crossd8262642014-01-24 23:17:21 -0800549$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
550 @echo "Copy: $@"
551 $(copy-file-to-target)
552
553my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
554
555ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800556
557###########################################################
Ying Wangb28ed232015-04-07 11:59:34 -0700558## Compile the .proto files to .cc (or .c) and then to .o
Ying Wanga5fc87a2010-11-02 18:43:16 -0700559###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800560proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700561proto_generated_objects :=
562proto_generated_headers :=
563ifneq ($(proto_sources),)
Ying Wangb28ed232015-04-07 11:59:34 -0700564proto_generated_sources_dir := $(generated_sources_dir)/proto
Ying Wangead89442014-02-25 11:18:40 -0800565proto_generated_obj_dir := $(intermediates)/proto
Ying Wangb28ed232015-04-07 11:59:34 -0700566
567ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE)))
568my_proto_source_suffix := .c
569my_proto_c_includes := external/nanopb-c
570my_protoc_flags := --nanopb_out=$(proto_generated_sources_dir) \
571 --plugin=external/nanopb-c/generator/protoc-gen-nanopb
572else
573my_proto_source_suffix := .cc
574my_proto_c_includes := external/protobuf/src
575my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
576my_protoc_flags := --cpp_out=$(proto_generated_sources_dir)
577endif
578my_proto_c_includes += $(proto_generated_sources_dir)
579
580proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
581proto_generated_sources := $(addprefix $(proto_generated_sources_dir)/, \
582 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
583proto_generated_headers := $(patsubst %.pb$(my_proto_source_suffix),%.pb.h, $(proto_generated_sources))
Ying Wangead89442014-02-25 11:18:40 -0800584proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
585 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700586
Ying Wangead89442014-02-25 11:18:40 -0800587# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
588ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wangb28ed232015-04-07 11:59:34 -0700589$(proto_generated_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
590$(proto_generated_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
591$(proto_generated_sources): $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix): %.proto $(PROTOC)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700592 $(transform-proto-to-cc)
593
Stephen Hines8ff92522014-06-06 12:51:47 -0700594# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wangb28ed232015-04-07 11:59:34 -0700595$(proto_generated_headers): $(proto_generated_sources_dir)/%.pb.h: $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix)
Ying Wang81ab8332014-05-28 16:17:09 -0700596 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700597
Ying Wangead89442014-02-25 11:18:40 -0800598$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
599endif # transform-proto-to-cc rule included only once
600
Ying Wang022a7b32012-06-13 11:38:10 -0700601$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
602$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wangb28ed232015-04-07 11:59:34 -0700603$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_sources_dir)/%$(my_proto_source_suffix) $(proto_generated_headers)
604ifeq ($(my_proto_source_suffix),.c)
605 $(transform-$(PRIVATE_HOST)c-to-o)
606else
Ying Wanga5fc87a2010-11-02 18:43:16 -0700607 $(transform-$(PRIVATE_HOST)cpp-to-o)
Ying Wangb28ed232015-04-07 11:59:34 -0700608endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700609-include $(proto_generated_objects:%.o=%.P)
610
Ying Wangb28ed232015-04-07 11:59:34 -0700611my_c_includes += $(my_proto_c_includes)
612# Auto-export the generated proto source dir.
613my_export_c_include_dirs += $(my_proto_c_includes)
614
615ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc)
Ying Wangf050c2f2015-04-08 09:54:34 -0700616 my_static_libraries += libprotobuf-c-nano-enable_malloc
Ying Wangb28ed232015-04-07 11:59:34 -0700617else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c)
Ying Wangf050c2f2015-04-08 09:54:34 -0700618 my_static_libraries += libprotobuf-c-nano
Ying Wangb28ed232015-04-07 11:59:34 -0700619else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Dan Albertc3031c72014-11-11 10:42:17 -0800620 ifdef LOCAL_SDK_VERSION
621 my_static_libraries += libprotobuf-cpp-full
622 else
623 my_shared_libraries += libprotobuf-cpp-full
624 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700625else
Dan Albertc3031c72014-11-11 10:42:17 -0800626 ifdef LOCAL_SDK_VERSION
627 my_static_libraries += libprotobuf-cpp-lite
628 else
629 my_shared_libraries += libprotobuf-cpp-lite
630 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700631endif
Ying Wangead89442014-02-25 11:18:40 -0800632endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700633
Ying Wanga5fc87a2010-11-02 18:43:16 -0700634###########################################################
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700635## Compile the .dbus-xml files to c++ headers
Christopher Wileybc2be462015-07-29 17:14:24 -0700636###########################################################
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700637dbus_definitions := $(filter %.dbus-xml,$(my_src_files))
Christopher Wiley529f1762015-08-14 14:55:32 -0700638dbus_generated_headers :=
639ifneq ($(dbus_definitions),)
Christopher Wileybc2be462015-07-29 17:14:24 -0700640
Christopher Wiley529f1762015-08-14 14:55:32 -0700641dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions))
Christopher Wileybc2be462015-07-29 17:14:24 -0700642dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files))
Christopher Wiley529f1762015-08-14 14:55:32 -0700643dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
Christopher Wileybc2be462015-07-29 17:14:24 -0700644
Christopher Wiley529f1762015-08-14 14:55:32 -0700645dbus_gen_dir := $(generated_sources_dir)/dbus_bindings
Christopher Wileybc2be462015-07-29 17:14:24 -0700646
Christopher Wiley529f1762015-08-14 14:55:32 -0700647ifdef LOCAL_DBUS_PROXY_PREFIX
648dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX)
649dbus_headers := dbus-proxies.h
650else
651dbus_header_dir := $(dbus_gen_dir)
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700652dbus_headers := $(patsubst %.dbus-xml,%.h,$(dbus_definitions))
Christopher Wiley529f1762015-08-14 14:55:32 -0700653endif
654dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers))
Christopher Wileybc2be462015-07-29 17:14:24 -0700655
656# Ensure that we only define build rules once in multilib builds.
657ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
658$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true
Christopher Wiley529f1762015-08-14 14:55:32 -0700659
660$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE)
661$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path)
662$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR)
663ifdef LOCAL_DBUS_PROXY_PREFIX
664$(dbus_generated_headers) : $(dbus_definition_paths)
665 $(generate-dbus-proxies)
666
667# Auto-export the generated dbus proxy directory.
668my_export_c_include_dirs += $(dbus_gen_dir)/include
669my_c_includes += $(dbus_gen_dir)/include
670else
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700671$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus-xml
Christopher Wiley529f1762015-08-14 14:55:32 -0700672 $(generate-dbus-adaptors)
673
674my_export_c_include_dirs += $(dbus_header_dir)
675my_c_includes += $(dbus_header_dir)
676endif # $(LOCAL_DBUS_PROXY_PREFIX)
Christopher Wileybc2be462015-07-29 17:14:24 -0700677endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
678
Christopher Wiley529f1762015-08-14 14:55:32 -0700679my_generated_sources += $(dbus_generated_headers)
680
681endif # $(dbus_definitions) non-empty
Christopher Wileybc2be462015-07-29 17:14:24 -0700682
683
684###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000685## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686###########################################################
687
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000688y_yacc_sources := $(filter %.y,$(my_src_files))
689y_yacc_cpps := $(addprefix \
690 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
691
692yy_yacc_sources := $(filter %.yy,$(my_src_files))
693yy_yacc_cpps := $(addprefix \
694 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
695
696yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800697yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
698yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
699
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000700ifneq ($(strip $(y_yacc_cpps)),)
701$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700702 $(TOPDIR)$(LOCAL_PATH)/%.y \
Dan Albert954b5bd2014-11-08 22:20:03 -0800703 $(lex_cpps) $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800704 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
705$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000706endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000708ifneq ($(strip $(yy_yacc_cpps)),)
709$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
710 $(TOPDIR)$(LOCAL_PATH)/%.yy \
Dan Albert954b5bd2014-11-08 22:20:03 -0800711 $(lex_cpps) $(my_additional_dependencies)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000712 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
713$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
714endif
715
716ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800717$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
718$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
719$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
720 $(transform-$(PRIVATE_HOST)cpp-to-o)
721endif
722
723###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000724## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800725###########################################################
726
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000727l_lex_sources := $(filter %.l,$(my_src_files))
728l_lex_cpps := $(addprefix \
729 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
730
731ll_lex_sources := $(filter %.ll,$(my_src_files))
732ll_lex_cpps := $(addprefix \
733 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
734
735lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800736lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
737
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000738ifneq ($(strip $(l_lex_cpps)),)
739$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700740 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800741 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000742endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000744ifneq ($(strip $(ll_lex_cpps)),)
745$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
746 $(TOPDIR)$(LOCAL_PATH)/%.ll
747 $(transform-l-to-cpp)
748endif
749
750ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800751$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
752$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
753$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700754 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800755 $(my_additional_dependencies) \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700756 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800757 $(transform-$(PRIVATE_HOST)cpp-to-o)
758endif
759
760###########################################################
761## C++: Compile .cpp files to .o.
762###########################################################
763
Jeff Browne33ba4c2011-07-11 22:11:46 -0700764# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800765# it's not really arm, because there are files that are shared.
Ying Wangfb22a422015-03-10 18:03:11 -0700766cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
767dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources))
768cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources))
769cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770
Ying Wangfb22a422015-03-10 18:03:11 -0700771# For source files starting with ../, we remove all the ../ in the object file path,
772# to avoid object file escaping the intermediate directory.
773dotdot_arm_objects :=
774$(foreach s,$(dotdot_arm_sources),\
775 $(eval $(call compile-dotdot-cpp-file,$(s),\
776 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
777 dotdot_arm_objects)))
778
779dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
780dotdot_objects :=
781$(foreach s,$(dotdot_sources),\
782 $(eval $(call compile-dotdot-cpp-file,$(s),\
783 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
784 dotdot_objects)))
785
786cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800787cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
788
Ying Wangfb22a422015-03-10 18:03:11 -0700789$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
790$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
791$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
792$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800793
794cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
795
796ifneq ($(strip $(cpp_objects)),)
797$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700798 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800799 $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800800 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800801 $(transform-$(PRIVATE_HOST)cpp-to-o)
802-include $(cpp_objects:%.o=%.P)
803endif
804
Ying Wangfb22a422015-03-10 18:03:11 -0700805cpp_objects += $(dotdot_arm_objects) $(dotdot_objects)
806
The Android Open Source Project88b60792009-03-03 19:28:42 -0800807###########################################################
808## C++: Compile generated .cpp files to .o.
809###########################################################
810
Ying Wangec6d6262014-01-16 16:21:03 -0800811gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
813
814ifneq ($(strip $(gen_cpp_objects)),)
815# Compile all generated files as thumb.
816# TODO: support compiling certain generated files as arm.
817$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
818$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400819$(gen_cpp_objects): $(intermediates)/%.o: \
820 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800821 $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800822 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800823 $(transform-$(PRIVATE_HOST)cpp-to-o)
824-include $(gen_cpp_objects:%.o=%.P)
825endif
826
827###########################################################
828## S: Compile generated .S and .s files to .o.
829###########################################################
830
Ying Wangec6d6262014-01-16 16:21:03 -0800831gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800832gen_S_objects := $(gen_S_sources:%.S=%.o)
833
834ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400835$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -0800836 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800837 $(transform-$(PRIVATE_HOST)s-to-o)
838-include $(gen_S_objects:%.o=%.P)
839endif
840
Ying Wangec6d6262014-01-16 16:21:03 -0800841gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800842gen_s_objects := $(gen_s_sources:%.s=%.o)
843
844ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400845$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -0800846 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800847 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
848-include $(gen_s_objects:%.o=%.P)
849endif
850
851gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
852
853###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000854## o: Include generated .o files in output.
855###########################################################
856
Ying Wangec6d6262014-01-16 16:21:03 -0800857gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000858
859###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800860## C: Compile .c files to .o.
861###########################################################
862
Ying Wangfb22a422015-03-10 18:03:11 -0700863c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
864dotdot_arm_sources := $(filter ../%,$(c_arm_sources))
865c_arm_sources := $(filter-out ../%,$(c_arm_sources))
866c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800867
Ying Wangfb22a422015-03-10 18:03:11 -0700868# For source files starting with ../, we remove all the ../ in the object file path,
869# to avoid object file escaping the intermediate directory.
870dotdot_arm_objects :=
871$(foreach s,$(dotdot_arm_sources),\
872 $(eval $(call compile-dotdot-c-file,$(s),\
873 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
874 dotdot_arm_objects)))
875
876dotdot_sources := $(filter ../%.c, $(my_src_files))
877dotdot_objects :=
878$(foreach s, $(dotdot_sources),\
879 $(eval $(call compile-dotdot-c-file,$(s),\
880 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
881 dotdot_objects)))
882
883c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800884c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
885
Ying Wangfb22a422015-03-10 18:03:11 -0700886$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
887$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
888$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
889$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890
891c_objects := $(c_arm_objects) $(c_normal_objects)
892
893ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400894$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800895 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800896 $(transform-$(PRIVATE_HOST)c-to-o)
897-include $(c_objects:%.o=%.P)
898endif
899
Ying Wangfb22a422015-03-10 18:03:11 -0700900c_objects += $(dotdot_arm_objects) $(dotdot_objects)
901
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700903## C: Compile generated .c files to .o.
904###########################################################
905
Ying Wangec6d6262014-01-16 16:21:03 -0800906gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700907gen_c_objects := $(gen_c_sources:%.c=%.o)
908
909ifneq ($(strip $(gen_c_objects)),)
910# Compile all generated files as thumb.
911# TODO: support compiling certain generated files as arm.
912$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
913$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400914$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800915 $(my_additional_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700916 $(transform-$(PRIVATE_HOST)c-to-o)
917-include $(gen_c_objects:%.o=%.P)
918endif
919
920###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200921## ObjC: Compile .m files to .o
922###########################################################
923
Ying Wangb8e01852014-01-23 15:09:04 -0800924objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200925objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
926
927ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400928$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800929 $(my_additional_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200930 $(transform-$(PRIVATE_HOST)m-to-o)
931-include $(objc_objects:%.o=%.P)
932endif
933
934###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935## AS: Compile .S files to .o.
936###########################################################
937
Ying Wangb8e01852014-01-23 15:09:04 -0800938asm_sources_S := $(filter %.S,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -0700939dotdot_sources := $(filter ../%,$(asm_sources_S))
940asm_sources_S := $(filter-out ../%,$(asm_sources_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800941asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
942
Ying Wangfb22a422015-03-10 18:03:11 -0700943dotdot_objects_S :=
944$(foreach s,$(dotdot_sources),\
945 $(eval $(call compile-dotdot-s-file,$(s),\
946 $(my_additional_dependencies),\
947 dotdot_objects_S)))
948
The Android Open Source Project88b60792009-03-03 19:28:42 -0800949ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400950$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -0800951 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800952 $(transform-$(PRIVATE_HOST)s-to-o)
953-include $(asm_objects_S:%.o=%.P)
954endif
955
Ying Wangb8e01852014-01-23 15:09:04 -0800956asm_sources_s := $(filter %.s,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -0700957dotdot_sources := $(filter ../%,$(asm_sources_s))
958asm_sources_s := $(filter-out ../%,$(asm_sources_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800959asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
960
Ying Wangfb22a422015-03-10 18:03:11 -0700961dotdot_objects_s :=
962$(foreach s,$(dotdot_sources),\
963 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
964 $(my_additional_dependencies),\
965 dotdot_objects_s)))
966
The Android Open Source Project88b60792009-03-03 19:28:42 -0800967ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400968$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -0800969 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800970 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971endif
972
Ying Wangfb22a422015-03-10 18:03:11 -0700973asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974
975
Ying Wangfe1e5c32015-03-09 18:57:40 -0700976# .asm for x86/x86_64 needs to be compiled with yasm.
Ying Wang7b913ce2014-06-05 19:05:47 -0700977asm_sources_asm := $(filter %.asm,$(my_src_files))
978ifneq ($(strip $(asm_sources_asm)),)
979asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
980$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
Dan Albert954b5bd2014-11-08 22:20:03 -0800981 $(my_additional_dependencies)
Ying Wang7b913ce2014-06-05 19:05:47 -0700982 $(transform-asm-to-o)
983
984asm_objects += $(asm_objects_asm)
985endif
Ying Wang7b913ce2014-06-05 19:05:47 -0700986
Jeff Davidson680f0712015-01-08 18:25:30 -0800987
988##########################################################
989## Set up installed module dependency
990## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
991## they may cusomize their install path with LOCAL_MODULE_PATH
992##########################################################
993# Get the list of INSTALLED libraries as module names.
994ifdef LOCAL_SDK_VERSION
995 installed_shared_library_module_names := \
996 $(my_shared_libraries)
997else
998 installed_shared_library_module_names := \
999 $(my_shared_libraries) $(my_system_shared_libraries)
1000endif
1001
1002# The real dependency will be added after all Android.mks are loaded and the install paths
1003# of the shared libraries are determined.
1004ifdef LOCAL_INSTALLED_MODULE
1005ifdef installed_shared_library_module_names
1006$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
1007 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names)))
1008endif
1009endif
1010
1011
Ying Wang5f074802011-11-08 09:31:21 -08001012####################################################
1013## Import includes
1014####################################################
1015import_includes := $(intermediates)/import_includes
1016import_includes_deps := $(strip \
1017 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -08001018 $(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 -08001019 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -08001020 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
Ying Wang14d02a32015-01-22 15:44:04 -08001021$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
1022$(import_includes) : $(LOCAL_MODULE_MAKEFILE) $(import_includes_deps)
Ying Wang5f074802011-11-08 09:31:21 -08001023 @echo Import includes file: $@
1024 $(hide) mkdir -p $(dir $@) && rm -f $@
1025ifdef import_includes_deps
Ying Wang14d02a32015-01-22 15:44:04 -08001026 $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \
Ying Wang5f074802011-11-08 09:31:21 -08001027 cat $$f >> $@; \
1028 done
1029else
1030 $(hide) touch $@
1031endif
1032
The Android Open Source Project88b60792009-03-03 19:28:42 -08001033###########################################################
1034## Common object handling.
1035###########################################################
1036
1037# some rules depend on asm_objects being first. If your code depends on
1038# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001039normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001040 $(asm_objects) \
1041 $(cpp_objects) \
1042 $(gen_cpp_objects) \
1043 $(gen_asm_objects) \
1044 $(c_objects) \
1045 $(gen_c_objects) \
1046 $(objc_objects) \
1047 $(yacc_objects) \
1048 $(lex_objects) \
1049 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001050 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
1051
1052all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001053
Colin Cross2d206702014-02-13 13:41:52 -08001054my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001055
Ying Wang848020f2012-08-14 10:13:16 -07001056ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -08001057 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -07001058endif
1059
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001060# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
1061# use normal_objects here to avoid creating circular dependencies. This assumes
1062# that custom build rules which generate .o files don't consume other generated
1063# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -08001064$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001065$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001066ALL_C_CPP_ETC_OBJECTS += $(all_objects)
1067
The Android Open Source Project88b60792009-03-03 19:28:42 -08001068
1069###########################################################
1070# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001071###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001072
1073###########################################################
1074# The list of libraries that this module will link against are in
1075# these variables. Each is a list of bare module names like "libc libm".
1076#
1077# LOCAL_SHARED_LIBRARIES
1078# LOCAL_STATIC_LIBRARIES
1079# LOCAL_WHOLE_STATIC_LIBRARIES
1080#
1081# We need to convert the bare names into the dependencies that
1082# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
1083# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
1084# libraries, so that simply building this module doesn't force
1085# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
1086# should depend on the INSTALLED versions of the libraries so
1087# that they get installed when this module does.
1088###########################################################
1089# NOTE:
1090# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
1091# module without leaving anything out, which is useful for turning
1092# a collection of .a files into a .so file. Linking against a
1093# normal STATIC_LIBRARY will only pull in code/symbols that are
1094# referenced by the module. (see gcc/ld's --whole-archive option)
1095###########################################################
1096
1097# Get the list of BUILT libraries, which are under
1098# various intermediates directories.
1099so_suffix := $($(my_prefix)SHLIB_SUFFIX)
1100a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
1101
Ying Wang848020f2012-08-14 10:13:16 -07001102ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -08001103built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001104 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001105 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -08001106 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001107
Ying Wangd8d37212014-03-21 16:17:04 -07001108# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -08001109my_system_shared_libraries_fullpath := \
1110 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -07001111 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -07001112 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -07001113
1114built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -07001115else
Ying Wang1a081002010-07-13 14:55:47 -07001116built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001117 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -07001118 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -07001119 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -07001120endif
1121
The Android Open Source Project88b60792009-03-03 19:28:42 -08001122built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001123 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001124 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -08001125 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 -08001126
Ying Wang848020f2012-08-14 10:13:16 -07001127ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -08001128built_static_libraries += $(my_ndk_stl_static_lib)
1129endif
1130
The Android Open Source Project88b60792009-03-03 19:28:42 -08001131built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -08001132 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001133 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -08001134 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 -08001135
The Android Open Source Project88b60792009-03-03 19:28:42 -08001136# We don't care about installed static libraries, since the
1137# libraries have already been linked into the module at that point.
1138# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +00001139# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001140
1141installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -08001142 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001143 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
1144
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001145# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001146ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1147LOCAL_RTTI_FLAG := -fno-rtti
1148endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001149
The Android Open Source Project88b60792009-03-03 19:28:42 -08001150###########################################################
1151# Rule-specific variable definitions
1152###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001153
Ying Wang824344a2014-05-27 13:03:36 -07001154ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001155my_cflags += $(LOCAL_CLANG_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -08001156my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
Dan Albertd2fa96d2014-11-28 14:00:12 -08001157my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -07001158my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
1159my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001160my_asflags += $(LOCAL_CLANG_ASFLAGS)
1161my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001162my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
Stephen Hines15680292014-11-26 00:53:46 -08001163my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix))
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001164my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
1165my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
1166my_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 -08001167my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
1168my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
1169my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
1170my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +08001171endif
1172
Ying Wangd7914632014-10-28 14:50:59 -07001173ifeq ($(my_fdo_build), true)
1174 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
1175 fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
1176 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
Dehao Chen295a6d22014-09-19 10:18:12 -07001177endif
1178
Dan Albertdf3fd1d2015-08-12 14:54:16 -07001179# No one should ever use this flag. On GCC it's mere presence will disable all
1180# warnings, even those that are specified after it (contrary to typical warning
1181# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
1182# warnings that are *always* bugs.
1183my_illegal_flags := -w
1184my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
1185my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
1186my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
1187
The Android Open Source Project88b60792009-03-03 19:28:42 -08001188$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001189$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Stephen Hines15680292014-11-26 00:53:46 -08001190$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001191$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1192$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Dan Albertd1600412015-06-10 16:33:43 -07001193$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1194$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001195$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001196$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001197$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -08001198$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001199$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001200$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001201
1202# this is really the way to get the files onto the command line instead
1203# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1204$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1205$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1206$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
1207$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
1208
1209###########################################################
1210# Define library dependencies.
1211###########################################################
1212# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1213all_libraries := \
1214 $(built_shared_libraries) \
1215 $(built_static_libraries) \
1216 $(built_whole_libraries)
1217
The Android Open Source Project88b60792009-03-03 19:28:42 -08001218# Also depend on the notice files for any static libraries that
1219# are linked into this module. This will force them to be installed
1220# when this module is.
1221$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001222
1223###########################################################
1224# Export includes
1225###########################################################
1226export_includes := $(intermediates)/export_includes
Ying Wangb28ed232015-04-07 11:59:34 -07001227$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
Ying Wang49085952014-05-06 13:03:32 -07001228# Make sure .pb.h are already generated before any dependent source files get compiled.
Christopher Wiley529f1762015-08-14 14:55:32 -07001229$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers) $(dbus_generated_headers)
Ying Wang5f074802011-11-08 09:31:21 -08001230 @echo Export includes file: $< -- $@
1231 $(hide) mkdir -p $(dir $@) && rm -f $@
Ying Wangb28ed232015-04-07 11:59:34 -07001232ifdef my_export_c_include_dirs
Ying Wang5f074802011-11-08 09:31:21 -08001233 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1234 echo "-I $$d" >> $@; \
1235 done
1236else
1237 $(hide) touch $@
1238endif
Ying Wang616e5962012-04-18 17:35:55 -07001239
1240# Make sure export_includes gets generated when you are running mm/mmm
1241$(LOCAL_BUILT_MODULE) : | $(export_includes)