blob: 7b51bc2e3262af98f8a99a504f1ce9cc5babcd3f [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building binary object files from
Ying Wangd8d37212014-03-21 16:17:04 -07003## asm/c/cpp/yacc/lex/etc source files.
The Android Open Source Project88b60792009-03-03 19:28:42 -08004##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
Ying Wangd8d37212014-03-21 16:17:04 -07008#######################################
9include $(BUILD_SYSTEM)/base_rules.mk
10#######################################
11
Andrew Hsieh140761af02014-04-25 23:47:10 -070012my_ndk_sysroot :=
13my_ndk_sysroot_include :=
14my_ndk_sysroot_lib :=
Ying Wang848020f2012-08-14 10:13:16 -070015ifdef LOCAL_SDK_VERSION
Ying Wangfe1bfe72012-08-14 11:08:03 -070016 ifdef LOCAL_NDK_VERSION
17 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
18 endif
Ying Wang1a081002010-07-13 14:55:47 -070019 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070020 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070021 endif
Ying Wang848020f2012-08-14 10:13:16 -070022 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
Andrew Hsieh140761af02014-04-25 23:47:10 -070023 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
24 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
25 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
26 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
27 else
28 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
29 endif
Ying Wangcce4c972011-03-03 18:53:53 -080030
31 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
32 # See ndk/docs/CPLUSPLUS-SUPPORT.html
33 my_ndk_stl_include_path :=
34 my_ndk_stl_shared_lib_fullpath :=
35 my_ndk_stl_shared_lib :=
36 my_ndk_stl_static_lib :=
Andrew Hsieh73d800e2014-03-04 17:11:52 +080037 my_ndk_stl_cppflags :=
38 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -080039 ifeq (,$(LOCAL_NDK_STL_VARIANT))
40 LOCAL_NDK_STL_VARIANT := system
41 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080042 ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -070043 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -080044 endif
45 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
46 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
47 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
48 else # LOCAL_NDK_STL_VARIANT is not system
49 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
50 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
51 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
Ying Wang6ef65192014-01-15 16:02:16 -080052 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a
Ying Wangcce4c972011-03-03 18:53:53 -080053 else
Ying Wang6ef65192014-01-15 16:02:16 -080054 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so
Ying Wangcce4c972011-03-03 18:53:53 -080055 my_ndk_stl_shared_lib := -lstlport_shared
56 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080057 else # LOCAL_NDK_STL_VARIANT is not stlport_* either
58 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
59 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
60 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
61 $(my_ndk_source_root)/android/support/include
62 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
63 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a
64 else
65 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so
66 my_ndk_stl_shared_lib := -lc++_shared
67 endif
68 my_ndk_stl_cppflags := -std=c++11
Ying Wangcce4c972011-03-03 18:53:53 -080069 else
70 # LOCAL_NDK_STL_VARIANT is gnustl_static
Ben Cheng4de6fa42014-04-10 22:46:26 -070071 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \
72 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
73 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a
Ying Wangcce4c972011-03-03 18:53:53 -080074 endif
75 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +080076 endif
Ying Wang1a081002010-07-13 14:55:47 -070077endif
78
Ying Wang704c0c92011-09-15 13:50:52 -070079##################################################
80# Compute the dependency of the shared libraries
81##################################################
82# On the target, we compile with -nostdlib, so we must add in the
83# default system shared libraries, unless they have requested not
84# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
85# supply that, for example, when building libc itself.
86ifdef LOCAL_IS_HOST_MODULE
87 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wangd8d37212014-03-21 16:17:04 -070088 my_system_shared_libraries :=
89 else
90 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang704c0c92011-09-15 13:50:52 -070091 endif
92else
93 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wangd8d37212014-03-21 16:17:04 -070094 my_system_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
95 else
96 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang704c0c92011-09-15 13:50:52 -070097 endif
98endif
99
Ying Wang6ef65192014-01-15 16:02:16 -0800100# The following LOCAL_ variables will be modified in this file.
101# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
102# we can't modify them in place.
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800103my_src_files := $(LOCAL_SRC_FILES)
104my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
105my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
106my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
107my_cflags := $(LOCAL_CFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800108my_cppflags := $(LOCAL_CPPFLAGS)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800109my_ldflags := $(LOCAL_LDFLAGS)
Dan Albertb05f2ca2014-09-12 14:46:57 -0700110my_ldlibs := $(LOCAL_LDLIBS)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800111my_asflags := $(LOCAL_ASFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800112my_cc := $(LOCAL_CC)
113my_cxx := $(LOCAL_CXX)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800114my_c_includes := $(LOCAL_C_INCLUDES)
115my_generated_sources := $(LOCAL_GENERATED_SOURCES)
Dan Albert4bbc6c72014-09-19 14:25:57 -0700116my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800117
Dan Albert95994de2014-08-07 18:29:11 -0700118# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
119# all code is position independent, and then those warnings get promoted to
120# errors.
Ying Wang594a10a2014-08-07 20:08:04 -0700121ifndef USE_MINGW
Dan Albert4803ce22014-08-06 12:36:46 -0700122ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
123my_cflags += -fpie
124else
125my_cflags += -fPIC
126endif
Dan Albert95994de2014-08-07 18:29:11 -0700127endif
Dan Albert4803ce22014-08-06 12:36:46 -0700128
Ying Wang6feb6d52014-04-17 10:03:35 -0700129my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
130my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
131my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
132my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
133my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
134my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
135my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
136my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800137
Dan Albertdb905e72014-08-18 11:14:38 -0700138my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700139ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700140my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700141endif
142ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700143my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700144endif
145
Tim Murray92d79cb2014-04-04 14:38:29 -0700146# clang is enabled by default for host builds
147# enable it unless we've specifically disabled clang above
148ifdef LOCAL_IS_HOST_MODULE
Tim Murrayf3ca3d52014-07-24 15:20:18 -0700149 ifneq ($(HOST_OS),windows)
Tim Murray5ca1dc12014-07-24 14:42:53 -0700150 ifeq ($(my_clang),)
151 my_clang := true
152 endif
153 endif
Tim Murray92d79cb2014-04-04 14:38:29 -0700154endif
155
Tim Murray06659bc2014-08-13 11:53:07 -0700156# Add option to make clang the default for device build
157ifeq ($(USE_CLANG_PLATFORM_BUILD),true)
158 ifeq ($(my_clang),)
159 my_clang := true
160 endif
161endif
162
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800163# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700164my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
165my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
Ying Wang6ef65192014-01-15 16:02:16 -0800166
Ying Wang6feb6d52014-04-17 10:03:35 -0700167my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
Ying Wang6ef65192014-01-15 16:02:16 -0800168
Ying Wang75e8fcb2014-10-07 13:03:29 -0700169include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700170
Ying Wang285045b2013-08-13 12:35:10 -0700171# Add static HAL libraries
172ifdef LOCAL_HAL_STATIC_LIBRARIES
173$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
174 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800175 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
176 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700177b_lib :=
178endif
179
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400180ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700181 my_clang := true
Evgeniy Stepanov5d8029f2014-02-21 18:10:53 +0400182 # Frame pointer based unwinder in ASan requires ARM frame setup.
183 LOCAL_ARM_MODE := arm
Ying Wang6ef65192014-01-15 16:02:16 -0800184 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
185 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
Dan Albert2daceaa2014-10-20 11:37:18 -0700186 ifdef LOCAL_IS_HOST_MODULE
Dan Albert4ffe3f52014-10-20 13:30:00 -0700187 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_HOST)
Dan Albert2daceaa2014-10-20 11:37:18 -0700188 my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_HOST)
189 my_shared_libraries += \
190 $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_HOST)
191 my_static_libraries += \
192 $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_HOST)
193 else
Dan Albert4ffe3f52014-10-20 13:30:00 -0700194 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS_TARGET)
Dan Albert2daceaa2014-10-20 11:37:18 -0700195 my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_TARGET)
196 my_shared_libraries += \
197 $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_TARGET)
198 my_static_libraries += \
199 $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_TARGET)
200 endif
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400201endif
202
Ying Wangba8b3772014-03-10 18:23:08 -0700203ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700204 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700205endif
206
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800207# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700208ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800209 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700210endif
211
Jing Yu2dcc8062009-09-21 16:31:50 -0700212####################################################
213## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700214## Please note that we will do option filtering during FDO build.
215## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
216##################################################################
Dehao Chenf7a909d2014-08-07 16:53:18 -0700217ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
synergydev4a605762013-08-05 02:44:37 -0700218 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800219 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
Dehao Chenf4294cd2014-08-20 16:48:17 -0700220 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700221 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700222endif
223
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800225## Explicitly declare assembly-only __ASSEMBLY__ macro for
226## assembly source
227###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800228my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800229
Ying Wangd8d37212014-03-21 16:17:04 -0700230
231##########################################################
232## Set up installed module dependency
233## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
234## they may cusomize their install path with LOCAL_MODULE_PATH
235##########################################################
236# Get the list of INSTALLED libraries as module names.
237ifdef LOCAL_SDK_VERSION
238 installed_shared_library_module_names := \
239 $(my_shared_libraries)
240else
241 installed_shared_library_module_names := \
242 $(my_system_shared_libraries) $(my_shared_libraries)
243endif
244installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
245
246# The real dependency will be added after all Android.mks are loaded and the install paths
247# of the shared libraries are determined.
248ifdef LOCAL_INSTALLED_MODULE
249ifdef installed_shared_library_module_names
250$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wange1b867d2014-06-10 14:21:20 -0700251 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wangd8d37212014-03-21 16:17:04 -0700252endif
253endif
254
Jim Huang20d1ba62010-10-14 16:15:56 +0800255###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700256## Define PRIVATE_ variables from global vars
257###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800258ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700259ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700260my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700261my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800262my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700263else
Ying Wang6ef65192014-01-15 16:02:16 -0800264my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
265my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800266my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700267endif # LOCAL_SDK_VERSION
268
Ying Wang824344a2014-05-27 13:03:36 -0700269ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800270my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800271my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800272my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700273else
Ying Wang6ef65192014-01-15 16:02:16 -0800274my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800275my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800276my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700277endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700278
Dan Albert4c12c032014-10-07 23:37:53 -0700279# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
280# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
281# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
282# clean build of your module after toggling it.
Dan Albert4bbc6c72014-09-19 14:25:57 -0700283ifeq ($(NATIVE_COVERAGE),true)
284 ifeq ($(my_native_coverage),true)
285 # We can't currently generate coverage for clang binaries for two
286 # reasons:
287 #
288 # 1) b/17574078 We currently don't have a prebuilt
289 # libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if
290 # --coverage is passed in the link stage. For now we manually link
291 # libprofile_rt (which is the name it is built as from
292 # external/compiler-rt).
293 #
294 # 2) b/17583330 Clang doesn't generate .gcno files when using
295 # -no-integrated-as. Since most of the assembly in our tree is
296 # incompatible with clang's assembler, we can't turn off this flag.
297 ifneq ($(my_clang),true)
Dan Albert4c12c032014-10-07 23:37:53 -0700298 my_cflags += --coverage -O0
299 my_ldflags += --coverage
Dan Albert4bbc6c72014-09-19 14:25:57 -0700300 endif
301 endif
302else
303 my_native_coverage := false
304endif
305
Ying Wang1a081002010-07-13 14:55:47 -0700306$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400307$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700308$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800309$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
310$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
311
Ying Wang7fff9a12014-01-09 14:39:41 -0800312else # LOCAL_IS_HOST_MODULE
313
Ying Wang824344a2014-05-27 13:03:36 -0700314ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700315my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
316my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
317my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
Stephen Hinesf0089662014-09-25 22:35:16 -0700318my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800319else
Ying Wang6feb6d52014-04-17 10:03:35 -0700320my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
321my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
322my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
323my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700324endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800325
326$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
327$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
328$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
329$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
330endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700331
332###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800333## Define PRIVATE_ variables used by multiple module types
334###########################################################
335$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700336 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800337
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800338ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
339 LOCAL_NO_SYNTAX_CHECK := true
340endif
341
Andrew Hsieh906cb782013-09-10 17:37:14 +0800342ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
343 LOCAL_NO_STATIC_ANALYZER := true
344endif
345
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800346ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
347 my_syntax_arch := host
348else
Ying Wang6ef65192014-01-15 16:02:16 -0800349 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800350endif
351
Ying Wang6ef65192014-01-15 16:02:16 -0800352ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700353 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800354 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400355 else
Ying Wang6ef65192014-01-15 16:02:16 -0800356 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400357 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800358endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800359ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800360 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800361else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800362ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800363 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800364endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800365endif
Ying Wang6ef65192014-01-15 16:02:16 -0800366$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367
Ying Wang6ef65192014-01-15 16:02:16 -0800368ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700369 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800370 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400371 else
Ying Wang6ef65192014-01-15 16:02:16 -0800372 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400373 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800374endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800375ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800376 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800377else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800378ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800379 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800380endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800381endif
Ying Wang6ef65192014-01-15 16:02:16 -0800382$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700383$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800384
385# TODO: support a mix of standard extensions so that this isn't necessary
386LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
387ifeq ($(LOCAL_CPP_EXTENSION),)
388 LOCAL_CPP_EXTENSION := .cpp
389endif
390$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
391
392# Certain modules like libdl have to have symbols resolved at runtime and blow
393# up if --no-undefined is passed to the linker.
394ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
395ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800396 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800397endif
398endif
399
Ying Wangfcdabd42011-04-25 14:22:41 -0700400ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
401$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
402else
403$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
404endif
405
The Android Open Source Project88b60792009-03-03 19:28:42 -0800406###########################################################
407## Define arm-vs-thumb-mode flags.
408###########################################################
409LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800410ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800411arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
412normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
413
Dave Bort95282482009-04-23 18:44:55 -0700414# Read the values from something like TARGET_arm_CFLAGS or
415# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
416# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800417arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
418normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700419ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800420arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
421normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400422endif
423
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800424else
425arm_objects_mode :=
426normal_objects_mode :=
427arm_objects_cflags :=
428normal_objects_cflags :=
429endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800430
431###########################################################
432## Define per-module debugging flags. Users can turn on
433## debugging for a particular module by setting DEBUG_MODULE_ModuleName
434## to a non-empty value in their environment or buildspec.mk,
435## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
436## debug flags that they want to use.
437###########################################################
438ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
439 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
440else
441 debug_cflags :=
442endif
443
Tim Murraya7aa8002012-10-29 16:06:00 -0700444####################################################
445## Compile RenderScript with reflected C++
446####################################################
447
Ying Wangb8e01852014-01-23 15:09:04 -0800448renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700449
450ifneq (,$(renderscript_sources))
451
452renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
453RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
454renderscript_intermediate := $(intermediates)/renderscript
455
456ifeq ($(LOCAL_RENDERSCRIPT_CC),)
457LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
458endif
459
460# Turn on all warnings and warnings as errors for RS compiles.
461# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
462renderscript_flags := -Wall -Werror
463renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700464# -m32 or -m64
465renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700466
Ying Wang6ef65192014-01-15 16:02:16 -0800467renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700468 $(TOPDIR)external/clang/lib/Headers \
469 $(TOPDIR)frameworks/rs/scriptc \
470 $(LOCAL_RENDERSCRIPT_INCLUDES)
471
472ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800473renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700474endif
475
Ying Wang6ef65192014-01-15 16:02:16 -0800476$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700477$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
478$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
479$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
480$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
481$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
482 $(transform-renderscripts-to-cpp-and-bc)
483
484# include the dependency files (.d) generated by llvm-rs-cc.
485renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
486 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
487-include $(renderscript_generated_dep_files)
488
489LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
490
491rs_generated_cpps := $(addprefix \
492 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
493 $(notdir $(renderscript_sources)))))
494
Stephen Hines8ff92522014-06-06 12:51:47 -0700495# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700496$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700497 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700498
Ying Wang6ef65192014-01-15 16:02:16 -0800499my_c_includes += $(renderscript_intermediate)
500my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700501
502endif
503
504
The Android Open Source Project88b60792009-03-03 19:28:42 -0800505###########################################################
506## Stuff source generated from one-off tools
507###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800508$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800509
Colin Crossd8262642014-01-24 23:17:21 -0800510my_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 -0800511
Colin Crossd8262642014-01-24 23:17:21 -0800512$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
513 @echo "Copy: $@"
514 $(copy-file-to-target)
515
516my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
517
518ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800519
520###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700521## Compile the .proto files to .cc and then to .o
522###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800523proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700524proto_generated_objects :=
525proto_generated_headers :=
526ifneq ($(proto_sources),)
527proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangead89442014-02-25 11:18:40 -0800528proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
Ying Wanga5fc87a2010-11-02 18:43:16 -0700529proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700530 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wangead89442014-02-25 11:18:40 -0800531proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
532proto_generated_obj_dir := $(intermediates)/proto
533proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
534 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700535
Ying Wang49085952014-05-06 13:03:32 -0700536# Auto-export the generated proto source dir.
537LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir)
538
Ying Wangead89442014-02-25 11:18:40 -0800539# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
540ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wanga5fc87a2010-11-02 18:43:16 -0700541$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
542$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700543$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700544$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
545 $(transform-proto-to-cc)
546
Stephen Hines8ff92522014-06-06 12:51:47 -0700547# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wanga5fc87a2010-11-02 18:43:16 -0700548$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
Ying Wang81ab8332014-05-28 16:17:09 -0700549 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700550
Ying Wangead89442014-02-25 11:18:40 -0800551$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
552endif # transform-proto-to-cc rule included only once
553
Ying Wang022a7b32012-06-13 11:38:10 -0700554$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
555$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wangead89442014-02-25 11:18:40 -0800556$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700557 $(transform-$(PRIVATE_HOST)cpp-to-o)
558-include $(proto_generated_objects:%.o=%.P)
559
Ying Wang6ef65192014-01-15 16:02:16 -0800560my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
561my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700562ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800563my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700564else
Ying Wang6ef65192014-01-15 16:02:16 -0800565my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700566endif
Ying Wangead89442014-02-25 11:18:40 -0800567endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700568
569
570###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000571## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572###########################################################
573
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000574y_yacc_sources := $(filter %.y,$(my_src_files))
575y_yacc_cpps := $(addprefix \
576 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
577
578yy_yacc_sources := $(filter %.yy,$(my_src_files))
579yy_yacc_cpps := $(addprefix \
580 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
581
582yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800583yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
584yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
585
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000586ifneq ($(strip $(y_yacc_cpps)),)
587$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700588 $(TOPDIR)$(LOCAL_PATH)/%.y \
589 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800590 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
591$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000592endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000594ifneq ($(strip $(yy_yacc_cpps)),)
595$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
596 $(TOPDIR)$(LOCAL_PATH)/%.yy \
597 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
598 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
599$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
600endif
601
602ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800603$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
604$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
605$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
606 $(transform-$(PRIVATE_HOST)cpp-to-o)
607endif
608
609###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000610## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800611###########################################################
612
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000613l_lex_sources := $(filter %.l,$(my_src_files))
614l_lex_cpps := $(addprefix \
615 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
616
617ll_lex_sources := $(filter %.ll,$(my_src_files))
618ll_lex_cpps := $(addprefix \
619 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
620
621lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
623
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000624ifneq ($(strip $(l_lex_cpps)),)
625$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700626 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800627 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000628endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000630ifneq ($(strip $(ll_lex_cpps)),)
631$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
632 $(TOPDIR)$(LOCAL_PATH)/%.ll
633 $(transform-l-to-cpp)
634endif
635
636ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800637$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
638$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
639$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700640 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
641 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
642 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800643 $(transform-$(PRIVATE_HOST)cpp-to-o)
644endif
645
646###########################################################
647## C++: Compile .cpp files to .o.
648###########################################################
649
Jeff Browne33ba4c2011-07-11 22:11:46 -0700650# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800651# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800652cpp_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 -0800653cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
654
Ying Wangb8e01852014-01-23 15:09:04 -0800655cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800656cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
657
658$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
659$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
660$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
661$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
662
663cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
664
665ifneq ($(strip $(cpp_objects)),)
666$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700667 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800668 $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700669 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800670 $(transform-$(PRIVATE_HOST)cpp-to-o)
671-include $(cpp_objects:%.o=%.P)
672endif
673
674###########################################################
675## C++: Compile generated .cpp files to .o.
676###########################################################
677
Ying Wangec6d6262014-01-16 16:21:03 -0800678gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800679gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
680
681ifneq ($(strip $(gen_cpp_objects)),)
682# Compile all generated files as thumb.
683# TODO: support compiling certain generated files as arm.
684$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
685$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400686$(gen_cpp_objects): $(intermediates)/%.o: \
687 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800688 $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700689 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800690 $(transform-$(PRIVATE_HOST)cpp-to-o)
691-include $(gen_cpp_objects:%.o=%.P)
692endif
693
694###########################################################
695## S: Compile generated .S and .s files to .o.
696###########################################################
697
Ying Wangec6d6262014-01-16 16:21:03 -0800698gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800699gen_S_objects := $(gen_S_sources:%.S=%.o)
700
701ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400702$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Alberta8fd6682014-10-03 13:29:42 -0700703 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800704 $(transform-$(PRIVATE_HOST)s-to-o)
705-include $(gen_S_objects:%.o=%.P)
706endif
707
Ying Wangec6d6262014-01-16 16:21:03 -0800708gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800709gen_s_objects := $(gen_s_sources:%.s=%.o)
710
711ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400712$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Alberta8fd6682014-10-03 13:29:42 -0700713 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
715-include $(gen_s_objects:%.o=%.P)
716endif
717
718gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
719
720###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000721## o: Include generated .o files in output.
722###########################################################
723
Ying Wangec6d6262014-01-16 16:21:03 -0800724gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000725
726###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727## C: Compile .c files to .o.
728###########################################################
729
Ying Wangb8e01852014-01-23 15:09:04 -0800730c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
732
Ying Wangb8e01852014-01-23 15:09:04 -0800733c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800734c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
735
736$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
737$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
738$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
739$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
740
741c_objects := $(c_arm_objects) $(c_normal_objects)
742
743ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400744$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700745 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800746 $(transform-$(PRIVATE_HOST)c-to-o)
747-include $(c_objects:%.o=%.P)
748endif
749
750###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700751## C: Compile generated .c files to .o.
752###########################################################
753
Ying Wangec6d6262014-01-16 16:21:03 -0800754gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700755gen_c_objects := $(gen_c_sources:%.c=%.o)
756
757ifneq ($(strip $(gen_c_objects)),)
758# Compile all generated files as thumb.
759# TODO: support compiling certain generated files as arm.
760$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
761$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400762$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700763 $(LOCAL_ADDITIONAL_DEPENDENCIES)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700764 $(transform-$(PRIVATE_HOST)c-to-o)
765-include $(gen_c_objects:%.o=%.P)
766endif
767
768###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200769## ObjC: Compile .m files to .o
770###########################################################
771
Ying Wangb8e01852014-01-23 15:09:04 -0800772objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200773objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
774
775ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400776$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Dan Alberta8fd6682014-10-03 13:29:42 -0700777 $(LOCAL_ADDITIONAL_DEPENDENCIES)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200778 $(transform-$(PRIVATE_HOST)m-to-o)
779-include $(objc_objects:%.o=%.P)
780endif
781
782###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783## AS: Compile .S files to .o.
784###########################################################
785
Ying Wangb8e01852014-01-23 15:09:04 -0800786asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800787asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
788
789ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400790$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Alberta8fd6682014-10-03 13:29:42 -0700791 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800792 $(transform-$(PRIVATE_HOST)s-to-o)
793-include $(asm_objects_S:%.o=%.P)
794endif
795
Ying Wangb8e01852014-01-23 15:09:04 -0800796asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800797asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
798
799ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400800$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Alberta8fd6682014-10-03 13:29:42 -0700801 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800802 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
803-include $(asm_objects_s:%.o=%.P)
804endif
805
806asm_objects := $(asm_objects_S) $(asm_objects_s)
807
808
Ying Wang7b913ce2014-06-05 19:05:47 -0700809# .asm for x86 needs to be compiled with yasm.
810ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
811asm_sources_asm := $(filter %.asm,$(my_src_files))
812ifneq ($(strip $(asm_sources_asm)),)
813asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
814$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
815 $(LOCAL_ADDITIONAL_DEPENDENCIES)
816 $(transform-asm-to-o)
817
818asm_objects += $(asm_objects_asm)
819endif
820endif
821
Ying Wang5f074802011-11-08 09:31:21 -0800822####################################################
823## Import includes
824####################################################
825import_includes := $(intermediates)/import_includes
826import_includes_deps := $(strip \
827 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800828 $(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 -0800829 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800830 $(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 -0800831$(import_includes) : $(import_includes_deps)
832 @echo Import includes file: $@
833 $(hide) mkdir -p $(dir $@) && rm -f $@
834ifdef import_includes_deps
835 $(hide) for f in $^; do \
836 cat $$f >> $@; \
837 done
838else
839 $(hide) touch $@
840endif
841
The Android Open Source Project88b60792009-03-03 19:28:42 -0800842###########################################################
843## Common object handling.
844###########################################################
845
846# some rules depend on asm_objects being first. If your code depends on
847# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100848normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700849 $(asm_objects) \
850 $(cpp_objects) \
851 $(gen_cpp_objects) \
852 $(gen_asm_objects) \
853 $(c_objects) \
854 $(gen_c_objects) \
855 $(objc_objects) \
856 $(yacc_objects) \
857 $(lex_objects) \
858 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100859 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
860
861all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800862
Colin Cross2d206702014-02-13 13:41:52 -0800863my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800864
Ying Wang848020f2012-08-14 10:13:16 -0700865ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800866 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700867endif
868
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100869# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
870# use normal_objects here to avoid creating circular dependencies. This assumes
871# that custom build rules which generate .o files don't consume other generated
872# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800873$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100874$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800875ALL_C_CPP_ETC_OBJECTS += $(all_objects)
876
The Android Open Source Project88b60792009-03-03 19:28:42 -0800877
878###########################################################
879# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800880###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800881
882###########################################################
883# The list of libraries that this module will link against are in
884# these variables. Each is a list of bare module names like "libc libm".
885#
886# LOCAL_SHARED_LIBRARIES
887# LOCAL_STATIC_LIBRARIES
888# LOCAL_WHOLE_STATIC_LIBRARIES
889#
890# We need to convert the bare names into the dependencies that
891# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
892# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
893# libraries, so that simply building this module doesn't force
894# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
895# should depend on the INSTALLED versions of the libraries so
896# that they get installed when this module does.
897###########################################################
898# NOTE:
899# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
900# module without leaving anything out, which is useful for turning
901# a collection of .a files into a .so file. Linking against a
902# normal STATIC_LIBRARY will only pull in code/symbols that are
903# referenced by the module. (see gcc/ld's --whole-archive option)
904###########################################################
905
906# Get the list of BUILT libraries, which are under
907# various intermediates directories.
908so_suffix := $($(my_prefix)SHLIB_SUFFIX)
909a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
910
Ying Wang848020f2012-08-14 10:13:16 -0700911ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800913 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800915 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800916
Ying Wangd8d37212014-03-21 16:17:04 -0700917# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -0800918my_system_shared_libraries_fullpath := \
919 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -0700920 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -0700921 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700922
923built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -0700924else
Ying Wang1a081002010-07-13 14:55:47 -0700925built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800926 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700927 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -0700928 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -0700929endif
930
The Android Open Source Project88b60792009-03-03 19:28:42 -0800931built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800932 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800933 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800934 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 -0800935
Ying Wang848020f2012-08-14 10:13:16 -0700936ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800937built_static_libraries += $(my_ndk_stl_static_lib)
938endif
939
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -0800941 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800942 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800943 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 -0800944
The Android Open Source Project88b60792009-03-03 19:28:42 -0800945# We don't care about installed static libraries, since the
946# libraries have already been linked into the module at that point.
947# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000948# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800949
950installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -0800951 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800952 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
953
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700954# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -0700955ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
956LOCAL_RTTI_FLAG := -fno-rtti
957endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700958
The Android Open Source Project88b60792009-03-03 19:28:42 -0800959###########################################################
960# Rule-specific variable definitions
961###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +0800962
Ying Wang824344a2014-05-27 13:03:36 -0700963ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -0700964my_cflags += $(LOCAL_CLANG_CFLAGS)
965my_cpplags += $(LOCAL_CLANG_CPPFLAGS)
966my_asflags += $(LOCAL_CLANG_ASFLAGS)
967my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -0700968my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
969my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
970my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
971my_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 -0800972my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
973my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
974my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
975my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +0800976endif
977
Dehao Chen295a6d22014-09-19 10:18:12 -0700978ifeq ($(LOCAL_FDO_SUPPORT), true)
979 build_with_fdo := false
980 ifeq ($(BUILD_FDO_INSTRUMENT), true)
981 build_with_fdo := true
982 endif
983 ifeq ($(BUILD_FDO_OPTIMIZE), true)
984 build_with_fdo := true
985 endif
986 ifeq ($(build_with_fdo), true)
987 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
988 fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
989 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
990 endif
991endif
992
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800994$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -0700995$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800996$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
997$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700998$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800999$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001000$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -08001001$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001002$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001003$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Ying Wangb8e01852014-01-23 15:09:04 -08001004$(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 -07001005$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001006
1007# this is really the way to get the files onto the command line instead
1008# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1009$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1010$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1011$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
1012$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
1013
1014###########################################################
1015# Define library dependencies.
1016###########################################################
1017# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1018all_libraries := \
1019 $(built_shared_libraries) \
1020 $(built_static_libraries) \
1021 $(built_whole_libraries)
1022
The Android Open Source Project88b60792009-03-03 19:28:42 -08001023# Also depend on the notice files for any static libraries that
1024# are linked into this module. This will force them to be installed
1025# when this module is.
1026$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001027
1028###########################################################
1029# Export includes
1030###########################################################
1031export_includes := $(intermediates)/export_includes
1032$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang49085952014-05-06 13:03:32 -07001033# Make sure .pb.h are already generated before any dependent source files get compiled.
1034$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
Ying Wang5f074802011-11-08 09:31:21 -08001035 @echo Export includes file: $< -- $@
1036 $(hide) mkdir -p $(dir $@) && rm -f $@
1037ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
1038 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1039 echo "-I $$d" >> $@; \
1040 done
1041else
1042 $(hide) touch $@
1043endif
Ying Wang616e5962012-04-18 17:35:55 -07001044
1045# Make sure export_includes gets generated when you are running mm/mmm
1046$(LOCAL_BUILT_MODULE) : | $(export_includes)