blob: 3a167f034c3035caf5b01c7a3d171a8d474cc287 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building binary object files from
Ying Wangd8d37212014-03-21 16:17:04 -07003## asm/c/cpp/yacc/lex/etc source files.
The Android Open Source Project88b60792009-03-03 19:28:42 -08004##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
Ying Wangd8d37212014-03-21 16:17:04 -07008#######################################
9include $(BUILD_SYSTEM)/base_rules.mk
10#######################################
11
Dan Albertd3d894d2014-11-14 15:28:49 -080012##################################################
13# Compute the dependency of the shared libraries
14##################################################
15# On the target, we compile with -nostdlib, so we must add in the
16# default system shared libraries, unless they have requested not
17# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
18# supply that, for example, when building libc itself.
19ifdef LOCAL_IS_HOST_MODULE
20 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
21 my_system_shared_libraries :=
22 else
23 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
24 endif
25else
26 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Dan Albert7ba582a2015-08-06 12:22:40 -070027 my_system_shared_libraries := libc libm
Dan Albertd3d894d2014-11-14 15:28:49 -080028 else
29 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
30 endif
31endif
32
33# The following LOCAL_ variables will be modified in this file.
34# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
35# we can't modify them in place.
36my_src_files := $(LOCAL_SRC_FILES)
37my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
38my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
39my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
40my_cflags := $(LOCAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -080041my_conlyflags := $(LOCAL_CONLYFLAGS)
Dan Albertd3d894d2014-11-14 15:28:49 -080042my_cppflags := $(LOCAL_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -070043my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE)
44my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080045my_ldflags := $(LOCAL_LDFLAGS)
46my_ldlibs := $(LOCAL_LDLIBS)
47my_asflags := $(LOCAL_ASFLAGS)
48my_cc := $(LOCAL_CC)
Ying Wang57d90602015-07-20 18:40:18 -070049my_cc_wrapper := $(CC_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080050my_cxx := $(LOCAL_CXX)
Ying Wang57d90602015-07-20 18:40:18 -070051my_cxx_wrapper := $(CXX_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080052my_c_includes := $(LOCAL_C_INCLUDES)
53my_generated_sources := $(LOCAL_GENERATED_SOURCES)
54my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
55my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
56
Dan Albertb58fb4a2014-11-14 17:15:00 -080057ifdef LOCAL_IS_HOST_MODULE
58my_allow_undefined_symbols := true
59else
60my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
61endif
62
Andrew Hsieh140761af02014-04-25 23:47:10 -070063my_ndk_sysroot :=
64my_ndk_sysroot_include :=
65my_ndk_sysroot_lib :=
Ying Wang848020f2012-08-14 10:13:16 -070066ifdef LOCAL_SDK_VERSION
Ying Wangfe1bfe72012-08-14 11:08:03 -070067 ifdef LOCAL_NDK_VERSION
68 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
69 endif
Ying Wang1a081002010-07-13 14:55:47 -070070 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070071 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070072 endif
Ying Wang848020f2012-08-14 10:13:16 -070073 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
Andrew Hsieh140761af02014-04-25 23:47:10 -070074 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
75 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
76 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
77 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
Duane Sand1a074872014-11-08 15:25:18 -080078 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
79 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6
Andrew Hsieh140761af02014-04-25 23:47:10 -070080 else
81 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
82 endif
Ying Wangcce4c972011-03-03 18:53:53 -080083
Dmitriy Ivanov3b51f202015-04-23 18:48:52 -070084 # The bionic linker now has support for packed relocations and gnu style
85 # hashes (which are much faster!), but shipping to older devices requires
86 # the old style hash and disabling packed relocations.
Dan Albertd3d894d2014-11-14 15:28:49 -080087 #ifeq ($(shell expr $(LOCAL_SDK_VERSION) >= FIRST_SUPPORTED_VERSION),0)
88 my_ldflags += -Wl,--hash-style=sysv
Dmitriy Ivanov3b51f202015-04-23 18:48:52 -070089 LOCAL_PACK_MODULE_RELOCATIONS := false
Dan Albertd3d894d2014-11-14 15:28:49 -080090 #endif
91
Ying Wangcce4c972011-03-03 18:53:53 -080092 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
93 # See ndk/docs/CPLUSPLUS-SUPPORT.html
94 my_ndk_stl_include_path :=
95 my_ndk_stl_shared_lib_fullpath :=
96 my_ndk_stl_shared_lib :=
97 my_ndk_stl_static_lib :=
Andrew Hsieh73d800e2014-03-04 17:11:52 +080098 my_ndk_stl_cppflags :=
Duane Sand1a074872014-11-08 15:25:18 -080099 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
100 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
101 my_cpu_variant := mips32r6
102 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800103 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800104 ifeq (,$(LOCAL_NDK_STL_VARIANT))
105 LOCAL_NDK_STL_VARIANT := system
106 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800107 ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -0700108 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800109 endif
110 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
111 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
112 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
113 else # LOCAL_NDK_STL_VARIANT is not system
114 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
115 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
116 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
Duane Sand1a074872014-11-08 15:25:18 -0800117 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a
Ying Wangcce4c972011-03-03 18:53:53 -0800118 else
Duane Sand1a074872014-11-08 15:25:18 -0800119 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so
Ying Wangcce4c972011-03-03 18:53:53 -0800120 my_ndk_stl_shared_lib := -lstlport_shared
121 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800122 else # LOCAL_NDK_STL_VARIANT is not stlport_* either
123 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
124 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
125 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
126 $(my_ndk_source_root)/android/support/include
127 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
Duane Sand1a074872014-11-08 15:25:18 -0800128 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_static.a
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800129 else
Duane Sand1a074872014-11-08 15:25:18 -0800130 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_shared.so
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800131 my_ndk_stl_shared_lib := -lc++_shared
132 endif
133 my_ndk_stl_cppflags := -std=c++11
Ying Wangcce4c972011-03-03 18:53:53 -0800134 else
135 # LOCAL_NDK_STL_VARIANT is gnustl_static
Duane Sand1a074872014-11-08 15:25:18 -0800136 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \
Ben Cheng4de6fa42014-04-10 22:46:26 -0700137 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
Duane Sand1a074872014-11-08 15:25:18 -0800138 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a
Ying Wangcce4c972011-03-03 18:53:53 -0800139 endif
140 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800141 endif
Ying Wang1a081002010-07-13 14:55:47 -0700142endif
143
Dan Albert95994de2014-08-07 18:29:11 -0700144# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
145# all code is position independent, and then those warnings get promoted to
146# errors.
Ying Wang594a10a2014-08-07 20:08:04 -0700147ifndef USE_MINGW
Dan Albert4803ce22014-08-06 12:36:46 -0700148ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
149my_cflags += -fpie
150else
151my_cflags += -fPIC
152endif
Dan Albert95994de2014-08-07 18:29:11 -0700153endif
Dan Albert4803ce22014-08-06 12:36:46 -0700154
Ying Wang6feb6d52014-04-17 10:03:35 -0700155my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
156my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
157my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
158my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
159my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
160my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
161my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
162my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800163
Dan Albertdb905e72014-08-18 11:14:38 -0700164my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700165ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700166my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700167endif
168ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700169my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700170endif
171
Tim Murray92d79cb2014-04-04 14:38:29 -0700172# clang is enabled by default for host builds
173# enable it unless we've specifically disabled clang above
174ifdef LOCAL_IS_HOST_MODULE
Tim Murrayf3ca3d52014-07-24 15:20:18 -0700175 ifneq ($(HOST_OS),windows)
Tim Murray5ca1dc12014-07-24 14:42:53 -0700176 ifeq ($(my_clang),)
177 my_clang := true
178 endif
179 endif
Tim Murray92d79cb2014-04-04 14:38:29 -0700180endif
181
Dan Albertc7d307d2015-07-29 15:13:57 -0700182my_cpp_std_version := -std=gnu++14
183ifdef LOCAL_SDK_VERSION
184 # The NDK handles this itself.
185 my_cpp_std_version :=
186endif
187
188ifdef LOCAL_IS_HOST_MODULE
189 ifneq ($(my_clang),true)
190 # The host GCC doesn't support C++14 (and is deprecated, so likely
191 # never will). Build these modules with C++11.
192 my_cpp_std_version := -std=gnu++11
193 endif
194endif
195
196my_cppflags := $(my_cpp_std_version) $(my_cppflags)
197
Tim Murray06659bc2014-08-13 11:53:07 -0700198# Add option to make clang the default for device build
199ifeq ($(USE_CLANG_PLATFORM_BUILD),true)
200 ifeq ($(my_clang),)
201 my_clang := true
202 endif
203endif
204
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800205# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700206my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
207my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
Ying Wang6ef65192014-01-15 16:02:16 -0800208
Ying Wang75e8fcb2014-10-07 13:03:29 -0700209include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700210
Ying Wang285045b2013-08-13 12:35:10 -0700211# Add static HAL libraries
212ifdef LOCAL_HAL_STATIC_LIBRARIES
213$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
214 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800215 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
216 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700217b_lib :=
218endif
219
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700220my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER)
221
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700222include $(BUILD_SYSTEM)/config_sanitizers.mk
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400223
Ying Wangba8b3772014-03-10 18:23:08 -0700224ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
Ying Wang824344a2014-05-27 13:03:36 -0700225 my_clang :=
Mike Lockwood051a1742013-06-14 10:52:50 -0700226endif
227
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800228# Add in libcompiler_rt for all regular device builds
Dan Albert30a9c352015-04-09 14:41:06 -0700229ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800230 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700231endif
232
Jing Yu2dcc8062009-09-21 16:31:50 -0700233####################################################
234## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700235## Please note that we will do option filtering during FDO build.
236## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
237##################################################################
Ying Wangd7914632014-10-28 14:50:59 -0700238my_fdo_build :=
239ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
240 ifeq ($(BUILD_FDO_INSTRUMENT),true)
241 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
242 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
243 my_fdo_build := true
244 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
245 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
246 my_fdo_build := true
synergydev4a605762013-08-05 02:44:37 -0700247 endif
Ying Wang57d90602015-07-20 18:40:18 -0700248 # Disable ccache (or other compiler wrapper).
249 my_cc_wrapper :=
250 my_cxx_wrapper :=
Jing Yu2dcc8062009-09-21 16:31:50 -0700251endif
252
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800254## Explicitly declare assembly-only __ASSEMBLY__ macro for
255## assembly source
256###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800257my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800258
Ying Wangd8d37212014-03-21 16:17:04 -0700259
Jim Huang20d1ba62010-10-14 16:15:56 +0800260###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700261## Define PRIVATE_ variables from global vars
262###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800263ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700264ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -0700265my_target_project_includes :=
Andrew Hsieh140761af02014-04-25 23:47:10 -0700266my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800267my_target_global_cppflags := $(my_ndk_stl_cppflags)
Ying Wang1a081002010-07-13 14:55:47 -0700268else
Ying Wang6ef65192014-01-15 16:02:16 -0800269my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
270my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800271my_target_global_cppflags :=
Ying Wangf4723fa2013-08-15 11:01:10 -0700272endif # LOCAL_SDK_VERSION
273
Ying Wang824344a2014-05-27 13:03:36 -0700274ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800275my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800276my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800277my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
Ying Wang1f982832014-02-06 18:08:44 -0800278my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700279else
Ying Wang6ef65192014-01-15 16:02:16 -0800280my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800281my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800282my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -0800283my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700284endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700285
Ying Wang1a081002010-07-13 14:55:47 -0700286$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
Evgeniy Stepanova7095e92012-03-30 12:18:52 +0400287$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700288$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800289$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800290$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
291$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
292
Ying Wang7fff9a12014-01-09 14:39:41 -0800293else # LOCAL_IS_HOST_MODULE
294
Ying Wang824344a2014-05-27 13:03:36 -0700295ifeq ($(my_clang),true)
Ying Wang6feb6d52014-04-17 10:03:35 -0700296my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800297my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CONLYFLAGS)
Ying Wang6feb6d52014-04-17 10:03:35 -0700298my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
299my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
Stephen Hinesf0089662014-09-25 22:35:16 -0700300my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Logan Chiene6f65432013-12-10 19:07:41 +0800301else
Ying Wang6feb6d52014-04-17 10:03:35 -0700302my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -0800303my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CONLYFLAGS)
Ying Wang6feb6d52014-04-17 10:03:35 -0700304my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
305my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
306my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
Ying Wang824344a2014-05-27 13:03:36 -0700307endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800308
309$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
310$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800311$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800312$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
313$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
314endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700315
Dan Albert43e128a2015-01-23 16:12:57 -0800316# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
317# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
318# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
319# clean build of your module after toggling it.
320ifeq ($(NATIVE_COVERAGE),true)
321 ifeq ($(my_native_coverage),true)
Dan Albert343ed672015-01-25 16:20:57 -0800322 # Note that clang coverage doesn't play nicely with acov out of the box.
323 # Clang apparently generates .gcno files that aren't compatible with
324 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
325 # with `--gcov-tool /usr/bin/gcov-4.6`.
326 #
327 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
Dan Albert2c03e042015-01-24 15:14:35 -0800328 my_cflags += --coverage -O0
Dan Albert343ed672015-01-25 16:20:57 -0800329 my_ldflags += --coverage
Dan Albert43e128a2015-01-23 16:12:57 -0800330 endif
331else
332 my_native_coverage := false
333endif
334
Ying Wang1a081002010-07-13 14:55:47 -0700335###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800336## Define PRIVATE_ variables used by multiple module types
337###########################################################
338$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700339 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800340
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800341ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
342 LOCAL_NO_SYNTAX_CHECK := true
343endif
344
Andrew Hsieh906cb782013-09-10 17:37:14 +0800345ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
346 LOCAL_NO_STATIC_ANALYZER := true
347endif
348
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800349ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
350 my_syntax_arch := host
351else
Ying Wang6ef65192014-01-15 16:02:16 -0800352 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800353endif
354
Ying Wang6ef65192014-01-15 16:02:16 -0800355ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700356 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800357 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400358 else
Ying Wang6ef65192014-01-15 16:02:16 -0800359 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400360 endif
Ying Wang57d90602015-07-20 18:40:18 -0700361 my_cc := $(my_cc_wrapper) $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800362endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800363ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800364 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800365else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800366ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800367 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800368endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800369endif
Ying Wang6ef65192014-01-15 16:02:16 -0800370$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800371
Ying Wang6ef65192014-01-15 16:02:16 -0800372ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700373 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800374 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400375 else
Ying Wang6ef65192014-01-15 16:02:16 -0800376 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400377 endif
Ying Wang57d90602015-07-20 18:40:18 -0700378 my_cxx := $(my_cxx_wrapper) $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800379endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800380ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800381 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh906cb782013-09-10 17:37:14 +0800382else
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800383ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800384 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800385endif
Andrew Hsieh906cb782013-09-10 17:37:14 +0800386endif
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700387$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
Ying Wang6ef65192014-01-15 16:02:16 -0800388$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700389$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800390
391# TODO: support a mix of standard extensions so that this isn't necessary
392LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
393ifeq ($(LOCAL_CPP_EXTENSION),)
394 LOCAL_CPP_EXTENSION := .cpp
395endif
396$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
397
398# Certain modules like libdl have to have symbols resolved at runtime and blow
399# up if --no-undefined is passed to the linker.
400ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
Dan Albertb58fb4a2014-11-14 17:15:00 -0800401ifeq ($(my_allow_undefined_symbols),)
Ying Wang6ef65192014-01-15 16:02:16 -0800402 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800403endif
404endif
405
Ying Wangfcdabd42011-04-25 14:22:41 -0700406ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
407$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
408else
409$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
410endif
411
The Android Open Source Project88b60792009-03-03 19:28:42 -0800412###########################################################
413## Define arm-vs-thumb-mode flags.
414###########################################################
415LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Colin Cross6e087a32014-01-22 17:36:05 -0800416ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800417arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
418normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
419
Dave Bort95282482009-04-23 18:44:55 -0700420# Read the values from something like TARGET_arm_CFLAGS or
421# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
422# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800423arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
424normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700425ifeq ($(my_clang),true)
Ying Wang1f982832014-02-06 18:08:44 -0800426arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
427normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400428endif
429
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800430else
431arm_objects_mode :=
432normal_objects_mode :=
433arm_objects_cflags :=
434normal_objects_cflags :=
435endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800436
437###########################################################
438## Define per-module debugging flags. Users can turn on
439## debugging for a particular module by setting DEBUG_MODULE_ModuleName
440## to a non-empty value in their environment or buildspec.mk,
441## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
442## debug flags that they want to use.
443###########################################################
444ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
445 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
446else
447 debug_cflags :=
448endif
449
Tim Murraya7aa8002012-10-29 16:06:00 -0700450####################################################
451## Compile RenderScript with reflected C++
452####################################################
453
Ying Wangb8e01852014-01-23 15:09:04 -0800454renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700455
456ifneq (,$(renderscript_sources))
457
458renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
459RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
460renderscript_intermediate := $(intermediates)/renderscript
461
Noah Presler4796a8c2015-08-13 17:04:10 -0700462renderscript_target_api :=
463
464ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
465renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
466else
467ifneq (,$(LOCAL_SDK_VERSION))
468# Set target-api for LOCAL_SDK_VERSIONs other than current.
469ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION)))
470renderscript_target_api := $(LOCAL_SDK_VERSION)
471endif
472endif # LOCAL_SDK_VERSION is set
473endif # LOCAL_RENDERSCRIPT_TARGET_API is set
474
475
Tim Murraya7aa8002012-10-29 16:06:00 -0700476ifeq ($(LOCAL_RENDERSCRIPT_CC),)
477LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
478endif
479
480# Turn on all warnings and warnings as errors for RS compiles.
481# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
482renderscript_flags := -Wall -Werror
483renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700484# -m32 or -m64
485renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700486
Ying Wang6ef65192014-01-15 16:02:16 -0800487renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700488 $(TOPDIR)external/clang/lib/Headers \
489 $(TOPDIR)frameworks/rs/scriptc \
490 $(LOCAL_RENDERSCRIPT_INCLUDES)
491
492ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800493renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700494endif
495
Ying Wangb9319562015-04-03 16:15:28 -0700496bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
497 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
498
Ying Wang6ef65192014-01-15 16:02:16 -0800499$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700500$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
501$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
502$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
503$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
Noah Presler4796a8c2015-08-13 17:04:10 -0700504$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api)
Ying Wangb9319562015-04-03 16:15:28 -0700505$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
Tim Murraya7aa8002012-10-29 16:06:00 -0700506$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
507 $(transform-renderscripts-to-cpp-and-bc)
508
Ying Wangb9319562015-04-03 16:15:28 -0700509# include the dependency files (.d/.P) generated by llvm-rs-cc.
510-include $(bc_dep_files:%.d=%.P)
Tim Murraya7aa8002012-10-29 16:06:00 -0700511
512LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
513
514rs_generated_cpps := $(addprefix \
515 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
516 $(notdir $(renderscript_sources)))))
517
Stephen Hines8ff92522014-06-06 12:51:47 -0700518# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700519$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700520 @echo "Updated RS generated cpp file $@."
Tim Murraya7aa8002012-10-29 16:06:00 -0700521
Ying Wang6ef65192014-01-15 16:02:16 -0800522my_c_includes += $(renderscript_intermediate)
523my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700524
525endif
526
527
The Android Open Source Project88b60792009-03-03 19:28:42 -0800528###########################################################
529## Stuff source generated from one-off tools
530###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800531$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532
Colin Crossd8262642014-01-24 23:17:21 -0800533my_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 -0800534
Colin Crossd8262642014-01-24 23:17:21 -0800535$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
536 @echo "Copy: $@"
537 $(copy-file-to-target)
538
539my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
540
541ALL_GENERATED_SOURCES += $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542
543###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700544## Compile the .proto files to .cc and then to .o
545###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800546proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700547proto_generated_objects :=
548proto_generated_headers :=
549ifneq ($(proto_sources),)
550proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangead89442014-02-25 11:18:40 -0800551proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
Ying Wanga5fc87a2010-11-02 18:43:16 -0700552proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700553 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
Ying Wangead89442014-02-25 11:18:40 -0800554proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
555proto_generated_obj_dir := $(intermediates)/proto
556proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
557 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700558
Ying Wang49085952014-05-06 13:03:32 -0700559# Auto-export the generated proto source dir.
560LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir)
561
Ying Wangead89442014-02-25 11:18:40 -0800562# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
563ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
Ying Wanga5fc87a2010-11-02 18:43:16 -0700564$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
565$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700566$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700567$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
568 $(transform-proto-to-cc)
569
Stephen Hines8ff92522014-06-06 12:51:47 -0700570# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Ying Wanga5fc87a2010-11-02 18:43:16 -0700571$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
Ying Wang81ab8332014-05-28 16:17:09 -0700572 @echo "Updated header file $@."
Ying Wanga5fc87a2010-11-02 18:43:16 -0700573
Ying Wangead89442014-02-25 11:18:40 -0800574$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
575endif # transform-proto-to-cc rule included only once
576
Ying Wang022a7b32012-06-13 11:38:10 -0700577$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
578$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wangead89442014-02-25 11:18:40 -0800579$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700580 $(transform-$(PRIVATE_HOST)cpp-to-o)
581-include $(proto_generated_objects:%.o=%.P)
582
Ying Wang6ef65192014-01-15 16:02:16 -0800583my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
584my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wanga5fc87a2010-11-02 18:43:16 -0700585ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Dan Albertc3031c72014-11-11 10:42:17 -0800586 ifdef LOCAL_SDK_VERSION
587 my_static_libraries += libprotobuf-cpp-full
588 else
589 my_shared_libraries += libprotobuf-cpp-full
590 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700591else
Dan Albertc3031c72014-11-11 10:42:17 -0800592 ifdef LOCAL_SDK_VERSION
593 my_static_libraries += libprotobuf-cpp-lite
594 else
595 my_shared_libraries += libprotobuf-cpp-lite
596 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700597endif
Ying Wangead89442014-02-25 11:18:40 -0800598endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700599
600
601###########################################################
Christopher Wileybc2be462015-07-29 17:14:24 -0700602## Compile the .dbus.xml files to c++ headers
603###########################################################
604dbus_if_sources := $(filter %.dbus.xml,$(my_src_files))
605ifneq ($(dbus_if_sources),)
606
607dbus_if_sources_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_if_sources))
608dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files))
609dbus_service_config_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
610
Gilad Arnold54e92d02015-08-06 12:50:23 -0700611dbus_header_prefix := $(generated_sources_dir)/dbus_bindings
Christopher Wileybc2be462015-07-29 17:14:24 -0700612dbus_adaptors_header := $(dbus_header_prefix)/adaptors.h
613dbus_proxies_header := $(dbus_header_prefix)/proxies.h
614dbus_method_names_header := $(dbus_header_prefix)/method_names.h
615
616dbus_generated_source_dependencies := \
617 $(dbus_if_sources_full_path) \
618 $(dbus_service_config_full_path) \
619 $(DBUS_GENERATOR)
620
621# Ensure that we only define build rules once in multilib builds.
622ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
623$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true
624$(dbus_adaptors_header) : PRIVATE_DBUS_MODULE := $(LOCAL_MODULE)
625$(dbus_adaptors_header) : PRIVATE_DBUS_HEADER_DIRECTORY := $(dbus_header_prefix)
626$(dbus_adaptors_header) : PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_full_path)
627$(dbus_adaptors_header) : PRIVATE_DBUS_ADAPTORS_HEADER := $(dbus_adaptors_header)
628$(dbus_adaptors_header) : PRIVATE_DBUS_PROXIES_HEADER := $(dbus_proxies_header)
629$(dbus_adaptors_header) : PRIVATE_DBUS_METHOD_NAMES_HEADER := $(dbus_method_names_header)
630$(dbus_adaptors_header) : PRIVATE_DBUS_INTERFACE_DEFINITIONS := $(dbus_if_sources_full_path)
631$(dbus_adaptors_header) : $(dbus_generated_source_dependencies)
632 $(generate-dbus-bindings)
633# These are actually generated by the above recipe, but we'd like to make the
634# dependency chain complete.
635$(dbus_proxies_header) : $(dbus_adaptors_header)
636$(dbus_method_names_header) : $(dbus_adaptors_header)
637endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
638
639my_generated_sources += \
640 $(dbus_adaptors_header) \
641 $(dbus_proxies_header) \
642 $(dbus_method_names_header)
643endif # $(dbus_if_sources) non-empty
644
645
646###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000647## YACC: Compile .y and .yy files to .cpp and the to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800648###########################################################
649
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000650y_yacc_sources := $(filter %.y,$(my_src_files))
651y_yacc_cpps := $(addprefix \
652 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
653
654yy_yacc_sources := $(filter %.yy,$(my_src_files))
655yy_yacc_cpps := $(addprefix \
656 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
657
658yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800659yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
660yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
661
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000662ifneq ($(strip $(y_yacc_cpps)),)
663$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700664 $(TOPDIR)$(LOCAL_PATH)/%.y \
Dan Albert954b5bd2014-11-08 22:20:03 -0800665 $(lex_cpps) $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800666 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
667$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000668endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800669
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000670ifneq ($(strip $(yy_yacc_cpps)),)
671$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
672 $(TOPDIR)$(LOCAL_PATH)/%.yy \
Dan Albert954b5bd2014-11-08 22:20:03 -0800673 $(lex_cpps) $(my_additional_dependencies)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000674 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
675$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
676endif
677
678ifneq ($(strip $(yacc_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800679$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
680$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
681$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
682 $(transform-$(PRIVATE_HOST)cpp-to-o)
683endif
684
685###########################################################
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000686## LEX: Compile .l and .ll files to .cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800687###########################################################
688
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000689l_lex_sources := $(filter %.l,$(my_src_files))
690l_lex_cpps := $(addprefix \
691 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
692
693ll_lex_sources := $(filter %.ll,$(my_src_files))
694ll_lex_cpps := $(addprefix \
695 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
696
697lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800698lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
699
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000700ifneq ($(strip $(l_lex_cpps)),)
701$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700702 $(TOPDIR)$(LOCAL_PATH)/%.l
The Android Open Source Project88b60792009-03-03 19:28:42 -0800703 $(transform-l-to-cpp)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000704endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800705
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000706ifneq ($(strip $(ll_lex_cpps)),)
707$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
708 $(TOPDIR)$(LOCAL_PATH)/%.ll
709 $(transform-l-to-cpp)
710endif
711
712ifneq ($(strip $(lex_cpps)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800713$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
714$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
715$(lex_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700716 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800717 $(my_additional_dependencies) \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700718 $(yacc_headers)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800719 $(transform-$(PRIVATE_HOST)cpp-to-o)
720endif
721
722###########################################################
723## C++: Compile .cpp files to .o.
724###########################################################
725
Jeff Browne33ba4c2011-07-11 22:11:46 -0700726# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727# it's not really arm, because there are files that are shared.
Ying Wangfb22a422015-03-10 18:03:11 -0700728cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
729dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources))
730cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources))
731cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800732
Ying Wangfb22a422015-03-10 18:03:11 -0700733# For source files starting with ../, we remove all the ../ in the object file path,
734# to avoid object file escaping the intermediate directory.
735dotdot_arm_objects :=
736$(foreach s,$(dotdot_arm_sources),\
737 $(eval $(call compile-dotdot-cpp-file,$(s),\
738 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
739 dotdot_arm_objects)))
740
741dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
742dotdot_objects :=
743$(foreach s,$(dotdot_sources),\
744 $(eval $(call compile-dotdot-cpp-file,$(s),\
745 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
746 dotdot_objects)))
747
748cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800749cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
750
Ying Wangfb22a422015-03-10 18:03:11 -0700751$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
752$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
753$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
754$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800755
756cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
757
758ifneq ($(strip $(cpp_objects)),)
759$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700760 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800761 $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800762 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763 $(transform-$(PRIVATE_HOST)cpp-to-o)
764-include $(cpp_objects:%.o=%.P)
765endif
766
Ying Wangfb22a422015-03-10 18:03:11 -0700767cpp_objects += $(dotdot_arm_objects) $(dotdot_objects)
768
The Android Open Source Project88b60792009-03-03 19:28:42 -0800769###########################################################
770## C++: Compile generated .cpp files to .o.
771###########################################################
772
Ying Wangec6d6262014-01-16 16:21:03 -0800773gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
775
776ifneq ($(strip $(gen_cpp_objects)),)
777# Compile all generated files as thumb.
778# TODO: support compiling certain generated files as arm.
779$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
780$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400781$(gen_cpp_objects): $(intermediates)/%.o: \
782 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
Ying Wang9c3aa052013-02-20 13:34:05 -0800783 $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800784 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800785 $(transform-$(PRIVATE_HOST)cpp-to-o)
786-include $(gen_cpp_objects:%.o=%.P)
787endif
788
789###########################################################
790## S: Compile generated .S and .s files to .o.
791###########################################################
792
Ying Wangec6d6262014-01-16 16:21:03 -0800793gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800794gen_S_objects := $(gen_S_sources:%.S=%.o)
795
796ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400797$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -0800798 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800799 $(transform-$(PRIVATE_HOST)s-to-o)
800-include $(gen_S_objects:%.o=%.P)
801endif
802
Ying Wangec6d6262014-01-16 16:21:03 -0800803gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800804gen_s_objects := $(gen_s_sources:%.s=%.o)
805
806ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400807$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -0800808 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800809 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
810-include $(gen_s_objects:%.o=%.P)
811endif
812
813gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
814
815###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000816## o: Include generated .o files in output.
817###########################################################
818
Ying Wangec6d6262014-01-16 16:21:03 -0800819gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000820
821###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800822## C: Compile .c files to .o.
823###########################################################
824
Ying Wangfb22a422015-03-10 18:03:11 -0700825c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
826dotdot_arm_sources := $(filter ../%,$(c_arm_sources))
827c_arm_sources := $(filter-out ../%,$(c_arm_sources))
828c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800829
Ying Wangfb22a422015-03-10 18:03:11 -0700830# For source files starting with ../, we remove all the ../ in the object file path,
831# to avoid object file escaping the intermediate directory.
832dotdot_arm_objects :=
833$(foreach s,$(dotdot_arm_sources),\
834 $(eval $(call compile-dotdot-c-file,$(s),\
835 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
836 dotdot_arm_objects)))
837
838dotdot_sources := $(filter ../%.c, $(my_src_files))
839dotdot_objects :=
840$(foreach s, $(dotdot_sources),\
841 $(eval $(call compile-dotdot-c-file,$(s),\
842 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
843 dotdot_objects)))
844
845c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
847
Ying Wangfb22a422015-03-10 18:03:11 -0700848$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
849$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
850$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
851$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800852
853c_objects := $(c_arm_objects) $(c_normal_objects)
854
855ifneq ($(strip $(c_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400856$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800857 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800858 $(transform-$(PRIVATE_HOST)c-to-o)
859-include $(c_objects:%.o=%.P)
860endif
861
Ying Wangfb22a422015-03-10 18:03:11 -0700862c_objects += $(dotdot_arm_objects) $(dotdot_objects)
863
The Android Open Source Project88b60792009-03-03 19:28:42 -0800864###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700865## C: Compile generated .c files to .o.
866###########################################################
867
Ying Wangec6d6262014-01-16 16:21:03 -0800868gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700869gen_c_objects := $(gen_c_sources:%.c=%.o)
870
871ifneq ($(strip $(gen_c_objects)),)
872# Compile all generated files as thumb.
873# TODO: support compiling certain generated files as arm.
874$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
875$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400876$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800877 $(my_additional_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700878 $(transform-$(PRIVATE_HOST)c-to-o)
879-include $(gen_c_objects:%.o=%.P)
880endif
881
882###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200883## ObjC: Compile .m files to .o
884###########################################################
885
Ying Wangb8e01852014-01-23 15:09:04 -0800886objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200887objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
888
889ifneq ($(strip $(objc_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400890$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
Dan Albert954b5bd2014-11-08 22:20:03 -0800891 $(my_additional_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200892 $(transform-$(PRIVATE_HOST)m-to-o)
893-include $(objc_objects:%.o=%.P)
894endif
895
896###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800897## AS: Compile .S files to .o.
898###########################################################
899
Ying Wangb8e01852014-01-23 15:09:04 -0800900asm_sources_S := $(filter %.S,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -0700901dotdot_sources := $(filter ../%,$(asm_sources_S))
902asm_sources_S := $(filter-out ../%,$(asm_sources_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800903asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
904
Ying Wangfb22a422015-03-10 18:03:11 -0700905dotdot_objects_S :=
906$(foreach s,$(dotdot_sources),\
907 $(eval $(call compile-dotdot-s-file,$(s),\
908 $(my_additional_dependencies),\
909 dotdot_objects_S)))
910
The Android Open Source Project88b60792009-03-03 19:28:42 -0800911ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400912$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -0800913 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914 $(transform-$(PRIVATE_HOST)s-to-o)
915-include $(asm_objects_S:%.o=%.P)
916endif
917
Ying Wangb8e01852014-01-23 15:09:04 -0800918asm_sources_s := $(filter %.s,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -0700919dotdot_sources := $(filter ../%,$(asm_sources_s))
920asm_sources_s := $(filter-out ../%,$(asm_sources_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
922
Ying Wangfb22a422015-03-10 18:03:11 -0700923dotdot_objects_s :=
924$(foreach s,$(dotdot_sources),\
925 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
926 $(my_additional_dependencies),\
927 dotdot_objects_s)))
928
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400930$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -0800931 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800933endif
934
Ying Wangfb22a422015-03-10 18:03:11 -0700935asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800936
937
Ying Wangfe1e5c32015-03-09 18:57:40 -0700938# .asm for x86/x86_64 needs to be compiled with yasm.
Ying Wang7b913ce2014-06-05 19:05:47 -0700939asm_sources_asm := $(filter %.asm,$(my_src_files))
940ifneq ($(strip $(asm_sources_asm)),)
941asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
942$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
Dan Albert954b5bd2014-11-08 22:20:03 -0800943 $(my_additional_dependencies)
Ying Wang7b913ce2014-06-05 19:05:47 -0700944 $(transform-asm-to-o)
945
946asm_objects += $(asm_objects_asm)
947endif
Ying Wang7b913ce2014-06-05 19:05:47 -0700948
Jeff Davidson680f0712015-01-08 18:25:30 -0800949
950##########################################################
951## Set up installed module dependency
952## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
953## they may cusomize their install path with LOCAL_MODULE_PATH
954##########################################################
955# Get the list of INSTALLED libraries as module names.
956ifdef LOCAL_SDK_VERSION
957 installed_shared_library_module_names := \
958 $(my_shared_libraries)
959else
960 installed_shared_library_module_names := \
961 $(my_shared_libraries) $(my_system_shared_libraries)
962endif
963
964# The real dependency will be added after all Android.mks are loaded and the install paths
965# of the shared libraries are determined.
966ifdef LOCAL_INSTALLED_MODULE
967ifdef installed_shared_library_module_names
968$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
969 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names)))
970endif
971endif
972
973
Ying Wang5f074802011-11-08 09:31:21 -0800974####################################################
975## Import includes
976####################################################
977import_includes := $(intermediates)/import_includes
978import_includes_deps := $(strip \
979 $(foreach l, $(installed_shared_library_module_names), \
Ying Wang6ef65192014-01-15 16:02:16 -0800980 $(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 -0800981 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Ying Wang6ef65192014-01-15 16:02:16 -0800982 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
Ying Wang14d02a32015-01-22 15:44:04 -0800983$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
984$(import_includes) : $(LOCAL_MODULE_MAKEFILE) $(import_includes_deps)
Ying Wang5f074802011-11-08 09:31:21 -0800985 @echo Import includes file: $@
986 $(hide) mkdir -p $(dir $@) && rm -f $@
987ifdef import_includes_deps
Ying Wang14d02a32015-01-22 15:44:04 -0800988 $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \
Ying Wang5f074802011-11-08 09:31:21 -0800989 cat $$f >> $@; \
990 done
991else
992 $(hide) touch $@
993endif
994
The Android Open Source Project88b60792009-03-03 19:28:42 -0800995###########################################################
996## Common object handling.
997###########################################################
998
999# some rules depend on asm_objects being first. If your code depends on
1000# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001001normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001002 $(asm_objects) \
1003 $(cpp_objects) \
1004 $(gen_cpp_objects) \
1005 $(gen_asm_objects) \
1006 $(c_objects) \
1007 $(gen_c_objects) \
1008 $(objc_objects) \
1009 $(yacc_objects) \
1010 $(lex_objects) \
1011 $(proto_generated_objects) \
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001012 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
1013
1014all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015
Colin Cross2d206702014-02-13 13:41:52 -08001016my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001017
Ying Wang848020f2012-08-14 10:13:16 -07001018ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -08001019 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -07001020endif
1021
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001022# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
1023# use normal_objects here to avoid creating circular dependencies. This assumes
1024# that custom build rules which generate .o files don't consume other generated
1025# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -08001026$(normal_objects) : | $(my_generated_sources)
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001027$(all_objects) : | $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001028ALL_C_CPP_ETC_OBJECTS += $(all_objects)
1029
The Android Open Source Project88b60792009-03-03 19:28:42 -08001030
1031###########################################################
1032# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001033###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001034
1035###########################################################
1036# The list of libraries that this module will link against are in
1037# these variables. Each is a list of bare module names like "libc libm".
1038#
1039# LOCAL_SHARED_LIBRARIES
1040# LOCAL_STATIC_LIBRARIES
1041# LOCAL_WHOLE_STATIC_LIBRARIES
1042#
1043# We need to convert the bare names into the dependencies that
1044# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
1045# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
1046# libraries, so that simply building this module doesn't force
1047# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
1048# should depend on the INSTALLED versions of the libraries so
1049# that they get installed when this module does.
1050###########################################################
1051# NOTE:
1052# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
1053# module without leaving anything out, which is useful for turning
1054# a collection of .a files into a .so file. Linking against a
1055# normal STATIC_LIBRARY will only pull in code/symbols that are
1056# referenced by the module. (see gcc/ld's --whole-archive option)
1057###########################################################
1058
1059# Get the list of BUILT libraries, which are under
1060# various intermediates directories.
1061so_suffix := $($(my_prefix)SHLIB_SUFFIX)
1062a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
1063
Ying Wang848020f2012-08-14 10:13:16 -07001064ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -08001065built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001066 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001067 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -08001068 $(my_shared_libraries)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001069
Ying Wangd8d37212014-03-21 16:17:04 -07001070# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -08001071my_system_shared_libraries_fullpath := \
1072 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -07001073 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -07001074 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -07001075
1076built_shared_libraries += $(my_system_shared_libraries_fullpath)
Ying Wang1a081002010-07-13 14:55:47 -07001077else
Ying Wang1a081002010-07-13 14:55:47 -07001078built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001079 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -07001080 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -07001081 $(installed_shared_library_module_names)))
Ying Wang1a081002010-07-13 14:55:47 -07001082endif
1083
The Android Open Source Project88b60792009-03-03 19:28:42 -08001084built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001085 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001086 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -08001087 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 -08001088
Ying Wang848020f2012-08-14 10:13:16 -07001089ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -08001090built_static_libraries += $(my_ndk_stl_static_lib)
1091endif
1092
The Android Open Source Project88b60792009-03-03 19:28:42 -08001093built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -08001094 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001095 $(call intermediates-dir-for, \
Ying Wang6ef65192014-01-15 16:02:16 -08001096 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 -08001097
The Android Open Source Project88b60792009-03-03 19:28:42 -08001098# We don't care about installed static libraries, since the
1099# libraries have already been linked into the module at that point.
1100# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +00001101# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001102
1103installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -08001104 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001105 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
1106
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001107# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001108ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1109LOCAL_RTTI_FLAG := -fno-rtti
1110endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001111
The Android Open Source Project88b60792009-03-03 19:28:42 -08001112###########################################################
1113# Rule-specific variable definitions
1114###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001115
Ying Wang824344a2014-05-27 13:03:36 -07001116ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001117my_cflags += $(LOCAL_CLANG_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -08001118my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
Dan Albertd2fa96d2014-11-28 14:00:12 -08001119my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -07001120my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
1121my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001122my_asflags += $(LOCAL_CLANG_ASFLAGS)
1123my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001124my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
Stephen Hines15680292014-11-26 00:53:46 -08001125my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix))
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001126my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
1127my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
1128my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
Ying Wang1f982832014-02-06 18:08:44 -08001129my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
1130my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
1131my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
1132my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +08001133endif
1134
Ying Wangd7914632014-10-28 14:50:59 -07001135ifeq ($(my_fdo_build), true)
1136 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
1137 fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
1138 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
Dehao Chen295a6d22014-09-19 10:18:12 -07001139endif
1140
Dan Albertdf3fd1d2015-08-12 14:54:16 -07001141# No one should ever use this flag. On GCC it's mere presence will disable all
1142# warnings, even those that are specified after it (contrary to typical warning
1143# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
1144# warnings that are *always* bugs.
1145my_illegal_flags := -w
1146my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
1147my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
1148my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
1149
The Android Open Source Project88b60792009-03-03 19:28:42 -08001150$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001151$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Stephen Hines15680292014-11-26 00:53:46 -08001152$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001153$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1154$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Dan Albertd1600412015-06-10 16:33:43 -07001155$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1156$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001157$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001158$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001159$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -08001160$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001161$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001162$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001163
1164# this is really the way to get the files onto the command line instead
1165# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1166$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1167$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1168$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
1169$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
1170
1171###########################################################
1172# Define library dependencies.
1173###########################################################
1174# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1175all_libraries := \
1176 $(built_shared_libraries) \
1177 $(built_static_libraries) \
1178 $(built_whole_libraries)
1179
The Android Open Source Project88b60792009-03-03 19:28:42 -08001180# Also depend on the notice files for any static libraries that
1181# are linked into this module. This will force them to be installed
1182# when this module is.
1183$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001184
1185###########################################################
1186# Export includes
1187###########################################################
1188export_includes := $(intermediates)/export_includes
1189$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Ying Wang49085952014-05-06 13:03:32 -07001190# Make sure .pb.h are already generated before any dependent source files get compiled.
1191$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
Ying Wang5f074802011-11-08 09:31:21 -08001192 @echo Export includes file: $< -- $@
1193 $(hide) mkdir -p $(dir $@) && rm -f $@
1194ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
1195 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
1196 echo "-I $$d" >> $@; \
1197 done
1198else
1199 $(hide) touch $@
1200endif
Ying Wang616e5962012-04-18 17:35:55 -07001201
1202# Make sure export_includes gets generated when you are running mm/mmm
1203$(LOCAL_BUILT_MODULE) : | $(export_includes)