blob: 3556b99c423975f8d0da619cef0a65fbecfb0615 [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))
Ying Wang6ef65192014-01-15 16:02:16 -080089my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
90my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
Ying Wangb8e01852014-01-23 15:09:04 -080091my_cflags := $(LOCAL_CFLAGS) $(LOCAL_CFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wang6ef65192014-01-15 16:02:16 -080092my_cppflags := $(LOCAL_CPPFLAGS)
Ying Wangb8e01852014-01-23 15:09:04 -080093my_ldflags := $(LOCAL_LDFLAGS) $(LOCAL_LDFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
94my_asflags := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wang6ef65192014-01-15 16:02:16 -080095my_cc := $(LOCAL_CC)
96my_cxx := $(LOCAL_CXX)
Ying Wangdbdafdb2014-01-27 10:27:19 -080097my_c_includes := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wang6ef65192014-01-15 16:02:16 -080098my_generated_sources := $(LOCAL_GENERATED_SOURCES)
99
100
Ying Wang9485a572013-02-22 14:32:30 -0800101# The real dependency will be added after all Android.mks are loaded and the install paths
102# of the shared libraries are determined.
103ifdef LOCAL_INSTALLED_MODULE
104ifdef installed_shared_library_module_names
Ying Wang6ef65192014-01-15 16:02:16 -0800105$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
106 $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Ying Wang9485a572013-02-22 14:32:30 -0800107endif
108endif
109
Ying Wang285045b2013-08-13 12:35:10 -0700110# Add static HAL libraries
111ifdef LOCAL_HAL_STATIC_LIBRARIES
112$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
113 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800114 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
115 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700116b_lib :=
117endif
118
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400119ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
120 LOCAL_CLANG := true
Ying Wang6ef65192014-01-15 16:02:16 -0800121 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
122 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
123 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
124 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400125endif
126
Mike Lockwood051a1742013-06-14 10:52:50 -0700127ifeq ($(strip $(WITHOUT_CLANG)),true)
128 LOCAL_CLANG :=
129endif
130
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800131# Add in libcompiler_rt for all regular device builds
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700132ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800133 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700134endif
135
Ying Wangdfbe79b2012-03-22 11:26:22 -0700136my_compiler_dependencies :=
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400137ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wangdfbe79b2012-03-22 11:26:22 -0700138 my_compiler_dependencies := $(CLANG) $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Jing Yu2dcc8062009-09-21 16:31:50 -0700141####################################################
142## Add FDO flags if FDO is turned on and supported
143####################################################
synergydev7c467422013-08-13 17:41:52 -0700144ifneq ($(strip $(LOCAL_FDO_SUPPORT)),)
synergydev4a605762013-08-05 02:44:37 -0700145 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800146 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
147 my_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
148 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
synergydev4a605762013-08-05 02:44:37 -0700149 endif
Jing Yu2dcc8062009-09-21 16:31:50 -0700150endif
151
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800153## Explicitly declare assembly-only __ASSEMBLY__ macro for
154## assembly source
155###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800156my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800157
158###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700159## Define PRIVATE_ variables from global vars
160###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800161ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700162ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700163my_target_project_includes :=
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400164my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_version_root)/usr/include
Ying Wang1a081002010-07-13 14:55:47 -0700165else
Ying Wang6ef65192014-01-15 16:02:16 -0800166my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
167my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Ying Wangf4723fa2013-08-15 11:01:10 -0700168endif # LOCAL_SDK_VERSION
169
170ifeq ($(LOCAL_CLANG),true)
Logan Chiene6f65432013-12-10 19:07:41 +0800171my_target_global_cflags := $(CLANG_TARGET_GLOBAL_CFLAGS)
172my_target_global_cppflags := $(CLANG_TARGET_GLOBAL_CPPFLAGS)
173my_target_global_ldflags := $(CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangf4723fa2013-08-15 11:01:10 -0700174my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
Ying Wangda4bf422012-08-16 16:45:01 -0700175else
Ying Wang6ef65192014-01-15 16:02:16 -0800176my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
177my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
178my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700179endif # LOCAL_CLANG
Ying Wangda4bf422012-08-16 16:45:01 -0700180
Ying Wang1a081002010-07-13 14:55:47 -0700181$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400182$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700183$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800184$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
185$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
186
Ying Wang7fff9a12014-01-09 14:39:41 -0800187else # LOCAL_IS_HOST_MODULE
188
Logan Chiene6f65432013-12-10 19:07:41 +0800189ifeq ($(LOCAL_CLANG),true)
190my_host_global_cflags := $(CLANG_HOST_GLOBAL_CFLAGS)
191my_host_global_cppflags := $(CLANG_HOST_GLOBAL_CPPFLAGS)
192my_host_global_ldflags := $(CLANG_HOST_GLOBAL_LDFLAGS)
193my_host_c_includes := $(HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
194else
195my_host_global_cflags := $(HOST_GLOBAL_CFLAGS)
196my_host_global_cppflags := $(HOST_GLOBAL_CPPFLAGS)
197my_host_global_ldflags := $(HOST_GLOBAL_LDFLAGS)
198my_host_c_includes := $(HOST_C_INCLUDES)
199endif # LOCAL_CLANG
200
201$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
202$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
203$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
204$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
205endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700206
207###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800208## Define PRIVATE_ variables used by multiple module types
209###########################################################
210$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700211 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800212
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800213ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
214 LOCAL_NO_SYNTAX_CHECK := true
215endif
216
Andrew Hsieh906cb782013-09-10 17:37:14 +0800217ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
218 LOCAL_NO_STATIC_ANALYZER := true
219endif
220
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800221ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
222 my_syntax_arch := host
223else
Ying Wang6ef65192014-01-15 16:02:16 -0800224 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800225endif
226
Ying Wang6ef65192014-01-15 16:02:16 -0800227ifeq ($(strip $(my_cc)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400228 ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800229 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400230 else
Ying Wang6ef65192014-01-15 16:02:16 -0800231 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400232 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800234ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800235 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800236else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800237ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800238 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800239endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800240endif
Ying Wang6ef65192014-01-15 16:02:16 -0800241$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800242
Ying Wang6ef65192014-01-15 16:02:16 -0800243ifeq ($(strip $(my_cxx)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400244 ifeq ($(strip $(LOCAL_CLANG)),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800245 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400246 else
Ying Wang6ef65192014-01-15 16:02:16 -0800247 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400248 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800249endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800250ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800251 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800252else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800253ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800254 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800255endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800256endif
Ying Wang6ef65192014-01-15 16:02:16 -0800257$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258
259# TODO: support a mix of standard extensions so that this isn't necessary
260LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
261ifeq ($(LOCAL_CPP_EXTENSION),)
262 LOCAL_CPP_EXTENSION := .cpp
263endif
264$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
265
266# Certain modules like libdl have to have symbols resolved at runtime and blow
267# up if --no-undefined is passed to the linker.
268ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
269ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
Ying Wang6ef65192014-01-15 16:02:16 -0800270 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800271endif
272endif
273
Ying Wangfcdabd42011-04-25 14:22:41 -0700274ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
275$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
276else
277$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
278endif
279
The Android Open Source Project88b60792009-03-03 19:28:42 -0800280###########################################################
281## Define arm-vs-thumb-mode flags.
282###########################################################
283LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800284ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
286normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
287
Dave Bort95282482009-04-23 18:44:55 -0700288# Read the values from something like TARGET_arm_CFLAGS or
289# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
290# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800291arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
292normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Logan Chiene6f65432013-12-10 19:07:41 +0800293ifeq ($(strip $(LOCAL_CLANG)),true)
294arm_objects_cflags := $(call convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
295normal_objects_cflags := $(call convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400296endif
297
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800298else
299arm_objects_mode :=
300normal_objects_mode :=
301arm_objects_cflags :=
302normal_objects_cflags :=
303endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800304
305###########################################################
306## Define per-module debugging flags. Users can turn on
307## debugging for a particular module by setting DEBUG_MODULE_ModuleName
308## to a non-empty value in their environment or buildspec.mk,
309## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
310## debug flags that they want to use.
311###########################################################
312ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
313 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
314else
315 debug_cflags :=
316endif
317
Tim Murraya7aa8002012-10-29 16:06:00 -0700318####################################################
319## Compile RenderScript with reflected C++
320####################################################
321
Ying Wangb8e01852014-01-23 15:09:04 -0800322renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700323
324ifneq (,$(renderscript_sources))
325
326renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
327RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
328renderscript_intermediate := $(intermediates)/renderscript
329
330ifeq ($(LOCAL_RENDERSCRIPT_CC),)
331LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
332endif
333
334# Turn on all warnings and warnings as errors for RS compiles.
335# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
336renderscript_flags := -Wall -Werror
337renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
338
Ying Wang6ef65192014-01-15 16:02:16 -0800339renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700340 $(TOPDIR)external/clang/lib/Headers \
341 $(TOPDIR)frameworks/rs/scriptc \
342 $(LOCAL_RENDERSCRIPT_INCLUDES)
343
344ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800345renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700346endif
347
Ying Wang6ef65192014-01-15 16:02:16 -0800348$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700349$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
350$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
351$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
352$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
353$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
354 $(transform-renderscripts-to-cpp-and-bc)
355
356# include the dependency files (.d) generated by llvm-rs-cc.
357renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
358 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
359-include $(renderscript_generated_dep_files)
360
361LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
362
363rs_generated_cpps := $(addprefix \
364 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
365 $(notdir $(renderscript_sources)))))
366
367$(rs_generated_cpps) : $(RenderScript_file_stamp)
368
Ying Wang6ef65192014-01-15 16:02:16 -0800369my_c_includes += $(renderscript_intermediate)
370my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700371
372endif
373
374
The Android Open Source Project88b60792009-03-03 19:28:42 -0800375###########################################################
376## Stuff source generated from one-off tools
377###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800378$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800379
Colin Crossd8262642014-01-24 23:17:21 -0800380my_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 -0800381
Colin Crossd8262642014-01-24 23:17:21 -0800382$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
383 @echo "Copy: $@"
384 $(copy-file-to-target)
385
386my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
387
388ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800389
390###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700391## Compile the .proto files to .cc and then to .o
392###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800393proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700394proto_generated_objects :=
395proto_generated_headers :=
396ifneq ($(proto_sources),)
397proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
398proto_generated_cc_sources_dir := $(intermediates)/proto
399proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700400 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700401proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources))
402
403$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
404$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700405$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700406$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
407 $(transform-proto-to-cc)
408
409proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
410$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
411
Ying Wang022a7b32012-06-13 11:38:10 -0700412$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
413$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Narayan Kamath21094872012-04-02 18:19:31 +0100414$(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 -0700415 $(transform-$(PRIVATE_HOST)cpp-to-o)
416-include $(proto_generated_objects:%.o=%.P)
417
Ying Wang6ef65192014-01-15 16:02:16 -0800418my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
419my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700420ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Ying Wang6ef65192014-01-15 16:02:16 -0800421my_static_libraries += libprotobuf-cpp-2.3.0-full
Ying Wanga5fc87a2010-11-02 18:43:16 -0700422else
Ying Wang6ef65192014-01-15 16:02:16 -0800423my_static_libraries += libprotobuf-cpp-2.3.0-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700424endif
425endif
426
427
428###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800429## YACC: Compile .y files to .cpp and the to .o.
430###########################################################
431
Ying Wangb8e01852014-01-23 15:09:04 -0800432yacc_sources := $(filter %.y,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433yacc_cpps := $(addprefix \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700434 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800435yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
436yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
437
438ifneq ($(strip $(yacc_cpps)),)
439$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700440 $(TOPDIR)$(LOCAL_PATH)/%.y \
441 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800442 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
443$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
444
445$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
446$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
447$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
448 $(transform-$(PRIVATE_HOST)cpp-to-o)
449endif
450
451###########################################################
452## LEX: Compile .l files to .cpp and then to .o.
453###########################################################
454
Ying Wangb8e01852014-01-23 15:09:04 -0800455lex_sources := $(filter %.l,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800456lex_cpps := $(addprefix \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700457 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800458lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
459
460ifneq ($(strip $(lex_cpps)),)
461$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700462 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800463 $(transform-l-to-cpp)
464
465$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
466$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
467$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700468 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
469 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
470 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800471 $(transform-$(PRIVATE_HOST)cpp-to-o)
472endif
473
474###########################################################
475## C++: Compile .cpp files to .o.
476###########################################################
477
Jeff Browne33ba4c2011-07-11 22:11:46 -0700478# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800479# it's not really arm, because there are files that are shared.
Ying Wangb8e01852014-01-23 15:09:04 -0800480cpp_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 -0800481cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
482
Ying Wangb8e01852014-01-23 15:09:04 -0800483cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800484cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
485
486$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
487$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
488$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
489$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
490
491cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
492
493ifneq ($(strip $(cpp_objects)),)
494$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700495 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800496 $(yacc_cpps) $(proto_generated_headers) \
497 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
498 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800499 $(transform-$(PRIVATE_HOST)cpp-to-o)
500-include $(cpp_objects:%.o=%.P)
501endif
502
503###########################################################
504## C++: Compile generated .cpp files to .o.
505###########################################################
506
Ying Wangec6d6262014-01-16 16:21:03 -0800507gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800508gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
509
510ifneq ($(strip $(gen_cpp_objects)),)
511# Compile all generated files as thumb.
512# TODO: support compiling certain generated files as arm.
513$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
514$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400515$(gen_cpp_objects): $(intermediates)/%.o: \
516 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800517 $(proto_generated_headers) \
518 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
519 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800520 $(transform-$(PRIVATE_HOST)cpp-to-o)
521-include $(gen_cpp_objects:%.o=%.P)
522endif
523
524###########################################################
525## S: Compile generated .S and .s files to .o.
526###########################################################
527
Ying Wangec6d6262014-01-16 16:21:03 -0800528gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800529gen_S_objects := $(gen_S_sources:%.S=%.o)
530
531ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400532$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800533 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
534 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800535 $(transform-$(PRIVATE_HOST)s-to-o)
536-include $(gen_S_objects:%.o=%.P)
537endif
538
Ying Wangec6d6262014-01-16 16:21:03 -0800539gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800540gen_s_objects := $(gen_s_sources:%.s=%.o)
541
542ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400543$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800544 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
545 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800546 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
547-include $(gen_s_objects:%.o=%.P)
548endif
549
550gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
551
552###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000553## o: Include generated .o files in output.
554###########################################################
555
Ying Wangec6d6262014-01-16 16:21:03 -0800556gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000557
558###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800559## C: Compile .c files to .o.
560###########################################################
561
Ying Wangb8e01852014-01-23 15:09:04 -0800562c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
564
Ying Wangb8e01852014-01-23 15:09:04 -0800565c_normal_sources := $(filter %.c,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800566c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
567
568$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
569$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
570$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
571$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
572
573c_objects := $(c_arm_objects) $(c_normal_objects)
574
575ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400576$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800577 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
578 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579 $(transform-$(PRIVATE_HOST)c-to-o)
580-include $(c_objects:%.o=%.P)
581endif
582
583###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700584## C: Compile generated .c files to .o.
585###########################################################
586
Ying Wangec6d6262014-01-16 16:21:03 -0800587gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700588gen_c_objects := $(gen_c_sources:%.c=%.o)
589
590ifneq ($(strip $(gen_c_objects)),)
591# Compile all generated files as thumb.
592# TODO: support compiling certain generated files as arm.
593$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
594$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400595$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800596 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
597 | $(my_compiler_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700598 $(transform-$(PRIVATE_HOST)c-to-o)
599-include $(gen_c_objects:%.o=%.P)
600endif
601
602###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200603## ObjC: Compile .m files to .o
604###########################################################
605
Ying Wangb8e01852014-01-23 15:09:04 -0800606objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200607objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
608
609ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400610$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800611 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
612 | $(my_compiler_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200613 $(transform-$(PRIVATE_HOST)m-to-o)
614-include $(objc_objects:%.o=%.P)
615endif
616
617###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800618## AS: Compile .S files to .o.
619###########################################################
620
Ying Wangb8e01852014-01-23 15:09:04 -0800621asm_sources_S := $(filter %.S,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
623
624ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400625$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Ying Wang9c3aa052013-02-20 13:34:05 -0800626 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
627 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800628 $(transform-$(PRIVATE_HOST)s-to-o)
629-include $(asm_objects_S:%.o=%.P)
630endif
631
Ying Wangb8e01852014-01-23 15:09:04 -0800632asm_sources_s := $(filter %.s,$(my_src_files))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800633asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
634
635ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400636$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Ying Wang9c3aa052013-02-20 13:34:05 -0800637 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
638 | $(my_compiler_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800639 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
640-include $(asm_objects_s:%.o=%.P)
641endif
642
643asm_objects := $(asm_objects_S) $(asm_objects_s)
644
645
Ying Wang5f074802011-11-08 09:31:21 -0800646####################################################
647## Import includes
648####################################################
649import_includes := $(intermediates)/import_includes
650import_includes_deps := $(strip \
651 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800652 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \
653 $(foreach l, $(my_static_libraries) $(LOCAL_WHOLE_STATIC_LIBRARIES), \
654 $(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 -0800655$(import_includes) : $(import_includes_deps)
656 @echo Import includes file: $@
657 $(hide) mkdir -p $(dir $@) && rm -f $@
658ifdef import_includes_deps
659 $(hide) for f in $^; do \
660 cat $$f >> $@; \
661 done
662else
663 $(hide) touch $@
664endif
665
The Android Open Source Project88b60792009-03-03 19:28:42 -0800666###########################################################
667## Common object handling.
668###########################################################
669
670# some rules depend on asm_objects being first. If your code depends on
671# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100672normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700673 $(asm_objects) \
674 $(cpp_objects) \
675 $(gen_cpp_objects) \
676 $(gen_asm_objects) \
677 $(c_objects) \
678 $(gen_c_objects) \
679 $(objc_objects) \
680 $(yacc_objects) \
681 $(lex_objects) \
682 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100683 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
684
685all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800686
Ying Wang6ef65192014-01-15 16:02:16 -0800687my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800688
Ying Wang848020f2012-08-14 10:13:16 -0700689ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -0800690 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -0700691endif
692
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100693# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
694# use normal_objects here to avoid creating circular dependencies. This assumes
695# that custom build rules which generate .o files don't consume other generated
696# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -0800697$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +0100698$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800699ALL_C_CPP_ETC_OBJECTS += $(all_objects)
700
701###########################################################
702## Copy headers to the install tree
703###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800704ifndef LOCAL_2ND_ARCH_VAR_PREFIX
The Android Open Source Project88b60792009-03-03 19:28:42 -0800705include $(BUILD_COPY_HEADERS)
Ying Wang6ef65192014-01-15 16:02:16 -0800706endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707
708###########################################################
709# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800711
712###########################################################
713# The list of libraries that this module will link against are in
714# these variables. Each is a list of bare module names like "libc libm".
715#
716# LOCAL_SHARED_LIBRARIES
717# LOCAL_STATIC_LIBRARIES
718# LOCAL_WHOLE_STATIC_LIBRARIES
719#
720# We need to convert the bare names into the dependencies that
721# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
722# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
723# libraries, so that simply building this module doesn't force
724# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
725# should depend on the INSTALLED versions of the libraries so
726# that they get installed when this module does.
727###########################################################
728# NOTE:
729# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
730# module without leaving anything out, which is useful for turning
731# a collection of .a files into a .so file. Linking against a
732# normal STATIC_LIBRARY will only pull in code/symbols that are
733# referenced by the module. (see gcc/ld's --whole-archive option)
734###########################################################
735
736# Get the list of BUILT libraries, which are under
737# various intermediates directories.
738so_suffix := $($(my_prefix)SHLIB_SUFFIX)
739a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
740
Ying Wang848020f2012-08-14 10:13:16 -0700741ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800742built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800743 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800744 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800745 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800746
Ying Wangcce4c972011-03-03 18:53:53 -0800747my_system_shared_libraries_fullpath := \
748 $(my_ndk_stl_shared_lib_fullpath) \
749 $(addprefix $(my_ndk_version_root)/usr/lib/, \
750 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
Ying Wang1a081002010-07-13 14:55:47 -0700751
752built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang6ef65192014-01-15 16:02:16 -0800753my_shared_libraries += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang1a081002010-07-13 14:55:47 -0700754else
Ying Wang6ef65192014-01-15 16:02:16 -0800755my_shared_libraries += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Ying Wang1a081002010-07-13 14:55:47 -0700756built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800757 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -0700758 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -0800759 $(my_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -0700760endif
761
The Android Open Source Project88b60792009-03-03 19:28:42 -0800762built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -0800763 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800764 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800765 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 -0800766
Ying Wang848020f2012-08-14 10:13:16 -0700767ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -0800768built_static_libraries += $(my_ndk_stl_static_lib)
769endif
770
The Android Open Source Project88b60792009-03-03 19:28:42 -0800771built_whole_libraries := \
772 $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
773 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -0800774 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 -0800775
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776# We don't care about installed static libraries, since the
777# libraries have already been linked into the module at that point.
778# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +0000779# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800780
781installed_static_library_notice_file_targets := \
Ying Wang6ef65192014-01-15 16:02:16 -0800782 $(foreach lib,$(my_static_libraries) $(LOCAL_WHOLE_STATIC_LIBRARIES), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
784
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700785# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -0700786ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
787LOCAL_RTTI_FLAG := -fno-rtti
788endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700789
The Android Open Source Project88b60792009-03-03 19:28:42 -0800790###########################################################
791# Rule-specific variable definitions
792###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +0800793
794ifeq ($(LOCAL_CLANG),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800795my_cflags := $(call convert-to-$(my_host)clang-flags,$(my_cflags))
796my_cppflags := $(call convert-to-$(my_host)clang-flags,$(my_cppflags))
797my_asflags := $(call convert-to-$(my_host)clang-flags,$(my_asflags))
798my_ldflags := $(call convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +0800799endif
800
The Android Open Source Project88b60792009-03-03 19:28:42 -0800801$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800802$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Ying Wang7429e212012-08-15 10:59:10 -0700803$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800804$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
805$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Doug Kwan9a8ecf92011-05-10 21:50:58 -0700806$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800807$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -0800808$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -0800809$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -0800810$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800811$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
Ying Wangb8e01852014-01-23 15:09:04 -0800812$(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 -0800813
814# this is really the way to get the files onto the command line instead
815# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
816$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
817$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
818$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
819$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
820
821###########################################################
822# Define library dependencies.
823###########################################################
824# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
825all_libraries := \
826 $(built_shared_libraries) \
827 $(built_static_libraries) \
828 $(built_whole_libraries)
829
The Android Open Source Project88b60792009-03-03 19:28:42 -0800830# Also depend on the notice files for any static libraries that
831# are linked into this module. This will force them to be installed
832# when this module is.
833$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -0800834
835###########################################################
836# Export includes
837###########################################################
838export_includes := $(intermediates)/export_includes
839$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang68f1c772012-04-23 21:29:18 -0700840$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
Ying Wang5f074802011-11-08 09:31:21 -0800841 @echo Export includes file: $< -- $@
842 $(hide) mkdir -p $(dir $@) && rm -f $@
843ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
844 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
845 echo "-I $$d" >> $@; \
846 done
847else
848 $(hide) touch $@
849endif
Ying Wang616e5962012-04-18 17:35:55 -0700850
851# Make sure export_includes gets generated when you are running mm/mmm
852$(LOCAL_BUILT_MODULE) : | $(export_includes)