blob: bbdf4d2b7069c67c45e2beb5cb1b6f1a359c7936 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building binary object files from
3## asm/c/cpp/yacc/lex source files.
4##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
Ying Wang1a081002010-07-13 14:55:47 -07008my_ndk_version_root :=
Ying Wang848020f2012-08-14 10:13:16 -07009ifdef LOCAL_SDK_VERSION
Ying Wangfe1bfe72012-08-14 11:08:03 -070010 ifdef LOCAL_NDK_VERSION
11 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
12 endif
Ying Wang1a081002010-07-13 14:55:47 -070013 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070014 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070015 endif
Ying Wang848020f2012-08-14 10:13:16 -070016 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
Ying Wang6ef65192014-01-15 16:02:16 -080017 my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Ying Wangcce4c972011-03-03 18:53:53 -080018
19 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
20 # See ndk/docs/CPLUSPLUS-SUPPORT.html
21 my_ndk_stl_include_path :=
22 my_ndk_stl_shared_lib_fullpath :=
23 my_ndk_stl_shared_lib :=
24 my_ndk_stl_static_lib :=
25 ifeq (,$(LOCAL_NDK_STL_VARIANT))
26 LOCAL_NDK_STL_VARIANT := system
27 endif
28 ifneq (1,$(words $(filter system stlport_static stlport_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -070029 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -080030 endif
31 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
32 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
33 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
34 else # LOCAL_NDK_STL_VARIANT is not system
35 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
36 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
37 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
Ying Wang6ef65192014-01-15 16:02:16 -080038 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 -080039 else
Ying Wang6ef65192014-01-15 16:02:16 -080040 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 -080041 my_ndk_stl_shared_lib := -lstlport_shared
42 endif
43 else
44 # LOCAL_NDK_STL_VARIANT is gnustl_static
Ying Wang6ef65192014-01-15 16:02:16 -080045 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \
Ying Wangd9020c22011-09-07 14:31:47 -070046 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include
Ying Wang6ef65192014-01-15 16:02:16 -080047 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a
Ying Wangcce4c972011-03-03 18:53:53 -080048 endif
49 endif
Ying Wang1a081002010-07-13 14:55:47 -070050endif
51
Ying Wang704c0c92011-09-15 13:50:52 -070052##################################################
53# Compute the dependency of the shared libraries
54##################################################
55# On the target, we compile with -nostdlib, so we must add in the
56# default system shared libraries, unless they have requested not
57# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
58# supply that, for example, when building libc itself.
59ifdef LOCAL_IS_HOST_MODULE
60 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
61 LOCAL_SYSTEM_SHARED_LIBRARIES :=
62 endif
63else
64 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
65 LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
66 endif
67endif
68
Ying Wang848020f2012-08-14 10:13:16 -070069ifdef LOCAL_SDK_VERSION
Ying Wang704c0c92011-09-15 13:50:52 -070070 # Get the list of INSTALLED libraries as module names.
Ian Rogers76a6dc32012-10-01 16:36:23 -070071 # We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
Ying Wang704c0c92011-09-15 13:50:52 -070072 # they may cusomize their install path with LOCAL_MODULE_PATH
73 installed_shared_library_module_names := \
74 $(LOCAL_SHARED_LIBRARIES)
75else
76 installed_shared_library_module_names := \
77 $(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES)
78endif
Ying Wang9485a572013-02-22 14:32:30 -080079installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
Ying Wang704c0c92011-09-15 13:50:52 -070080
The Android Open Source Project88b60792009-03-03 19:28:42 -080081#######################################
82include $(BUILD_SYSTEM)/base_rules.mk
83#######################################
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +040084
Ying Wang6ef65192014-01-15 16:02:16 -080085# The following LOCAL_ variables will be modified in this file.
86# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
87# we can't modify them in place.
Ying Wangb8e01852014-01-23 15:09:04 -080088my_src_files := $(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Colin Cross90353fe2014-02-04 14:53:25 -080089my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES)
90my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
91my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Colin Cross44a75262014-01-29 17:46:37 -080092my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_IS_64_BIT),64,32)
93my_cflags := $(LOCAL_CFLAGS) $(LOCAL_CFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
Ying Wang6ef65192014-01-15 16:02:16 -080094my_cppflags := $(LOCAL_CPPFLAGS)
Colin Cross44a75262014-01-29 17:46:37 -080095my_ldflags := $(LOCAL_LDFLAGS) $(LOCAL_LDFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
96my_asflags := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
Ying Wang6ef65192014-01-15 16:02:16 -080097my_cc := $(LOCAL_CC)
98my_cxx := $(LOCAL_CXX)
Colin Cross44a75262014-01-29 17:46:37 -080099my_c_includes := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
Colin Cross90353fe2014-02-04 14:53:25 -0800100my_generated_sources := $(LOCAL_GENERATED_SOURCES) $(LOCAL_GENERATED_SOURCES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wang6ef65192014-01-15 16:02:16 -0800101
Colin Cross8f47fc32014-01-27 17:34:21 -0800102my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
Ying Wang6ef65192014-01-15 16:02:16 -0800103
Ying Wang9485a572013-02-22 14:32:30 -0800104# The real dependency will be added after all Android.mks are loaded and the install paths
105# of the shared libraries are determined.
106ifdef LOCAL_INSTALLED_MODULE
107ifdef installed_shared_library_module_names
Ying Wang6ef65192014-01-15 16:02:16 -0800108$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
109 $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wang9485a572013-02-22 14:32:30 -0800110endif
111endif
112
Ying Wang285045b2013-08-13 12:35:10 -0700113# Add static HAL libraries
114ifdef LOCAL_HAL_STATIC_LIBRARIES
115$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
116 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800117 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
118 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700119b_lib :=
120endif
121
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400122ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
123 LOCAL_CLANG := true
Ying Wang6ef65192014-01-15 16:02:16 -0800124 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
125 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
126 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
127 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400128endif
129
Ying Wang1f982832014-02-06 18:08:44 -0800130ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_CLANG)),true)
Mike Lockwood051a1742013-06-14 10:52:50 -0700131 LOCAL_CLANG :=
132endif
133
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800134# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700135ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800136 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700137endif
138
Ying Wangdfbe79b2012-03-22 11:26:22 -0700139my_compiler_dependencies :=
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400140ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wangdfbe79b2012-03-22 11:26:22 -0700141 my_compiler_dependencies := $(CLANG) $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400142endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143
Jing Yu2dcc8062009-09-21 16:31:50 -0700144####################################################
145## Add FDO flags if FDO is turned on and supported
146####################################################
synergydev7c467422013-08-13 17:41:52 -0700147ifneq ($(strip $(LOCAL_FDO_SUPPORT)),)
synergydev4a605762013-08-05 02:44:37 -0700148 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800149 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
150 my_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
151 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700152 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700153endif
154
The Android Open Source Project88b60792009-03-03 19:28:42 -0800155###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800156## Explicitly declare assembly-only __ASSEMBLY__ macro for
157## assembly source
158###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800159my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800160
161###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700162## Define PRIVATE_ variables from global vars
163###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800164ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700165ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700166my_target_project_includes :=
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400167my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_version_root)/usr/include
Ying Wang1a081002010-07-13 14:55:47 -0700168else
Ying Wang6ef65192014-01-15 16:02:16 -0800169my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
170my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Ying Wangf4723fa2013-08-15 11:01:10 -0700171endif # LOCAL_SDK_VERSION
172
173ifeq ($(LOCAL_CLANG),true)
Ying Wang1f982832014-02-06 18:08:44 -0800174my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
175my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
176my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangf4723fa2013-08-15 11:01:10 -0700177my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
Ying Wangda4bf422012-08-16 16:45:01 -0700178else
Ying Wang6ef65192014-01-15 16:02:16 -0800179my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
180my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
181my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700182endif # LOCAL_CLANG
Ying Wangda4bf422012-08-16 16:45:01 -0700183
Ying Wang1a081002010-07-13 14:55:47 -0700184$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400185$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700186$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800187$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
188$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
189
Ying Wang7fff9a12014-01-09 14:39:41 -0800190else # LOCAL_IS_HOST_MODULE
191
Logan Chiene6f65432013-12-10 19:07:41 +0800192ifeq ($(LOCAL_CLANG),true)
193my_host_global_cflags := $(CLANG_HOST_GLOBAL_CFLAGS)
194my_host_global_cppflags := $(CLANG_HOST_GLOBAL_CPPFLAGS)
195my_host_global_ldflags := $(CLANG_HOST_GLOBAL_LDFLAGS)
196my_host_c_includes := $(HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
197else
198my_host_global_cflags := $(HOST_GLOBAL_CFLAGS)
199my_host_global_cppflags := $(HOST_GLOBAL_CPPFLAGS)
200my_host_global_ldflags := $(HOST_GLOBAL_LDFLAGS)
201my_host_c_includes := $(HOST_C_INCLUDES)
202endif # LOCAL_CLANG
203
204$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
205$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
206$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
207$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
208endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700209
210###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800211## Define PRIVATE_ variables used by multiple module types
212###########################################################
213$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700214 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800215
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800216ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
217 LOCAL_NO_SYNTAX_CHECK := true
218endif
219
Andrew Hsieh906cb782013-09-10 17:37:14 +0800220ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
221 LOCAL_NO_STATIC_ANALYZER := true
222endif
223
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800224ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
225 my_syntax_arch := host
226else
Ying Wang6ef65192014-01-15 16:02:16 -0800227 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800228endif
229
Ying Wang6ef65192014-01-15 16:02:16 -0800230ifeq ($(strip $(my_cc)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400231 ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800232 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400233 else
Ying Wang6ef65192014-01-15 16:02:16 -0800234 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400235 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800236endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800237ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800238 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800239else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800240ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800241 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800242endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800243endif
Ying Wang6ef65192014-01-15 16:02:16 -0800244$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800245
Ying Wang6ef65192014-01-15 16:02:16 -0800246ifeq ($(strip $(my_cxx)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400247 ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800248 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400249 else
Ying Wang6ef65192014-01-15 16:02:16 -0800250 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400251 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800252endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800253ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800254 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800255else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800256ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800257 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800258endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800259endif
Ying Wang6ef65192014-01-15 16:02:16 -0800260$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800261
262# TODO: support a mix of standard extensions so that this isn't necessary
263LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
264ifeq ($(LOCAL_CPP_EXTENSION),)
265 LOCAL_CPP_EXTENSION := .cpp
266endif
267$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
268
269# Certain modules like libdl have to have symbols resolved at runtime and blow
270# up if --no-undefined is passed to the linker.
271ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
272ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800273 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800274endif
275endif
276
Ying Wangfcdabd42011-04-25 14:22:41 -0700277ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
278$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
279else
280$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
281endif
282
The Android Open Source Project88b60792009-03-03 19:28:42 -0800283###########################################################
284## Define arm-vs-thumb-mode flags.
285###########################################################
286LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800287ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
289normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
290
Dave Bort95282482009-04-23 18:44:55 -0700291# Read the values from something like TARGET_arm_CFLAGS or
292# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
293# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800294arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
295normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Logan Chiene6f65432013-12-10 19:07:41 +0800296ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wang1f982832014-02-06 18:08:44 -0800297arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
298normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400299endif
300
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800301else
302arm_objects_mode :=
303normal_objects_mode :=
304arm_objects_cflags :=
305normal_objects_cflags :=
306endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800307
308###########################################################
309## Define per-module debugging flags. Users can turn on
310## debugging for a particular module by setting DEBUG_MODULE_ModuleName
311## to a non-empty value in their environment or buildspec.mk,
312## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
313## debug flags that they want to use.
314###########################################################
315ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
316 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
317else
318 debug_cflags :=
319endif
320
Tim Murraya7aa8002012-10-29 16:06:00 -0700321####################################################
322## Compile RenderScript with reflected C++
323####################################################
324
Ying Wangb8e01852014-01-23 15:09:04 -0800325renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700326
327ifneq (,$(renderscript_sources))
328
329renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
330RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
331renderscript_intermediate := $(intermediates)/renderscript
332
333ifeq ($(LOCAL_RENDERSCRIPT_CC),)
334LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
335endif
336
337# Turn on all warnings and warnings as errors for RS compiles.
338# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
339renderscript_flags := -Wall -Werror
340renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
341
Ying Wang6ef65192014-01-15 16:02:16 -0800342renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700343 $(TOPDIR)external/clang/lib/Headers \
344 $(TOPDIR)frameworks/rs/scriptc \
345 $(LOCAL_RENDERSCRIPT_INCLUDES)
346
347ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800348renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700349endif
350
Ying Wang6ef65192014-01-15 16:02:16 -0800351$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700352$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
353$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
354$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
355$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
356$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
357 $(transform-renderscripts-to-cpp-and-bc)
358
359# include the dependency files (.d) generated by llvm-rs-cc.
360renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
361 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
362-include $(renderscript_generated_dep_files)
363
364LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
365
366rs_generated_cpps := $(addprefix \
367 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
368 $(notdir $(renderscript_sources)))))
369
370$(rs_generated_cpps) : $(RenderScript_file_stamp)
371
Ying Wang6ef65192014-01-15 16:02:16 -0800372my_c_includes += $(renderscript_intermediate)
373my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700374
375endif
376
377
The Android Open Source Project88b60792009-03-03 19:28:42 -0800378###########################################################
379## Stuff source generated from one-off tools
380###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800381$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800382
Colin Crossd8262642014-01-24 23:17:21 -0800383my_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 -0800384
Colin Crossd8262642014-01-24 23:17:21 -0800385$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
386 @echo "Copy: $@"
387 $(copy-file-to-target)
388
389my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
390
391ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800392
393###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700394## Compile the .proto files to .cc and then to .o
395###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800396proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700397proto_generated_objects :=
398proto_generated_headers :=
399ifneq ($(proto_sources),)
400proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
401proto_generated_cc_sources_dir := $(intermediates)/proto
402proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700403 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700404proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources))
405
406$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
407$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700408$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700409$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
410 $(transform-proto-to-cc)
411
412proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
413$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
414
Ying Wang022a7b32012-06-13 11:38:10 -0700415$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
416$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Narayan Kamath21094872012-04-02 18:19:31 +0100417$(proto_generated_objects): $(proto_generated_cc_sources_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700418 $(transform-$(PRIVATE_HOST)cpp-to-o)
419-include $(proto_generated_objects:%.o=%.P)
420
Ying Wang6ef65192014-01-15 16:02:16 -0800421my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
422my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700423ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800424my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700425else
Ying Wang6ef65192014-01-15 16:02:16 -0800426my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700427endif
428endif
429
430
431###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800432## YACC: Compile .y files to .cpp and the to .o.
433###########################################################
434
Ying Wangb8e01852014-01-23 15:09:04 -0800435yacc_sources := $(filter %.y,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800436yacc_cpps := $(addprefix \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700437 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800438yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
439yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
440
441ifneq ($(strip $(yacc_cpps)),)
442$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700443 $(TOPDIR)$(LOCAL_PATH)/%.y \
444 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800445 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
446$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
447
448$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
449$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
450$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
451 $(transform-$(PRIVATE_HOST)cpp-to-o)
452endif
453
454###########################################################
455## LEX: Compile .l files to .cpp and then to .o.
456###########################################################
457
Ying Wangb8e01852014-01-23 15:09:04 -0800458lex_sources := $(filter %.l,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800459lex_cpps := $(addprefix \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700460 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800461lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
462
463ifneq ($(strip $(lex_cpps)),)
464$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700465 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800466 $(transform-l-to-cpp)
467
468$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
469$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
470$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700471 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
472 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
473 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800474 $(transform-$(PRIVATE_HOST)cpp-to-o)
475endif
476
477###########################################################
478## C++: Compile .cpp files to .o.
479###########################################################
480
Jeff Browne33ba4c2011-07-11 22:11:46 -0700481# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800482# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800483cpp_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 -0800484cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
485
Ying Wangb8e01852014-01-23 15:09:04 -0800486cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800487cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
488
489$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
490$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
491$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
492$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
493
494cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
495
496ifneq ($(strip $(cpp_objects)),)
497$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700498 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800499 $(yacc_cpps) $(proto_generated_headers) \
500 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
501 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800502 $(transform-$(PRIVATE_HOST)cpp-to-o)
503-include $(cpp_objects:%.o=%.P)
504endif
505
506###########################################################
507## C++: Compile generated .cpp files to .o.
508###########################################################
509
Ying Wangec6d6262014-01-16 16:21:03 -0800510gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800511gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
512
513ifneq ($(strip $(gen_cpp_objects)),)
514# Compile all generated files as thumb.
515# TODO: support compiling certain generated files as arm.
516$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
517$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400518$(gen_cpp_objects): $(intermediates)/%.o: \
519 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800520 $(proto_generated_headers) \
521 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
522 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523 $(transform-$(PRIVATE_HOST)cpp-to-o)
524-include $(gen_cpp_objects:%.o=%.P)
525endif
526
527###########################################################
528## S: Compile generated .S and .s files to .o.
529###########################################################
530
Ying Wangec6d6262014-01-16 16:21:03 -0800531gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532gen_S_objects := $(gen_S_sources:%.S=%.o)
533
534ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400535$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800536 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
537 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800538 $(transform-$(PRIVATE_HOST)s-to-o)
539-include $(gen_S_objects:%.o=%.P)
540endif
541
Ying Wangec6d6262014-01-16 16:21:03 -0800542gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800543gen_s_objects := $(gen_s_sources:%.s=%.o)
544
545ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400546$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800547 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
548 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800549 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
550-include $(gen_s_objects:%.o=%.P)
551endif
552
553gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
554
555###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000556## o: Include generated .o files in output.
557###########################################################
558
Ying Wangec6d6262014-01-16 16:21:03 -0800559gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000560
561###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800562## C: Compile .c files to .o.
563###########################################################
564
Ying Wangb8e01852014-01-23 15:09:04 -0800565c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800566c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
567
Ying Wangb8e01852014-01-23 15:09:04 -0800568c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800569c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
570
571$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
572$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
573$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
574$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
575
576c_objects := $(c_arm_objects) $(c_normal_objects)
577
578ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400579$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800580 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
581 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582 $(transform-$(PRIVATE_HOST)c-to-o)
583-include $(c_objects:%.o=%.P)
584endif
585
586###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700587## C: Compile generated .c files to .o.
588###########################################################
589
Ying Wangec6d6262014-01-16 16:21:03 -0800590gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700591gen_c_objects := $(gen_c_sources:%.c=%.o)
592
593ifneq ($(strip $(gen_c_objects)),)
594# Compile all generated files as thumb.
595# TODO: support compiling certain generated files as arm.
596$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
597$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400598$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800599 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
600 | $(my_compiler_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700601 $(transform-$(PRIVATE_HOST)c-to-o)
602-include $(gen_c_objects:%.o=%.P)
603endif
604
605###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200606## ObjC: Compile .m files to .o
607###########################################################
608
Ying Wangb8e01852014-01-23 15:09:04 -0800609objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200610objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
611
612ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400613$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800614 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
615 | $(my_compiler_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200616 $(transform-$(PRIVATE_HOST)m-to-o)
617-include $(objc_objects:%.o=%.P)
618endif
619
620###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800621## AS: Compile .S files to .o.
622###########################################################
623
Ying Wangb8e01852014-01-23 15:09:04 -0800624asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800625asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
626
627ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400628$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800629 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
630 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800631 $(transform-$(PRIVATE_HOST)s-to-o)
632-include $(asm_objects_S:%.o=%.P)
633endif
634
Ying Wangb8e01852014-01-23 15:09:04 -0800635asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800636asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
637
638ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400639$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800640 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
641 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800642 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
643-include $(asm_objects_s:%.o=%.P)
644endif
645
646asm_objects := $(asm_objects_S) $(asm_objects_s)
647
648
Ying Wang5f074802011-11-08 09:31:21 -0800649####################################################
650## Import includes
651####################################################
652import_includes := $(intermediates)/import_includes
653import_includes_deps := $(strip \
654 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800655 $(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 -0800656 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800657 $(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 -0800658$(import_includes) : $(import_includes_deps)
659 @echo Import includes file: $@
660 $(hide) mkdir -p $(dir $@) && rm -f $@
661ifdef import_includes_deps
662 $(hide) for f in $^; do \
663 cat $$f >> $@; \
664 done
665else
666 $(hide) touch $@
667endif
668
The Android Open Source Project88b60792009-03-03 19:28:42 -0800669###########################################################
670## Common object handling.
671###########################################################
672
673# some rules depend on asm_objects being first. If your code depends on
674# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100675normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700676 $(asm_objects) \
677 $(cpp_objects) \
678 $(gen_cpp_objects) \
679 $(gen_asm_objects) \
680 $(c_objects) \
681 $(gen_c_objects) \
682 $(objc_objects) \
683 $(yacc_objects) \
684 $(lex_objects) \
685 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100686 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
687
688all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800689
Ying Wang6ef65192014-01-15 16:02:16 -0800690my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800691
Ying Wang848020f2012-08-14 10:13:16 -0700692ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800693 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700694endif
695
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100696# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
697# use normal_objects here to avoid creating circular dependencies. This assumes
698# that custom build rules which generate .o files don't consume other generated
699# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800700$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100701$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800702ALL_C_CPP_ETC_OBJECTS += $(all_objects)
703
704###########################################################
705## Copy headers to the install tree
706###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800707ifndef LOCAL_2ND_ARCH_VAR_PREFIX
The Android Open Source Project88b60792009-03-03 19:28:42 -0800708include $(BUILD_COPY_HEADERS)
Ying Wang6ef65192014-01-15 16:02:16 -0800709endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710
711###########################################################
712# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800713###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714
715###########################################################
716# The list of libraries that this module will link against are in
717# these variables. Each is a list of bare module names like "libc libm".
718#
719# LOCAL_SHARED_LIBRARIES
720# LOCAL_STATIC_LIBRARIES
721# LOCAL_WHOLE_STATIC_LIBRARIES
722#
723# We need to convert the bare names into the dependencies that
724# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
725# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
726# libraries, so that simply building this module doesn't force
727# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
728# should depend on the INSTALLED versions of the libraries so
729# that they get installed when this module does.
730###########################################################
731# NOTE:
732# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
733# module without leaving anything out, which is useful for turning
734# a collection of .a files into a .so file. Linking against a
735# normal STATIC_LIBRARY will only pull in code/symbols that are
736# referenced by the module. (see gcc/ld's --whole-archive option)
737###########################################################
738
739# Get the list of BUILT libraries, which are under
740# various intermediates directories.
741so_suffix := $($(my_prefix)SHLIB_SUFFIX)
742a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
743
Ying Wang848020f2012-08-14 10:13:16 -0700744ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800745built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800746 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800747 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800748 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800749
Ying Wangcce4c972011-03-03 18:53:53 -0800750my_system_shared_libraries_fullpath := \
751 $(my_ndk_stl_shared_lib_fullpath) \
752 $(addprefix $(my_ndk_version_root)/usr/lib/, \
753 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
Ying Wang1a081002010-07-13 14:55:47 -0700754
755built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang6ef65192014-01-15 16:02:16 -0800756my_shared_libraries += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang1a081002010-07-13 14:55:47 -0700757else
Ying Wang6ef65192014-01-15 16:02:16 -0800758my_shared_libraries += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang1a081002010-07-13 14:55:47 -0700759built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800760 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700761 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800762 $(my_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700763endif
764
The Android Open Source Project88b60792009-03-03 19:28:42 -0800765built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800766 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800767 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800768 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 -0800769
Ying Wang848020f2012-08-14 10:13:16 -0700770ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800771built_static_libraries += $(my_ndk_stl_static_lib)
772endif
773
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -0800775 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800777 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 -0800778
The Android Open Source Project88b60792009-03-03 19:28:42 -0800779# We don't care about installed static libraries, since the
780# libraries have already been linked into the module at that point.
781# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000782# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783
784installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -0800785 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800786 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
787
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700788# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -0700789ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
790LOCAL_RTTI_FLAG := -fno-rtti
791endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700792
The Android Open Source Project88b60792009-03-03 19:28:42 -0800793###########################################################
794# Rule-specific variable definitions
795###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +0800796
797ifeq ($(LOCAL_CLANG),true)
Ying Wang1f982832014-02-06 18:08:44 -0800798my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
799my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
800my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
801my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +0800802endif
803
The Android Open Source Project88b60792009-03-03 19:28:42 -0800804$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800805$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -0700806$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800807$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
808$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700809$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800810$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -0800811$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -0800812$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -0800813$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
Ying Wangb8e01852014-01-23 15:09:04 -0800815$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800816
817# this is really the way to get the files onto the command line instead
818# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
819$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
820$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
821$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
822$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
823
824###########################################################
825# Define library dependencies.
826###########################################################
827# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
828all_libraries := \
829 $(built_shared_libraries) \
830 $(built_static_libraries) \
831 $(built_whole_libraries)
832
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833# Also depend on the notice files for any static libraries that
834# are linked into this module. This will force them to be installed
835# when this module is.
836$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -0800837
838###########################################################
839# Export includes
840###########################################################
841export_includes := $(intermediates)/export_includes
842$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang68f1c772012-04-23 21:29:18 -0700843$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
Ying Wang5f074802011-11-08 09:31:21 -0800844 @echo Export includes file: $< -- $@
845 $(hide) mkdir -p $(dir $@) && rm -f $@
846ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
847 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
848 echo "-I $$d" >> $@; \
849 done
850else
851 $(hide) touch $@
852endif
Ying Wang616e5962012-04-18 17:35:55 -0700853
854# Make sure export_includes gets generated when you are running mm/mmm
855$(LOCAL_BUILT_MODULE) : | $(export_includes)