blob: ac7e14f7e8226a24c4570e08adaa0e1f58c2df5a [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)
110my_asflags := $(LOCAL_ASFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800111my_cc := $(LOCAL_CC)
112my_cxx := $(LOCAL_CXX)
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800113my_c_includes := $(LOCAL_C_INCLUDES)
114my_generated_sources := $(LOCAL_GENERATED_SOURCES)
115
Ying Wang6feb6d52014-04-17 10:03:35 -0700116my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
117my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
118my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
119my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
120my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
121my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
122my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
123my_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 -0800124
Ying Wang824344a2014-05-27 13:03:36 -0700125my_clang := $(LOCAL_CLANG)
126ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
127my_clang := $(LOCAL_CLANG_$(my_32_64_bit_suffix))
128endif
129ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
130my_clang := $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
131endif
132
Tim Murray92d79cb2014-04-04 14:38:29 -0700133# clang is enabled by default for host builds
134# enable it unless we've specifically disabled clang above
135ifdef LOCAL_IS_HOST_MODULE
136ifeq ($(my_clang),)
137 my_clang := true
138endif
139endif
140
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800141# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700142my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
143my_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 -0800144
Ying Wang6feb6d52014-04-17 10:03:35 -0700145my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
Ying Wang6ef65192014-01-15 16:02:16 -0800146
Ying Wangd90de322014-05-23 16:42:37 -0700147
148# Replace libstdc++ with libc++ if it's seen
149my_libcxx := $(filter libc++, $(my_shared_libraries))
150ifdef my_libcxx
151my_system_shared_libraries := $(filter-out libstdc++, $(my_system_shared_libraries))
152endif
153
Ying Wang285045b2013-08-13 12:35:10 -0700154# Add static HAL libraries
155ifdef LOCAL_HAL_STATIC_LIBRARIES
156$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
157 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800158 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
159 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700160b_lib :=
161endif
162
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400163ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700164 my_clang := true
Ying Wang6ef65192014-01-15 16:02:16 -0800165 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
166 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
167 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
168 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400169endif
170
Ying Wangba8b3772014-03-10 18:23:08 -0700171ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700172 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700173endif
174
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800175# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700176ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800177 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700178endif
179
Ying Wangdfbe79b2012-03-22 11:26:22 -0700180my_compiler_dependencies :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800181
Jing Yu2dcc8062009-09-21 16:31:50 -0700182####################################################
183## Add FDO flags if FDO is turned on and supported
184####################################################
synergydev7c467422013-08-13 17:41:52 -0700185ifneq ($(strip $(LOCAL_FDO_SUPPORT)),)
synergydev4a605762013-08-05 02:44:37 -0700186 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800187 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800188 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700189 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700190endif
191
The Android Open Source Project88b60792009-03-03 19:28:42 -0800192###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800193## Explicitly declare assembly-only __ASSEMBLY__ macro for
194## assembly source
195###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800196my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800197
Ying Wangd8d37212014-03-21 16:17:04 -0700198
199##########################################################
200## Set up installed module dependency
201## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
202## they may cusomize their install path with LOCAL_MODULE_PATH
203##########################################################
204# Get the list of INSTALLED libraries as module names.
205ifdef LOCAL_SDK_VERSION
206 installed_shared_library_module_names := \
207 $(my_shared_libraries)
208else
209 installed_shared_library_module_names := \
210 $(my_system_shared_libraries) $(my_shared_libraries)
211endif
212installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
213
214# The real dependency will be added after all Android.mks are loaded and the install paths
215# of the shared libraries are determined.
216ifdef LOCAL_INSTALLED_MODULE
217ifdef installed_shared_library_module_names
218$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wange1b867d2014-06-10 14:21:20 -0700219 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wangd8d37212014-03-21 16:17:04 -0700220endif
221endif
222
Jim Huang20d1ba62010-10-14 16:15:56 +0800223###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700224## Define PRIVATE_ variables from global vars
225###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800226ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700227ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700228my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700229my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800230my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700231else
Ying Wang6ef65192014-01-15 16:02:16 -0800232my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
233my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800234my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700235endif # LOCAL_SDK_VERSION
236
Ying Wang824344a2014-05-27 13:03:36 -0700237ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800238my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800239my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800240my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangf4723fa2013-08-15 11:01:10 -0700241my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
Ying Wangda4bf422012-08-16 16:45:01 -0700242else
Ying Wang6ef65192014-01-15 16:02:16 -0800243my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800244my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800245my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700246endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700247
Ying Wang1a081002010-07-13 14:55:47 -0700248$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400249$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700250$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800251$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
252$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
253
Ying Wang7fff9a12014-01-09 14:39:41 -0800254else # LOCAL_IS_HOST_MODULE
255
Ying Wang824344a2014-05-27 13:03:36 -0700256ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700257my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
258my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
259my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
260my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800261else
Ying Wang6feb6d52014-04-17 10:03:35 -0700262my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
263my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
264my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
265my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700266endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800267
268$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
269$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
270$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
271$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
272endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700273
274###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800275## Define PRIVATE_ variables used by multiple module types
276###########################################################
277$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700278 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800279
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800280ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
281 LOCAL_NO_SYNTAX_CHECK := true
282endif
283
Andrew Hsieh906cb782013-09-10 17:37:14 +0800284ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
285 LOCAL_NO_STATIC_ANALYZER := true
286endif
287
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800288ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
289 my_syntax_arch := host
290else
Ying Wang6ef65192014-01-15 16:02:16 -0800291 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800292endif
293
Ying Wang6ef65192014-01-15 16:02:16 -0800294ifeq ($(strip $(my_cc)),)
Ying Wang824344a2014-05-27 13:03:36 -0700295 ifeq ($(strip $(my_clang)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800296 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400297 else
Ying Wang6ef65192014-01-15 16:02:16 -0800298 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400299 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800300endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800301ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800302 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800303else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800304ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800305 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800306endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800307endif
Ying Wang6ef65192014-01-15 16:02:16 -0800308$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800309
Ying Wang6ef65192014-01-15 16:02:16 -0800310ifeq ($(strip $(my_cxx)),)
Ying Wang824344a2014-05-27 13:03:36 -0700311 ifeq ($(strip $(my_clang)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800312 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400313 else
Ying Wang6ef65192014-01-15 16:02:16 -0800314 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400315 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800316endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800317ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800318 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800319else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800320ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800321 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800322endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800323endif
Ying Wang6ef65192014-01-15 16:02:16 -0800324$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800325
326# TODO: support a mix of standard extensions so that this isn't necessary
327LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
328ifeq ($(LOCAL_CPP_EXTENSION),)
329 LOCAL_CPP_EXTENSION := .cpp
330endif
331$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
332
333# Certain modules like libdl have to have symbols resolved at runtime and blow
334# up if --no-undefined is passed to the linker.
335ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
336ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800337 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800338endif
339endif
340
Ying Wangfcdabd42011-04-25 14:22:41 -0700341ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
342$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
343else
344$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
345endif
346
The Android Open Source Project88b60792009-03-03 19:28:42 -0800347###########################################################
348## Define arm-vs-thumb-mode flags.
349###########################################################
350LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800351ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800352arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
353normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
354
Dave Bort95282482009-04-23 18:44:55 -0700355# Read the values from something like TARGET_arm_CFLAGS or
356# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
357# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800358arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
359normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700360ifeq ($(strip $(my_clang)),true)
Ying Wang1f982832014-02-06 18:08:44 -0800361arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
362normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400363endif
364
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800365else
366arm_objects_mode :=
367normal_objects_mode :=
368arm_objects_cflags :=
369normal_objects_cflags :=
370endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800371
372###########################################################
373## Define per-module debugging flags. Users can turn on
374## debugging for a particular module by setting DEBUG_MODULE_ModuleName
375## to a non-empty value in their environment or buildspec.mk,
376## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
377## debug flags that they want to use.
378###########################################################
379ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
380 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
381else
382 debug_cflags :=
383endif
384
Tim Murraya7aa8002012-10-29 16:06:00 -0700385####################################################
386## Compile RenderScript with reflected C++
387####################################################
388
Ying Wangb8e01852014-01-23 15:09:04 -0800389renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700390
391ifneq (,$(renderscript_sources))
392
393renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
394RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
395renderscript_intermediate := $(intermediates)/renderscript
396
397ifeq ($(LOCAL_RENDERSCRIPT_CC),)
398LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
399endif
400
401# Turn on all warnings and warnings as errors for RS compiles.
402# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
403renderscript_flags := -Wall -Werror
404renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
405
Ying Wang6ef65192014-01-15 16:02:16 -0800406renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700407 $(TOPDIR)external/clang/lib/Headers \
408 $(TOPDIR)frameworks/rs/scriptc \
409 $(LOCAL_RENDERSCRIPT_INCLUDES)
410
411ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800412renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700413endif
414
Ying Wang6ef65192014-01-15 16:02:16 -0800415$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700416$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
417$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
418$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
419$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
420$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
421 $(transform-renderscripts-to-cpp-and-bc)
422
423# include the dependency files (.d) generated by llvm-rs-cc.
424renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
425 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
426-include $(renderscript_generated_dep_files)
427
428LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
429
430rs_generated_cpps := $(addprefix \
431 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
432 $(notdir $(renderscript_sources)))))
433
Stephen Hines8ff92522014-06-06 12:51:47 -0700434# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700435$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700436 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700437
Ying Wang6ef65192014-01-15 16:02:16 -0800438my_c_includes += $(renderscript_intermediate)
439my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700440
441endif
442
443
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444###########################################################
445## Stuff source generated from one-off tools
446###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800447$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448
Colin Crossd8262642014-01-24 23:17:21 -0800449my_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 -0800450
Colin Crossd8262642014-01-24 23:17:21 -0800451$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
452 @echo "Copy: $@"
453 $(copy-file-to-target)
454
455my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
456
457ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800458
459###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700460## Compile the .proto files to .cc and then to .o
461###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800462proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700463proto_generated_objects :=
464proto_generated_headers :=
465ifneq ($(proto_sources),)
466proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wang031e0fb2014-02-25 11:18:40 -0800467proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
Ying Wanga5fc87a2010-11-02 18:43:16 -0700468proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700469 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wang031e0fb2014-02-25 11:18:40 -0800470proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
471proto_generated_obj_dir := $(intermediates)/proto
472proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
473 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700474
Ying Wang031e0fb2014-02-25 11:18:40 -0800475# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
476ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wanga5fc87a2010-11-02 18:43:16 -0700477$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
478$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700479$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700480$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
481 $(transform-proto-to-cc)
482
Stephen Hines8ff92522014-06-06 12:51:47 -0700483# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wanga5fc87a2010-11-02 18:43:16 -0700484$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
Ying Wang81ab8332014-05-28 16:17:09 -0700485 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700486
Ying Wang031e0fb2014-02-25 11:18:40 -0800487$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
488endif # transform-proto-to-cc rule included only once
489
Ying Wang022a7b32012-06-13 11:38:10 -0700490$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
491$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wang031e0fb2014-02-25 11:18:40 -0800492$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700493 $(transform-$(PRIVATE_HOST)cpp-to-o)
494-include $(proto_generated_objects:%.o=%.P)
495
Ying Wang6ef65192014-01-15 16:02:16 -0800496my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
497my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700498ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800499my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700500else
Ying Wang6ef65192014-01-15 16:02:16 -0800501my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700502endif
Ying Wang031e0fb2014-02-25 11:18:40 -0800503endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700504
505
506###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000507## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800508###########################################################
509
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000510y_yacc_sources := $(filter %.y,$(my_src_files))
511y_yacc_cpps := $(addprefix \
512 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
513
514yy_yacc_sources := $(filter %.yy,$(my_src_files))
515yy_yacc_cpps := $(addprefix \
516 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
517
518yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800519yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
520yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
521
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000522ifneq ($(strip $(y_yacc_cpps)),)
523$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700524 $(TOPDIR)$(LOCAL_PATH)/%.y \
525 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800526 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
527$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000528endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800529
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000530ifneq ($(strip $(yy_yacc_cpps)),)
531$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
532 $(TOPDIR)$(LOCAL_PATH)/%.yy \
533 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
534 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
535$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
536endif
537
538ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800539$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
540$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
541$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
542 $(transform-$(PRIVATE_HOST)cpp-to-o)
543endif
544
545###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000546## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547###########################################################
548
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000549l_lex_sources := $(filter %.l,$(my_src_files))
550l_lex_cpps := $(addprefix \
551 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
552
553ll_lex_sources := $(filter %.ll,$(my_src_files))
554ll_lex_cpps := $(addprefix \
555 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
556
557lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800558lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
559
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000560ifneq ($(strip $(l_lex_cpps)),)
561$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700562 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000564endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800565
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000566ifneq ($(strip $(ll_lex_cpps)),)
567$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
568 $(TOPDIR)$(LOCAL_PATH)/%.ll
569 $(transform-l-to-cpp)
570endif
571
572ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
574$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
575$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700576 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
577 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
578 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579 $(transform-$(PRIVATE_HOST)cpp-to-o)
580endif
581
582###########################################################
583## C++: Compile .cpp files to .o.
584###########################################################
585
Jeff Browne33ba4c2011-07-11 22:11:46 -0700586# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800587# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800588cpp_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 -0800589cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
590
Ying Wangb8e01852014-01-23 15:09:04 -0800591cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800592cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
593
594$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
595$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
596$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
597$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
598
599cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
600
601ifneq ($(strip $(cpp_objects)),)
602$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700603 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800604 $(yacc_cpps) $(proto_generated_headers) \
605 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
606 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607 $(transform-$(PRIVATE_HOST)cpp-to-o)
608-include $(cpp_objects:%.o=%.P)
609endif
610
611###########################################################
612## C++: Compile generated .cpp files to .o.
613###########################################################
614
Ying Wangec6d6262014-01-16 16:21:03 -0800615gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800616gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
617
618ifneq ($(strip $(gen_cpp_objects)),)
619# Compile all generated files as thumb.
620# TODO: support compiling certain generated files as arm.
621$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
622$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400623$(gen_cpp_objects): $(intermediates)/%.o: \
624 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800625 $(proto_generated_headers) \
626 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
627 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800628 $(transform-$(PRIVATE_HOST)cpp-to-o)
629-include $(gen_cpp_objects:%.o=%.P)
630endif
631
632###########################################################
633## S: Compile generated .S and .s files to .o.
634###########################################################
635
Ying Wangec6d6262014-01-16 16:21:03 -0800636gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800637gen_S_objects := $(gen_S_sources:%.S=%.o)
638
639ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400640$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800641 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
642 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800643 $(transform-$(PRIVATE_HOST)s-to-o)
644-include $(gen_S_objects:%.o=%.P)
645endif
646
Ying Wangec6d6262014-01-16 16:21:03 -0800647gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800648gen_s_objects := $(gen_s_sources:%.s=%.o)
649
650ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400651$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800652 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
653 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800654 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
655-include $(gen_s_objects:%.o=%.P)
656endif
657
658gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
659
660###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000661## o: Include generated .o files in output.
662###########################################################
663
Ying Wangec6d6262014-01-16 16:21:03 -0800664gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000665
666###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800667## C: Compile .c files to .o.
668###########################################################
669
Ying Wangb8e01852014-01-23 15:09:04 -0800670c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
672
Ying Wangb8e01852014-01-23 15:09:04 -0800673c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
675
676$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
677$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
678$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
679$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
680
681c_objects := $(c_arm_objects) $(c_normal_objects)
682
683ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400684$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800685 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
686 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800687 $(transform-$(PRIVATE_HOST)c-to-o)
688-include $(c_objects:%.o=%.P)
689endif
690
691###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700692## C: Compile generated .c files to .o.
693###########################################################
694
Ying Wangec6d6262014-01-16 16:21:03 -0800695gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700696gen_c_objects := $(gen_c_sources:%.c=%.o)
697
698ifneq ($(strip $(gen_c_objects)),)
699# Compile all generated files as thumb.
700# TODO: support compiling certain generated files as arm.
701$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
702$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400703$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800704 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
705 | $(my_compiler_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700706 $(transform-$(PRIVATE_HOST)c-to-o)
707-include $(gen_c_objects:%.o=%.P)
708endif
709
710###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200711## ObjC: Compile .m files to .o
712###########################################################
713
Ying Wangb8e01852014-01-23 15:09:04 -0800714objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200715objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
716
717ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400718$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800719 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
720 | $(my_compiler_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200721 $(transform-$(PRIVATE_HOST)m-to-o)
722-include $(objc_objects:%.o=%.P)
723endif
724
725###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800726## AS: Compile .S files to .o.
727###########################################################
728
Ying Wangb8e01852014-01-23 15:09:04 -0800729asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800730asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
731
732ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400733$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800734 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
735 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800736 $(transform-$(PRIVATE_HOST)s-to-o)
737-include $(asm_objects_S:%.o=%.P)
738endif
739
Ying Wangb8e01852014-01-23 15:09:04 -0800740asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800741asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
742
743ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400744$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800745 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
746 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800747 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
748-include $(asm_objects_s:%.o=%.P)
749endif
750
751asm_objects := $(asm_objects_S) $(asm_objects_s)
752
753
Ying Wang7b913ce2014-06-05 19:05:47 -0700754# .asm for x86 needs to be compiled with yasm.
755ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
756asm_sources_asm := $(filter %.asm,$(my_src_files))
757ifneq ($(strip $(asm_sources_asm)),)
758asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
759$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
760 $(LOCAL_ADDITIONAL_DEPENDENCIES)
761 $(transform-asm-to-o)
762
763asm_objects += $(asm_objects_asm)
764endif
765endif
766
Ying Wang5f074802011-11-08 09:31:21 -0800767####################################################
768## Import includes
769####################################################
770import_includes := $(intermediates)/import_includes
771import_includes_deps := $(strip \
772 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800773 $(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 -0800774 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800775 $(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 -0800776$(import_includes) : $(import_includes_deps)
777 @echo Import includes file: $@
778 $(hide) mkdir -p $(dir $@) && rm -f $@
779ifdef import_includes_deps
780 $(hide) for f in $^; do \
781 cat $$f >> $@; \
782 done
783else
784 $(hide) touch $@
785endif
786
The Android Open Source Project88b60792009-03-03 19:28:42 -0800787###########################################################
788## Common object handling.
789###########################################################
790
791# some rules depend on asm_objects being first. If your code depends on
792# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100793normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700794 $(asm_objects) \
795 $(cpp_objects) \
796 $(gen_cpp_objects) \
797 $(gen_asm_objects) \
798 $(c_objects) \
799 $(gen_c_objects) \
800 $(objc_objects) \
801 $(yacc_objects) \
802 $(lex_objects) \
803 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100804 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
805
806all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800807
Colin Cross2d206702014-02-13 13:41:52 -0800808my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800809
Ying Wang848020f2012-08-14 10:13:16 -0700810ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800811 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700812endif
813
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100814# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
815# use normal_objects here to avoid creating circular dependencies. This assumes
816# that custom build rules which generate .o files don't consume other generated
817# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800818$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100819$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800820ALL_C_CPP_ETC_OBJECTS += $(all_objects)
821
The Android Open Source Project88b60792009-03-03 19:28:42 -0800822
823###########################################################
824# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800825###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800826
827###########################################################
828# The list of libraries that this module will link against are in
829# these variables. Each is a list of bare module names like "libc libm".
830#
831# LOCAL_SHARED_LIBRARIES
832# LOCAL_STATIC_LIBRARIES
833# LOCAL_WHOLE_STATIC_LIBRARIES
834#
835# We need to convert the bare names into the dependencies that
836# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
837# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
838# libraries, so that simply building this module doesn't force
839# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
840# should depend on the INSTALLED versions of the libraries so
841# that they get installed when this module does.
842###########################################################
843# NOTE:
844# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
845# module without leaving anything out, which is useful for turning
846# a collection of .a files into a .so file. Linking against a
847# normal STATIC_LIBRARY will only pull in code/symbols that are
848# referenced by the module. (see gcc/ld's --whole-archive option)
849###########################################################
850
851# Get the list of BUILT libraries, which are under
852# various intermediates directories.
853so_suffix := $($(my_prefix)SHLIB_SUFFIX)
854a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
855
Ying Wang848020f2012-08-14 10:13:16 -0700856ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800857built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800858 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800859 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800860 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861
Ying Wangd8d37212014-03-21 16:17:04 -0700862# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -0800863my_system_shared_libraries_fullpath := \
864 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -0700865 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -0700866 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700867
868built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -0700869else
Ying Wang1a081002010-07-13 14:55:47 -0700870built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800871 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700872 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -0700873 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -0700874endif
875
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800877 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800879 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 -0800880
Ying Wang848020f2012-08-14 10:13:16 -0700881ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800882built_static_libraries += $(my_ndk_stl_static_lib)
883endif
884
The Android Open Source Project88b60792009-03-03 19:28:42 -0800885built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -0800886 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800887 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800888 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 -0800889
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890# We don't care about installed static libraries, since the
891# libraries have already been linked into the module at that point.
892# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000893# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800894
895installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -0800896 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800897 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
898
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700899# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -0700900ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
901LOCAL_RTTI_FLAG := -fno-rtti
902endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700903
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904###########################################################
905# Rule-specific variable definitions
906###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +0800907
Ying Wang824344a2014-05-27 13:03:36 -0700908ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800909my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
910my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
911my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
912my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +0800913endif
914
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800916$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -0700917$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800918$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
919$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700920$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -0800922$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -0800923$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -0800924$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800925$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
Ying Wangb8e01852014-01-23 15:09:04 -0800926$(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 -0700927$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928
929# this is really the way to get the files onto the command line instead
930# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
931$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
932$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
933$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
934$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
935
936###########################################################
937# Define library dependencies.
938###########################################################
939# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
940all_libraries := \
941 $(built_shared_libraries) \
942 $(built_static_libraries) \
943 $(built_whole_libraries)
944
The Android Open Source Project88b60792009-03-03 19:28:42 -0800945# Also depend on the notice files for any static libraries that
946# are linked into this module. This will force them to be installed
947# when this module is.
948$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -0800949
950###########################################################
951# Export includes
952###########################################################
953export_includes := $(intermediates)/export_includes
954$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang68f1c772012-04-23 21:29:18 -0700955$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
Ying Wang5f074802011-11-08 09:31:21 -0800956 @echo Export includes file: $< -- $@
957 $(hide) mkdir -p $(dir $@) && rm -f $@
958ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
959 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
960 echo "-I $$d" >> $@; \
961 done
962else
963 $(hide) touch $@
964endif
Ying Wang616e5962012-04-18 17:35:55 -0700965
966# Make sure export_includes gets generated when you are running mm/mmm
967$(LOCAL_BUILT_MODULE) : | $(export_includes)