The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | ########################################################### |
| 2 | ## Standard rules for building binary object files from |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 3 | ## asm/c/cpp/yacc/lex/etc source files. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 4 | ## |
| 5 | ## The list of object files is exported in $(all_objects). |
| 6 | ########################################################### |
| 7 | |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 8 | ####################################### |
| 9 | include $(BUILD_SYSTEM)/base_rules.mk |
| 10 | ####################################### |
| 11 | |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 12 | ################################################## |
| 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. |
| 19 | ifdef 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 |
| 25 | else |
| 26 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
Dimitry Ivanov | cdf3927 | 2017-06-26 13:13:44 -0700 | [diff] [blame] | 27 | my_system_shared_libraries := libc libm libdl |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 28 | else |
| 29 | my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
Dimitry Ivanov | cdf3927 | 2017-06-26 13:13:44 -0700 | [diff] [blame] | 30 | my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries)) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 31 | endif |
| 32 | endif |
| 33 | |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 34 | my_soong_problems := |
| 35 | |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 36 | # The following LOCAL_ variables will be modified in this file. |
| 37 | # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, |
| 38 | # we can't modify them in place. |
| 39 | my_src_files := $(LOCAL_SRC_FILES) |
Colin Cross | a04abc8 | 2015-06-30 12:21:59 -0700 | [diff] [blame] | 40 | my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 41 | my_static_libraries := $(LOCAL_STATIC_LIBRARIES) |
| 42 | my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) |
Dimitry Ivanov | cdf3927 | 2017-06-26 13:13:44 -0700 | [diff] [blame] | 43 | my_shared_libraries := $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES)) |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 44 | my_header_libraries := $(LOCAL_HEADER_LIBRARIES) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 45 | my_cflags := $(LOCAL_CFLAGS) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 46 | my_conlyflags := $(LOCAL_CONLYFLAGS) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 47 | my_cppflags := $(LOCAL_CPPFLAGS) |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 48 | my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE) |
| 49 | my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 50 | my_ldflags := $(LOCAL_LDFLAGS) |
| 51 | my_ldlibs := $(LOCAL_LDLIBS) |
| 52 | my_asflags := $(LOCAL_ASFLAGS) |
| 53 | my_cc := $(LOCAL_CC) |
Ying Wang | c671a7c | 2015-07-20 18:40:18 -0700 | [diff] [blame] | 54 | my_cc_wrapper := $(CC_WRAPPER) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 55 | my_cxx := $(LOCAL_CXX) |
Ying Wang | c671a7c | 2015-07-20 18:40:18 -0700 | [diff] [blame] | 56 | my_cxx_wrapper := $(CXX_WRAPPER) |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 57 | my_c_includes := $(LOCAL_C_INCLUDES) |
| 58 | my_generated_sources := $(LOCAL_GENERATED_SOURCES) |
Dan Willemsen | 1c6dc5b | 2016-01-06 14:28:36 -0800 | [diff] [blame] | 59 | my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES) |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 60 | my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
Dan Willemsen | ba6a164 | 2016-09-29 12:08:29 -0700 | [diff] [blame] | 61 | my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS) |
Evgenii Stepanov | e1b96f3 | 2017-01-23 16:57:38 -0800 | [diff] [blame] | 62 | my_arflags := |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 63 | |
Ryan Campbell | 20f301f | 2016-10-18 10:25:15 -0700 | [diff] [blame] | 64 | ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH))))) |
Ryan Campbell | b55ff74 | 2017-02-27 09:09:16 -0800 | [diff] [blame] | 65 | ifeq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_EXCLUDE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH))))) |
Ryan Campbell | 81c9d29 | 2016-09-12 13:56:50 -0700 | [diff] [blame] | 66 | my_native_coverage := true |
| 67 | else |
| 68 | my_native_coverage := false |
| 69 | endif |
Ryan Campbell | b55ff74 | 2017-02-27 09:09:16 -0800 | [diff] [blame] | 70 | else |
| 71 | my_native_coverage := false |
| 72 | endif |
Ryan Campbell | 81c9d29 | 2016-09-12 13:56:50 -0700 | [diff] [blame] | 73 | |
Colin Cross | a82fa12 | 2016-10-20 12:38:21 -0700 | [diff] [blame] | 74 | my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)) |
| 75 | ifdef SANITIZE_HOST |
Dan Albert | b58fb4a | 2014-11-14 17:15:00 -0800 | [diff] [blame] | 76 | ifdef LOCAL_IS_HOST_MODULE |
| 77 | my_allow_undefined_symbols := true |
Colin Cross | a82fa12 | 2016-10-20 12:38:21 -0700 | [diff] [blame] | 78 | endif |
Dan Albert | b58fb4a | 2014-11-14 17:15:00 -0800 | [diff] [blame] | 79 | endif |
| 80 | |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 81 | my_ndk_sysroot := |
| 82 | my_ndk_sysroot_include := |
| 83 | my_ndk_sysroot_lib := |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 84 | ifneq ($(LOCAL_SDK_VERSION),) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 85 | ifdef LOCAL_IS_HOST_MODULE |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 86 | $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 87 | endif |
Nikola Veljkovic | f738562 | 2016-04-06 19:20:02 +0200 | [diff] [blame] | 88 | |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 89 | # Make sure we've built the NDK. |
Colin Cross | 723b37e | 2016-07-29 15:09:03 -0700 | [diff] [blame] | 90 | my_additional_dependencies += $(SOONG_OUT_DIR)/ndk.timestamp |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 91 | |
Nikola Veljkovic | f738562 | 2016-04-06 19:20:02 +0200 | [diff] [blame] | 92 | # mips32r6 is not supported by the NDK. No released NDK contains these |
| 93 | # libraries, but the r10 in prebuilts/ndk had a local hack to add them :( |
| 94 | # |
| 95 | # We need to find a real solution to this problem, but until we do just drop |
| 96 | # mips32r6 things back to r10 to get the tree building again. |
| 97 | ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) |
| 98 | ifeq ($(LOCAL_NDK_VERSION), current) |
| 99 | LOCAL_NDK_VERSION := r10 |
| 100 | endif |
| 101 | endif |
| 102 | |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 103 | my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
| 104 | ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) |
| 105 | my_min_sdk_version := 21 |
| 106 | else |
| 107 | my_min_sdk_version := 9 |
| 108 | endif |
| 109 | |
| 110 | # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map |
| 111 | # missing API levels to existing ones where necessary, but we're not doing |
| 112 | # that for the generated libraries. Clip the API level to the minimum where |
| 113 | # appropriate. |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 114 | my_ndk_api := $(LOCAL_SDK_VERSION) |
| 115 | ifneq ($(my_ndk_api),current) |
| 116 | my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version)) |
Dan Albert | 988107d | 2016-11-08 15:10:09 -0800 | [diff] [blame] | 117 | endif |
| 118 | |
| 119 | my_ndk_api_def := $(my_ndk_api) |
| 120 | my_ndk_hist_api := $(my_ndk_api) |
| 121 | ifeq ($(my_ndk_api),current) |
| 122 | my_ndk_api_def := __ANDROID_API_FUTURE__ |
| 123 | # The last API level supported by the old prebuilt NDKs. |
| 124 | my_ndk_hist_api := 24 |
| 125 | endif |
| 126 | |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 127 | |
Dan Albert | 754790d | 2016-08-05 16:34:40 -0700 | [diff] [blame] | 128 | # Traditionally this has come from android/api-level.h, but with the libc |
| 129 | # headers unified it must be set by the build system since we don't have |
| 130 | # per-API level copies of that header now. |
Dan Albert | 988107d | 2016-11-08 15:10:09 -0800 | [diff] [blame] | 131 | my_cflags += -D__ANDROID_API__=$(my_ndk_api_def) |
Dan Albert | 754790d | 2016-08-05 16:34:40 -0700 | [diff] [blame] | 132 | |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 133 | my_ndk_source_root := \ |
| 134 | $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources |
| 135 | my_ndk_sysroot := \ |
Dan Albert | 988107d | 2016-11-08 15:10:09 -0800 | [diff] [blame] | 136 | $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_hist_api)/arch-$(my_arch) |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 137 | my_built_ndk := $(SOONG_OUT_DIR)/ndk |
| 138 | my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE) |
| 139 | my_ndk_sysroot_include := \ |
| 140 | $(my_built_ndk)/sysroot/usr/include \ |
| 141 | $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \ |
| 142 | $(my_ndk_sysroot)/usr/include \ |
Dan Albert | 445bc2f | 2015-12-11 12:49:18 -0800 | [diff] [blame] | 143 | |
| 144 | # x86_64 and and mips64 are both multilib toolchains, so their libraries are |
| 145 | # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib |
| 146 | # compiler, so its libraries are in /usr/lib. |
| 147 | # |
| 148 | # Mips32r6 is yet another variation, with libraries installed in libr6. |
| 149 | # |
| 150 | # For the rest, the libraries are installed simply to /usr/lib. |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 151 | ifneq (,$(filter x86_64 mips64,$(my_arch))) |
| 152 | my_ndk_libdir_name := lib64 |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 153 | else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 154 | my_ndk_libdir_name := libr6 |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 155 | else |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 156 | my_ndk_libdir_name := lib |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 157 | endif |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 158 | |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 159 | my_ndk_platform_dir := \ |
| 160 | $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch) |
| 161 | my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name) |
| 162 | my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name) |
| 163 | |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 164 | # The bionic linker now has support for packed relocations and gnu style |
| 165 | # hashes (which are much faster!), but shipping to older devices requires |
| 166 | # the old style hash. Fortunately, we can build with both and it'll work |
| 167 | # anywhere. |
| 168 | # |
| 169 | # This is not currently supported on MIPS architectures. |
| 170 | ifeq (,$(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) |
| 171 | my_ldflags += -Wl,--hash-style=both |
Dan Willemsen | bab0fa6 | 2016-11-18 14:05:39 -0800 | [diff] [blame] | 172 | endif |
Dan Albert | d3d894d | 2014-11-14 15:28:49 -0800 | [diff] [blame] | 173 | |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 174 | # We don't want to expose the relocation packer to the NDK just yet. |
| 175 | LOCAL_PACK_MODULE_RELOCATIONS := false |
| 176 | |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 177 | # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. |
| 178 | # See ndk/docs/CPLUSPLUS-SUPPORT.html |
| 179 | my_ndk_stl_include_path := |
| 180 | my_ndk_stl_shared_lib_fullpath := |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 181 | my_ndk_stl_static_lib := |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 182 | my_ndk_cpp_std_version := |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 183 | my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) |
Nikola Veljkovic | f738562 | 2016-04-06 19:20:02 +0200 | [diff] [blame] | 184 | ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) |
| 185 | my_cpu_variant := mips32r6 |
| 186 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 187 | LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 188 | ifeq (,$(LOCAL_NDK_STL_VARIANT)) |
| 189 | LOCAL_NDK_STL_VARIANT := system |
| 190 | endif |
Dan Albert | 0e2e71d | 2015-12-09 14:46:13 -0800 | [diff] [blame] | 191 | ifneq (1,$(words $(filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 192 | $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 193 | endif |
| 194 | ifeq (system,$(LOCAL_NDK_STL_VARIANT)) |
| 195 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include |
Dan Albert | 0e2e71d | 2015-12-09 14:46:13 -0800 | [diff] [blame] | 196 | my_system_shared_libraries += libstdc++ |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 197 | else # LOCAL_NDK_STL_VARIANT is not system |
| 198 | ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) |
| 199 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport |
Dan Albert | 0e2e71d | 2015-12-09 14:46:13 -0800 | [diff] [blame] | 200 | my_system_shared_libraries += libstdc++ |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 201 | ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 202 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a |
Dan Albert | a81e1b7 | 2016-03-10 15:17:09 -0800 | [diff] [blame] | 203 | my_ldlibs += -ldl |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 204 | else |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 205 | my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 206 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 207 | else # LOCAL_NDK_STL_VARIANT is not stlport_* either |
| 208 | ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) |
Dan Albert | 658d1e0 | 2016-03-22 17:17:40 -0700 | [diff] [blame] | 209 | # Pre-r11 NDKs used libgabi++ for libc++'s C++ ABI, but r11 and later use |
| 210 | # libc++abi. |
Dan Albert | 0960770 | 2016-08-08 17:14:59 -0700 | [diff] [blame] | 211 | # |
| 212 | # r13 no longer has the inner directory as a side effect of just using |
| 213 | # external/libcxx. |
| 214 | ifeq (r10,$(LOCAL_NDK_VERSION)) |
| 215 | my_ndk_stl_include_path := \ |
| 216 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include |
Dan Albert | 658d1e0 | 2016-03-22 17:17:40 -0700 | [diff] [blame] | 217 | my_ndk_stl_include_path += \ |
| 218 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include |
Dan Albert | 0960770 | 2016-08-08 17:14:59 -0700 | [diff] [blame] | 219 | else ifeq (r11,$(LOCAL_NDK_VERSION)) |
| 220 | my_ndk_stl_include_path := \ |
| 221 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include |
Dan Albert | 658d1e0 | 2016-03-22 17:17:40 -0700 | [diff] [blame] | 222 | my_ndk_stl_include_path += \ |
| 223 | $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/libcxxabi/include |
Dan Albert | 0960770 | 2016-08-08 17:14:59 -0700 | [diff] [blame] | 224 | else |
| 225 | my_ndk_stl_include_path := \ |
| 226 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/include |
| 227 | my_ndk_stl_include_path += \ |
| 228 | $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include |
| 229 | endif |
| 230 | my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include |
| 231 | |
| 232 | my_libcxx_libdir := \ |
| 233 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant) |
| 234 | |
| 235 | ifneq (,$(filter r10 r11,$(LOCAL_NDK_VERSION))) |
| 236 | ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) |
| 237 | my_ndk_stl_static_lib := $(my_libcxx_libdir)/libc++_static.a |
Dan Albert | 0960770 | 2016-08-08 17:14:59 -0700 | [diff] [blame] | 238 | else |
| 239 | my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so |
| 240 | endif |
| 241 | else |
| 242 | ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) |
| 243 | my_ndk_stl_static_lib := \ |
| 244 | $(my_libcxx_libdir)/libc++_static.a \ |
| 245 | $(my_libcxx_libdir)/libc++abi.a |
Dan Albert | 0960770 | 2016-08-08 17:14:59 -0700 | [diff] [blame] | 246 | else |
| 247 | my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so |
| 248 | endif |
| 249 | |
| 250 | my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a |
| 251 | ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant))) |
| 252 | my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a |
| 253 | endif |
Dan Albert | 658d1e0 | 2016-03-22 17:17:40 -0700 | [diff] [blame] | 254 | endif |
| 255 | |
Dan Albert | 2936a1e | 2016-09-14 16:08:04 -0700 | [diff] [blame] | 256 | my_ldlibs += -ldl |
| 257 | |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 258 | my_ndk_cpp_std_version := c++11 |
Dan Albert | 0e2e71d | 2015-12-09 14:46:13 -0800 | [diff] [blame] | 259 | else # LOCAL_NDK_STL_VARIANT is not c++_* either |
| 260 | ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT))) |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 261 | 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 Cheng | 4de6fa4 | 2014-04-10 22:46:26 -0700 | [diff] [blame] | 262 | $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include |
Duane Sand | 1a07487 | 2014-11-08 15:25:18 -0800 | [diff] [blame] | 263 | 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 Albert | 0e2e71d | 2015-12-09 14:46:13 -0800 | [diff] [blame] | 264 | else # LOCAL_NDK_STL_VARIANT must be none |
| 265 | # Do nothing. |
| 266 | endif |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 267 | endif |
| 268 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 269 | endif |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 270 | endif |
| 271 | |
| 272 | ifneq ($(LOCAL_USE_VNDK),) |
| 273 | my_cflags += -D__ANDROID_API__=__ANDROID_API_FUTURE__ |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 274 | endif |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 275 | |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 276 | ifndef LOCAL_IS_HOST_MODULE |
| 277 | # For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We |
| 278 | # no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're |
| 279 | # linking my_shared_libraries by full path now. |
| 280 | my_allowed_ldlibs := |
| 281 | |
| 282 | # Sort ldlibs and ldflags between -l and other linker flags |
| 283 | # We'll do this again later, since there are still changes happening, but that's fine. |
| 284 | my_ldlib_flags := $(my_ldflags) $(my_ldlibs) |
| 285 | my_ldlibs := $(filter -l%,$(my_ldlib_flags)) |
| 286 | my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) |
| 287 | my_ldlib_flags := |
| 288 | |
| 289 | # Move other ldlibs back to shared libraries |
| 290 | my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs))) |
| 291 | my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs)) |
| 292 | endif |
| 293 | |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 294 | ifneq ($(LOCAL_SDK_VERSION),) |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 295 | my_all_ndk_libraries := \ |
| 296 | $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES)) |
| 297 | my_ndk_shared_libraries := \ |
| 298 | $(filter $(my_all_ndk_libraries),\ |
| 299 | $(my_shared_libraries) $(my_system_shared_libraries)) |
| 300 | |
| 301 | my_shared_libraries := \ |
| 302 | $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries)) |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 303 | my_system_shared_libraries := \ |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 304 | $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries)) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 305 | endif |
| 306 | |
Dan Albert | 95994de | 2014-08-07 18:29:11 -0700 | [diff] [blame] | 307 | # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because |
| 308 | # all code is position independent, and then those warnings get promoted to |
| 309 | # errors. |
Alexey Polyudov | cbb038c | 2016-08-01 17:36:39 -0700 | [diff] [blame] | 310 | ifneq ($(LOCAL_NO_PIC),true) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 311 | ifneq ($($(my_prefix)OS),windows) |
Dan Willemsen | 7fe992c | 2016-03-02 13:54:51 -0800 | [diff] [blame] | 312 | ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) |
Vishwath Mohan | c3b2556 | 2017-04-17 13:19:35 -0700 | [diff] [blame] | 313 | my_cflags += -fPIE |
Dan Albert | 4803ce2 | 2014-08-06 12:36:46 -0700 | [diff] [blame] | 314 | else |
| 315 | my_cflags += -fPIC |
| 316 | endif |
Dan Albert | 95994de | 2014-08-07 18:29:11 -0700 | [diff] [blame] | 317 | endif |
Alexey Polyudov | cbb038c | 2016-08-01 17:36:39 -0700 | [diff] [blame] | 318 | endif |
Dan Albert | 4803ce2 | 2014-08-06 12:36:46 -0700 | [diff] [blame] | 319 | |
Dan Willemsen | 7a54985 | 2015-08-13 17:51:40 -0700 | [diff] [blame] | 320 | ifdef LOCAL_IS_HOST_MODULE |
Dan Willemsen | 85ac8d2 | 2015-08-18 17:47:06 -0700 | [diff] [blame] | 321 | my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
Dan Willemsen | 7a54985 | 2015-08-13 17:51:40 -0700 | [diff] [blame] | 322 | my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS)) |
| 323 | my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS)) |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 324 | my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS)) |
Dan Willemsen | 7a54985 | 2015-08-13 17:51:40 -0700 | [diff] [blame] | 325 | my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS)) |
| 326 | my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS)) |
| 327 | my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS)) |
| 328 | my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS)) |
| 329 | my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS)) |
| 330 | my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS)) |
| 331 | my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS)) |
| 332 | endif |
| 333 | |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 334 | my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) |
Colin Cross | a04abc8 | 2015-06-30 12:21:59 -0700 | [diff] [blame] | 335 | my_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 Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 336 | my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) |
| 337 | my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) |
| 338 | my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) |
| 339 | my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) |
| 340 | my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) |
| 341 | my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) |
| 342 | my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 343 | |
Dan Willemsen | c29172c | 2015-12-03 22:58:39 -0800 | [diff] [blame] | 344 | my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude)) |
| 345 | ifneq ($(my_missing_exclude_files),) |
| 346 | $(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES) |
| 347 | $(error $(my_missing_exclude_files)) |
| 348 | endif |
Colin Cross | a04abc8 | 2015-06-30 12:21:59 -0700 | [diff] [blame] | 349 | my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files)) |
| 350 | |
Dan Willemsen | c57894c | 2016-10-28 16:30:48 -0700 | [diff] [blame] | 351 | # Strip '/' from the beginning of each src file. This helps the ../ detection in case |
| 352 | # the source file is in the form of /../file |
| 353 | my_src_files := $(patsubst /%,%,$(my_src_files)) |
| 354 | |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 355 | my_clang := $(strip $(LOCAL_CLANG)) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 356 | ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 357 | my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 358 | endif |
| 359 | ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 360 | my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 361 | endif |
| 362 | |
Alexey Polyudov | 7d6b3f1 | 2016-06-24 11:22:51 -0700 | [diff] [blame] | 363 | # if custom toolchain is in use, default is not to use clang, if not explicitly required |
| 364 | ifneq ($(my_cc)$(my_cxx),) |
| 365 | ifeq ($(my_clang),) |
| 366 | my_clang := false |
| 367 | endif |
| 368 | endif |
Chih-Hung Hsieh | d9cd1fa | 2016-08-02 14:22:06 -0700 | [diff] [blame] | 369 | # Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found |
| 370 | # in the exception project list. |
| 371 | ifeq ($(my_clang),false) |
| 372 | ifeq ($(call find_in_local_clang_exception_projects,$(LOCAL_MODULE_MAKEFILE)),) |
Chih-Hung Hsieh | 2ee4c1a | 2016-08-04 15:35:51 -0700 | [diff] [blame] | 373 | $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_CLANG is set to false) |
Chih-Hung Hsieh | d9cd1fa | 2016-08-02 14:22:06 -0700 | [diff] [blame] | 374 | endif |
| 375 | endif |
Alexey Polyudov | 7d6b3f1 | 2016-06-24 11:22:51 -0700 | [diff] [blame] | 376 | |
Tim Murray | 92d79cb | 2014-04-04 14:38:29 -0700 | [diff] [blame] | 377 | # clang is enabled by default for host builds |
| 378 | # enable it unless we've specifically disabled clang above |
| 379 | ifdef LOCAL_IS_HOST_MODULE |
Dan Willemsen | 9537477 | 2016-03-29 12:34:03 -0700 | [diff] [blame] | 380 | ifeq ($($(my_prefix)OS),windows) |
| 381 | ifeq ($(my_clang),true) |
| 382 | $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Clang is not yet supported for windows binaries) |
| 383 | endif |
| 384 | my_clang := false |
| 385 | else |
| 386 | ifeq ($(my_clang),) |
| 387 | my_clang := true |
| 388 | endif |
Tim Murray | 5ca1dc1 | 2014-07-24 14:42:53 -0700 | [diff] [blame] | 389 | endif |
Chih-Hung Hsieh | b5da9d9 | 2016-01-06 11:49:25 -0800 | [diff] [blame] | 390 | # Add option to make gcc the default for device build |
| 391 | else ifeq ($(USE_CLANG_PLATFORM_BUILD),false) |
Dan Willemsen | 7728817 | 2015-09-09 15:45:21 -0700 | [diff] [blame] | 392 | ifeq ($(my_clang),) |
Chih-Hung Hsieh | b5da9d9 | 2016-01-06 11:49:25 -0800 | [diff] [blame] | 393 | my_clang := false |
Dan Willemsen | 7728817 | 2015-09-09 15:45:21 -0700 | [diff] [blame] | 394 | endif |
Chih-Hung Hsieh | b5da9d9 | 2016-01-06 11:49:25 -0800 | [diff] [blame] | 395 | else ifeq ($(my_clang),) |
| 396 | my_clang := true |
Dan Willemsen | 7728817 | 2015-09-09 15:45:21 -0700 | [diff] [blame] | 397 | endif |
| 398 | |
Dan Albert | 76bfcd4 | 2017-02-03 16:16:11 -0800 | [diff] [blame] | 399 | ifeq ($(LOCAL_C_STD),) |
| 400 | my_c_std_version := $(DEFAULT_C_STD_VERSION) |
| 401 | else ifeq ($(LOCAL_C_STD),experimental) |
| 402 | my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION) |
| 403 | else |
| 404 | my_c_std_version := $(LOCAL_C_STD) |
| 405 | endif |
| 406 | |
| 407 | ifeq ($(LOCAL_CPP_STD),) |
| 408 | my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION) |
| 409 | else ifeq ($(LOCAL_CPP_STD),experimental) |
| 410 | my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION) |
| 411 | else |
| 412 | my_cpp_std_version := $(LOCAL_CPP_STD) |
| 413 | endif |
Dan Albert | da63739 | 2015-10-26 11:09:24 -0700 | [diff] [blame] | 414 | |
| 415 | ifneq ($(my_clang),true) |
| 416 | # GCC uses an invalid C++14 ABI (emits calls to |
| 417 | # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI). |
| 418 | # http://b/25022512 |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 419 | my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION) |
Dan Albert | da63739 | 2015-10-26 11:09:24 -0700 | [diff] [blame] | 420 | endif |
| 421 | |
Dan Albert | c7d307d | 2015-07-29 15:13:57 -0700 | [diff] [blame] | 422 | ifdef LOCAL_SDK_VERSION |
| 423 | # The NDK handles this itself. |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 424 | my_cpp_std_version := $(my_ndk_cpp_std_version) |
Dan Albert | c7d307d | 2015-07-29 15:13:57 -0700 | [diff] [blame] | 425 | endif |
| 426 | |
| 427 | ifdef LOCAL_IS_HOST_MODULE |
| 428 | ifneq ($(my_clang),true) |
| 429 | # The host GCC doesn't support C++14 (and is deprecated, so likely |
| 430 | # never will). Build these modules with C++11. |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 431 | my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION) |
Dan Albert | c7d307d | 2015-07-29 15:13:57 -0700 | [diff] [blame] | 432 | endif |
| 433 | endif |
| 434 | |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 435 | my_c_std_conlyflags := |
| 436 | my_cpp_std_cppflags := |
| 437 | ifneq (,$(my_c_std_version)) |
| 438 | my_c_std_conlyflags := -std=$(my_c_std_version) |
| 439 | endif |
Dan Albert | c7d307d | 2015-07-29 15:13:57 -0700 | [diff] [blame] | 440 | |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 441 | ifneq (,$(my_cpp_std_version)) |
| 442 | my_cpp_std_cppflags := -std=$(my_cpp_std_version) |
| 443 | endif |
Tim Murray | 06659bc | 2014-08-13 11:53:07 -0700 | [diff] [blame] | 444 | |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 445 | # arch-specific static libraries go first so that generic ones can depend on them |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 446 | my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) |
| 447 | my_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) |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 448 | my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 449 | |
Ying Wang | 75e8fcb | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 450 | include $(BUILD_SYSTEM)/cxx_stl_setup.mk |
Ying Wang | d90de32 | 2014-05-23 16:42:37 -0700 | [diff] [blame] | 451 | |
Ying Wang | 285045b | 2013-08-13 12:35:10 -0700 | [diff] [blame] | 452 | # Add static HAL libraries |
| 453 | ifdef LOCAL_HAL_STATIC_LIBRARIES |
| 454 | $(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ |
| 455 | $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 456 | $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ |
| 457 | $(eval my_static_libraries += $(lib).default))) |
Ying Wang | 285045b | 2013-08-13 12:35:10 -0700 | [diff] [blame] | 458 | b_lib := |
| 459 | endif |
| 460 | |
Nicolas Geoffray | b7c9f32 | 2015-09-25 13:54:09 +0100 | [diff] [blame] | 461 | ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),) |
| 462 | my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER) |
| 463 | else |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 464 | my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER) |
Nicolas Geoffray | b7c9f32 | 2015-09-25 13:54:09 +0100 | [diff] [blame] | 465 | endif |
Evgenii Stepanov | 8f5e67a | 2015-07-10 18:06:51 -0700 | [diff] [blame] | 466 | |
Jiyong Park | a9c4c71 | 2017-07-18 13:35:27 +0900 | [diff] [blame^] | 467 | # Modules from soong do not need this since the dependencies are already handled there. |
| 468 | ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 469 | include $(BUILD_SYSTEM)/config_sanitizers.mk |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 470 | |
Alexey Polyudov | ee27d81 | 2016-08-01 17:38:35 -0700 | [diff] [blame] | 471 | ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true) |
Shih-wei Liao | c8dfc16 | 2013-01-27 01:45:59 -0800 | [diff] [blame] | 472 | # Add in libcompiler_rt for all regular device builds |
Dan Albert | c28e4bc | 2016-09-14 16:08:48 -0700 | [diff] [blame] | 473 | ifeq (,$(WITHOUT_LIBCOMPILER_RT)) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 474 | my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) |
Stephen Hines | c72f396 | 2012-06-11 14:53:34 -0700 | [diff] [blame] | 475 | endif |
Alexey Polyudov | ee27d81 | 2016-08-01 17:38:35 -0700 | [diff] [blame] | 476 | endif |
Stephen Hines | c72f396 | 2012-06-11 14:53:34 -0700 | [diff] [blame] | 477 | |
Josh Gao | 4d9268e | 2017-02-23 13:17:46 -0800 | [diff] [blame] | 478 | # Statically link libwinpthread when cross compiling win32. |
| 479 | ifeq ($($(my_prefix)OS),windows) |
| 480 | my_static_libraries += libwinpthread |
| 481 | endif |
Jiyong Park | a9c4c71 | 2017-07-18 13:35:27 +0900 | [diff] [blame^] | 482 | endif # this module is not from soong |
Josh Gao | 4d9268e | 2017-02-23 13:17:46 -0800 | [diff] [blame] | 483 | |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 484 | ifneq ($(filter ../%,$(my_src_files)),) |
| 485 | my_soong_problems += dotdot_srcs |
| 486 | endif |
| 487 | ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),) |
| 488 | my_soong_problems += dotdot_incs |
| 489 | endif |
| 490 | ifneq ($(filter %.arm,$(my_src_files)),) |
| 491 | my_soong_problems += srcs_dotarm |
| 492 | endif |
| 493 | |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 494 | #################################################### |
| 495 | ## Add FDO flags if FDO is turned on and supported |
Dehao Chen | 295a6d2 | 2014-09-19 10:18:12 -0700 | [diff] [blame] | 496 | ## Please note that we will do option filtering during FDO build. |
| 497 | ## i.e. Os->O2, remove -fno-early-inline and -finline-limit. |
| 498 | ################################################################## |
Ying Wang | 45d0143 | 2014-10-28 14:50:59 -0700 | [diff] [blame] | 499 | my_fdo_build := |
| 500 | ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),) |
| 501 | ifeq ($(BUILD_FDO_INSTRUMENT),true) |
| 502 | my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS) |
| 503 | my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS) |
| 504 | my_fdo_build := true |
| 505 | else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),) |
| 506 | my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS) |
| 507 | my_fdo_build := true |
synergydev | 4a60576 | 2013-08-05 02:44:37 -0700 | [diff] [blame] | 508 | endif |
Shinichiro Hamaji | 09295a8 | 2015-09-24 17:51:20 +0900 | [diff] [blame] | 509 | # Disable ccache (or other compiler wrapper) except gomacc, which |
| 510 | # can handle -fprofile-use properly. |
| 511 | my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper)) |
| 512 | my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper)) |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 513 | endif |
| 514 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 515 | ########################################################### |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 516 | ## Explicitly declare assembly-only __ASSEMBLY__ macro for |
| 517 | ## assembly source |
| 518 | ########################################################### |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 519 | my_asflags += -D__ASSEMBLY__ |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 520 | |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 521 | ########################################################### |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 522 | ## Define PRIVATE_ variables from global vars |
| 523 | ########################################################### |
Ying Wang | 7fff9a1 | 2014-01-09 14:39:41 -0800 | [diff] [blame] | 524 | ifndef LOCAL_IS_HOST_MODULE |
Dan Willemsen | bab0fa6 | 2016-11-18 14:05:39 -0800 | [diff] [blame] | 525 | ifdef LOCAL_USE_VNDK |
| 526 | my_target_global_c_includes := \ |
| 527 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) |
| 528 | my_target_global_c_system_includes := \ |
Jiyong Park | 7f8be9f | 2017-07-06 09:45:26 +0900 | [diff] [blame] | 529 | $(TARGET_OUT_HEADERS) \ |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 530 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) |
Dan Willemsen | bab0fa6 | 2016-11-18 14:05:39 -0800 | [diff] [blame] | 531 | else ifdef LOCAL_SDK_VERSION |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 532 | my_target_global_c_includes := |
| 533 | my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) |
Dan Willemsen | bab0fa6 | 2016-11-18 14:05:39 -0800 | [diff] [blame] | 534 | else ifdef BOARD_VNDK_VERSION |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 535 | my_target_global_c_includes := $(SRC_HEADERS) \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 536 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \ |
| 537 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 538 | my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 539 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \ |
| 540 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) |
Dan Willemsen | bab0fa6 | 2016-11-18 14:05:39 -0800 | [diff] [blame] | 541 | else |
| 542 | my_target_global_c_includes := $(SRC_HEADERS) \ |
| 543 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \ |
| 544 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) |
| 545 | my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) $(TARGET_OUT_HEADERS) \ |
| 546 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \ |
| 547 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) |
| 548 | endif |
Ying Wang | f4723fa | 2013-08-15 11:01:10 -0700 | [diff] [blame] | 549 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 550 | ifeq ($(my_clang),true) |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 551 | my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 552 | my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) |
| 553 | my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 554 | my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 555 | else |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 556 | my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 557 | my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) |
| 558 | my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 559 | my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 560 | endif # my_clang |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 561 | |
Colin Cross | e25fd79 | 2016-07-19 13:19:21 -0700 | [diff] [blame] | 562 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes) |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 563 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 564 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 565 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 566 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) |
| 567 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) |
| 568 | |
Ying Wang | 7fff9a1 | 2014-01-09 14:39:41 -0800 | [diff] [blame] | 569 | else # LOCAL_IS_HOST_MODULE |
| 570 | |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 571 | my_host_global_c_includes := $(SRC_HEADERS) \ |
Colin Cross | e25fd79 | 2016-07-19 13:19:21 -0700 | [diff] [blame] | 572 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 573 | my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \ |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 574 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) |
Colin Cross | e25fd79 | 2016-07-19 13:19:21 -0700 | [diff] [blame] | 575 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 576 | ifeq ($(my_clang),true) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 577 | my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 578 | my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) |
| 579 | my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 580 | my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 581 | else |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 582 | my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) |
Colin Cross | e56e356 | 2016-10-17 15:34:29 -0700 | [diff] [blame] | 583 | my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) |
| 584 | my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 585 | my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 586 | endif # my_clang |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 587 | |
Colin Cross | e25fd79 | 2016-07-19 13:19:21 -0700 | [diff] [blame] | 588 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes) |
Colin Cross | 23ba612 | 2016-07-20 12:22:57 -0700 | [diff] [blame] | 589 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 590 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 591 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 592 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) |
| 593 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) |
| 594 | endif # LOCAL_IS_HOST_MODULE |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 595 | |
Dan Albert | 43e128a | 2015-01-23 16:12:57 -0800 | [diff] [blame] | 596 | # To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and |
| 597 | # build with NATIVE_COVERAGE=true in your enviornment. Note that the build |
| 598 | # system is not sensitive to changes to NATIVE_COVERAGE, so you should do a |
| 599 | # clean build of your module after toggling it. |
| 600 | ifeq ($(NATIVE_COVERAGE),true) |
| 601 | ifeq ($(my_native_coverage),true) |
Dan Albert | 343ed67 | 2015-01-25 16:20:57 -0800 | [diff] [blame] | 602 | # Note that clang coverage doesn't play nicely with acov out of the box. |
| 603 | # Clang apparently generates .gcno files that aren't compatible with |
| 604 | # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov |
| 605 | # with `--gcov-tool /usr/bin/gcov-4.6`. |
| 606 | # |
| 607 | # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output |
Dan Albert | 2c03e04 | 2015-01-24 15:14:35 -0800 | [diff] [blame] | 608 | my_cflags += --coverage -O0 |
Dan Albert | 343ed67 | 2015-01-25 16:20:57 -0800 | [diff] [blame] | 609 | my_ldflags += --coverage |
Dan Albert | 43e128a | 2015-01-23 16:12:57 -0800 | [diff] [blame] | 610 | endif |
Dan Willemsen | 7db70a3 | 2016-08-23 06:53:47 +0000 | [diff] [blame] | 611 | |
| 612 | ifeq ($(my_clang),true) |
| 613 | my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT) |
| 614 | else |
| 615 | my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$(filter AUX,$(my_kind)),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a |
| 616 | endif |
| 617 | |
| 618 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib) |
| 619 | $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib) |
Dan Albert | 43e128a | 2015-01-23 16:12:57 -0800 | [diff] [blame] | 620 | else |
| 621 | my_native_coverage := false |
| 622 | endif |
| 623 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 624 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 625 | ## Define PRIVATE_ variables used by multiple module types |
| 626 | ########################################################### |
| 627 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 628 | $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 629 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 630 | ifeq ($(strip $(WITH_STATIC_ANALYZER)),) |
| 631 | LOCAL_NO_STATIC_ANALYZER := true |
| 632 | endif |
| 633 | |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 634 | # Clang does not recognize all gcc flags. |
| 635 | # Use static analyzer only if clang is used. |
| 636 | ifneq ($(my_clang),true) |
| 637 | LOCAL_NO_STATIC_ANALYZER := true |
| 638 | endif |
| 639 | |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 640 | ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) |
| 641 | my_syntax_arch := host |
| 642 | else |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 643 | my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 644 | endif |
| 645 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 646 | ifeq ($(strip $(my_cc)),) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 647 | ifeq ($(my_clang),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 648 | my_cc := $(CLANG) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 649 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 650 | my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 651 | endif |
Ying Wang | c671a7c | 2015-07-20 18:40:18 -0700 | [diff] [blame] | 652 | my_cc := $(my_cc_wrapper) $(my_cc) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 653 | endif |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 654 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 655 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 656 | my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \ |
| 657 | $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 658 | endif |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 659 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 660 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 661 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 662 | ifeq ($(strip $(my_cxx)),) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 663 | ifeq ($(my_clang),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 664 | my_cxx := $(CLANG_CXX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 665 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 666 | my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 667 | endif |
Ying Wang | c671a7c | 2015-07-20 18:40:18 -0700 | [diff] [blame] | 668 | my_cxx := $(my_cxx_wrapper) $(my_cxx) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 669 | endif |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 670 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 671 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 672 | my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \ |
| 673 | $(SYNTAX_TOOLS_PREFIX)/c++-analyzer |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 674 | endif |
Chih-Hung Hsieh | 765c1ea | 2016-02-02 11:30:39 -0800 | [diff] [blame] | 675 | |
Evgenii Stepanov | 8f5e67a | 2015-07-10 18:06:51 -0700 | [diff] [blame] | 676 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 677 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) |
Dan Albert | b6bb71b | 2014-08-05 14:44:41 -0700 | [diff] [blame] | 678 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 679 | |
| 680 | # TODO: support a mix of standard extensions so that this isn't necessary |
| 681 | LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) |
| 682 | ifeq ($(LOCAL_CPP_EXTENSION),) |
| 683 | LOCAL_CPP_EXTENSION := .cpp |
| 684 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 685 | |
| 686 | # Certain modules like libdl have to have symbols resolved at runtime and blow |
| 687 | # up if --no-undefined is passed to the linker. |
| 688 | ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) |
Colin Cross | a82fa12 | 2016-10-20 12:38:21 -0700 | [diff] [blame] | 689 | ifeq ($(my_allow_undefined_symbols),) |
| 690 | ifneq ($(HOST_OS),darwin) |
| 691 | my_ldflags += -Wl,--no-undefined |
| 692 | endif |
| 693 | else |
| 694 | ifdef LOCAL_IS_HOST_MODULE |
| 695 | ifeq ($(HOST_OS),darwin) |
| 696 | # darwin defaults to treating undefined symbols as errors |
| 697 | my_ldflags += -Wl,-undefined,dynamic_lookup |
| 698 | endif |
| 699 | endif |
| 700 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 701 | endif |
| 702 | |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 703 | ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) |
| 704 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true |
| 705 | else |
| 706 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := |
| 707 | endif |
| 708 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 709 | ########################################################### |
| 710 | ## Define arm-vs-thumb-mode flags. |
| 711 | ########################################################### |
| 712 | LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 713 | ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 714 | arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) |
| 715 | normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) |
| 716 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 717 | # Read the values from something like TARGET_arm_CFLAGS or |
| 718 | # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't |
| 719 | # actually used (although they are usually empty). |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 720 | arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) |
| 721 | normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 722 | ifeq ($(my_clang),true) |
Dan Willemsen | 02268f0 | 2016-05-19 14:39:25 -0700 | [diff] [blame] | 723 | arm_objects_cflags := $(call convert-to-clang-flags,$(arm_objects_cflags)) |
| 724 | normal_objects_cflags := $(call convert-to-clang-flags,$(normal_objects_cflags)) |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 725 | endif |
| 726 | |
Chih-Wei Huang | 0d09e58 | 2010-07-09 10:07:52 +0800 | [diff] [blame] | 727 | else |
| 728 | arm_objects_mode := |
| 729 | normal_objects_mode := |
| 730 | arm_objects_cflags := |
| 731 | normal_objects_cflags := |
| 732 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 733 | |
| 734 | ########################################################### |
| 735 | ## Define per-module debugging flags. Users can turn on |
| 736 | ## debugging for a particular module by setting DEBUG_MODULE_ModuleName |
| 737 | ## to a non-empty value in their environment or buildspec.mk, |
| 738 | ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the |
| 739 | ## debug flags that they want to use. |
| 740 | ########################################################### |
| 741 | ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) |
| 742 | debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) |
| 743 | else |
| 744 | debug_cflags := |
| 745 | endif |
| 746 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 747 | #################################################### |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 748 | ## Keep track of src -> obj mapping |
| 749 | #################################################### |
| 750 | |
| 751 | my_tracked_gen_files := |
| 752 | my_tracked_src_files := |
| 753 | |
| 754 | ########################################################### |
| 755 | ## Stuff source generated from one-off tools |
| 756 | ########################################################### |
| 757 | $(my_generated_sources): PRIVATE_MODULE := $(my_register_name) |
| 758 | |
| 759 | my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) |
| 760 | |
Dan Willemsen | 7f01615 | 2016-02-29 17:52:39 -0800 | [diff] [blame] | 761 | $(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 762 | @echo "Copy: $@" |
| 763 | $(copy-file-to-target) |
| 764 | |
| 765 | my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) |
| 766 | |
| 767 | # Generated sources that will actually produce object files. |
| 768 | # Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES, |
| 769 | # since other compiled sources may depend on them, and we set up |
| 770 | # the dependencies. |
Dan Willemsen | 444c323 | 2016-02-04 14:18:48 -0800 | [diff] [blame] | 771 | my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 772 | |
| 773 | ALL_GENERATED_SOURCES += $(my_generated_sources) |
| 774 | |
| 775 | #################################################### |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 776 | ## Compile RenderScript with reflected C++ |
| 777 | #################################################### |
| 778 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 779 | renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 780 | |
| 781 | ifneq (,$(renderscript_sources)) |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 782 | my_soong_problems += rs |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 783 | |
| 784 | renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) |
| 785 | RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp |
| 786 | renderscript_intermediate := $(intermediates)/renderscript |
| 787 | |
Noah Presler | 4796a8c | 2015-08-13 17:04:10 -0700 | [diff] [blame] | 788 | renderscript_target_api := |
| 789 | |
| 790 | ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) |
| 791 | renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) |
| 792 | else |
| 793 | ifneq (,$(LOCAL_SDK_VERSION)) |
| 794 | # Set target-api for LOCAL_SDK_VERSIONs other than current. |
Michael Wright | 0fb087f | 2015-11-06 15:20:51 +0000 | [diff] [blame] | 795 | ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) |
Noah Presler | 4796a8c | 2015-08-13 17:04:10 -0700 | [diff] [blame] | 796 | renderscript_target_api := $(LOCAL_SDK_VERSION) |
| 797 | endif |
| 798 | endif # LOCAL_SDK_VERSION is set |
| 799 | endif # LOCAL_RENDERSCRIPT_TARGET_API is set |
| 800 | |
| 801 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 802 | ifeq ($(LOCAL_RENDERSCRIPT_CC),) |
| 803 | LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) |
| 804 | endif |
| 805 | |
| 806 | # Turn on all warnings and warnings as errors for RS compiles. |
| 807 | # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error |
| 808 | renderscript_flags := -Wall -Werror |
| 809 | renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) |
Ying Wang | acaada1 | 2014-09-10 16:11:41 -0700 | [diff] [blame] | 810 | # -m32 or -m64 |
| 811 | renderscript_flags += -m$(my_32_64_bit_suffix) |
Tim Murray | f0020c6 | 2014-09-10 15:11:01 -0700 | [diff] [blame] | 812 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 813 | renderscript_includes := \ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 814 | $(TOPDIR)external/clang/lib/Headers \ |
Jean-Luc Brouillet | eba4493 | 2017-01-08 17:40:21 -0800 | [diff] [blame] | 815 | $(TOPDIR)frameworks/rs/script_api/include \ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 816 | $(LOCAL_RENDERSCRIPT_INCLUDES) |
| 817 | |
| 818 | ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 819 | renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 820 | endif |
| 821 | |
Ying Wang | b931956 | 2015-04-03 16:15:28 -0700 | [diff] [blame] | 822 | bc_dep_files := $(addprefix $(renderscript_intermediate)/, \ |
| 823 | $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) |
| 824 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 825 | $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 826 | $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) |
| 827 | $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) |
| 828 | $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) |
| 829 | $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) |
Noah Presler | 4796a8c | 2015-08-13 17:04:10 -0700 | [diff] [blame] | 830 | $(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) |
Ying Wang | b931956 | 2015-04-03 16:15:28 -0700 | [diff] [blame] | 831 | $(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 832 | $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) |
| 833 | $(transform-renderscripts-to-cpp-and-bc) |
| 834 | |
Dan Willemsen | 461d844 | 2016-11-10 18:19:36 -0800 | [diff] [blame] | 835 | # include the dependency files (.d) generated by llvm-rs-cc. |
| 836 | $(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp)) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 837 | |
| 838 | LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) |
| 839 | |
| 840 | rs_generated_cpps := $(addprefix \ |
| 841 | $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ |
| 842 | $(notdir $(renderscript_sources))))) |
| 843 | |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 844 | $(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps)) |
| 845 | |
Stephen Hines | 8ff9252 | 2014-06-06 12:51:47 -0700 | [diff] [blame] | 846 | # This is just a dummy rule to make sure gmake doesn't skip updating the dependents. |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 847 | $(rs_generated_cpps) : $(RenderScript_file_stamp) |
Ying Wang | 81ab833 | 2014-05-28 16:17:09 -0700 | [diff] [blame] | 848 | @echo "Updated RS generated cpp file $@." |
Ying Wang | e25b398 | 2015-02-26 18:47:21 -0800 | [diff] [blame] | 849 | $(hide) touch $@ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 850 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 851 | my_c_includes += $(renderscript_intermediate) |
| 852 | my_generated_sources += $(rs_generated_cpps) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 853 | |
| 854 | endif |
| 855 | |
| 856 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 857 | ########################################################### |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 858 | ## Compile the .proto files to .cc (or .c) and then to .o |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 859 | ########################################################### |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 860 | proto_sources := $(filter %.proto,$(my_src_files)) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 861 | ifneq ($(proto_sources),) |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 862 | proto_gen_dir := $(generated_sources_dir)/proto |
Shinichiro Hamaji | a3184dc | 2016-04-05 17:34:51 +0900 | [diff] [blame] | 863 | proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 864 | |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 865 | my_rename_cpp_ext := |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 866 | ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE))) |
| 867 | my_proto_source_suffix := .c |
| 868 | my_proto_c_includes := external/nanopb-c |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 869 | my_protoc_flags := --nanopb_out=$(proto_gen_dir) \ |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 870 | --plugin=external/nanopb-c/generator/protoc-gen-nanopb |
Shinichiro Hamaji | a3184dc | 2016-04-05 17:34:51 +0900 | [diff] [blame] | 871 | my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options) |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 872 | else |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 873 | my_proto_source_suffix := $(LOCAL_CPP_EXTENSION) |
| 874 | ifneq ($(my_proto_source_suffix),.cc) |
| 875 | # aprotoc is hardcoded to write out only .cc file. |
| 876 | # We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc. |
| 877 | my_rename_cpp_ext := true |
| 878 | endif |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 879 | my_proto_c_includes := external/protobuf/src |
| 880 | my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 881 | my_protoc_flags := --cpp_out=$(proto_gen_dir) |
Shinichiro Hamaji | a3184dc | 2016-04-05 17:34:51 +0900 | [diff] [blame] | 882 | my_protoc_deps := |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 883 | endif |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 884 | my_proto_c_includes += $(proto_gen_dir) |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 885 | |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 886 | proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \ |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 887 | $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath))) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 888 | |
Ying Wang | ead8944 | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 889 | # Ensure the transform-proto-to-cc rule is only defined once in multilib build. |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 890 | ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined |
| 891 | $(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP) |
| 892 | $(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags) |
| 893 | $(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext) |
| 894 | $(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 895 | $(transform-proto-to-cc) |
| 896 | |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 897 | $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 898 | endif |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 899 | # Ideally we can generate the source directly into $(intermediates). |
| 900 | # But many Android.mks assume the .pb.hs are in $(generated_sources_dir). |
| 901 | # As a workaround, we make a copy in the $(intermediates). |
| 902 | proto_intermediate_dir := $(intermediates)/proto |
| 903 | proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\ |
| 904 | $(proto_generated_cpps)) |
| 905 | $(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/% |
| 906 | @echo "Copy: $@" |
| 907 | $(copy-file-to-target) |
| 908 | $(hide) cp $(basename $<).h $(basename $@).h |
| 909 | $(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps)) |
| 910 | |
| 911 | my_generated_sources += $(proto_intermediate_cpps) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 912 | |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 913 | my_c_includes += $(my_proto_c_includes) |
| 914 | # Auto-export the generated proto source dir. |
| 915 | my_export_c_include_dirs += $(my_proto_c_includes) |
| 916 | |
| 917 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc) |
Ying Wang | 8a0d53e | 2015-04-08 09:54:34 -0700 | [diff] [blame] | 918 | my_static_libraries += libprotobuf-c-nano-enable_malloc |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 919 | else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c) |
Ying Wang | 8a0d53e | 2015-04-08 09:54:34 -0700 | [diff] [blame] | 920 | my_static_libraries += libprotobuf-c-nano |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 921 | else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) |
Dan Albert | c3031c7 | 2014-11-11 10:42:17 -0800 | [diff] [blame] | 922 | ifdef LOCAL_SDK_VERSION |
Dan Albert | a187fb5 | 2015-09-08 10:47:03 -0700 | [diff] [blame] | 923 | my_static_libraries += libprotobuf-cpp-full-ndk |
Dan Albert | c3031c7 | 2014-11-11 10:42:17 -0800 | [diff] [blame] | 924 | else |
| 925 | my_shared_libraries += libprotobuf-cpp-full |
| 926 | endif |
Yabin Cui | 72a1156 | 2016-06-07 19:21:12 -0700 | [diff] [blame] | 927 | else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static) |
| 928 | my_static_libraries += libprotobuf-cpp-lite |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 929 | else |
Dan Albert | c3031c7 | 2014-11-11 10:42:17 -0800 | [diff] [blame] | 930 | ifdef LOCAL_SDK_VERSION |
Dan Albert | a187fb5 | 2015-09-08 10:47:03 -0700 | [diff] [blame] | 931 | my_static_libraries += libprotobuf-cpp-lite-ndk |
Dan Albert | c3031c7 | 2014-11-11 10:42:17 -0800 | [diff] [blame] | 932 | else |
| 933 | my_shared_libraries += libprotobuf-cpp-lite |
| 934 | endif |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 935 | endif |
Ying Wang | ead8944 | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 936 | endif # $(proto_sources) non-empty |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 937 | |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 938 | ########################################################### |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 939 | ## AIDL: Compile .aidl files to .cpp and .h files |
| 940 | ########################################################### |
| 941 | aidl_src := $(strip $(filter %.aidl,$(my_src_files))) |
| 942 | aidl_gen_cpp := |
| 943 | ifneq ($(aidl_src),) |
| 944 | |
Christopher Wiley | 257796c | 2016-01-19 08:58:35 -0800 | [diff] [blame] | 945 | # Use the intermediates directory to avoid writing our own .cpp -> .o rules. |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 946 | aidl_gen_cpp_root := $(intermediates)/aidl-generated/src |
| 947 | aidl_gen_include_root := $(intermediates)/aidl-generated/include |
| 948 | |
Christopher Wiley | 257796c | 2016-01-19 08:58:35 -0800 | [diff] [blame] | 949 | # Multi-architecture builds have distinct intermediates directories. |
| 950 | # Thus we'll actually generate source for each architecture. |
| 951 | $(foreach s,$(aidl_src),\ |
| 952 | $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp))) |
Christopher Wiley | 087f327 | 2016-01-19 09:26:10 -0800 | [diff] [blame] | 953 | $(foreach cpp,$(aidl_gen_cpp), \ |
Dan Willemsen | fb84281 | 2016-11-13 09:42:19 -0800 | [diff] [blame] | 954 | $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 955 | $(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp)) |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 956 | |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 957 | $(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) |
| 958 | $(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root) |
| 959 | $(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) |
| 960 | |
Christopher Wiley | c7e936f | 2015-11-19 07:06:01 -0800 | [diff] [blame] | 961 | # Add generated headers to include paths. |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 962 | my_c_includes += $(aidl_gen_include_root) |
Christopher Wiley | c7e936f | 2015-11-19 07:06:01 -0800 | [diff] [blame] | 963 | my_export_c_include_dirs += $(aidl_gen_include_root) |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 964 | # Pick up the generated C++ files later for transformation to .o files. |
| 965 | my_generated_sources += $(aidl_gen_cpp) |
| 966 | |
| 967 | endif # $(aidl_src) non-empty |
| 968 | |
| 969 | ########################################################### |
Keun Soo Yim | 3d48475 | 2016-02-19 11:06:58 -0800 | [diff] [blame] | 970 | ## Compile the .vts files to .cc (or .c) and then to .o |
| 971 | ########################################################### |
| 972 | |
| 973 | vts_src := $(strip $(filter %.vts,$(my_src_files))) |
| 974 | vts_gen_cpp := |
| 975 | ifneq ($(vts_src),) |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 976 | my_soong_problems += vts |
Keun Soo Yim | 3d48475 | 2016-02-19 11:06:58 -0800 | [diff] [blame] | 977 | |
| 978 | # Use the intermediates directory to avoid writing our own .cpp -> .o rules. |
| 979 | vts_gen_cpp_root := $(intermediates)/vts-generated/src |
| 980 | vts_gen_include_root := $(intermediates)/vts-generated/include |
| 981 | |
| 982 | # Multi-architecture builds have distinct intermediates directories. |
| 983 | # Thus we'll actually generate source for each architecture. |
| 984 | $(foreach s,$(vts_src),\ |
| 985 | $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp))) |
| 986 | $(foreach cpp,$(vts_gen_cpp), \ |
| 987 | $(call include-depfile,$(addsuffix .vts.P,$(basename $(cpp))),$(cpp))) |
| 988 | $(call track-src-file-gen,$(vts_src),$(vts_gen_cpp)) |
| 989 | |
| 990 | $(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) |
| 991 | $(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root) |
| 992 | $(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) |
| 993 | |
| 994 | # Add generated headers to include paths. |
| 995 | my_c_includes += $(vts_gen_include_root) |
| 996 | my_export_c_include_dirs += $(vts_gen_include_root) |
| 997 | # Pick up the generated C++ files later for transformation to .o files. |
| 998 | my_generated_sources += $(vts_gen_cpp) |
| 999 | |
| 1000 | endif # $(vts_src) non-empty |
| 1001 | |
| 1002 | ########################################################### |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1003 | ## YACC: Compile .y/.yy files to .c/.cpp and then to .o. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1004 | ########################################################### |
| 1005 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1006 | y_yacc_sources := $(filter %.y,$(my_src_files)) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1007 | y_yacc_cs := $(addprefix \ |
| 1008 | $(intermediates)/,$(y_yacc_sources:.y=.c)) |
| 1009 | ifneq ($(y_yacc_cs),) |
| 1010 | $(y_yacc_cs): $(intermediates)/%.c: \ |
Shinichiro Hamaji | b708bc5 | 2016-04-05 20:12:48 +0900 | [diff] [blame] | 1011 | $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) \ |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1012 | $(my_additional_dependencies) |
| 1013 | $(call transform-y-to-c-or-cpp) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1014 | $(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs)) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1015 | |
| 1016 | my_generated_sources += $(y_yacc_cs) |
| 1017 | endif |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1018 | |
| 1019 | yy_yacc_sources := $(filter %.yy,$(my_src_files)) |
| 1020 | yy_yacc_cpps := $(addprefix \ |
| 1021 | $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1022 | ifneq ($(yy_yacc_cpps),) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1023 | $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
Shinichiro Hamaji | b708bc5 | 2016-04-05 20:12:48 +0900 | [diff] [blame] | 1024 | $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) \ |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1025 | $(my_additional_dependencies) |
| 1026 | $(call transform-y-to-c-or-cpp) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1027 | $(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps)) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1028 | |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1029 | my_generated_sources += $(yy_yacc_cpps) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1030 | endif |
| 1031 | |
| 1032 | ########################################################### |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1033 | ## LEX: Compile .l/.ll files to .c/.cpp and then to .o. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1034 | ########################################################### |
| 1035 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1036 | l_lex_sources := $(filter %.l,$(my_src_files)) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1037 | l_lex_cs := $(addprefix \ |
| 1038 | $(intermediates)/,$(l_lex_sources:.l=.c)) |
| 1039 | ifneq ($(l_lex_cs),) |
| 1040 | $(l_lex_cs): $(intermediates)/%.c: \ |
| 1041 | $(TOPDIR)$(LOCAL_PATH)/%.l |
| 1042 | $(transform-l-to-c-or-cpp) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1043 | $(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs)) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1044 | |
| 1045 | my_generated_sources += $(l_lex_cs) |
| 1046 | endif |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1047 | |
| 1048 | ll_lex_sources := $(filter %.ll,$(my_src_files)) |
| 1049 | ll_lex_cpps := $(addprefix \ |
| 1050 | $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1051 | ifneq ($(ll_lex_cpps),) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1052 | $(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 1053 | $(TOPDIR)$(LOCAL_PATH)/%.ll |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1054 | $(transform-l-to-c-or-cpp) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1055 | $(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps)) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 1056 | |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 1057 | my_generated_sources += $(ll_lex_cpps) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1058 | endif |
| 1059 | |
| 1060 | ########################################################### |
| 1061 | ## C++: Compile .cpp files to .o. |
| 1062 | ########################################################### |
| 1063 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 1064 | # we also do this on host modules, even though |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1065 | # it's not really arm, because there are files that are shared. |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1066 | cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) |
| 1067 | dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources)) |
| 1068 | cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources)) |
| 1069 | cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1070 | $(call track-src-file-obj,$(patsubst %,%.arm,$(cpp_arm_sources)),$(cpp_arm_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1071 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1072 | # For source files starting with ../, we remove all the ../ in the object file path, |
| 1073 | # to avoid object file escaping the intermediate directory. |
| 1074 | dotdot_arm_objects := |
| 1075 | $(foreach s,$(dotdot_arm_sources),\ |
| 1076 | $(eval $(call compile-dotdot-cpp-file,$(s),\ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1077 | $(my_additional_dependencies),\ |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1078 | dotdot_arm_objects))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1079 | $(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1080 | |
| 1081 | dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files)) |
| 1082 | dotdot_objects := |
| 1083 | $(foreach s,$(dotdot_sources),\ |
| 1084 | $(eval $(call compile-dotdot-cpp-file,$(s),\ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1085 | $(my_additional_dependencies),\ |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1086 | dotdot_objects))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1087 | $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1088 | |
| 1089 | cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1090 | cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1091 | $(call track-src-file-obj,$(cpp_normal_sources),$(cpp_normal_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1092 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1093 | $(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 1094 | $(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 1095 | $(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 1096 | $(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1097 | |
| 1098 | cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) |
| 1099 | |
| 1100 | ifneq ($(strip $(cpp_objects)),) |
| 1101 | $(cpp_objects): $(intermediates)/%.o: \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 1102 | $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1103 | $(my_additional_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1104 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1105 | $(call include-depfiles-for-objs, $(cpp_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1106 | endif |
| 1107 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1108 | cpp_objects += $(dotdot_arm_objects) $(dotdot_objects) |
| 1109 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1110 | ########################################################### |
| 1111 | ## C++: Compile generated .cpp files to .o. |
| 1112 | ########################################################### |
| 1113 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1114 | gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1115 | gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1116 | $(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1117 | |
| 1118 | ifneq ($(strip $(gen_cpp_objects)),) |
| 1119 | # Compile all generated files as thumb. |
| 1120 | # TODO: support compiling certain generated files as arm. |
| 1121 | $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 1122 | $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 1123 | $(gen_cpp_objects): $(intermediates)/%.o: \ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1124 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1125 | $(my_additional_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1126 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1127 | $(call include-depfiles-for-objs, $(gen_cpp_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1128 | endif |
| 1129 | |
| 1130 | ########################################################### |
| 1131 | ## S: Compile generated .S and .s files to .o. |
| 1132 | ########################################################### |
| 1133 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1134 | gen_S_sources := $(filter %.S,$(my_generated_sources)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1135 | gen_S_objects := $(gen_S_sources:%.S=%.o) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1136 | $(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1137 | |
| 1138 | ifneq ($(strip $(gen_S_sources)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 1139 | $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1140 | $(my_additional_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1141 | $(transform-$(PRIVATE_HOST)s-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1142 | $(call include-depfiles-for-objs, $(gen_S_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1143 | endif |
| 1144 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1145 | gen_s_sources := $(filter %.s,$(my_generated_sources)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1146 | gen_s_objects := $(gen_s_sources:%.s=%.o) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1147 | $(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1148 | |
| 1149 | ifneq ($(strip $(gen_s_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 1150 | $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1151 | $(my_additional_dependencies) |
Dan Willemsen | 461d844 | 2016-11-10 18:19:36 -0800 | [diff] [blame] | 1152 | $(transform-$(PRIVATE_HOST)s-to-o) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1153 | endif |
| 1154 | |
| 1155 | gen_asm_objects := $(gen_S_objects) $(gen_s_objects) |
Dan Willemsen | 45d38c0 | 2016-01-15 16:38:46 -0800 | [diff] [blame] | 1156 | $(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1157 | |
| 1158 | ########################################################### |
Torne (Richard Coles) | aace202 | 2013-02-21 14:01:35 +0000 | [diff] [blame] | 1159 | ## o: Include generated .o files in output. |
| 1160 | ########################################################### |
| 1161 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1162 | gen_o_objects := $(filter %.o,$(my_generated_sources)) |
Torne (Richard Coles) | aace202 | 2013-02-21 14:01:35 +0000 | [diff] [blame] | 1163 | |
| 1164 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1165 | ## C: Compile .c files to .o. |
| 1166 | ########################################################### |
| 1167 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1168 | c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) |
| 1169 | dotdot_arm_sources := $(filter ../%,$(c_arm_sources)) |
| 1170 | c_arm_sources := $(filter-out ../%,$(c_arm_sources)) |
| 1171 | c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1172 | $(call track-src-file-obj,$(patsubst %,%.arm,$(c_arm_sources)),$(c_arm_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1173 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1174 | # For source files starting with ../, we remove all the ../ in the object file path, |
| 1175 | # to avoid object file escaping the intermediate directory. |
| 1176 | dotdot_arm_objects := |
| 1177 | $(foreach s,$(dotdot_arm_sources),\ |
| 1178 | $(eval $(call compile-dotdot-c-file,$(s),\ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1179 | $(my_additional_dependencies),\ |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1180 | dotdot_arm_objects))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1181 | $(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1182 | |
| 1183 | dotdot_sources := $(filter ../%.c, $(my_src_files)) |
| 1184 | dotdot_objects := |
| 1185 | $(foreach s, $(dotdot_sources),\ |
| 1186 | $(eval $(call compile-dotdot-c-file,$(s),\ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1187 | $(my_additional_dependencies),\ |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1188 | dotdot_objects))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1189 | $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1190 | |
| 1191 | c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1192 | c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1193 | $(call track-src-file-obj,$(c_normal_sources),$(c_normal_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1194 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1195 | $(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 1196 | $(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 1197 | $(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 1198 | $(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1199 | |
| 1200 | c_objects := $(c_arm_objects) $(c_normal_objects) |
| 1201 | |
| 1202 | ifneq ($(strip $(c_objects)),) |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1203 | $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1204 | $(my_additional_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1205 | $(transform-$(PRIVATE_HOST)c-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1206 | $(call include-depfiles-for-objs, $(c_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1207 | endif |
| 1208 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1209 | c_objects += $(dotdot_arm_objects) $(dotdot_objects) |
| 1210 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1211 | ########################################################### |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 1212 | ## C: Compile generated .c files to .o. |
| 1213 | ########################################################### |
| 1214 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1215 | gen_c_sources := $(filter %.c,$(my_generated_sources)) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 1216 | gen_c_objects := $(gen_c_sources:%.c=%.o) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1217 | $(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects)) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 1218 | |
| 1219 | ifneq ($(strip $(gen_c_objects)),) |
| 1220 | # Compile all generated files as thumb. |
| 1221 | # TODO: support compiling certain generated files as arm. |
| 1222 | $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 1223 | $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1224 | $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1225 | $(my_additional_dependencies) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 1226 | $(transform-$(PRIVATE_HOST)c-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1227 | $(call include-depfiles-for-objs, $(gen_c_objects)) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 1228 | endif |
| 1229 | |
| 1230 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1231 | ## ObjC: Compile .m files to .o |
| 1232 | ########################################################### |
| 1233 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 1234 | objc_sources := $(filter %.m,$(my_src_files)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1235 | objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) |
Dan Willemsen | 62f2e56 | 2016-02-01 18:55:23 -0800 | [diff] [blame] | 1236 | $(call track-src-file-obj,$(objc_sources),$(objc_objects)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1237 | |
| 1238 | ifneq ($(strip $(objc_objects)),) |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 1239 | my_soong_problems += objc |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1240 | $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1241 | $(my_additional_dependencies) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1242 | $(transform-$(PRIVATE_HOST)m-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1243 | $(call include-depfiles-for-objs, $(objc_objects)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1244 | endif |
| 1245 | |
| 1246 | ########################################################### |
Scott James Remnant | dd86e5a | 2015-09-17 15:40:49 -0700 | [diff] [blame] | 1247 | ## ObjC++: Compile .mm files to .o |
| 1248 | ########################################################### |
| 1249 | |
| 1250 | objcpp_sources := $(filter %.mm,$(my_src_files)) |
| 1251 | objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o)) |
Dan Willemsen | 62f2e56 | 2016-02-01 18:55:23 -0800 | [diff] [blame] | 1252 | $(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects)) |
Scott James Remnant | dd86e5a | 2015-09-17 15:40:49 -0700 | [diff] [blame] | 1253 | |
| 1254 | ifneq ($(strip $(objcpp_objects)),) |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1255 | $(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \ |
Scott James Remnant | dd86e5a | 2015-09-17 15:40:49 -0700 | [diff] [blame] | 1256 | $(my_additional_dependencies) |
| 1257 | $(transform-$(PRIVATE_HOST)mm-to-o) |
Shinichiro Hamaji | 4037c42 | 2016-03-03 18:12:52 +0900 | [diff] [blame] | 1258 | $(call include-depfiles-for-objs, $(objcpp_objects)) |
Scott James Remnant | dd86e5a | 2015-09-17 15:40:49 -0700 | [diff] [blame] | 1259 | endif |
| 1260 | |
| 1261 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1262 | ## AS: Compile .S files to .o. |
| 1263 | ########################################################### |
| 1264 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 1265 | asm_sources_S := $(filter %.S,$(my_src_files)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1266 | dotdot_sources := $(filter ../%,$(asm_sources_S)) |
| 1267 | asm_sources_S := $(filter-out ../%,$(asm_sources_S)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1268 | asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1269 | $(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1270 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1271 | dotdot_objects_S := |
| 1272 | $(foreach s,$(dotdot_sources),\ |
| 1273 | $(eval $(call compile-dotdot-s-file,$(s),\ |
| 1274 | $(my_additional_dependencies),\ |
| 1275 | dotdot_objects_S))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1276 | $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1277 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1278 | ifneq ($(strip $(asm_objects_S)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 1279 | $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1280 | $(my_additional_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1281 | $(transform-$(PRIVATE_HOST)s-to-o) |
Shinichiro Hamaji | 7290477 | 2016-03-16 06:40:04 +0900 | [diff] [blame] | 1282 | $(call include-depfiles-for-objs, $(asm_objects_S)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1283 | endif |
| 1284 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 1285 | asm_sources_s := $(filter %.s,$(my_src_files)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1286 | dotdot_sources := $(filter ../%,$(asm_sources_s)) |
| 1287 | asm_sources_s := $(filter-out ../%,$(asm_sources_s)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1288 | asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1289 | $(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1290 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1291 | dotdot_objects_s := |
| 1292 | $(foreach s,$(dotdot_sources),\ |
| 1293 | $(eval $(call compile-dotdot-s-file-no-deps,$(s),\ |
| 1294 | $(my_additional_dependencies),\ |
| 1295 | dotdot_objects_s))) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1296 | $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s)) |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1297 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1298 | ifneq ($(strip $(asm_objects_s)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 1299 | $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1300 | $(my_additional_dependencies) |
Dan Willemsen | 461d844 | 2016-11-10 18:19:36 -0800 | [diff] [blame] | 1301 | $(transform-$(PRIVATE_HOST)s-to-o) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1302 | endif |
| 1303 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1304 | asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s) |
Dan Willemsen | 45d38c0 | 2016-01-15 16:38:46 -0800 | [diff] [blame] | 1305 | $(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1306 | |
| 1307 | |
Ying Wang | fe1e5c3 | 2015-03-09 18:57:40 -0700 | [diff] [blame] | 1308 | # .asm for x86/x86_64 needs to be compiled with yasm. |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1309 | asm_sources_asm := $(filter %.asm,$(my_src_files)) |
| 1310 | ifneq ($(strip $(asm_sources_asm)),) |
| 1311 | asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) |
| 1312 | $(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 1313 | $(my_additional_dependencies) |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1314 | $(transform-asm-to-o) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1315 | $(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm)) |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1316 | |
| 1317 | asm_objects += $(asm_objects_asm) |
| 1318 | endif |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1319 | |
Jiyong Park | c8f57d9 | 2017-04-18 20:15:14 +0900 | [diff] [blame] | 1320 | ########################################################### |
| 1321 | ## When compiling against the VNDK, use LL-NDK libraries |
| 1322 | ########################################################### |
| 1323 | ifneq ($(LOCAL_USE_VNDK),) |
| 1324 | #################################################### |
| 1325 | ## Soong modules may be built twice, once for /system |
| 1326 | ## and once for /vendor. If we're using the VNDK, |
| 1327 | ## switch all soong libraries over to the /vendor |
| 1328 | ## variant. |
| 1329 | #################################################### |
Jiyong Park | a9c4c71 | 2017-07-18 13:35:27 +0900 | [diff] [blame^] | 1330 | ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) |
| 1331 | # We don't do this renaming for soong-defined modules since they already have correct |
| 1332 | # names (with .vendor suffix when necessary) in their LOCAL_*_LIBRARIES. |
Jiyong Park | c8f57d9 | 2017-04-18 20:15:14 +0900 | [diff] [blame] | 1333 | my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\ |
| 1334 | $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) |
| 1335 | my_static_libraries := $(foreach l,$(my_static_libraries),\ |
| 1336 | $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) |
| 1337 | my_shared_libraries := $(foreach l,$(my_shared_libraries),\ |
| 1338 | $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) |
| 1339 | my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\ |
| 1340 | $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) |
| 1341 | my_header_libraries := $(foreach l,$(my_header_libraries),\ |
| 1342 | $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l))) |
| 1343 | endif |
| 1344 | endif |
Jeff Davidson | 680f071 | 2015-01-08 18:25:30 -0800 | [diff] [blame] | 1345 | |
| 1346 | ########################################################## |
| 1347 | ## Set up installed module dependency |
| 1348 | ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for |
| 1349 | ## they may cusomize their install path with LOCAL_MODULE_PATH |
| 1350 | ########################################################## |
| 1351 | # Get the list of INSTALLED libraries as module names. |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1352 | ifneq ($(LOCAL_SDK_VERSION),) |
Jeff Davidson | 680f071 | 2015-01-08 18:25:30 -0800 | [diff] [blame] | 1353 | installed_shared_library_module_names := \ |
| 1354 | $(my_shared_libraries) |
| 1355 | else |
| 1356 | installed_shared_library_module_names := \ |
| 1357 | $(my_shared_libraries) $(my_system_shared_libraries) |
| 1358 | endif |
| 1359 | |
| 1360 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 1361 | # of the shared libraries are determined. |
| 1362 | ifdef LOCAL_INSTALLED_MODULE |
| 1363 | ifdef installed_shared_library_module_names |
| 1364 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
Dimitry Ivanov | cdf3927 | 2017-06-26 13:13:44 -0700 | [diff] [blame] | 1365 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names)) |
Jeff Davidson | 680f071 | 2015-01-08 18:25:30 -0800 | [diff] [blame] | 1366 | endif |
| 1367 | endif |
| 1368 | |
| 1369 | |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1370 | #################################################### |
| 1371 | ## Import includes |
| 1372 | #################################################### |
| 1373 | import_includes := $(intermediates)/import_includes |
| 1374 | import_includes_deps := $(strip \ |
Jiyong Park | 0c59dab | 2017-07-03 13:14:52 +0900 | [diff] [blame] | 1375 | $(if $(LOCAL_USE_VNDK),\ |
Jiyong Park | a9c4c71 | 2017-07-18 13:35:27 +0900 | [diff] [blame^] | 1376 | $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1377 | $(foreach l, $(installed_shared_library_module_names), \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1378 | $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 1379 | $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 1380 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ |
| 1381 | $(foreach l, $(my_header_libraries), \ |
| 1382 | $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) |
Ying Wang | 14d02a3 | 2015-01-22 15:44:04 -0800 | [diff] [blame] | 1383 | $(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) |
Dan Willemsen | 1c6dc5b | 2016-01-06 14:28:36 -0800 | [diff] [blame] | 1384 | $(import_includes) : $(import_includes_deps) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1385 | @echo Import includes file: $@ |
| 1386 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 1387 | ifdef import_includes_deps |
Ying Wang | 14d02a3 | 2015-01-22 15:44:04 -0800 | [diff] [blame] | 1388 | $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \ |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1389 | cat $$f >> $@; \ |
| 1390 | done |
| 1391 | else |
| 1392 | $(hide) touch $@ |
| 1393 | endif |
| 1394 | |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1395 | #################################################### |
| 1396 | ## Verify that NDK-built libraries only link against |
| 1397 | ## other NDK-built libraries |
| 1398 | #################################################### |
| 1399 | |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1400 | ifdef LOCAL_SDK_VERSION |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 1401 | my_link_type := native:ndk |
| 1402 | my_warn_types := |
| 1403 | my_allowed_types := native:ndk |
Dan Willemsen | 9d2b328 | 2017-04-07 20:58:43 -0700 | [diff] [blame] | 1404 | else ifdef LOCAL_USE_VNDK |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 1405 | my_link_type := native:vendor |
| 1406 | my_warn_types := |
| 1407 | my_allowed_types := native:vendor |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1408 | else |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 1409 | my_link_type := native:platform |
| 1410 | my_warn_types := |
| 1411 | my_allowed_types := native:ndk native:platform |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1412 | endif |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1413 | |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 1414 | my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries)) |
| 1415 | ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 1416 | my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries)) |
| 1417 | endif |
| 1418 | |
| 1419 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 1420 | my_common := |
| 1421 | include $(BUILD_SYSTEM)/link_type.mk |
Dan Willemsen | b097fbe | 2016-06-07 14:25:14 -0700 | [diff] [blame] | 1422 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1423 | ########################################################### |
| 1424 | ## Common object handling. |
| 1425 | ########################################################### |
| 1426 | |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1427 | my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files)) |
| 1428 | ifneq ($(my_unused_src_files),) |
Dan Willemsen | 9efeb1e | 2016-06-28 10:22:08 -0700 | [diff] [blame] | 1429 | $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1430 | endif |
| 1431 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1432 | # some rules depend on asm_objects being first. If your code depends on |
| 1433 | # being first, it's reasonable to require it to be assembly |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 1434 | normal_objects := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 1435 | $(asm_objects) \ |
| 1436 | $(cpp_objects) \ |
| 1437 | $(gen_cpp_objects) \ |
| 1438 | $(gen_asm_objects) \ |
| 1439 | $(c_objects) \ |
| 1440 | $(gen_c_objects) \ |
| 1441 | $(objc_objects) \ |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1442 | $(objcpp_objects) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1443 | |
| 1444 | new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f))) |
| 1445 | new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f))) |
| 1446 | |
| 1447 | ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects))) |
| 1448 | $(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old) |
| 1449 | $(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects)))) |
| 1450 | $(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects)))) |
| 1451 | endif |
| 1452 | |
| 1453 | ifeq ($(BINARY_OBJECTS_ORDER),soong) |
| 1454 | normal_objects := $(new_order_normal_objects) |
| 1455 | endif |
| 1456 | |
| 1457 | normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 1458 | |
| 1459 | all_objects := $(normal_objects) $(gen_o_objects) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1460 | |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 1461 | # Cleanup file tracking |
| 1462 | $(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=)) |
| 1463 | my_tracked_gen_files := |
| 1464 | $(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=)) |
| 1465 | my_tracked_src_files := |
| 1466 | |
Colin Cross | 2d20670 | 2014-02-13 13:41:52 -0800 | [diff] [blame] | 1467 | my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1468 | |
Jiyong Park | b43a52d | 2017-07-13 15:51:07 +0900 | [diff] [blame] | 1469 | # The platform JNI header is for platform modules only. |
| 1470 | ifeq ($(LOCAL_SDK_VERSION)$(LOCAL_USE_VNDK),) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1471 | my_c_includes += $(JNI_H_INCLUDE) |
Ying Wang | bce4b75 | 2010-07-22 15:51:56 -0700 | [diff] [blame] | 1472 | endif |
| 1473 | |
Dan Willemsen | 062e30b | 2016-05-24 13:06:07 -0700 | [diff] [blame] | 1474 | my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes))) |
| 1475 | ifneq ($(my_outside_includes),) |
| 1476 | $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): C_INCLUDES must be under the source or output directories: $(my_outside_includes)) |
| 1477 | endif |
| 1478 | |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 1479 | # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; |
| 1480 | # use normal_objects here to avoid creating circular dependencies. This assumes |
| 1481 | # that custom build rules which generate .o files don't consume other generated |
| 1482 | # sources as input (or if they do they take care of that dependency themselves). |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 1483 | $(normal_objects) : | $(my_generated_sources) |
Colin Cross | 6b9bddd | 2015-11-30 17:33:26 -0800 | [diff] [blame] | 1484 | $(all_objects) : $(import_includes) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1485 | ALL_C_CPP_ETC_OBJECTS += $(all_objects) |
| 1486 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1487 | |
| 1488 | ########################################################### |
| 1489 | # Standard library handling. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1490 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1491 | |
| 1492 | ########################################################### |
| 1493 | # The list of libraries that this module will link against are in |
| 1494 | # these variables. Each is a list of bare module names like "libc libm". |
| 1495 | # |
| 1496 | # LOCAL_SHARED_LIBRARIES |
| 1497 | # LOCAL_STATIC_LIBRARIES |
| 1498 | # LOCAL_WHOLE_STATIC_LIBRARIES |
| 1499 | # |
| 1500 | # We need to convert the bare names into the dependencies that |
| 1501 | # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. |
| 1502 | # LOCAL_BUILT_MODULE should depend on the BUILT versions of the |
| 1503 | # libraries, so that simply building this module doesn't force |
| 1504 | # an install of a library. Similarly, LOCAL_INSTALLED_MODULE |
| 1505 | # should depend on the INSTALLED versions of the libraries so |
| 1506 | # that they get installed when this module does. |
| 1507 | ########################################################### |
| 1508 | # NOTE: |
| 1509 | # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the |
| 1510 | # module without leaving anything out, which is useful for turning |
| 1511 | # a collection of .a files into a .so file. Linking against a |
| 1512 | # normal STATIC_LIBRARY will only pull in code/symbols that are |
| 1513 | # referenced by the module. (see gcc/ld's --whole-archive option) |
| 1514 | ########################################################### |
| 1515 | |
| 1516 | # Get the list of BUILT libraries, which are under |
| 1517 | # various intermediates directories. |
| 1518 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 1519 | a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) |
| 1520 | |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1521 | ifneq ($(LOCAL_SDK_VERSION),) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1522 | built_shared_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1523 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1524 | $(addsuffix $(so_suffix), \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1525 | $(my_shared_libraries))) |
Ying Wang | c01f2dc | 2015-12-15 10:00:19 -0800 | [diff] [blame] | 1526 | built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1527 | |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 1528 | # Add the NDK libraries to the built module dependency |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 1529 | my_system_shared_libraries_fullpath := \ |
| 1530 | $(my_ndk_stl_shared_lib_fullpath) \ |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 1531 | $(addprefix $(my_ndk_sysroot_lib)/, \ |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 1532 | $(addsuffix $(so_suffix), $(my_system_shared_libraries))) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1533 | |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 1534 | # We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of |
| 1535 | # whether the libs are generated or prebuilt, so we simply can't split into two |
| 1536 | # lists and use addprefix. |
| 1537 | my_ndk_shared_libraries_fullpath := \ |
| 1538 | $(foreach _lib,$(my_ndk_shared_libraries),\ |
| 1539 | $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\ |
| 1540 | $(my_built_ndk_libs)/$(_lib)$(so_suffix),\ |
| 1541 | $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix))) |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 1542 | |
| 1543 | built_shared_libraries += \ |
Dan Albert | c1ca190 | 2016-08-04 14:14:50 -0700 | [diff] [blame] | 1544 | $(my_ndk_shared_libraries_fullpath) \ |
Dan Albert | 02bf138 | 2016-07-21 10:04:12 -0700 | [diff] [blame] | 1545 | $(my_system_shared_libraries_fullpath) \ |
| 1546 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1547 | else |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1548 | built_shared_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1549 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1550 | $(addsuffix $(so_suffix), \ |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 1551 | $(installed_shared_library_module_names))) |
Ying Wang | c01f2dc | 2015-12-15 10:00:19 -0800 | [diff] [blame] | 1552 | built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) |
Shinichiro Hamaji | 0e7587a | 2015-10-09 14:36:04 +0900 | [diff] [blame] | 1553 | my_system_shared_libraries_fullpath := |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1554 | endif |
| 1555 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1556 | built_static_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1557 | $(foreach lib,$(my_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1558 | $(call intermediates-dir-for, \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1559 | STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1560 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 1561 | ifdef LOCAL_SDK_VERSION |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 1562 | built_static_libraries += $(my_ndk_stl_static_lib) |
| 1563 | endif |
| 1564 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1565 | built_whole_libraries := \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 1566 | $(foreach lib,$(my_whole_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1567 | $(call intermediates-dir-for, \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1568 | STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1569 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1570 | # We don't care about installed static libraries, since the |
| 1571 | # libraries have already been linked into the module at that point. |
| 1572 | # We do, however, care about the NOTICE files for any static |
Steve Block | d14d3b4 | 2012-03-01 11:34:41 +0000 | [diff] [blame] | 1573 | # libraries that we use. (see notice_files.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1574 | |
| 1575 | installed_static_library_notice_file_targets := \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 1576 | $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1577 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) |
| 1578 | |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1579 | # Default is -fno-rtti. |
Doug Kwan | e3c3c6d | 2011-06-07 10:55:48 -0700 | [diff] [blame] | 1580 | ifeq ($(strip $(LOCAL_RTTI_FLAG)),) |
| 1581 | LOCAL_RTTI_FLAG := -fno-rtti |
| 1582 | endif |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1583 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1584 | ########################################################### |
| 1585 | # Rule-specific variable definitions |
| 1586 | ########################################################### |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1587 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 1588 | ifeq ($(my_clang),true) |
Chih-Hung Hsieh | 9aa69a6 | 2014-09-04 17:15:47 -0700 | [diff] [blame] | 1589 | my_cflags += $(LOCAL_CLANG_CFLAGS) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 1590 | my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS) |
Dan Albert | d2fa96d | 2014-11-28 14:00:12 -0800 | [diff] [blame] | 1591 | my_cppflags += $(LOCAL_CLANG_CPPFLAGS) |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1592 | my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE) |
| 1593 | my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE) |
Chih-Hung Hsieh | 9aa69a6 | 2014-09-04 17:15:47 -0700 | [diff] [blame] | 1594 | my_asflags += $(LOCAL_CLANG_ASFLAGS) |
| 1595 | my_ldflags += $(LOCAL_CLANG_LDFLAGS) |
Chih-Hung Hsieh | 619fdb8 | 2014-09-26 17:13:48 -0700 | [diff] [blame] | 1596 | my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix)) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 1597 | my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix)) |
Chih-Hung Hsieh | 619fdb8 | 2014-09-26 17:13:48 -0700 | [diff] [blame] | 1598 | my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix)) |
| 1599 | my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix)) |
| 1600 | my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix)) |
Dan Willemsen | 02268f0 | 2016-05-19 14:39:25 -0700 | [diff] [blame] | 1601 | my_cflags := $(call convert-to-clang-flags,$(my_cflags)) |
| 1602 | my_cppflags := $(call convert-to-clang-flags,$(my_cppflags)) |
| 1603 | my_asflags := $(call convert-to-clang-flags,$(my_asflags)) |
| 1604 | my_ldflags := $(call convert-to-clang-flags,$(my_ldflags)) |
Dan Austin | 75e7af1 | 2016-04-06 11:18:30 -0700 | [diff] [blame] | 1605 | else |
| 1606 | # gcc does not handle hidden functions in a manner compatible with LLVM libcxx |
| 1607 | # see b/27908145 |
| 1608 | my_cflags += -Wno-attributes |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1609 | endif |
| 1610 | |
Ying Wang | 45d0143 | 2014-10-28 14:50:59 -0700 | [diff] [blame] | 1611 | ifeq ($(my_fdo_build), true) |
| 1612 | my_cflags := $(patsubst -Os,-O2,$(my_cflags)) |
| 1613 | fdo_incompatible_flags := -fno-early-inlining -finline-limit=% |
| 1614 | my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags)) |
Dehao Chen | 295a6d2 | 2014-09-19 10:18:12 -0700 | [diff] [blame] | 1615 | endif |
| 1616 | |
Dan Albert | df3fd1d | 2015-08-12 14:54:16 -0700 | [diff] [blame] | 1617 | # No one should ever use this flag. On GCC it's mere presence will disable all |
| 1618 | # warnings, even those that are specified after it (contrary to typical warning |
| 1619 | # flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the |
| 1620 | # warnings that are *always* bugs. |
| 1621 | my_illegal_flags := -w |
| 1622 | my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags)) |
| 1623 | my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags)) |
| 1624 | my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags)) |
| 1625 | |
Dan Albert | 5ae31dd | 2016-01-29 16:51:51 -0800 | [diff] [blame] | 1626 | # We can enforce some rules more strictly in the code we own. my_strict |
| 1627 | # indicates if this is code that we can be stricter with. If we have rules that |
| 1628 | # we want to apply to *our* code (but maybe can't for vendor/device specific |
| 1629 | # things), we could extend this to be a ternary value. |
| 1630 | my_strict := true |
| 1631 | ifneq ($(filter external/%,$(LOCAL_PATH)),) |
| 1632 | my_strict := false |
| 1633 | endif |
| 1634 | |
| 1635 | # Can be used to make some annotations stricter for code we can fix (such as |
| 1636 | # when we mark functions as deprecated). |
| 1637 | ifeq ($(my_strict),true) |
| 1638 | my_cflags += -DANDROID_STRICT |
| 1639 | endif |
| 1640 | |
Chih-Hung Hsieh | bab0488 | 2016-10-11 15:38:39 -0700 | [diff] [blame] | 1641 | # Add -Werror if LOCAL_PATH is in the WARNING_DISALLOWED project list, |
| 1642 | # or not in the WARNING_ALLOWED project list. |
| 1643 | ifneq (,$(strip $(call find_warning_disallowed_projects,$(LOCAL_PATH)))) |
| 1644 | my_cflags_no_override += -Werror |
| 1645 | else |
| 1646 | ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH)))) |
| 1647 | my_cflags_no_override += -Werror |
| 1648 | endif |
| 1649 | endif |
| 1650 | |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 1651 | # Disable clang-tidy if it is not found. |
| 1652 | ifeq ($(PATH_TO_CLANG_TIDY),) |
| 1653 | my_tidy_enabled := false |
| 1654 | else |
| 1655 | # If LOCAL_TIDY is not defined, use global WITH_TIDY |
| 1656 | my_tidy_enabled := $(LOCAL_TIDY) |
| 1657 | ifeq ($(my_tidy_enabled),) |
| 1658 | my_tidy_enabled := $(WITH_TIDY) |
| 1659 | endif |
| 1660 | endif |
| 1661 | |
| 1662 | # my_tidy_checks is empty if clang-tidy is disabled. |
| 1663 | my_tidy_checks := |
| 1664 | my_tidy_flags := |
| 1665 | ifneq (,$(filter 1 true,$(my_tidy_enabled))) |
| 1666 | ifneq ($(my_clang),true) |
| 1667 | # Disable clang-tidy if clang is disabled. |
| 1668 | my_tidy_enabled := false |
| 1669 | else |
| 1670 | tidy_only: $(cpp_objects) $(c_objects) |
| 1671 | # Set up global default checks |
| 1672 | my_tidy_checks := $(WITH_TIDY_CHECKS) |
| 1673 | ifeq ($(my_tidy_checks),) |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 1674 | my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH)) |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 1675 | endif |
| 1676 | # Append local clang-tidy checks. |
| 1677 | ifneq ($(LOCAL_TIDY_CHECKS),) |
| 1678 | my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS) |
| 1679 | endif |
| 1680 | # Set up global default clang-tidy flags, which is none. |
| 1681 | my_tidy_flags := $(WITH_TIDY_FLAGS) |
| 1682 | # Use local clang-tidy flags if specified. |
| 1683 | ifneq ($(LOCAL_TIDY_FLAGS),) |
| 1684 | my_tidy_flags := $(LOCAL_TIDY_FLAGS) |
| 1685 | endif |
Chih-Hung Hsieh | 870f087 | 2016-06-02 15:20:05 -0700 | [diff] [blame] | 1686 | # If tidy flags are not specified, default to check all header files. |
| 1687 | ifeq ($(my_tidy_flags),) |
Chih-Hung Hsieh | 0a33f65 | 2016-09-06 20:06:28 -0700 | [diff] [blame] | 1688 | my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH)) |
Chih-Hung Hsieh | 870f087 | 2016-06-02 15:20:05 -0700 | [diff] [blame] | 1689 | endif |
George Burgess IV | 5ab07d4 | 2017-05-03 18:10:47 -0700 | [diff] [blame] | 1690 | |
| 1691 | # We might be using the static analyzer through clang-tidy. |
| 1692 | # https://bugs.llvm.org/show_bug.cgi?id=32914 |
| 1693 | ifneq ($(my_tidy_checks),) |
| 1694 | my_tidy_flags += "-extra-arg-before=-D__clang_analyzer__" |
| 1695 | endif |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 1696 | endif |
| 1697 | endif |
| 1698 | |
Chih-Hung Hsieh | ba64625 | 2016-08-16 16:27:30 -0700 | [diff] [blame] | 1699 | my_tidy_checks := $(subst $(space),,$(my_tidy_checks)) |
| 1700 | |
Dan Willemsen | 6731b49 | 2016-06-07 16:55:57 -0700 | [diff] [blame] | 1701 | # Move -l* entries from ldflags to ldlibs, and everything else to ldflags |
| 1702 | my_ldlib_flags := $(my_ldflags) $(my_ldlibs) |
| 1703 | my_ldlibs := $(filter -l%,$(my_ldlib_flags)) |
| 1704 | my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) |
| 1705 | |
| 1706 | # One last verification check for ldlibs |
| 1707 | ifndef LOCAL_IS_HOST_MODULE |
| 1708 | my_allowed_ldlibs := |
Dan Willemsen | ffa3258 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1709 | ifneq ($(LOCAL_SDK_VERSION),) |
Dan Willemsen | 6731b49 | 2016-06-07 16:55:57 -0700 | [diff] [blame] | 1710 | my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES)) |
| 1711 | endif |
| 1712 | |
| 1713 | my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs)) |
| 1714 | ifneq ($(my_bad_ldlibs),) |
| 1715 | $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs)) |
| 1716 | endif |
| 1717 | endif |
| 1718 | |
Dan Willemsen | c9aa6fc | 2016-09-13 10:44:44 -0700 | [diff] [blame] | 1719 | # my_cxx_ldlibs may contain linker flags need to wrap certain libraries |
| 1720 | # (start-group/end-group), so append after the check above. |
| 1721 | my_ldlibs += $(my_cxx_ldlibs) |
| 1722 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1723 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1724 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 1725 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1726 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) |
| 1727 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1728 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) |
| 1729 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1730 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1731 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1732 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1733 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1734 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) |
Dan Albert | b05f2ca | 2014-09-12 14:46:57 -0700 | [diff] [blame] | 1735 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 1736 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks) |
| 1737 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags) |
Evgenii Stepanov | e1b96f3 | 2017-01-23 16:57:38 -0800 | [diff] [blame] | 1738 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1739 | |
| 1740 | # this is really the way to get the files onto the command line instead |
| 1741 | # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work |
| 1742 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) |
| 1743 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) |
| 1744 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) |
Ying Wang | 4aaa1a1 | 2016-03-22 18:23:13 -0700 | [diff] [blame] | 1745 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1746 | |
| 1747 | ########################################################### |
| 1748 | # Define library dependencies. |
| 1749 | ########################################################### |
| 1750 | # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. |
| 1751 | all_libraries := \ |
Ying Wang | c01f2dc | 2015-12-15 10:00:19 -0800 | [diff] [blame] | 1752 | $(built_shared_library_deps) \ |
Shinichiro Hamaji | 0e7587a | 2015-10-09 14:36:04 +0900 | [diff] [blame] | 1753 | $(my_system_shared_libraries_fullpath) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1754 | $(built_static_libraries) \ |
| 1755 | $(built_whole_libraries) |
| 1756 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1757 | # Also depend on the notice files for any static libraries that |
| 1758 | # are linked into this module. This will force them to be installed |
| 1759 | # when this module is. |
| 1760 | $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1761 | |
| 1762 | ########################################################### |
| 1763 | # Export includes |
| 1764 | ########################################################### |
| 1765 | export_includes := $(intermediates)/export_includes |
Dan Willemsen | 2a8a393 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1766 | export_cflags := $(foreach d,$(my_export_c_include_dirs),-I $(d)) |
| 1767 | # Soong exports cflags instead of include dirs, so that -isystem can be included. |
| 1768 | ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) |
| 1769 | export_cflags += $(LOCAL_EXPORT_CFLAGS) |
| 1770 | else ifdef LOCAL_EXPORT_CFLAGS |
| 1771 | $(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead) |
| 1772 | endif |
| 1773 | $(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags) |
Christopher Wiley | ff1c3f2 | 2016-04-11 12:40:36 -0700 | [diff] [blame] | 1774 | # Headers exported by whole static libraries are also exported by this library. |
Dan Willemsen | a7808ac | 2016-03-04 12:40:25 -0800 | [diff] [blame] | 1775 | export_include_deps := $(strip \ |
| 1776 | $(foreach l,$(my_whole_static_libraries), \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1777 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) |
Christopher Wiley | ff1c3f2 | 2016-04-11 12:40:36 -0700 | [diff] [blame] | 1778 | # Re-export requested headers from shared libraries. |
| 1779 | export_include_deps += $(strip \ |
| 1780 | $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1781 | $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) |
Christopher Wiley | ff1c3f2 | 2016-04-11 12:40:36 -0700 | [diff] [blame] | 1782 | # Re-export requested headers from static libraries. |
| 1783 | export_include_deps += $(strip \ |
| 1784 | $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \ |
Alexey Polyudov | ccdc311 | 2016-08-01 17:41:49 -0700 | [diff] [blame] | 1785 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 1786 | # Re-export requested headers from header libraries. |
| 1787 | export_include_deps += $(strip \ |
| 1788 | $(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \ |
| 1789 | $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) |
Dan Willemsen | a7808ac | 2016-03-04 12:40:25 -0800 | [diff] [blame] | 1790 | $(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps) |
Ying Wang | 05f9f35 | 2016-05-05 20:02:08 -0700 | [diff] [blame] | 1791 | # By adding $(my_generated_sources) it makes sure the headers get generated |
| 1792 | # before any dependent source files get compiled. |
Dan Willemsen | 8dae49c | 2017-02-15 15:48:11 -0800 | [diff] [blame] | 1793 | $(export_includes) : $(my_export_c_include_deps) $(my_generated_sources) $(export_include_deps) $(LOCAL_EXPORT_C_INCLUDE_DEPS) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1794 | @echo Export includes file: $< -- $@ |
Dan Willemsen | a7808ac | 2016-03-04 12:40:25 -0800 | [diff] [blame] | 1795 | $(hide) mkdir -p $(dir $@) && rm -f $@.tmp && touch $@.tmp |
Dan Willemsen | 2a8a393 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1796 | ifdef export_cflags |
| 1797 | $(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >>$@.tmp |
Dan Willemsen | a7808ac | 2016-03-04 12:40:25 -0800 | [diff] [blame] | 1798 | endif |
| 1799 | ifdef export_include_deps |
| 1800 | $(hide) for f in $(PRIVATE_REEXPORTED_INCLUDES); do \ |
| 1801 | cat $$f >> $@.tmp; \ |
| 1802 | done |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1803 | endif |
Colin Cross | 6b9bddd | 2015-11-30 17:33:26 -0800 | [diff] [blame] | 1804 | $(hide) if cmp -s $@.tmp $@ ; then \ |
| 1805 | rm $@.tmp ; \ |
| 1806 | else \ |
| 1807 | mv $@.tmp $@ ; \ |
| 1808 | fi |
Dan Willemsen | 2a8a393 | 2017-03-19 13:22:45 -0700 | [diff] [blame] | 1809 | export_cflags := |
Colin Cross | 6b9bddd | 2015-11-30 17:33:26 -0800 | [diff] [blame] | 1810 | |
| 1811 | # Kati adds restat=1 to ninja. GNU make does nothing for this. |
| 1812 | .KATI_RESTAT: $(export_includes) |
Ying Wang | 616e596 | 2012-04-18 17:35:55 -0700 | [diff] [blame] | 1813 | |
| 1814 | # Make sure export_includes gets generated when you are running mm/mmm |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 1815 | $(LOCAL_BUILT_MODULE) : | $(export_includes) |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 1816 | |
| 1817 | ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) |
Dan Willemsen | 0be6907 | 2016-12-13 18:28:33 -0800 | [diff] [blame] | 1818 | ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs))) |
| 1819 | my_soong_problems += non_local__export_c_include_dirs |
| 1820 | endif |
| 1821 | |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 1822 | SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \ |
| 1823 | $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems) |
| 1824 | SOONG_CONV.$(LOCAL_MODULE).DEPS := \ |
| 1825 | $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \ |
Dan Willemsen | 0bf506f | 2017-04-25 15:42:14 -0700 | [diff] [blame] | 1826 | $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY),\ |
| 1827 | $(my_static_libraries) \ |
| 1828 | $(my_whole_static_libraries) \ |
| 1829 | $(my_shared_libraries) \ |
| 1830 | $(my_system_shared_libraries)) |
Dan Willemsen | fc92fb2 | 2016-08-26 13:27:13 -0700 | [diff] [blame] | 1831 | SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE) |
| 1832 | endif |
Ryan Campbell | 81c9d29 | 2016-09-12 13:56:50 -0700 | [diff] [blame] | 1833 | |
| 1834 | ########################################################### |
| 1835 | # Coverage packaging. |
| 1836 | ########################################################### |
| 1837 | ifeq ($(my_native_coverage),true) |
Ryan Campbell | 5a6ea36 | 2017-02-28 16:20:23 -0800 | [diff] [blame] | 1838 | my_gcno_objects := \ |
| 1839 | $(cpp_objects) \ |
| 1840 | $(gen_cpp_objects) \ |
| 1841 | $(c_objects) \ |
| 1842 | $(gen_c_objects) \ |
| 1843 | $(objc_objects) \ |
| 1844 | $(objcpp_objects) |
| 1845 | |
| 1846 | LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects)) |
| 1847 | $(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno)))) |
Ryan Campbell | 81c9d29 | 2016-09-12 13:56:50 -0700 | [diff] [blame] | 1848 | endif |