blob: 8467876b10ee816f049586cd426c809060eb6cfa [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
Dan Willemsenfc92fb22016-08-26 13:27:13 -070033my_soong_problems :=
34
Dan Albertd3d894d2014-11-14 15:28:49 -080035# The following LOCAL_ variables will be modified in this file.
36# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
37# we can't modify them in place.
38my_src_files := $(LOCAL_SRC_FILES)
Colin Crossa04abc82015-06-30 12:21:59 -070039my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080040my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
41my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
42my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
43my_cflags := $(LOCAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -080044my_conlyflags := $(LOCAL_CONLYFLAGS)
Dan Albertd3d894d2014-11-14 15:28:49 -080045my_cppflags := $(LOCAL_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -070046my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE)
47my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080048my_ldflags := $(LOCAL_LDFLAGS)
49my_ldlibs := $(LOCAL_LDLIBS)
50my_asflags := $(LOCAL_ASFLAGS)
51my_cc := $(LOCAL_CC)
Ying Wangc671a7c2015-07-20 18:40:18 -070052my_cc_wrapper := $(CC_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080053my_cxx := $(LOCAL_CXX)
Ying Wangc671a7c2015-07-20 18:40:18 -070054my_cxx_wrapper := $(CXX_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080055my_c_includes := $(LOCAL_C_INCLUDES)
56my_generated_sources := $(LOCAL_GENERATED_SOURCES)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -080057my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
Ying Wangfaeb6932015-04-07 11:59:34 -070058my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Willemsenba6a1642016-09-29 12:08:29 -070059my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
Dan Albertd3d894d2014-11-14 15:28:49 -080060
Ryan Campbell20f301f2016-10-18 10:25:15 -070061ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
Ryan Campbell81c9d292016-09-12 13:56:50 -070062 my_native_coverage := true
63else
64 my_native_coverage := false
65endif
66
Dan Albertb58fb4a2014-11-14 17:15:00 -080067ifdef LOCAL_IS_HOST_MODULE
68my_allow_undefined_symbols := true
69else
70my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
71endif
72
Andrew Hsieh140761af02014-04-25 23:47:10 -070073my_ndk_sysroot :=
74my_ndk_sysroot_include :=
75my_ndk_sysroot_lib :=
Ying Wang848020f2012-08-14 10:13:16 -070076ifdef LOCAL_SDK_VERSION
Ying Wang1a081002010-07-13 14:55:47 -070077 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -070078 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -070079 endif
Nikola Veljkovicf7385622016-04-06 19:20:02 +020080
Dan Albert02bf1382016-07-21 10:04:12 -070081 # Make sure we've built the NDK.
Colin Cross723b37e2016-07-29 15:09:03 -070082 my_additional_dependencies += $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert02bf1382016-07-21 10:04:12 -070083
Nikola Veljkovicf7385622016-04-06 19:20:02 +020084 # mips32r6 is not supported by the NDK. No released NDK contains these
85 # libraries, but the r10 in prebuilts/ndk had a local hack to add them :(
86 #
87 # We need to find a real solution to this problem, but until we do just drop
88 # mips32r6 things back to r10 to get the tree building again.
89 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
90 ifeq ($(LOCAL_NDK_VERSION), current)
91 LOCAL_NDK_VERSION := r10
92 endif
93 endif
94
Dan Albert02bf1382016-07-21 10:04:12 -070095 my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
96 ifneq (,$(filter arm64 mips64 x86_64,$(my_arch)))
97 my_min_sdk_version := 21
98 else
99 my_min_sdk_version := 9
100 endif
101
102 # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
103 # missing API levels to existing ones where necessary, but we're not doing
104 # that for the generated libraries. Clip the API level to the minimum where
105 # appropriate.
Dan Willemsenb0118102016-09-30 17:30:32 -0700106 my_ndk_api := $(call math_max,$(LOCAL_SDK_VERSION),$(my_min_sdk_version))
Dan Albert02bf1382016-07-21 10:04:12 -0700107
Dan Albert754790d2016-08-05 16:34:40 -0700108 # Traditionally this has come from android/api-level.h, but with the libc
109 # headers unified it must be set by the build system since we don't have
110 # per-API level copies of that header now.
111 my_cflags += -D__ANDROID_API__=$(my_ndk_api)
112
Dan Albert02bf1382016-07-21 10:04:12 -0700113 my_ndk_source_root := \
114 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources
115 my_ndk_sysroot := \
116 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_api)/arch-$(my_arch)
117 my_built_ndk := $(SOONG_OUT_DIR)/ndk
118 my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE)
119 my_ndk_sysroot_include := \
120 $(my_built_ndk)/sysroot/usr/include \
121 $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \
122 $(my_ndk_sysroot)/usr/include \
Dan Albert445bc2f2015-12-11 12:49:18 -0800123
124 # x86_64 and and mips64 are both multilib toolchains, so their libraries are
125 # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib
126 # compiler, so its libraries are in /usr/lib.
127 #
128 # Mips32r6 is yet another variation, with libraries installed in libr6.
129 #
130 # For the rest, the libraries are installed simply to /usr/lib.
Dan Albert02bf1382016-07-21 10:04:12 -0700131 ifneq (,$(filter x86_64 mips64,$(my_arch)))
132 my_ndk_libdir_name := lib64
Duane Sand1a074872014-11-08 15:25:18 -0800133 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
Dan Albert02bf1382016-07-21 10:04:12 -0700134 my_ndk_libdir_name := libr6
Andrew Hsieh140761af02014-04-25 23:47:10 -0700135 else
Dan Albert02bf1382016-07-21 10:04:12 -0700136 my_ndk_libdir_name := lib
Andrew Hsieh140761af02014-04-25 23:47:10 -0700137 endif
Ying Wangcce4c972011-03-03 18:53:53 -0800138
Dan Albert02bf1382016-07-21 10:04:12 -0700139 my_ndk_platform_dir := \
140 $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch)
141 my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name)
142 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name)
143
Dmitriy Ivanov3b51f202015-04-23 18:48:52 -0700144 # The bionic linker now has support for packed relocations and gnu style
145 # hashes (which are much faster!), but shipping to older devices requires
Dan Albertee629c92015-12-09 14:52:25 -0800146 # the old style hash. Fortunately, we can build with both and it'll work
147 # anywhere.
Dan Albert8dca15f2015-12-09 16:26:20 -0800148 #
149 # This is not currently supported on MIPS architectures.
150 ifeq (,$(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
151 my_ldflags += -Wl,--hash-style=both
152 endif
Dan Albertee629c92015-12-09 14:52:25 -0800153
154 # We don't want to expose the relocation packer to the NDK just yet.
155 LOCAL_PACK_MODULE_RELOCATIONS := false
Dan Albertd3d894d2014-11-14 15:28:49 -0800156
Ying Wangcce4c972011-03-03 18:53:53 -0800157 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
158 # See ndk/docs/CPLUSPLUS-SUPPORT.html
159 my_ndk_stl_include_path :=
160 my_ndk_stl_shared_lib_fullpath :=
Ying Wangcce4c972011-03-03 18:53:53 -0800161 my_ndk_stl_static_lib :=
Colin Crosse56e3562016-10-17 15:34:29 -0700162 my_ndk_cpp_std_version :=
Duane Sand1a074872014-11-08 15:25:18 -0800163 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
Nikola Veljkovicf7385622016-04-06 19:20:02 +0200164 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
165 my_cpu_variant := mips32r6
166 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800167 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800168 ifeq (,$(LOCAL_NDK_STL_VARIANT))
169 LOCAL_NDK_STL_VARIANT := system
170 endif
Dan Albert0e2e71d2015-12-09 14:46:13 -0800171 ifneq (1,$(words $(filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -0700172 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800173 endif
174 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
175 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
Dan Albert0e2e71d2015-12-09 14:46:13 -0800176 my_system_shared_libraries += libstdc++
Ying Wangcce4c972011-03-03 18:53:53 -0800177 else # LOCAL_NDK_STL_VARIANT is not system
178 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
179 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
Dan Albert0e2e71d2015-12-09 14:46:13 -0800180 my_system_shared_libraries += libstdc++
Ying Wangcce4c972011-03-03 18:53:53 -0800181 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
Duane Sand1a074872014-11-08 15:25:18 -0800182 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a
Dan Alberta81e1b72016-03-10 15:17:09 -0800183 my_ldlibs += -ldl
Ying Wangcce4c972011-03-03 18:53:53 -0800184 else
Duane Sand1a074872014-11-08 15:25:18 -0800185 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 -0800186 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800187 else # LOCAL_NDK_STL_VARIANT is not stlport_* either
188 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
Dan Albert658d1e02016-03-22 17:17:40 -0700189 # Pre-r11 NDKs used libgabi++ for libc++'s C++ ABI, but r11 and later use
190 # libc++abi.
Dan Albert09607702016-08-08 17:14:59 -0700191 #
192 # r13 no longer has the inner directory as a side effect of just using
193 # external/libcxx.
194 ifeq (r10,$(LOCAL_NDK_VERSION))
195 my_ndk_stl_include_path := \
196 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include
Dan Albert658d1e02016-03-22 17:17:40 -0700197 my_ndk_stl_include_path += \
198 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include
Dan Albert09607702016-08-08 17:14:59 -0700199 else ifeq (r11,$(LOCAL_NDK_VERSION))
200 my_ndk_stl_include_path := \
201 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include
Dan Albert658d1e02016-03-22 17:17:40 -0700202 my_ndk_stl_include_path += \
203 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/libcxxabi/include
Dan Albert09607702016-08-08 17:14:59 -0700204 else
205 my_ndk_stl_include_path := \
206 $(my_ndk_source_root)/cxx-stl/llvm-libc++/include
207 my_ndk_stl_include_path += \
208 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include
209 endif
210 my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include
211
212 my_libcxx_libdir := \
213 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)
214
215 ifneq (,$(filter r10 r11,$(LOCAL_NDK_VERSION)))
216 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
217 my_ndk_stl_static_lib := $(my_libcxx_libdir)/libc++_static.a
Dan Albert09607702016-08-08 17:14:59 -0700218 else
219 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
220 endif
221 else
222 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
223 my_ndk_stl_static_lib := \
224 $(my_libcxx_libdir)/libc++_static.a \
225 $(my_libcxx_libdir)/libc++abi.a
Dan Albert09607702016-08-08 17:14:59 -0700226 else
227 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
228 endif
229
230 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a
231 ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant)))
232 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
233 endif
Dan Albert658d1e02016-03-22 17:17:40 -0700234 endif
235
Dan Albert2936a1e2016-09-14 16:08:04 -0700236 my_ldlibs += -ldl
237
Colin Crosse56e3562016-10-17 15:34:29 -0700238 my_ndk_cpp_std_version := c++11
Dan Albert0e2e71d2015-12-09 14:46:13 -0800239 else # LOCAL_NDK_STL_VARIANT is not c++_* either
240 ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT)))
Duane Sand1a074872014-11-08 15:25:18 -0800241 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 -0700242 $(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 -0800243 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
Dan Albert0e2e71d2015-12-09 14:46:13 -0800244 else # LOCAL_NDK_STL_VARIANT must be none
245 # Do nothing.
246 endif
Ying Wangcce4c972011-03-03 18:53:53 -0800247 endif
248 endif
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800249 endif
Dan Albertc1ca1902016-08-04 14:14:50 -0700250endif
Dan Albert02bf1382016-07-21 10:04:12 -0700251
Dan Albertc1ca1902016-08-04 14:14:50 -0700252ifndef LOCAL_IS_HOST_MODULE
253# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
254# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
255# linking my_shared_libraries by full path now.
256my_allowed_ldlibs :=
257
258# Sort ldlibs and ldflags between -l and other linker flags
259# We'll do this again later, since there are still changes happening, but that's fine.
260my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
261my_ldlibs := $(filter -l%,$(my_ldlib_flags))
262my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
263my_ldlib_flags :=
264
265# Move other ldlibs back to shared libraries
266my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
267my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
268endif
269
270ifdef LOCAL_SDK_VERSION
271 my_all_ndk_libraries := \
272 $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))
273 my_ndk_shared_libraries := \
274 $(filter $(my_all_ndk_libraries),\
275 $(my_shared_libraries) $(my_system_shared_libraries))
276
277 my_shared_libraries := \
278 $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries))
Dan Albert02bf1382016-07-21 10:04:12 -0700279 my_system_shared_libraries := \
Dan Albertc1ca1902016-08-04 14:14:50 -0700280 $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries))
Ying Wang1a081002010-07-13 14:55:47 -0700281endif
282
Dan Albert95994de2014-08-07 18:29:11 -0700283# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
284# all code is position independent, and then those warnings get promoted to
285# errors.
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700286ifneq ($(LOCAL_NO_PIC),true)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700287ifneq ($($(my_prefix)OS),windows)
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800288ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dan Albert4803ce22014-08-06 12:36:46 -0700289my_cflags += -fpie
290else
291my_cflags += -fPIC
292endif
Dan Albert95994de2014-08-07 18:29:11 -0700293endif
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700294endif
Dan Albert4803ce22014-08-06 12:36:46 -0700295
Dan Willemsen7a549852015-08-13 17:51:40 -0700296ifdef LOCAL_IS_HOST_MODULE
Dan Willemsen85ac8d22015-08-18 17:47:06 -0700297my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Dan Willemsen7a549852015-08-13 17:51:40 -0700298my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
299my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
300my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
301my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
302my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
303my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS))
304my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS))
305my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS))
306my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS))
307endif
308
Ying Wang6feb6d52014-04-17 10:03:35 -0700309my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
Colin Crossa04abc82015-06-30 12:21:59 -0700310my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix))
Ying Wang6feb6d52014-04-17 10:03:35 -0700311my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
312my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
313my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
314my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
315my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
316my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
317my_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 -0800318
Dan Willemsenc29172c2015-12-03 22:58:39 -0800319my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude))
320ifneq ($(my_missing_exclude_files),)
321$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES)
322$(error $(my_missing_exclude_files))
323endif
Colin Crossa04abc82015-06-30 12:21:59 -0700324my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files))
325
Dan Albertdb905e72014-08-18 11:14:38 -0700326my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700327ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700328my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700329endif
330ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700331my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700332endif
333
Alexey Polyudov7d6b3f12016-06-24 11:22:51 -0700334# if custom toolchain is in use, default is not to use clang, if not explicitly required
335ifneq ($(my_cc)$(my_cxx),)
336 ifeq ($(my_clang),)
337 my_clang := false
338 endif
339endif
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700340# Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found
341# in the exception project list.
342ifeq ($(my_clang),false)
343 ifeq ($(call find_in_local_clang_exception_projects,$(LOCAL_MODULE_MAKEFILE)),)
Chih-Hung Hsieh2ee4c1a2016-08-04 15:35:51 -0700344 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_CLANG is set to false)
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700345 endif
346endif
Alexey Polyudov7d6b3f12016-06-24 11:22:51 -0700347
Tim Murray92d79cb2014-04-04 14:38:29 -0700348# clang is enabled by default for host builds
349# enable it unless we've specifically disabled clang above
350ifdef LOCAL_IS_HOST_MODULE
Dan Willemsen95374772016-03-29 12:34:03 -0700351 ifeq ($($(my_prefix)OS),windows)
352 ifeq ($(my_clang),true)
353 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Clang is not yet supported for windows binaries)
354 endif
355 my_clang := false
356 else
357 ifeq ($(my_clang),)
358 my_clang := true
359 endif
Tim Murray5ca1dc12014-07-24 14:42:53 -0700360 endif
Chih-Hung Hsiehb5da9d92016-01-06 11:49:25 -0800361# Add option to make gcc the default for device build
362else ifeq ($(USE_CLANG_PLATFORM_BUILD),false)
Dan Willemsen77288172015-09-09 15:45:21 -0700363 ifeq ($(my_clang),)
Chih-Hung Hsiehb5da9d92016-01-06 11:49:25 -0800364 my_clang := false
Dan Willemsen77288172015-09-09 15:45:21 -0700365 endif
Chih-Hung Hsiehb5da9d92016-01-06 11:49:25 -0800366else ifeq ($(my_clang),)
367 my_clang := true
Dan Willemsen77288172015-09-09 15:45:21 -0700368endif
369
Colin Crosse56e3562016-10-17 15:34:29 -0700370my_c_std_version := $(DEFAULT_C_STD_VERSION)
371my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
Dan Albertda637392015-10-26 11:09:24 -0700372
373ifneq ($(my_clang),true)
374 # GCC uses an invalid C++14 ABI (emits calls to
375 # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI).
376 # http://b/25022512
Colin Crosse56e3562016-10-17 15:34:29 -0700377 my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
Dan Albertda637392015-10-26 11:09:24 -0700378endif
379
Dan Albertc7d307d2015-07-29 15:13:57 -0700380ifdef LOCAL_SDK_VERSION
381 # The NDK handles this itself.
Colin Crosse56e3562016-10-17 15:34:29 -0700382 my_cpp_std_version := $(my_ndk_cpp_std_version)
Dan Albertc7d307d2015-07-29 15:13:57 -0700383endif
384
385ifdef LOCAL_IS_HOST_MODULE
386 ifneq ($(my_clang),true)
387 # The host GCC doesn't support C++14 (and is deprecated, so likely
388 # never will). Build these modules with C++11.
Colin Crosse56e3562016-10-17 15:34:29 -0700389 my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
Dan Albertc7d307d2015-07-29 15:13:57 -0700390 endif
391endif
392
Colin Crosse56e3562016-10-17 15:34:29 -0700393my_c_std_conlyflags :=
394my_cpp_std_cppflags :=
395ifneq (,$(my_c_std_version))
396 my_c_std_conlyflags := -std=$(my_c_std_version)
397endif
Dan Albertc7d307d2015-07-29 15:13:57 -0700398
Colin Crosse56e3562016-10-17 15:34:29 -0700399ifneq (,$(my_cpp_std_version))
400 my_cpp_std_cppflags := -std=$(my_cpp_std_version)
401endif
Tim Murray06659bc2014-08-13 11:53:07 -0700402
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800403# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700404my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
405my_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 -0800406
Ying Wang75e8fcb2014-10-07 13:03:29 -0700407include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700408
Ying Wang285045b2013-08-13 12:35:10 -0700409# Add static HAL libraries
410ifdef LOCAL_HAL_STATIC_LIBRARIES
411$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
412 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
Ying Wang6ef65192014-01-15 16:02:16 -0800413 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
414 $(eval my_static_libraries += $(lib).default)))
Ying Wang285045b2013-08-13 12:35:10 -0700415b_lib :=
416endif
417
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100418ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),)
419 my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)
420else
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700421 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100422endif
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700423
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700424include $(BUILD_SYSTEM)/config_sanitizers.mk
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400425
Alexey Polyudovee27d812016-08-01 17:38:35 -0700426ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true)
Shih-wei Liaoc8dfc162013-01-27 01:45:59 -0800427# Add in libcompiler_rt for all regular device builds
Dan Albertc28e4bc2016-09-14 16:08:48 -0700428ifeq (,$(WITHOUT_LIBCOMPILER_RT))
Ying Wang6ef65192014-01-15 16:02:16 -0800429 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
Stephen Hinesc72f3962012-06-11 14:53:34 -0700430endif
Alexey Polyudovee27d812016-08-01 17:38:35 -0700431endif
Stephen Hinesc72f3962012-06-11 14:53:34 -0700432
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700433ifneq ($(filter ../%,$(my_src_files)),)
434my_soong_problems += dotdot_srcs
435endif
436ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),)
437my_soong_problems += dotdot_incs
438endif
439ifneq ($(filter %.arm,$(my_src_files)),)
440my_soong_problems += srcs_dotarm
441endif
442
Jing Yu2dcc8062009-09-21 16:31:50 -0700443####################################################
444## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700445## Please note that we will do option filtering during FDO build.
446## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
447##################################################################
Ying Wang45d01432014-10-28 14:50:59 -0700448my_fdo_build :=
449ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
450 ifeq ($(BUILD_FDO_INSTRUMENT),true)
451 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
452 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
453 my_fdo_build := true
454 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
455 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
456 my_fdo_build := true
synergydev4a605762013-08-05 02:44:37 -0700457 endif
Shinichiro Hamaji09295a82015-09-24 17:51:20 +0900458 # Disable ccache (or other compiler wrapper) except gomacc, which
459 # can handle -fprofile-use properly.
460 my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper))
461 my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper))
Jing Yu2dcc8062009-09-21 16:31:50 -0700462endif
463
The Android Open Source Project88b60792009-03-03 19:28:42 -0800464###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800465## Explicitly declare assembly-only __ASSEMBLY__ macro for
466## assembly source
467###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800468my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800469
Ying Wangd8d37212014-03-21 16:17:04 -0700470
Jim Huang20d1ba62010-10-14 16:15:56 +0800471###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700472## Define PRIVATE_ variables from global vars
473###########################################################
Ying Wang7fff9a12014-01-09 14:39:41 -0800474ifndef LOCAL_IS_HOST_MODULE
Ying Wang848020f2012-08-14 10:13:16 -0700475ifdef LOCAL_SDK_VERSION
Colin Cross23ba6122016-07-20 12:22:57 -0700476my_target_global_c_includes :=
477my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Ying Wang1a081002010-07-13 14:55:47 -0700478else
Colin Cross23ba6122016-07-20 12:22:57 -0700479my_target_global_c_includes := $(SRC_HEADERS) \
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700480 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
481 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
Colin Cross23ba6122016-07-20 12:22:57 -0700482my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700483 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
484 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
Ying Wangf4723fa2013-08-15 11:01:10 -0700485endif # LOCAL_SDK_VERSION
486
Ying Wang824344a2014-05-27 13:03:36 -0700487ifeq ($(my_clang),true)
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700488my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
Colin Crosse56e3562016-10-17 15:34:29 -0700489my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
490my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700491my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
Ying Wangda4bf422012-08-16 16:45:01 -0700492else
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700493my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
Colin Crosse56e3562016-10-17 15:34:29 -0700494my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
495my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700496my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700497endif # my_clang
Ying Wangda4bf422012-08-16 16:45:01 -0700498
Colin Crosse25fd792016-07-19 13:19:21 -0700499$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
Colin Cross23ba6122016-07-20 12:22:57 -0700500$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
Ying Wang1a081002010-07-13 14:55:47 -0700501$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800502$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800503$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
504$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
505
Ying Wang7fff9a12014-01-09 14:39:41 -0800506else # LOCAL_IS_HOST_MODULE
507
Colin Cross23ba6122016-07-20 12:22:57 -0700508my_host_global_c_includes := $(SRC_HEADERS) \
509 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
Colin Crosse25fd792016-07-19 13:19:21 -0700510 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
Colin Cross23ba6122016-07-20 12:22:57 -0700511my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
512 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
513 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
Colin Crosse25fd792016-07-19 13:19:21 -0700514
Ying Wang824344a2014-05-27 13:03:36 -0700515ifeq ($(my_clang),true)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700516my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
Colin Crosse56e3562016-10-17 15:34:29 -0700517my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
518my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700519my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
Logan Chiene6f65432013-12-10 19:07:41 +0800520else
Dan Willemsen057aaea2015-08-14 12:59:50 -0700521my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
Colin Crosse56e3562016-10-17 15:34:29 -0700522my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
523my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700524my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
Ying Wang824344a2014-05-27 13:03:36 -0700525endif # my_clang
Logan Chiene6f65432013-12-10 19:07:41 +0800526
Colin Crosse25fd792016-07-19 13:19:21 -0700527$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes)
Colin Cross23ba6122016-07-20 12:22:57 -0700528$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes)
Logan Chiene6f65432013-12-10 19:07:41 +0800529$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
Stephen Hines15680292014-11-26 00:53:46 -0800530$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
Logan Chiene6f65432013-12-10 19:07:41 +0800531$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
532$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
533endif # LOCAL_IS_HOST_MODULE
Ying Wang1a081002010-07-13 14:55:47 -0700534
Dan Albert43e128a2015-01-23 16:12:57 -0800535# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
536# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
537# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
538# clean build of your module after toggling it.
539ifeq ($(NATIVE_COVERAGE),true)
540 ifeq ($(my_native_coverage),true)
Dan Albert343ed672015-01-25 16:20:57 -0800541 # Note that clang coverage doesn't play nicely with acov out of the box.
542 # Clang apparently generates .gcno files that aren't compatible with
543 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
544 # with `--gcov-tool /usr/bin/gcov-4.6`.
545 #
546 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
Dan Albert2c03e042015-01-24 15:14:35 -0800547 my_cflags += --coverage -O0
Dan Albert343ed672015-01-25 16:20:57 -0800548 my_ldflags += --coverage
Dan Albert43e128a2015-01-23 16:12:57 -0800549 endif
Dan Willemsen7db70a32016-08-23 06:53:47 +0000550
551 ifeq ($(my_clang),true)
552 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
553 else
554 my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$(filter AUX,$(my_kind)),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a
555 endif
556
557 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
558 $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib)
Dan Albert43e128a2015-01-23 16:12:57 -0800559else
560 my_native_coverage := false
561endif
562
Ying Wang1a081002010-07-13 14:55:47 -0700563###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564## Define PRIVATE_ variables used by multiple module types
565###########################################################
566$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700567 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568
Andrew Hsieh906cb782013-09-10 17:37:14 +0800569ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
570 LOCAL_NO_STATIC_ANALYZER := true
571endif
572
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800573# Clang does not recognize all gcc flags.
574# Use static analyzer only if clang is used.
575ifneq ($(my_clang),true)
576 LOCAL_NO_STATIC_ANALYZER := true
577endif
578
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800579ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
580 my_syntax_arch := host
581else
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700582 my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Andrew Hsieh6cea59a2013-08-27 17:33:06 +0800583endif
584
Ying Wang6ef65192014-01-15 16:02:16 -0800585ifeq ($(strip $(my_cc)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700586 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800587 my_cc := $(CLANG)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400588 else
Ying Wang6ef65192014-01-15 16:02:16 -0800589 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400590 endif
Ying Wangc671a7c2015-07-20 18:40:18 -0700591 my_cc := $(my_cc_wrapper) $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800592endif
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800593
Andrew Hsieh906cb782013-09-10 17:37:14 +0800594ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800595 my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
596 $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer
Andrew Hsieh906cb782013-09-10 17:37:14 +0800597endif
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800598
Ying Wang6ef65192014-01-15 16:02:16 -0800599$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800600
Ying Wang6ef65192014-01-15 16:02:16 -0800601ifeq ($(strip $(my_cxx)),)
Dan Albertdb905e72014-08-18 11:14:38 -0700602 ifeq ($(my_clang),true)
Ying Wang6ef65192014-01-15 16:02:16 -0800603 my_cxx := $(CLANG_CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400604 else
Ying Wang6ef65192014-01-15 16:02:16 -0800605 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400606 endif
Ying Wangc671a7c2015-07-20 18:40:18 -0700607 my_cxx := $(my_cxx_wrapper) $(my_cxx)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800608endif
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800609
Andrew Hsieh906cb782013-09-10 17:37:14 +0800610ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800611 my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
612 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
Andrew Hsieh906cb782013-09-10 17:37:14 +0800613endif
Chih-Hung Hsieh765c1ea2016-02-02 11:30:39 -0800614
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700615$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
Ying Wang6ef65192014-01-15 16:02:16 -0800616$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Dan Albertb6bb71b2014-08-05 14:44:41 -0700617$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800618
619# TODO: support a mix of standard extensions so that this isn't necessary
620LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
621ifeq ($(LOCAL_CPP_EXTENSION),)
622 LOCAL_CPP_EXTENSION := .cpp
623endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800624
625# Certain modules like libdl have to have symbols resolved at runtime and blow
626# up if --no-undefined is passed to the linker.
627ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
Dan Albertb58fb4a2014-11-14 17:15:00 -0800628ifeq ($(my_allow_undefined_symbols),)
Dan Willemsen8308f502016-05-18 12:50:53 -0700629 my_ldflags += -Wl,--no-undefined
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630endif
631endif
632
Ying Wangfcdabd42011-04-25 14:22:41 -0700633ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
634$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
635else
636$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
637endif
638
The Android Open Source Project88b60792009-03-03 19:28:42 -0800639###########################################################
640## Define arm-vs-thumb-mode flags.
641###########################################################
642LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Ying Wangfaeb6932015-04-07 11:59:34 -0700643ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800644arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
645normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
646
Dave Bort95282482009-04-23 18:44:55 -0700647# Read the values from something like TARGET_arm_CFLAGS or
648# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
649# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800650arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
651normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Dan Albertdb905e72014-08-18 11:14:38 -0700652ifeq ($(my_clang),true)
Dan Willemsen02268f02016-05-19 14:39:25 -0700653arm_objects_cflags := $(call convert-to-clang-flags,$(arm_objects_cflags))
654normal_objects_cflags := $(call convert-to-clang-flags,$(normal_objects_cflags))
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400655endif
656
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800657else
658arm_objects_mode :=
659normal_objects_mode :=
660arm_objects_cflags :=
661normal_objects_cflags :=
662endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800663
664###########################################################
665## Define per-module debugging flags. Users can turn on
666## debugging for a particular module by setting DEBUG_MODULE_ModuleName
667## to a non-empty value in their environment or buildspec.mk,
668## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
669## debug flags that they want to use.
670###########################################################
671ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
672 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
673else
674 debug_cflags :=
675endif
676
Tim Murraya7aa8002012-10-29 16:06:00 -0700677####################################################
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800678## Keep track of src -> obj mapping
679####################################################
680
681my_tracked_gen_files :=
682my_tracked_src_files :=
683
684###########################################################
685## Stuff source generated from one-off tools
686###########################################################
687$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
688
689my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
690
Dan Willemsen7f016152016-02-29 17:52:39 -0800691$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/%
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800692 @echo "Copy: $@"
693 $(copy-file-to-target)
694
695my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
696
697# Generated sources that will actually produce object files.
698# Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES,
699# since other compiled sources may depend on them, and we set up
700# the dependencies.
Dan Willemsen444c3232016-02-04 14:18:48 -0800701my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800702
703ALL_GENERATED_SOURCES += $(my_generated_sources)
704
705####################################################
Tim Murraya7aa8002012-10-29 16:06:00 -0700706## Compile RenderScript with reflected C++
707####################################################
708
Ying Wangb8e01852014-01-23 15:09:04 -0800709renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700710
711ifneq (,$(renderscript_sources))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700712my_soong_problems += rs
Tim Murraya7aa8002012-10-29 16:06:00 -0700713
714renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
715RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
716renderscript_intermediate := $(intermediates)/renderscript
717
Noah Presler4796a8c2015-08-13 17:04:10 -0700718renderscript_target_api :=
719
720ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
721renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
722else
723ifneq (,$(LOCAL_SDK_VERSION))
724# Set target-api for LOCAL_SDK_VERSIONs other than current.
Michael Wright0fb087f2015-11-06 15:20:51 +0000725ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Noah Presler4796a8c2015-08-13 17:04:10 -0700726renderscript_target_api := $(LOCAL_SDK_VERSION)
727endif
728endif # LOCAL_SDK_VERSION is set
729endif # LOCAL_RENDERSCRIPT_TARGET_API is set
730
731
Tim Murraya7aa8002012-10-29 16:06:00 -0700732ifeq ($(LOCAL_RENDERSCRIPT_CC),)
733LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
734endif
735
736# Turn on all warnings and warnings as errors for RS compiles.
737# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
738renderscript_flags := -Wall -Werror
739renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700740# -m32 or -m64
741renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700742
Ying Wang6ef65192014-01-15 16:02:16 -0800743renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700744 $(TOPDIR)external/clang/lib/Headers \
745 $(TOPDIR)frameworks/rs/scriptc \
746 $(LOCAL_RENDERSCRIPT_INCLUDES)
747
748ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800749renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700750endif
751
Ying Wangb9319562015-04-03 16:15:28 -0700752bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
753 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
754
Ying Wang6ef65192014-01-15 16:02:16 -0800755$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700756$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
757$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
758$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
759$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
Noah Presler4796a8c2015-08-13 17:04:10 -0700760$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api)
Ying Wangb9319562015-04-03 16:15:28 -0700761$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
Tim Murraya7aa8002012-10-29 16:06:00 -0700762$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
763 $(transform-renderscripts-to-cpp-and-bc)
764
Ying Wangb9319562015-04-03 16:15:28 -0700765# include the dependency files (.d/.P) generated by llvm-rs-cc.
Shinichiro Hamaji2e45fd02016-01-25 18:59:43 +0900766$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp))
Tim Murraya7aa8002012-10-29 16:06:00 -0700767
768LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
769
770rs_generated_cpps := $(addprefix \
771 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
772 $(notdir $(renderscript_sources)))))
773
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800774$(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps))
775
Stephen Hines8ff92522014-06-06 12:51:47 -0700776# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700777$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700778 @echo "Updated RS generated cpp file $@."
Ying Wange25b3982015-02-26 18:47:21 -0800779 $(hide) touch $@
Tim Murraya7aa8002012-10-29 16:06:00 -0700780
Ying Wang6ef65192014-01-15 16:02:16 -0800781my_c_includes += $(renderscript_intermediate)
782my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700783
784endif
785
786
The Android Open Source Project88b60792009-03-03 19:28:42 -0800787###########################################################
Ying Wangfaeb6932015-04-07 11:59:34 -0700788## Compile the .proto files to .cc (or .c) and then to .o
Ying Wanga5fc87a2010-11-02 18:43:16 -0700789###########################################################
Ying Wangb8e01852014-01-23 15:09:04 -0800790proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700791ifneq ($(proto_sources),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700792my_soong_problems += proto
Ying Wang05f9f352016-05-05 20:02:08 -0700793proto_gen_dir := $(generated_sources_dir)/proto
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900794proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangfaeb6932015-04-07 11:59:34 -0700795
Ying Wang05f9f352016-05-05 20:02:08 -0700796my_rename_cpp_ext :=
Ying Wangfaeb6932015-04-07 11:59:34 -0700797ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE)))
798my_proto_source_suffix := .c
799my_proto_c_includes := external/nanopb-c
Ying Wang05f9f352016-05-05 20:02:08 -0700800my_protoc_flags := --nanopb_out=$(proto_gen_dir) \
Ying Wangfaeb6932015-04-07 11:59:34 -0700801 --plugin=external/nanopb-c/generator/protoc-gen-nanopb
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900802my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
Ying Wangfaeb6932015-04-07 11:59:34 -0700803else
Ying Wang05f9f352016-05-05 20:02:08 -0700804my_proto_source_suffix := $(LOCAL_CPP_EXTENSION)
805ifneq ($(my_proto_source_suffix),.cc)
806# aprotoc is hardcoded to write out only .cc file.
807# We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc.
808my_rename_cpp_ext := true
809endif
Ying Wangfaeb6932015-04-07 11:59:34 -0700810my_proto_c_includes := external/protobuf/src
811my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Ying Wang05f9f352016-05-05 20:02:08 -0700812my_protoc_flags := --cpp_out=$(proto_gen_dir)
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900813my_protoc_deps :=
Ying Wangfaeb6932015-04-07 11:59:34 -0700814endif
Ying Wang05f9f352016-05-05 20:02:08 -0700815my_proto_c_includes += $(proto_gen_dir)
Ying Wangfaeb6932015-04-07 11:59:34 -0700816
Ying Wang05f9f352016-05-05 20:02:08 -0700817proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \
Ying Wangfaeb6932015-04-07 11:59:34 -0700818 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700819
Ying Wangead89442014-02-25 11:18:40 -0800820# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
Ying Wang05f9f352016-05-05 20:02:08 -0700821ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
822$(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP)
823$(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
824$(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext)
825$(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700826 $(transform-proto-to-cc)
827
Ying Wang05f9f352016-05-05 20:02:08 -0700828$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
Ying Wangfaeb6932015-04-07 11:59:34 -0700829endif
Ying Wang05f9f352016-05-05 20:02:08 -0700830# Ideally we can generate the source directly into $(intermediates).
831# But many Android.mks assume the .pb.hs are in $(generated_sources_dir).
832# As a workaround, we make a copy in the $(intermediates).
833proto_intermediate_dir := $(intermediates)/proto
834proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\
835 $(proto_generated_cpps))
836$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/%
837 @echo "Copy: $@"
838 $(copy-file-to-target)
839 $(hide) cp $(basename $<).h $(basename $@).h
840$(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps))
841
842my_generated_sources += $(proto_intermediate_cpps)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700843
Ying Wangfaeb6932015-04-07 11:59:34 -0700844my_c_includes += $(my_proto_c_includes)
845# Auto-export the generated proto source dir.
846my_export_c_include_dirs += $(my_proto_c_includes)
847
848ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700849 my_static_libraries += libprotobuf-c-nano-enable_malloc
Ying Wangfaeb6932015-04-07 11:59:34 -0700850else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700851 my_static_libraries += libprotobuf-c-nano
Ying Wangfaeb6932015-04-07 11:59:34 -0700852else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Dan Albertc3031c72014-11-11 10:42:17 -0800853 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700854 my_static_libraries += libprotobuf-cpp-full-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800855 else
856 my_shared_libraries += libprotobuf-cpp-full
857 endif
Yabin Cui72a11562016-06-07 19:21:12 -0700858else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static)
859 my_static_libraries += libprotobuf-cpp-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700860else
Dan Albertc3031c72014-11-11 10:42:17 -0800861 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700862 my_static_libraries += libprotobuf-cpp-lite-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800863 else
864 my_shared_libraries += libprotobuf-cpp-lite
865 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700866endif
Ying Wangead89442014-02-25 11:18:40 -0800867endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700868
Ying Wanga5fc87a2010-11-02 18:43:16 -0700869###########################################################
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700870## Compile the .dbus-xml files to c++ headers
Christopher Wileybc2be462015-07-29 17:14:24 -0700871###########################################################
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700872dbus_definitions := $(filter %.dbus-xml,$(my_src_files))
Christopher Wiley529f1762015-08-14 14:55:32 -0700873dbus_generated_headers :=
874ifneq ($(dbus_definitions),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700875my_soong_problems += dbus
Christopher Wileybc2be462015-07-29 17:14:24 -0700876
Christopher Wiley529f1762015-08-14 14:55:32 -0700877dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions))
Christopher Wileybc2be462015-07-29 17:14:24 -0700878dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files))
Christopher Wiley529f1762015-08-14 14:55:32 -0700879dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
Christopher Wileybc2be462015-07-29 17:14:24 -0700880
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800881# Mark these source files as not producing objects
882$(call track-src-file-obj,$(dbus_definitions) $(dbus_service_config),)
883
Christopher Wiley529f1762015-08-14 14:55:32 -0700884dbus_gen_dir := $(generated_sources_dir)/dbus_bindings
Christopher Wileybc2be462015-07-29 17:14:24 -0700885
Christopher Wiley529f1762015-08-14 14:55:32 -0700886ifdef LOCAL_DBUS_PROXY_PREFIX
887dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX)
888dbus_headers := dbus-proxies.h
889else
890dbus_header_dir := $(dbus_gen_dir)
Christopher Wiley9b17dea2015-08-20 09:08:17 -0700891dbus_headers := $(patsubst %.dbus-xml,%.h,$(dbus_definitions))
Christopher Wiley529f1762015-08-14 14:55:32 -0700892endif
893dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers))
Christopher Wileybc2be462015-07-29 17:14:24 -0700894
895# Ensure that we only define build rules once in multilib builds.
896ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
897$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true
Christopher Wiley529f1762015-08-14 14:55:32 -0700898
899$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE)
900$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path)
901$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR)
902ifdef LOCAL_DBUS_PROXY_PREFIX
903$(dbus_generated_headers) : $(dbus_definition_paths)
904 $(generate-dbus-proxies)
Peter Qiu425e0192015-10-14 16:46:41 -0700905else
906$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus-xml
907 $(generate-dbus-adaptors)
908endif # $(LOCAL_DBUS_PROXY_PREFIX)
909endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
Christopher Wiley529f1762015-08-14 14:55:32 -0700910
Peter Qiu425e0192015-10-14 16:46:41 -0700911ifdef LOCAL_DBUS_PROXY_PREFIX
Christopher Wiley529f1762015-08-14 14:55:32 -0700912# Auto-export the generated dbus proxy directory.
913my_export_c_include_dirs += $(dbus_gen_dir)/include
914my_c_includes += $(dbus_gen_dir)/include
915else
Christopher Wiley529f1762015-08-14 14:55:32 -0700916my_export_c_include_dirs += $(dbus_header_dir)
917my_c_includes += $(dbus_header_dir)
918endif # $(LOCAL_DBUS_PROXY_PREFIX)
Christopher Wileybc2be462015-07-29 17:14:24 -0700919
Christopher Wiley529f1762015-08-14 14:55:32 -0700920my_generated_sources += $(dbus_generated_headers)
921
922endif # $(dbus_definitions) non-empty
Christopher Wileybc2be462015-07-29 17:14:24 -0700923
924
925###########################################################
Christopher Wiley2df75d12015-10-14 17:27:24 -0700926## AIDL: Compile .aidl files to .cpp and .h files
927###########################################################
928aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
929aidl_gen_cpp :=
930ifneq ($(aidl_src),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700931my_soong_problems += aidl
Christopher Wiley2df75d12015-10-14 17:27:24 -0700932
Christopher Wiley257796c2016-01-19 08:58:35 -0800933# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700934aidl_gen_cpp_root := $(intermediates)/aidl-generated/src
935aidl_gen_include_root := $(intermediates)/aidl-generated/include
936
Christopher Wiley257796c2016-01-19 08:58:35 -0800937# Multi-architecture builds have distinct intermediates directories.
938# Thus we'll actually generate source for each architecture.
939$(foreach s,$(aidl_src),\
940 $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
Christopher Wiley087f3272016-01-19 09:26:10 -0800941$(foreach cpp,$(aidl_gen_cpp), \
Shinichiro Hamaji2e45fd02016-01-25 18:59:43 +0900942 $(call include-depfile,$(addsuffix .aidl.P,$(basename $(cpp))),$(cpp)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800943$(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
Christopher Wiley2df75d12015-10-14 17:27:24 -0700944
Christopher Wiley2df75d12015-10-14 17:27:24 -0700945$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
946$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root)
947$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
948
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800949# Add generated headers to include paths.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700950my_c_includes += $(aidl_gen_include_root)
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800951my_export_c_include_dirs += $(aidl_gen_include_root)
Christopher Wiley2df75d12015-10-14 17:27:24 -0700952# Pick up the generated C++ files later for transformation to .o files.
953my_generated_sources += $(aidl_gen_cpp)
954
955endif # $(aidl_src) non-empty
956
957###########################################################
Keun Soo Yim3d484752016-02-19 11:06:58 -0800958## Compile the .vts files to .cc (or .c) and then to .o
959###########################################################
960
961vts_src := $(strip $(filter %.vts,$(my_src_files)))
962vts_gen_cpp :=
963ifneq ($(vts_src),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700964my_soong_problems += vts
Keun Soo Yim3d484752016-02-19 11:06:58 -0800965
966# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
967vts_gen_cpp_root := $(intermediates)/vts-generated/src
968vts_gen_include_root := $(intermediates)/vts-generated/include
969
970# Multi-architecture builds have distinct intermediates directories.
971# Thus we'll actually generate source for each architecture.
972$(foreach s,$(vts_src),\
973 $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp)))
974$(foreach cpp,$(vts_gen_cpp), \
975 $(call include-depfile,$(addsuffix .vts.P,$(basename $(cpp))),$(cpp)))
976$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp))
977
978$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
979$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
980$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES))
981
982# Add generated headers to include paths.
983my_c_includes += $(vts_gen_include_root)
984my_export_c_include_dirs += $(vts_gen_include_root)
985# Pick up the generated C++ files later for transformation to .o files.
986my_generated_sources += $(vts_gen_cpp)
987
988endif # $(vts_src) non-empty
989
990###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -0800991## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800992###########################################################
993
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000994y_yacc_sources := $(filter %.y,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -0800995y_yacc_cs := $(addprefix \
996 $(intermediates)/,$(y_yacc_sources:.y=.c))
997ifneq ($(y_yacc_cs),)
998$(y_yacc_cs): $(intermediates)/%.c: \
Shinichiro Hamajib708bc52016-04-05 20:12:48 +0900999 $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) \
Ying Wangf0ebe162016-01-11 16:28:45 -08001000 $(my_additional_dependencies)
1001 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001002$(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -08001003
1004my_generated_sources += $(y_yacc_cs)
1005endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001006
1007yy_yacc_sources := $(filter %.yy,$(my_src_files))
1008yy_yacc_cpps := $(addprefix \
1009 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -08001010ifneq ($(yy_yacc_cpps),)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001011$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Shinichiro Hamajib708bc52016-04-05 20:12:48 +09001012 $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) \
Ying Wangf0ebe162016-01-11 16:28:45 -08001013 $(my_additional_dependencies)
1014 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001015$(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001016
Ying Wangf0ebe162016-01-11 16:28:45 -08001017my_generated_sources += $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001018endif
1019
1020###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -08001021## LEX: Compile .l/.ll files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001022###########################################################
1023
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001024l_lex_sources := $(filter %.l,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -08001025l_lex_cs := $(addprefix \
1026 $(intermediates)/,$(l_lex_sources:.l=.c))
1027ifneq ($(l_lex_cs),)
1028$(l_lex_cs): $(intermediates)/%.c: \
1029 $(TOPDIR)$(LOCAL_PATH)/%.l
1030 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001031$(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -08001032
1033my_generated_sources += $(l_lex_cs)
1034endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001035
1036ll_lex_sources := $(filter %.ll,$(my_src_files))
1037ll_lex_cpps := $(addprefix \
1038 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -08001039ifneq ($(ll_lex_cpps),)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001040$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
1041 $(TOPDIR)$(LOCAL_PATH)/%.ll
Ying Wangf0ebe162016-01-11 16:28:45 -08001042 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001043$(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +00001044
Ying Wangf0ebe162016-01-11 16:28:45 -08001045my_generated_sources += $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001046endif
1047
1048###########################################################
1049## C++: Compile .cpp files to .o.
1050###########################################################
1051
Jeff Browne33ba4c2011-07-11 22:11:46 -07001052# we also do this on host modules, even though
The Android Open Source Project88b60792009-03-03 19:28:42 -08001053# it's not really arm, because there are files that are shared.
Ying Wangfb22a422015-03-10 18:03:11 -07001054cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
1055dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources))
1056cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources))
1057cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001058$(call track-src-file-obj,$(patsubst %,%.arm,$(cpp_arm_sources)),$(cpp_arm_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001059
Ying Wangfb22a422015-03-10 18:03:11 -07001060# For source files starting with ../, we remove all the ../ in the object file path,
1061# to avoid object file escaping the intermediate directory.
1062dotdot_arm_objects :=
1063$(foreach s,$(dotdot_arm_sources),\
1064 $(eval $(call compile-dotdot-cpp-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -07001065 $(my_additional_dependencies),\
Ying Wangfb22a422015-03-10 18:03:11 -07001066 dotdot_arm_objects)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001067$(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects))
Ying Wangfb22a422015-03-10 18:03:11 -07001068
1069dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
1070dotdot_objects :=
1071$(foreach s,$(dotdot_sources),\
1072 $(eval $(call compile-dotdot-cpp-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -07001073 $(my_additional_dependencies),\
Ying Wangfb22a422015-03-10 18:03:11 -07001074 dotdot_objects)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001075$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -07001076
1077cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001078cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001079$(call track-src-file-obj,$(cpp_normal_sources),$(cpp_normal_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001080
Ying Wangfb22a422015-03-10 18:03:11 -07001081$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
1082$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
1083$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
1084$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001085
1086cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
1087
1088ifneq ($(strip $(cpp_objects)),)
1089$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001090 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Dan Albert954b5bd2014-11-08 22:20:03 -08001091 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001092 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001093$(call include-depfiles-for-objs, $(cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001094endif
1095
Ying Wangfb22a422015-03-10 18:03:11 -07001096cpp_objects += $(dotdot_arm_objects) $(dotdot_objects)
1097
The Android Open Source Project88b60792009-03-03 19:28:42 -08001098###########################################################
1099## C++: Compile generated .cpp files to .o.
1100###########################################################
1101
Ying Wangec6d6262014-01-16 16:21:03 -08001102gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001103gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001104$(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001105
1106ifneq ($(strip $(gen_cpp_objects)),)
1107# Compile all generated files as thumb.
1108# TODO: support compiling certain generated files as arm.
1109$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
1110$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001111$(gen_cpp_objects): $(intermediates)/%.o: \
Ying Wang05f9f352016-05-05 20:02:08 -07001112 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Dan Albert954b5bd2014-11-08 22:20:03 -08001113 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001114 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001115$(call include-depfiles-for-objs, $(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001116endif
1117
1118###########################################################
1119## S: Compile generated .S and .s files to .o.
1120###########################################################
1121
Ying Wangec6d6262014-01-16 16:21:03 -08001122gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001123gen_S_objects := $(gen_S_sources:%.S=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001124$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001125
1126ifneq ($(strip $(gen_S_sources)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001127$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -08001128 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001129 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001130$(call include-depfiles-for-objs, $(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001131endif
1132
Ying Wangec6d6262014-01-16 16:21:03 -08001133gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001134gen_s_objects := $(gen_s_sources:%.s=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001135$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001136
1137ifneq ($(strip $(gen_s_objects)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001138$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -08001139 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001140 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001141endif
1142
1143gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
Dan Willemsen45d38c02016-01-15 16:38:46 -08001144$(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001145
1146###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +00001147## o: Include generated .o files in output.
1148###########################################################
1149
Ying Wangec6d6262014-01-16 16:21:03 -08001150gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +00001151
1152###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001153## C: Compile .c files to .o.
1154###########################################################
1155
Ying Wangfb22a422015-03-10 18:03:11 -07001156c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
1157dotdot_arm_sources := $(filter ../%,$(c_arm_sources))
1158c_arm_sources := $(filter-out ../%,$(c_arm_sources))
1159c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001160$(call track-src-file-obj,$(patsubst %,%.arm,$(c_arm_sources)),$(c_arm_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001161
Ying Wangfb22a422015-03-10 18:03:11 -07001162# For source files starting with ../, we remove all the ../ in the object file path,
1163# to avoid object file escaping the intermediate directory.
1164dotdot_arm_objects :=
1165$(foreach s,$(dotdot_arm_sources),\
1166 $(eval $(call compile-dotdot-c-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -07001167 $(my_additional_dependencies),\
Ying Wangfb22a422015-03-10 18:03:11 -07001168 dotdot_arm_objects)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001169$(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects))
Ying Wangfb22a422015-03-10 18:03:11 -07001170
1171dotdot_sources := $(filter ../%.c, $(my_src_files))
1172dotdot_objects :=
1173$(foreach s, $(dotdot_sources),\
1174 $(eval $(call compile-dotdot-c-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -07001175 $(my_additional_dependencies),\
Ying Wangfb22a422015-03-10 18:03:11 -07001176 dotdot_objects)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001177$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -07001178
1179c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001180c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001181$(call track-src-file-obj,$(c_normal_sources),$(c_normal_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001182
Ying Wangfb22a422015-03-10 18:03:11 -07001183$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
1184$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
1185$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
1186$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001187
1188c_objects := $(c_arm_objects) $(c_normal_objects)
1189
1190ifneq ($(strip $(c_objects)),)
Ying Wang05f9f352016-05-05 20:02:08 -07001191$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \
Dan Albert954b5bd2014-11-08 22:20:03 -08001192 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001193 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001194$(call include-depfiles-for-objs, $(c_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001195endif
1196
Ying Wangfb22a422015-03-10 18:03:11 -07001197c_objects += $(dotdot_arm_objects) $(dotdot_objects)
1198
The Android Open Source Project88b60792009-03-03 19:28:42 -08001199###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001200## C: Compile generated .c files to .o.
1201###########################################################
1202
Ying Wangec6d6262014-01-16 16:21:03 -08001203gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001204gen_c_objects := $(gen_c_sources:%.c=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001205$(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001206
1207ifneq ($(strip $(gen_c_objects)),)
1208# Compile all generated files as thumb.
1209# TODO: support compiling certain generated files as arm.
1210$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
1211$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wang05f9f352016-05-05 20:02:08 -07001212$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \
Dan Albert954b5bd2014-11-08 22:20:03 -08001213 $(my_additional_dependencies)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001214 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001215$(call include-depfiles-for-objs, $(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001216endif
1217
1218###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001219## ObjC: Compile .m files to .o
1220###########################################################
1221
Ying Wangb8e01852014-01-23 15:09:04 -08001222objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001223objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -08001224$(call track-src-file-obj,$(objc_sources),$(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001225
1226ifneq ($(strip $(objc_objects)),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001227my_soong_problems += objc
Ying Wang05f9f352016-05-05 20:02:08 -07001228$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
Dan Albert954b5bd2014-11-08 22:20:03 -08001229 $(my_additional_dependencies)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001230 $(transform-$(PRIVATE_HOST)m-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001231$(call include-depfiles-for-objs, $(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001232endif
1233
1234###########################################################
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001235## ObjC++: Compile .mm files to .o
1236###########################################################
1237
1238objcpp_sources := $(filter %.mm,$(my_src_files))
1239objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -08001240$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001241
1242ifneq ($(strip $(objcpp_objects)),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001243my_soong_problems += objc
Ying Wang05f9f352016-05-05 20:02:08 -07001244$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001245 $(my_additional_dependencies)
1246 $(transform-$(PRIVATE_HOST)mm-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001247$(call include-depfiles-for-objs, $(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001248endif
1249
1250###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001251## AS: Compile .S files to .o.
1252###########################################################
1253
Ying Wangb8e01852014-01-23 15:09:04 -08001254asm_sources_S := $(filter %.S,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001255dotdot_sources := $(filter ../%,$(asm_sources_S))
1256asm_sources_S := $(filter-out ../%,$(asm_sources_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001257asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001258$(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259
Ying Wangfb22a422015-03-10 18:03:11 -07001260dotdot_objects_S :=
1261$(foreach s,$(dotdot_sources),\
1262 $(eval $(call compile-dotdot-s-file,$(s),\
1263 $(my_additional_dependencies),\
1264 dotdot_objects_S)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001265$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S))
Ying Wangfb22a422015-03-10 18:03:11 -07001266
The Android Open Source Project88b60792009-03-03 19:28:42 -08001267ifneq ($(strip $(asm_objects_S)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001268$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Albert954b5bd2014-11-08 22:20:03 -08001269 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001270 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji72904772016-03-16 06:40:04 +09001271$(call include-depfiles-for-objs, $(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001272endif
1273
Ying Wangb8e01852014-01-23 15:09:04 -08001274asm_sources_s := $(filter %.s,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001275dotdot_sources := $(filter ../%,$(asm_sources_s))
1276asm_sources_s := $(filter-out ../%,$(asm_sources_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001277asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001278$(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001279
Ying Wangfb22a422015-03-10 18:03:11 -07001280dotdot_objects_s :=
1281$(foreach s,$(dotdot_sources),\
1282 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
1283 $(my_additional_dependencies),\
1284 dotdot_objects_s)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001285$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s))
Ying Wangfb22a422015-03-10 18:03:11 -07001286
The Android Open Source Project88b60792009-03-03 19:28:42 -08001287ifneq ($(strip $(asm_objects_s)),)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001288$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Albert954b5bd2014-11-08 22:20:03 -08001289 $(my_additional_dependencies)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001290 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001291endif
1292
Ying Wangfb22a422015-03-10 18:03:11 -07001293asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
Dan Willemsen45d38c02016-01-15 16:38:46 -08001294$(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001295
1296
Ying Wangfe1e5c32015-03-09 18:57:40 -07001297# .asm for x86/x86_64 needs to be compiled with yasm.
Ying Wang7b913ce2014-06-05 19:05:47 -07001298asm_sources_asm := $(filter %.asm,$(my_src_files))
1299ifneq ($(strip $(asm_sources_asm)),)
1300asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
1301$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
Dan Albert954b5bd2014-11-08 22:20:03 -08001302 $(my_additional_dependencies)
Ying Wang7b913ce2014-06-05 19:05:47 -07001303 $(transform-asm-to-o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001304$(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm))
Ying Wang7b913ce2014-06-05 19:05:47 -07001305
1306asm_objects += $(asm_objects_asm)
1307endif
Ying Wang7b913ce2014-06-05 19:05:47 -07001308
Jeff Davidson680f0712015-01-08 18:25:30 -08001309
1310##########################################################
1311## Set up installed module dependency
1312## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
1313## they may cusomize their install path with LOCAL_MODULE_PATH
1314##########################################################
1315# Get the list of INSTALLED libraries as module names.
1316ifdef LOCAL_SDK_VERSION
1317 installed_shared_library_module_names := \
1318 $(my_shared_libraries)
1319else
1320 installed_shared_library_module_names := \
1321 $(my_shared_libraries) $(my_system_shared_libraries)
1322endif
1323
1324# The real dependency will be added after all Android.mks are loaded and the install paths
1325# of the shared libraries are determined.
1326ifdef LOCAL_INSTALLED_MODULE
1327ifdef installed_shared_library_module_names
1328$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
1329 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names)))
1330endif
1331endif
1332
1333
Ying Wang5f074802011-11-08 09:31:21 -08001334####################################################
1335## Import includes
1336####################################################
1337import_includes := $(intermediates)/import_includes
1338import_includes_deps := $(strip \
1339 $(foreach l, $(installed_shared_library_module_names), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001340 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \
Colin Cross90353fe2014-02-04 14:53:25 -08001341 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001342 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
Ying Wang14d02a32015-01-22 15:44:04 -08001343$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -08001344$(import_includes) : $(import_includes_deps)
Ying Wang5f074802011-11-08 09:31:21 -08001345 @echo Import includes file: $@
1346 $(hide) mkdir -p $(dir $@) && rm -f $@
1347ifdef import_includes_deps
Ying Wang14d02a32015-01-22 15:44:04 -08001348 $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \
Ying Wang5f074802011-11-08 09:31:21 -08001349 cat $$f >> $@; \
1350 done
1351else
1352 $(hide) touch $@
1353endif
1354
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001355####################################################
1356## Verify that NDK-built libraries only link against
1357## other NDK-built libraries
1358####################################################
1359
1360my_link_type := $(intermediates)/link_type
Dan Willemsen121e2842016-09-14 21:38:29 -07001361all_link_types: $(my_link_type)
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001362ifdef LOCAL_SDK_VERSION
Dan Willemsen121e2842016-09-14 21:38:29 -07001363$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
1364$(my_link_type): PRIVATE_WARN_TYPES :=
1365$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001366else
Dan Willemsen121e2842016-09-14 21:38:29 -07001367$(my_link_type): PRIVATE_LINK_TYPE := native:platform
1368$(my_link_type): PRIVATE_WARN_TYPES :=
1369$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk native:platform
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001370endif
Dan Willemsen121e2842016-09-14 21:38:29 -07001371$(eval $(call link-type-partitions,$(my_link_type)))
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001372my_link_type_deps := $(strip \
1373 $(foreach l,$(my_whole_static_libraries) $(my_static_libraries), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001374 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001375ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
1376my_link_type_deps += $(strip \
1377 $(foreach l,$(my_shared_libraries), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001378 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001379endif
1380$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
1381$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
1382$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
Dan Willemsen121e2842016-09-14 21:38:29 -07001383$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001384 @echo Check module type: $@
Dan Willemsen121e2842016-09-14 21:38:29 -07001385 $(check-link-type)
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001386
1387
The Android Open Source Project88b60792009-03-03 19:28:42 -08001388###########################################################
1389## Common object handling.
1390###########################################################
1391
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001392my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files))
1393ifneq ($(my_unused_src_files),)
Dan Willemsen9efeb1e2016-06-28 10:22:08 -07001394 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001395endif
1396
The Android Open Source Project88b60792009-03-03 19:28:42 -08001397# some rules depend on asm_objects being first. If your code depends on
1398# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001399normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001400 $(asm_objects) \
1401 $(cpp_objects) \
1402 $(gen_cpp_objects) \
1403 $(gen_asm_objects) \
1404 $(c_objects) \
1405 $(gen_c_objects) \
1406 $(objc_objects) \
Ying Wang05f9f352016-05-05 20:02:08 -07001407 $(objcpp_objects)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001408
1409new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f)))
1410new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f)))
1411
1412ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects)))
1413$(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old)
1414$(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects))))
1415$(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects))))
1416endif
1417
1418ifeq ($(BINARY_OBJECTS_ORDER),soong)
1419normal_objects := $(new_order_normal_objects)
1420endif
1421
1422normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001423
1424all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001425
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001426# Cleanup file tracking
1427$(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=))
1428my_tracked_gen_files :=
1429$(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=))
1430my_tracked_src_files :=
1431
Colin Cross2d206702014-02-13 13:41:52 -08001432my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001433
Ying Wang848020f2012-08-14 10:13:16 -07001434ifndef LOCAL_SDK_VERSION
Ying Wang6ef65192014-01-15 16:02:16 -08001435 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -07001436endif
1437
Dan Willemsen062e30b2016-05-24 13:06:07 -07001438my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)))
1439ifneq ($(my_outside_includes),)
1440$(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): C_INCLUDES must be under the source or output directories: $(my_outside_includes))
1441endif
1442
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001443# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
1444# use normal_objects here to avoid creating circular dependencies. This assumes
1445# that custom build rules which generate .o files don't consume other generated
1446# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -08001447$(normal_objects) : | $(my_generated_sources)
Colin Cross6b9bddd2015-11-30 17:33:26 -08001448$(all_objects) : $(import_includes)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001449ALL_C_CPP_ETC_OBJECTS += $(all_objects)
1450
The Android Open Source Project88b60792009-03-03 19:28:42 -08001451
1452###########################################################
1453# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001454###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001455
1456###########################################################
1457# The list of libraries that this module will link against are in
1458# these variables. Each is a list of bare module names like "libc libm".
1459#
1460# LOCAL_SHARED_LIBRARIES
1461# LOCAL_STATIC_LIBRARIES
1462# LOCAL_WHOLE_STATIC_LIBRARIES
1463#
1464# We need to convert the bare names into the dependencies that
1465# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
1466# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
1467# libraries, so that simply building this module doesn't force
1468# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
1469# should depend on the INSTALLED versions of the libraries so
1470# that they get installed when this module does.
1471###########################################################
1472# NOTE:
1473# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
1474# module without leaving anything out, which is useful for turning
1475# a collection of .a files into a .so file. Linking against a
1476# normal STATIC_LIBRARY will only pull in code/symbols that are
1477# referenced by the module. (see gcc/ld's --whole-archive option)
1478###########################################################
1479
1480# Get the list of BUILT libraries, which are under
1481# various intermediates directories.
1482so_suffix := $($(my_prefix)SHLIB_SUFFIX)
1483a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
1484
Ying Wang848020f2012-08-14 10:13:16 -07001485ifdef LOCAL_SDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -08001486built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001487 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001488 $(addsuffix $(so_suffix), \
Ying Wang6ef65192014-01-15 16:02:16 -08001489 $(my_shared_libraries)))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001490built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001491
Ying Wangd8d37212014-03-21 16:17:04 -07001492# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -08001493my_system_shared_libraries_fullpath := \
1494 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -07001495 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -07001496 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -07001497
Dan Albertc1ca1902016-08-04 14:14:50 -07001498# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
1499# whether the libs are generated or prebuilt, so we simply can't split into two
1500# lists and use addprefix.
1501my_ndk_shared_libraries_fullpath := \
1502 $(foreach _lib,$(my_ndk_shared_libraries),\
1503 $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\
1504 $(my_built_ndk_libs)/$(_lib)$(so_suffix),\
1505 $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
Dan Albert02bf1382016-07-21 10:04:12 -07001506
1507built_shared_libraries += \
Dan Albertc1ca1902016-08-04 14:14:50 -07001508 $(my_ndk_shared_libraries_fullpath) \
Dan Albert02bf1382016-07-21 10:04:12 -07001509 $(my_system_shared_libraries_fullpath) \
1510
Ying Wang1a081002010-07-13 14:55:47 -07001511else
Ying Wang1a081002010-07-13 14:55:47 -07001512built_shared_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001513 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Ying Wang1a081002010-07-13 14:55:47 -07001514 $(addsuffix $(so_suffix), \
Ying Wangd8d37212014-03-21 16:17:04 -07001515 $(installed_shared_library_module_names)))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001516built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001517my_system_shared_libraries_fullpath :=
Ying Wang1a081002010-07-13 14:55:47 -07001518endif
1519
The Android Open Source Project88b60792009-03-03 19:28:42 -08001520built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001521 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001522 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001523 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001524
Ying Wang848020f2012-08-14 10:13:16 -07001525ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -08001526built_static_libraries += $(my_ndk_stl_static_lib)
1527endif
1528
The Android Open Source Project88b60792009-03-03 19:28:42 -08001529built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -08001530 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001531 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001532 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001533
The Android Open Source Project88b60792009-03-03 19:28:42 -08001534# We don't care about installed static libraries, since the
1535# libraries have already been linked into the module at that point.
1536# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +00001537# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001538
1539installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -08001540 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001541 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
1542
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001543# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001544ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1545LOCAL_RTTI_FLAG := -fno-rtti
1546endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001547
The Android Open Source Project88b60792009-03-03 19:28:42 -08001548###########################################################
1549# Rule-specific variable definitions
1550###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001551
Ying Wang824344a2014-05-27 13:03:36 -07001552ifeq ($(my_clang),true)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001553my_cflags += $(LOCAL_CLANG_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -08001554my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
Dan Albertd2fa96d2014-11-28 14:00:12 -08001555my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
Dan Albertd1600412015-06-10 16:33:43 -07001556my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
1557my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001558my_asflags += $(LOCAL_CLANG_ASFLAGS)
1559my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001560my_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 -08001561my_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 -07001562my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
1563my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
1564my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
Dan Willemsen02268f02016-05-19 14:39:25 -07001565my_cflags := $(call convert-to-clang-flags,$(my_cflags))
1566my_cppflags := $(call convert-to-clang-flags,$(my_cppflags))
1567my_asflags := $(call convert-to-clang-flags,$(my_asflags))
1568my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
Dan Austin75e7af12016-04-06 11:18:30 -07001569else
1570# gcc does not handle hidden functions in a manner compatible with LLVM libcxx
1571# see b/27908145
1572my_cflags += -Wno-attributes
Logan Chiene6f65432013-12-10 19:07:41 +08001573endif
1574
Ying Wang45d01432014-10-28 14:50:59 -07001575ifeq ($(my_fdo_build), true)
1576 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
1577 fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
1578 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
Dehao Chen295a6d22014-09-19 10:18:12 -07001579endif
1580
Dan Albertdf3fd1d2015-08-12 14:54:16 -07001581# No one should ever use this flag. On GCC it's mere presence will disable all
1582# warnings, even those that are specified after it (contrary to typical warning
1583# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
1584# warnings that are *always* bugs.
1585my_illegal_flags := -w
1586my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
1587my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
1588my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
1589
Dan Albert5ae31dd2016-01-29 16:51:51 -08001590# We can enforce some rules more strictly in the code we own. my_strict
1591# indicates if this is code that we can be stricter with. If we have rules that
1592# we want to apply to *our* code (but maybe can't for vendor/device specific
1593# things), we could extend this to be a ternary value.
1594my_strict := true
1595ifneq ($(filter external/%,$(LOCAL_PATH)),)
1596 my_strict := false
1597endif
1598
1599# Can be used to make some annotations stricter for code we can fix (such as
1600# when we mark functions as deprecated).
1601ifeq ($(my_strict),true)
1602 my_cflags += -DANDROID_STRICT
1603endif
1604
Chih-Hung Hsiehbab04882016-10-11 15:38:39 -07001605# Add -Werror if LOCAL_PATH is in the WARNING_DISALLOWED project list,
1606# or not in the WARNING_ALLOWED project list.
1607ifneq (,$(strip $(call find_warning_disallowed_projects,$(LOCAL_PATH))))
1608 my_cflags_no_override += -Werror
1609else
1610 ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
1611 my_cflags_no_override += -Werror
1612 endif
1613endif
1614
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001615# Disable clang-tidy if it is not found.
1616ifeq ($(PATH_TO_CLANG_TIDY),)
1617 my_tidy_enabled := false
1618else
1619 # If LOCAL_TIDY is not defined, use global WITH_TIDY
1620 my_tidy_enabled := $(LOCAL_TIDY)
1621 ifeq ($(my_tidy_enabled),)
1622 my_tidy_enabled := $(WITH_TIDY)
1623 endif
1624endif
1625
1626# my_tidy_checks is empty if clang-tidy is disabled.
1627my_tidy_checks :=
1628my_tidy_flags :=
1629ifneq (,$(filter 1 true,$(my_tidy_enabled)))
1630 ifneq ($(my_clang),true)
1631 # Disable clang-tidy if clang is disabled.
1632 my_tidy_enabled := false
1633 else
1634 tidy_only: $(cpp_objects) $(c_objects)
1635 # Set up global default checks
1636 my_tidy_checks := $(WITH_TIDY_CHECKS)
1637 ifeq ($(my_tidy_checks),)
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -07001638 my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH))
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001639 endif
1640 # Append local clang-tidy checks.
1641 ifneq ($(LOCAL_TIDY_CHECKS),)
1642 my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS)
1643 endif
1644 # Set up global default clang-tidy flags, which is none.
1645 my_tidy_flags := $(WITH_TIDY_FLAGS)
1646 # Use local clang-tidy flags if specified.
1647 ifneq ($(LOCAL_TIDY_FLAGS),)
1648 my_tidy_flags := $(LOCAL_TIDY_FLAGS)
1649 endif
Chih-Hung Hsieh870f0872016-06-02 15:20:05 -07001650 # If tidy flags are not specified, default to check all header files.
1651 ifeq ($(my_tidy_flags),)
Chih-Hung Hsieh0a33f652016-09-06 20:06:28 -07001652 my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH))
Chih-Hung Hsieh870f0872016-06-02 15:20:05 -07001653 endif
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001654 endif
1655endif
1656
Chih-Hung Hsiehba646252016-08-16 16:27:30 -07001657my_tidy_checks := $(subst $(space),,$(my_tidy_checks))
1658
Dan Willemsen6731b492016-06-07 16:55:57 -07001659# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
1660my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
1661my_ldlibs := $(filter -l%,$(my_ldlib_flags))
1662my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
1663
1664# One last verification check for ldlibs
1665ifndef LOCAL_IS_HOST_MODULE
1666my_allowed_ldlibs :=
1667ifdef LOCAL_SDK_VERSION
1668 my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES))
1669endif
1670
1671my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs))
1672ifneq ($(my_bad_ldlibs),)
1673 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs))
1674endif
1675endif
1676
Dan Willemsenc9aa6fc2016-09-13 10:44:44 -07001677# my_cxx_ldlibs may contain linker flags need to wrap certain libraries
1678# (start-group/end-group), so append after the check above.
1679my_ldlibs += $(my_cxx_ldlibs)
1680
The Android Open Source Project88b60792009-03-03 19:28:42 -08001681$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001682$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Stephen Hines15680292014-11-26 00:53:46 -08001683$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001684$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1685$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Dan Albertd1600412015-06-10 16:33:43 -07001686$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1687$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001688$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001689$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001690$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Ying Wang5f074802011-11-08 09:31:21 -08001691$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001692$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001693$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001694$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
1695$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001696
1697# this is really the way to get the files onto the command line instead
1698# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1699$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1700$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1701$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
Ying Wang4aaa1a12016-03-22 18:23:13 -07001702$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001703
1704###########################################################
1705# Define library dependencies.
1706###########################################################
1707# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1708all_libraries := \
Ying Wangc01f2dc2015-12-15 10:00:19 -08001709 $(built_shared_library_deps) \
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001710 $(my_system_shared_libraries_fullpath) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001711 $(built_static_libraries) \
1712 $(built_whole_libraries)
1713
The Android Open Source Project88b60792009-03-03 19:28:42 -08001714# Also depend on the notice files for any static libraries that
1715# are linked into this module. This will force them to be installed
1716# when this module is.
1717$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
Ying Wang5f074802011-11-08 09:31:21 -08001718
1719###########################################################
1720# Export includes
1721###########################################################
1722export_includes := $(intermediates)/export_includes
Ying Wangfaeb6932015-04-07 11:59:34 -07001723$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001724# Headers exported by whole static libraries are also exported by this library.
Dan Willemsena7808ac2016-03-04 12:40:25 -08001725export_include_deps := $(strip \
1726 $(foreach l,$(my_whole_static_libraries), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001727 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001728# Re-export requested headers from shared libraries.
1729export_include_deps += $(strip \
1730 $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001731 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001732# Re-export requested headers from static libraries.
1733export_include_deps += $(strip \
1734 $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001735 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
Dan Willemsena7808ac2016-03-04 12:40:25 -08001736$(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps)
Ying Wang05f9f352016-05-05 20:02:08 -07001737# By adding $(my_generated_sources) it makes sure the headers get generated
1738# before any dependent source files get compiled.
Dan Willemsenba6a1642016-09-29 12:08:29 -07001739$(export_includes) : $(my_export_c_include_deps) $(my_generated_sources) $(export_include_deps)
Ying Wang5f074802011-11-08 09:31:21 -08001740 @echo Export includes file: $< -- $@
Dan Willemsena7808ac2016-03-04 12:40:25 -08001741 $(hide) mkdir -p $(dir $@) && rm -f $@.tmp && touch $@.tmp
Ying Wangfaeb6932015-04-07 11:59:34 -07001742ifdef my_export_c_include_dirs
Ying Wang5f074802011-11-08 09:31:21 -08001743 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
Colin Cross6b9bddd2015-11-30 17:33:26 -08001744 echo "-I $$d" >> $@.tmp; \
Ying Wang5f074802011-11-08 09:31:21 -08001745 done
Dan Willemsena7808ac2016-03-04 12:40:25 -08001746endif
1747ifdef export_include_deps
1748 $(hide) for f in $(PRIVATE_REEXPORTED_INCLUDES); do \
1749 cat $$f >> $@.tmp; \
1750 done
Ying Wang5f074802011-11-08 09:31:21 -08001751endif
Colin Cross6b9bddd2015-11-30 17:33:26 -08001752 $(hide) if cmp -s $@.tmp $@ ; then \
1753 rm $@.tmp ; \
1754 else \
1755 mv $@.tmp $@ ; \
1756 fi
Colin Cross6b9bddd2015-11-30 17:33:26 -08001757
1758# Kati adds restat=1 to ninja. GNU make does nothing for this.
1759.KATI_RESTAT: $(export_includes)
Ying Wang616e5962012-04-18 17:35:55 -07001760
1761# Make sure export_includes gets generated when you are running mm/mmm
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001762$(LOCAL_BUILT_MODULE) : | $(export_includes) $(my_link_type)
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001763
1764ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
1765SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
1766 $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
1767SOONG_CONV.$(LOCAL_MODULE).DEPS := \
1768 $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
1769 $(my_static_libraries) \
1770 $(my_whole_static_libraries) \
1771 $(my_shared_libraries) \
1772 $(my_system_shared_libraries)
1773SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
1774endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07001775
1776###########################################################
1777# Coverage packaging.
1778###########################################################
1779ifeq ($(my_native_coverage),true)
1780LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(all_objects))
1781$(foreach f,$(all_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
1782endif