blob: ae018603992f258ebf6b46d05ff8c67782d9dfed [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
Dan Albertb05f2ca2014-09-12 14:46:57 -0700169# Only around for development purposes. Will be removed soon.
170my_libcxx_is_default := false
Ying Wangd90de322014-05-23 16:42:37 -0700171
Dan Albertb05f2ca2014-09-12 14:46:57 -0700172# Select the appropriate C++ STL
173ifeq ($(strip $(LOCAL_CXX_STL)),default)
174 ifndef LOCAL_SDK_VERSION
175 ifeq ($(strip $(my_libcxx_is_default)),true)
176 # Platform code. Select the appropriate STL.
177 my_cxx_stl := libc++
178 else
179 my_cxx_stl := bionic
180 endif
181 else
182 my_cxx_stl := ndk
183 endif
184else
185 my_cxx_stl := $(strip $(LOCAL_CXX_STL))
186endif
187
188ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
189 my_cflags += -D_USING_LIBCXX
190 my_c_includes += external/libcxx/include
191 ifeq ($(my_cxx_stl),libc++)
192 my_shared_libraries += libc++
193 else
194 my_static_libraries += libc++_static
195 endif
196
197 ifdef LOCAL_IS_HOST_MODULE
198 my_cppflags += -nostdinc++
199 my_ldflags += -nodefaultlibs
200 my_ldlibs += -lc -lm
201 endif
202else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),)
203 my_c_includes += external/stlport/stlport bionic/libstdc++/include bionic
204 ifeq ($(my_cxx_stl),stlport)
205 my_shared_libraries += libstdc++ libstlport
206 else
207 my_static_libraries += libstdc++ libstlport_static
208 endif
209else ifeq ($(my_cxx_stl),ndk)
210 # Using an NDK STL. Handled farther up in this file.
211 ifndef LOCAL_IS_HOST_MODULE
212 my_system_shared_libraries += libstdc++
213 endif
214else ifeq ($(my_cxx_stl),bionic)
215 # Using bionic's basic libstdc++. Not actually an STL. Only around until the
216 # tree is in good enough shape to not need it.
217 ifndef LOCAL_IS_HOST_MODULE
218 my_c_includes += bionic/libstdc++/include
219 my_system_shared_libraries += libstdc++
220 endif
221 # Host builds will use GNU libstdc++.
222else ifeq ($(my_cxx_stl),none)
223 ifdef LOCAL_IS_HOST_MODULE
224 my_cppflags += -nostdinc++
225 my_ldflags += -nodefaultlibs -lc -lm
226 endif
227else
228 $(error $(my_cxx_stl) is not a supported STL.)
Ying Wangd90de322014-05-23 16:42:37 -0700229endif
230
Ying Wang285045b2013-08-13 12:35:10 -0700231# Add static HAL libraries
232ifdef LOCAL_HAL_STATIC_LIBRARIES
233$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
234 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800235 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
236 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700237b_lib :=
238endif
239
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400240ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700241 my_clang := true
Ying Wang6ef65192014-01-15 16:02:16 -0800242 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
243 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
244 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
245 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400246endif
247
Ying Wangba8b3772014-03-10 18:23:08 -0700248ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700249 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700250endif
251
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800252# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700253ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800254 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700255endif
256
Ying Wangdfbe79b2012-03-22 11:26:22 -0700257my_compiler_dependencies :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258
Jing Yu2dcc8062009-09-21 16:31:50 -0700259####################################################
260## Add FDO flags if FDO is turned on and supported
261####################################################
synergydev7c467422013-08-13 17:41:52 -0700262ifneq ($(strip $(LOCAL_FDO_SUPPORT)),)
synergydev4a605762013-08-05 02:44:37 -0700263 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800264 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800265 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700266 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700267endif
268
The Android Open Source Project88b60792009-03-03 19:28:42 -0800269###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800270## Explicitly declare assembly-only __ASSEMBLY__ macro for
271## assembly source
272###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800273my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800274
Ying Wangd8d37212014-03-21 16:17:04 -0700275
276##########################################################
277## Set up installed module dependency
278## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
279## they may cusomize their install path with LOCAL_MODULE_PATH
280##########################################################
281# Get the list of INSTALLED libraries as module names.
282ifdef LOCAL_SDK_VERSION
283 installed_shared_library_module_names := \
284 $(my_shared_libraries)
285else
286 installed_shared_library_module_names := \
287 $(my_system_shared_libraries) $(my_shared_libraries)
288endif
289installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
290
291# The real dependency will be added after all Android.mks are loaded and the install paths
292# of the shared libraries are determined.
293ifdef LOCAL_INSTALLED_MODULE
294ifdef installed_shared_library_module_names
295$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wange1b867d2014-06-10 14:21:20 -0700296 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wangd8d37212014-03-21 16:17:04 -0700297endif
298endif
299
Jim Huang20d1ba62010-10-14 16:15:56 +0800300###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700301## Define PRIVATE_ variables from global vars
302###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800303ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700304ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700305my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700306my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800307my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700308else
Ying Wang6ef65192014-01-15 16:02:16 -0800309my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
310my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800311my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700312endif # LOCAL_SDK_VERSION
313
Ying Wang824344a2014-05-27 13:03:36 -0700314ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800315my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800316my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800317my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangf4723fa2013-08-15 11:01:10 -0700318my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
Ying Wangda4bf422012-08-16 16:45:01 -0700319else
Ying Wang6ef65192014-01-15 16:02:16 -0800320my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800321my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800322my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700323endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700324
Dan Albert4bbc6c72014-09-19 14:25:57 -0700325# If the global flag NATIVE_COVERAGE is set, my_native_coverage will be true
326# unless the module explicitly sets my_native_coverage := false.
327ifeq ($(NATIVE_COVERAGE),true)
328 ifeq ($(my_native_coverage),true)
329 # We can't currently generate coverage for clang binaries for two
330 # reasons:
331 #
332 # 1) b/17574078 We currently don't have a prebuilt
333 # libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if
334 # --coverage is passed in the link stage. For now we manually link
335 # libprofile_rt (which is the name it is built as from
336 # external/compiler-rt).
337 #
338 # 2) b/17583330 Clang doesn't generate .gcno files when using
339 # -no-integrated-as. Since most of the assembly in our tree is
340 # incompatible with clang's assembler, we can't turn off this flag.
341 ifneq ($(my_clang),true)
342 my_target_global_cflags += --coverage
343 my_target_global_ldflags += --coverage
344 endif
345 endif
346else
347 my_native_coverage := false
348endif
349
Ying Wang1a081002010-07-13 14:55:47 -0700350$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400351$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700352$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800353$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
354$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
355
Ying Wang7fff9a12014-01-09 14:39:41 -0800356else # LOCAL_IS_HOST_MODULE
357
Ying Wang824344a2014-05-27 13:03:36 -0700358ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700359my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
360my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
361my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
362my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800363else
Ying Wang6feb6d52014-04-17 10:03:35 -0700364my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
365my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
366my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
367my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700368endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800369
370$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
371$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
372$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
373$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
374endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700375
376###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800377## Define PRIVATE_ variables used by multiple module types
378###########################################################
379$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700380 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800381
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800382ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
383 LOCAL_NO_SYNTAX_CHECK := true
384endif
385
Andrew Hsieh906cb782013-09-10 17:37:14 +0800386ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
387 LOCAL_NO_STATIC_ANALYZER := true
388endif
389
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800390ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
391 my_syntax_arch := host
392else
Ying Wang6ef65192014-01-15 16:02:16 -0800393 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800394endif
395
Ying Wang6ef65192014-01-15 16:02:16 -0800396ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700397 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800398 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400399 else
Ying Wang6ef65192014-01-15 16:02:16 -0800400 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400401 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800402endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800403ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800404 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800405else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800406ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800407 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800408endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800409endif
Ying Wang6ef65192014-01-15 16:02:16 -0800410$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800411
Ying Wang6ef65192014-01-15 16:02:16 -0800412ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700413 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800414 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400415 else
Ying Wang6ef65192014-01-15 16:02:16 -0800416 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400417 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800418endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800419ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800420 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800421else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800422ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800423 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800424endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800425endif
Ying Wang6ef65192014-01-15 16:02:16 -0800426$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700427$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800428
429# TODO: support a mix of standard extensions so that this isn't necessary
430LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
431ifeq ($(LOCAL_CPP_EXTENSION),)
432 LOCAL_CPP_EXTENSION := .cpp
433endif
434$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
435
436# Certain modules like libdl have to have symbols resolved at runtime and blow
437# up if --no-undefined is passed to the linker.
438ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
439ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800440 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800441endif
442endif
443
Ying Wangfcdabd42011-04-25 14:22:41 -0700444ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
445$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
446else
447$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
448endif
449
The Android Open Source Project88b60792009-03-03 19:28:42 -0800450###########################################################
451## Define arm-vs-thumb-mode flags.
452###########################################################
453LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800454ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800455arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
456normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
457
Dave Bort95282482009-04-23 18:44:55 -0700458# Read the values from something like TARGET_arm_CFLAGS or
459# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
460# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800461arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
462normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700463ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800464arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
465normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400466endif
467
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800468else
469arm_objects_mode :=
470normal_objects_mode :=
471arm_objects_cflags :=
472normal_objects_cflags :=
473endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800474
475###########################################################
476## Define per-module debugging flags. Users can turn on
477## debugging for a particular module by setting DEBUG_MODULE_ModuleName
478## to a non-empty value in their environment or buildspec.mk,
479## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
480## debug flags that they want to use.
481###########################################################
482ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
483 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
484else
485 debug_cflags :=
486endif
487
Tim Murraya7aa8002012-10-29 16:06:00 -0700488####################################################
489## Compile RenderScript with reflected C++
490####################################################
491
Ying Wangb8e01852014-01-23 15:09:04 -0800492renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700493
494ifneq (,$(renderscript_sources))
495
496renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
497RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
498renderscript_intermediate := $(intermediates)/renderscript
499
500ifeq ($(LOCAL_RENDERSCRIPT_CC),)
501LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
502endif
503
504# Turn on all warnings and warnings as errors for RS compiles.
505# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
506renderscript_flags := -Wall -Werror
507renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
508
Ying Wang6ef65192014-01-15 16:02:16 -0800509renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700510 $(TOPDIR)external/clang/lib/Headers \
511 $(TOPDIR)frameworks/rs/scriptc \
512 $(LOCAL_RENDERSCRIPT_INCLUDES)
513
514ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800515renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700516endif
517
Ying Wang6ef65192014-01-15 16:02:16 -0800518$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700519$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
520$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
521$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
522$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
523$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
524 $(transform-renderscripts-to-cpp-and-bc)
525
526# include the dependency files (.d) generated by llvm-rs-cc.
527renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
528 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
529-include $(renderscript_generated_dep_files)
530
531LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
532
533rs_generated_cpps := $(addprefix \
534 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
535 $(notdir $(renderscript_sources)))))
536
Stephen Hines8ff92522014-06-06 12:51:47 -0700537# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700538$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700539 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700540
Ying Wang6ef65192014-01-15 16:02:16 -0800541my_c_includes += $(renderscript_intermediate)
542my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700543
544endif
545
546
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547###########################################################
548## Stuff source generated from one-off tools
549###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800550$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800551
Colin Crossd8262642014-01-24 23:17:21 -0800552my_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 -0800553
Colin Crossd8262642014-01-24 23:17:21 -0800554$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
555 @echo "Copy: $@"
556 $(copy-file-to-target)
557
558my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
559
560ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800561
562###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700563## Compile the .proto files to .cc and then to .o
564###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800565proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700566proto_generated_objects :=
567proto_generated_headers :=
568ifneq ($(proto_sources),)
569proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wang031e0fb2014-02-25 11:18:40 -0800570proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
Ying Wanga5fc87a2010-11-02 18:43:16 -0700571proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700572 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wang031e0fb2014-02-25 11:18:40 -0800573proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
574proto_generated_obj_dir := $(intermediates)/proto
575proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
576 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700577
Ying Wang031e0fb2014-02-25 11:18:40 -0800578# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
579ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wanga5fc87a2010-11-02 18:43:16 -0700580$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
581$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700582$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700583$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
584 $(transform-proto-to-cc)
585
Stephen Hines8ff92522014-06-06 12:51:47 -0700586# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wanga5fc87a2010-11-02 18:43:16 -0700587$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
Ying Wang81ab8332014-05-28 16:17:09 -0700588 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700589
Ying Wang031e0fb2014-02-25 11:18:40 -0800590$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
591endif # transform-proto-to-cc rule included only once
592
Ying Wang022a7b32012-06-13 11:38:10 -0700593$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
594$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wang031e0fb2014-02-25 11:18:40 -0800595$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700596 $(transform-$(PRIVATE_HOST)cpp-to-o)
597-include $(proto_generated_objects:%.o=%.P)
598
Ying Wang6ef65192014-01-15 16:02:16 -0800599my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
600my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700601ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800602my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700603else
Ying Wang6ef65192014-01-15 16:02:16 -0800604my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700605endif
Ying Wang031e0fb2014-02-25 11:18:40 -0800606endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700607
608
609###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000610## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800611###########################################################
612
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000613y_yacc_sources := $(filter %.y,$(my_src_files))
614y_yacc_cpps := $(addprefix \
615 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
616
617yy_yacc_sources := $(filter %.yy,$(my_src_files))
618yy_yacc_cpps := $(addprefix \
619 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
620
621yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
623yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
624
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000625ifneq ($(strip $(y_yacc_cpps)),)
626$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700627 $(TOPDIR)$(LOCAL_PATH)/%.y \
628 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
630$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000631endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800632
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000633ifneq ($(strip $(yy_yacc_cpps)),)
634$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
635 $(TOPDIR)$(LOCAL_PATH)/%.yy \
636 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
637 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
638$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
639endif
640
641ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800642$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
643$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
644$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
645 $(transform-$(PRIVATE_HOST)cpp-to-o)
646endif
647
648###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000649## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800650###########################################################
651
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000652l_lex_sources := $(filter %.l,$(my_src_files))
653l_lex_cpps := $(addprefix \
654 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
655
656ll_lex_sources := $(filter %.ll,$(my_src_files))
657ll_lex_cpps := $(addprefix \
658 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
659
660lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
662
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000663ifneq ($(strip $(l_lex_cpps)),)
664$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700665 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800666 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000667endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800668
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000669ifneq ($(strip $(ll_lex_cpps)),)
670$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
671 $(TOPDIR)$(LOCAL_PATH)/%.ll
672 $(transform-l-to-cpp)
673endif
674
675ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800676$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
677$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
678$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700679 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
680 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
681 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800682 $(transform-$(PRIVATE_HOST)cpp-to-o)
683endif
684
685###########################################################
686## C++: Compile .cpp files to .o.
687###########################################################
688
Jeff Browne33ba4c2011-07-11 22:11:46 -0700689# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800690# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800691cpp_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 -0800692cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
693
Ying Wangb8e01852014-01-23 15:09:04 -0800694cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800695cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
696
697$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
698$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
699$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
700$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
701
702cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
703
704ifneq ($(strip $(cpp_objects)),)
705$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700706 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800707 $(yacc_cpps) $(proto_generated_headers) \
708 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
709 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710 $(transform-$(PRIVATE_HOST)cpp-to-o)
711-include $(cpp_objects:%.o=%.P)
712endif
713
714###########################################################
715## C++: Compile generated .cpp files to .o.
716###########################################################
717
Ying Wangec6d6262014-01-16 16:21:03 -0800718gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800719gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
720
721ifneq ($(strip $(gen_cpp_objects)),)
722# Compile all generated files as thumb.
723# TODO: support compiling certain generated files as arm.
724$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
725$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400726$(gen_cpp_objects): $(intermediates)/%.o: \
727 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800728 $(proto_generated_headers) \
729 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
730 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731 $(transform-$(PRIVATE_HOST)cpp-to-o)
732-include $(gen_cpp_objects:%.o=%.P)
733endif
734
735###########################################################
736## S: Compile generated .S and .s files to .o.
737###########################################################
738
Ying Wangec6d6262014-01-16 16:21:03 -0800739gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800740gen_S_objects := $(gen_S_sources:%.S=%.o)
741
742ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400743$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800744 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
745 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800746 $(transform-$(PRIVATE_HOST)s-to-o)
747-include $(gen_S_objects:%.o=%.P)
748endif
749
Ying Wangec6d6262014-01-16 16:21:03 -0800750gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800751gen_s_objects := $(gen_s_sources:%.s=%.o)
752
753ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400754$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800755 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
756 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800757 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
758-include $(gen_s_objects:%.o=%.P)
759endif
760
761gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
762
763###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000764## o: Include generated .o files in output.
765###########################################################
766
Ying Wangec6d6262014-01-16 16:21:03 -0800767gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000768
769###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770## C: Compile .c files to .o.
771###########################################################
772
Ying Wangb8e01852014-01-23 15:09:04 -0800773c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
775
Ying Wangb8e01852014-01-23 15:09:04 -0800776c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800777c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
778
779$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
780$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
781$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
782$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
783
784c_objects := $(c_arm_objects) $(c_normal_objects)
785
786ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400787$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800788 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
789 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800790 $(transform-$(PRIVATE_HOST)c-to-o)
791-include $(c_objects:%.o=%.P)
792endif
793
794###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700795## C: Compile generated .c files to .o.
796###########################################################
797
Ying Wangec6d6262014-01-16 16:21:03 -0800798gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700799gen_c_objects := $(gen_c_sources:%.c=%.o)
800
801ifneq ($(strip $(gen_c_objects)),)
802# Compile all generated files as thumb.
803# TODO: support compiling certain generated files as arm.
804$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
805$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400806$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800807 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
808 | $(my_compiler_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700809 $(transform-$(PRIVATE_HOST)c-to-o)
810-include $(gen_c_objects:%.o=%.P)
811endif
812
813###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200814## ObjC: Compile .m files to .o
815###########################################################
816
Ying Wangb8e01852014-01-23 15:09:04 -0800817objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200818objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
819
820ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400821$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800822 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
823 | $(my_compiler_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200824 $(transform-$(PRIVATE_HOST)m-to-o)
825-include $(objc_objects:%.o=%.P)
826endif
827
828###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800829## AS: Compile .S files to .o.
830###########################################################
831
Ying Wangb8e01852014-01-23 15:09:04 -0800832asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
834
835ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400836$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800837 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
838 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800839 $(transform-$(PRIVATE_HOST)s-to-o)
840-include $(asm_objects_S:%.o=%.P)
841endif
842
Ying Wangb8e01852014-01-23 15:09:04 -0800843asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800844asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
845
846ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400847$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800848 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
849 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800850 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
851-include $(asm_objects_s:%.o=%.P)
852endif
853
854asm_objects := $(asm_objects_S) $(asm_objects_s)
855
856
Ying Wang7b913ce2014-06-05 19:05:47 -0700857# .asm for x86 needs to be compiled with yasm.
858ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
859asm_sources_asm := $(filter %.asm,$(my_src_files))
860ifneq ($(strip $(asm_sources_asm)),)
861asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
862$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
863 $(LOCAL_ADDITIONAL_DEPENDENCIES)
864 $(transform-asm-to-o)
865
866asm_objects += $(asm_objects_asm)
867endif
868endif
869
Ying Wang5f074802011-11-08 09:31:21 -0800870####################################################
871## Import includes
872####################################################
873import_includes := $(intermediates)/import_includes
874import_includes_deps := $(strip \
875 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800876 $(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 -0800877 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800878 $(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 -0800879$(import_includes) : $(import_includes_deps)
880 @echo Import includes file: $@
881 $(hide) mkdir -p $(dir $@) && rm -f $@
882ifdef import_includes_deps
883 $(hide) for f in $^; do \
884 cat $$f >> $@; \
885 done
886else
887 $(hide) touch $@
888endif
889
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890###########################################################
891## Common object handling.
892###########################################################
893
894# some rules depend on asm_objects being first. If your code depends on
895# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100896normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700897 $(asm_objects) \
898 $(cpp_objects) \
899 $(gen_cpp_objects) \
900 $(gen_asm_objects) \
901 $(c_objects) \
902 $(gen_c_objects) \
903 $(objc_objects) \
904 $(yacc_objects) \
905 $(lex_objects) \
906 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100907 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
908
909all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910
Colin Cross2d206702014-02-13 13:41:52 -0800911my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912
Ying Wang848020f2012-08-14 10:13:16 -0700913ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800914 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700915endif
916
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100917# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
918# use normal_objects here to avoid creating circular dependencies. This assumes
919# that custom build rules which generate .o files don't consume other generated
920# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800921$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100922$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923ALL_C_CPP_ETC_OBJECTS += $(all_objects)
924
The Android Open Source Project88b60792009-03-03 19:28:42 -0800925
926###########################################################
927# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929
930###########################################################
931# The list of libraries that this module will link against are in
932# these variables. Each is a list of bare module names like "libc libm".
933#
934# LOCAL_SHARED_LIBRARIES
935# LOCAL_STATIC_LIBRARIES
936# LOCAL_WHOLE_STATIC_LIBRARIES
937#
938# We need to convert the bare names into the dependencies that
939# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
940# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
941# libraries, so that simply building this module doesn't force
942# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
943# should depend on the INSTALLED versions of the libraries so
944# that they get installed when this module does.
945###########################################################
946# NOTE:
947# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
948# module without leaving anything out, which is useful for turning
949# a collection of .a files into a .so file. Linking against a
950# normal STATIC_LIBRARY will only pull in code/symbols that are
951# referenced by the module. (see gcc/ld's --whole-archive option)
952###########################################################
953
954# Get the list of BUILT libraries, which are under
955# various intermediates directories.
956so_suffix := $($(my_prefix)SHLIB_SUFFIX)
957a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
958
Ying Wang848020f2012-08-14 10:13:16 -0700959ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800960built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800961 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800963 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964
Ying Wangd8d37212014-03-21 16:17:04 -0700965# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -0800966my_system_shared_libraries_fullpath := \
967 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -0700968 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -0700969 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700970
971built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -0700972else
Ying Wang1a081002010-07-13 14:55:47 -0700973built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800974 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700975 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -0700976 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -0700977endif
978
The Android Open Source Project88b60792009-03-03 19:28:42 -0800979built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800980 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800981 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800982 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 -0800983
Ying Wang848020f2012-08-14 10:13:16 -0700984ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800985built_static_libraries += $(my_ndk_stl_static_lib)
986endif
987
The Android Open Source Project88b60792009-03-03 19:28:42 -0800988built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -0800989 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800990 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800991 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 -0800992
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993# We don't care about installed static libraries, since the
994# libraries have already been linked into the module at that point.
995# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000996# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800997
998installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -0800999 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001000 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
1001
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001002# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001003ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1004LOCAL_RTTI_FLAG := -fno-rtti
1005endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001006
The Android Open Source Project88b60792009-03-03 19:28:42 -08001007###########################################################
1008# Rule-specific variable definitions
1009###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001010
Ying Wang824344a2014-05-27 13:03:36 -07001011ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001012my_cflags += $(LOCAL_CLANG_CFLAGS)
1013my_cpplags += $(LOCAL_CLANG_CPPFLAGS)
1014my_asflags += $(LOCAL_CLANG_ASFLAGS)
1015my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -08001016my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
1017my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
1018my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
1019my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +08001020endif
1021
The Android Open Source Project88b60792009-03-03 19:28:42 -08001022$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001023$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -07001024$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001025$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1026$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001027$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001028$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001029$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -08001030$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001031$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001032$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Ying Wangb8e01852014-01-23 15:09:04 -08001033$(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 -07001034$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001035
1036# this is really the way to get the files onto the command line instead
1037# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1038$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1039$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1040$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
1041$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
1042
1043###########################################################
1044# Define library dependencies.
1045###########################################################
1046# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1047all_libraries := \
1048 $(built_shared_libraries) \
1049 $(built_static_libraries) \
1050 $(built_whole_libraries)
1051
The Android Open Source Project88b60792009-03-03 19:28:42 -08001052# Also depend on the notice files for any static libraries that
1053# are linked into this module. This will force them to be installed
1054# when this module is.
1055$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001056
1057###########################################################
1058# Export includes
1059###########################################################
1060export_includes := $(intermediates)/export_includes
1061$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang68f1c772012-04-23 21:29:18 -07001062$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
Ying Wang5f074802011-11-08 09:31:21 -08001063 @echo Export includes file: $< -- $@
1064 $(hide) mkdir -p $(dir $@) && rm -f $@
1065ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
1066 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1067 echo "-I $$d" >> $@; \
1068 done
1069else
1070 $(hide) touch $@
1071endif
Ying Wang616e5962012-04-18 17:35:55 -07001072
1073# Make sure export_includes gets generated when you are running mm/mmm
1074$(LOCAL_BUILT_MODULE) : | $(export_includes)