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 | |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 12 | my_ndk_sysroot := |
| 13 | my_ndk_sysroot_include := |
| 14 | my_ndk_sysroot_lib := |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 15 | ifdef LOCAL_SDK_VERSION |
Ying Wang | fe1bfe7 | 2012-08-14 11:08:03 -0700 | [diff] [blame] | 16 | ifdef LOCAL_NDK_VERSION |
| 17 | $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.) |
| 18 | endif |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 19 | ifdef LOCAL_IS_HOST_MODULE |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 20 | $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 21 | endif |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 22 | my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 23 | my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
| 24 | my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include |
| 25 | ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
| 26 | my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64 |
| 27 | else |
| 28 | my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib |
| 29 | endif |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 30 | |
| 31 | # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. |
| 32 | # See ndk/docs/CPLUSPLUS-SUPPORT.html |
| 33 | my_ndk_stl_include_path := |
| 34 | my_ndk_stl_shared_lib_fullpath := |
| 35 | my_ndk_stl_shared_lib := |
| 36 | my_ndk_stl_static_lib := |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 37 | my_ndk_stl_cppflags := |
| 38 | LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 39 | ifeq (,$(LOCAL_NDK_STL_VARIANT)) |
| 40 | LOCAL_NDK_STL_VARIANT := system |
| 41 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 42 | ifneq (1,$(words $(filter 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] | 43 | $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 44 | endif |
| 45 | ifeq (system,$(LOCAL_NDK_STL_VARIANT)) |
| 46 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include |
| 47 | # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default. |
| 48 | else # LOCAL_NDK_STL_VARIANT is not system |
| 49 | ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) |
| 50 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport |
| 51 | ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 52 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 53 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 54 | my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 55 | my_ndk_stl_shared_lib := -lstlport_shared |
| 56 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 57 | else # LOCAL_NDK_STL_VARIANT is not stlport_* either |
| 58 | ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) |
| 59 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \ |
| 60 | $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \ |
| 61 | $(my_ndk_source_root)/android/support/include |
| 62 | ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) |
| 63 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a |
| 64 | else |
| 65 | my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so |
| 66 | my_ndk_stl_shared_lib := -lc++_shared |
| 67 | endif |
| 68 | my_ndk_stl_cppflags := -std=c++11 |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 69 | else |
| 70 | # LOCAL_NDK_STL_VARIANT is gnustl_static |
Ben Cheng | 4de6fa4 | 2014-04-10 22:46:26 -0700 | [diff] [blame] | 71 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \ |
| 72 | $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include |
| 73 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 74 | endif |
| 75 | endif |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 76 | endif |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 77 | endif |
| 78 | |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 79 | ################################################## |
| 80 | # Compute the dependency of the shared libraries |
| 81 | ################################################## |
| 82 | # On the target, we compile with -nostdlib, so we must add in the |
| 83 | # default system shared libraries, unless they have requested not |
| 84 | # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would |
| 85 | # supply that, for example, when building libc itself. |
| 86 | ifdef LOCAL_IS_HOST_MODULE |
| 87 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 88 | my_system_shared_libraries := |
| 89 | else |
| 90 | my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 91 | endif |
| 92 | else |
| 93 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 94 | my_system_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES) |
| 95 | else |
| 96 | my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 97 | endif |
| 98 | endif |
| 99 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 100 | # The following LOCAL_ variables will be modified in this file. |
| 101 | # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, |
| 102 | # we can't modify them in place. |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 103 | my_src_files := $(LOCAL_SRC_FILES) |
| 104 | my_static_libraries := $(LOCAL_STATIC_LIBRARIES) |
| 105 | my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) |
| 106 | my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) |
| 107 | my_cflags := $(LOCAL_CFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 108 | my_cppflags := $(LOCAL_CPPFLAGS) |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 109 | my_ldflags := $(LOCAL_LDFLAGS) |
Dan Albert | b05f2ca | 2014-09-12 14:46:57 -0700 | [diff] [blame] | 110 | my_ldlibs := $(LOCAL_LDLIBS) |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 111 | my_asflags := $(LOCAL_ASFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 112 | my_cc := $(LOCAL_CC) |
| 113 | my_cxx := $(LOCAL_CXX) |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 114 | my_c_includes := $(LOCAL_C_INCLUDES) |
| 115 | my_generated_sources := $(LOCAL_GENERATED_SOURCES) |
Dan Albert | 4bbc6c7 | 2014-09-19 14:25:57 -0700 | [diff] [blame^] | 116 | my_native_coverage := $(LOCAL_NATIVE_COVERAGE) |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 117 | |
Dan Albert | 95994de | 2014-08-07 18:29:11 -0700 | [diff] [blame] | 118 | # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because |
| 119 | # all code is position independent, and then those warnings get promoted to |
| 120 | # errors. |
Ying Wang | 594a10a | 2014-08-07 20:08:04 -0700 | [diff] [blame] | 121 | ifndef USE_MINGW |
Dan Albert | 4803ce2 | 2014-08-06 12:36:46 -0700 | [diff] [blame] | 122 | ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) |
| 123 | my_cflags += -fpie |
| 124 | else |
| 125 | my_cflags += -fPIC |
| 126 | endif |
Dan Albert | 95994de | 2014-08-07 18:29:11 -0700 | [diff] [blame] | 127 | endif |
Dan Albert | 4803ce2 | 2014-08-06 12:36:46 -0700 | [diff] [blame] | 128 | |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 129 | my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) |
| 130 | my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) |
| 131 | my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) |
| 132 | my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) |
| 133 | my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) |
| 134 | my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) |
| 135 | my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) |
| 136 | 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] | 137 | |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 138 | my_clang := $(strip $(LOCAL_CLANG)) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 139 | ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 140 | my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 141 | endif |
| 142 | ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 143 | 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] | 144 | endif |
| 145 | |
Tim Murray | 92d79cb | 2014-04-04 14:38:29 -0700 | [diff] [blame] | 146 | # clang is enabled by default for host builds |
| 147 | # enable it unless we've specifically disabled clang above |
| 148 | ifdef LOCAL_IS_HOST_MODULE |
Tim Murray | f3ca3d5 | 2014-07-24 15:20:18 -0700 | [diff] [blame] | 149 | ifneq ($(HOST_OS),windows) |
Tim Murray | 5ca1dc1 | 2014-07-24 14:42:53 -0700 | [diff] [blame] | 150 | ifeq ($(my_clang),) |
| 151 | my_clang := true |
| 152 | endif |
| 153 | endif |
Tim Murray | 92d79cb | 2014-04-04 14:38:29 -0700 | [diff] [blame] | 154 | endif |
| 155 | |
Tim Murray | 06659bc | 2014-08-13 11:53:07 -0700 | [diff] [blame] | 156 | # Add option to make clang the default for device build |
| 157 | ifeq ($(USE_CLANG_PLATFORM_BUILD),true) |
| 158 | ifeq ($(my_clang),) |
| 159 | my_clang := true |
| 160 | endif |
| 161 | endif |
| 162 | |
Colin Cross | f4f2fbe | 2014-02-12 21:15:12 -0800 | [diff] [blame] | 163 | # 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] | 164 | 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) |
| 165 | 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) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 166 | |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 167 | my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags)) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 168 | |
Dan Albert | b05f2ca | 2014-09-12 14:46:57 -0700 | [diff] [blame] | 169 | # Only around for development purposes. Will be removed soon. |
| 170 | my_libcxx_is_default := false |
Ying Wang | d90de32 | 2014-05-23 16:42:37 -0700 | [diff] [blame] | 171 | |
Dan Albert | b05f2ca | 2014-09-12 14:46:57 -0700 | [diff] [blame] | 172 | # Select the appropriate C++ STL |
| 173 | ifeq ($(strip $(LOCAL_CXX_STL)),default) |
| 174 | ifndef LOCAL_SDK_VERSION |
| 175 | ifeq ($(strip $(my_libcxx_is_default)),true) |
| 176 | # Platform code. Select the appropriate STL. |
| 177 | my_cxx_stl := libc++ |
| 178 | else |
| 179 | my_cxx_stl := bionic |
| 180 | endif |
| 181 | else |
| 182 | my_cxx_stl := ndk |
| 183 | endif |
| 184 | else |
| 185 | my_cxx_stl := $(strip $(LOCAL_CXX_STL)) |
| 186 | endif |
| 187 | |
| 188 | ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),) |
| 189 | my_cflags += -D_USING_LIBCXX |
| 190 | my_c_includes += external/libcxx/include |
| 191 | ifeq ($(my_cxx_stl),libc++) |
| 192 | my_shared_libraries += libc++ |
| 193 | else |
| 194 | my_static_libraries += libc++_static |
| 195 | endif |
| 196 | |
| 197 | ifdef LOCAL_IS_HOST_MODULE |
| 198 | my_cppflags += -nostdinc++ |
| 199 | my_ldflags += -nodefaultlibs |
| 200 | my_ldlibs += -lc -lm |
| 201 | endif |
| 202 | else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),) |
| 203 | my_c_includes += external/stlport/stlport bionic/libstdc++/include bionic |
| 204 | ifeq ($(my_cxx_stl),stlport) |
| 205 | my_shared_libraries += libstdc++ libstlport |
| 206 | else |
| 207 | my_static_libraries += libstdc++ libstlport_static |
| 208 | endif |
| 209 | else ifeq ($(my_cxx_stl),ndk) |
| 210 | # Using an NDK STL. Handled farther up in this file. |
| 211 | ifndef LOCAL_IS_HOST_MODULE |
| 212 | my_system_shared_libraries += libstdc++ |
| 213 | endif |
| 214 | else ifeq ($(my_cxx_stl),bionic) |
| 215 | # Using bionic's basic libstdc++. Not actually an STL. Only around until the |
| 216 | # tree is in good enough shape to not need it. |
| 217 | ifndef LOCAL_IS_HOST_MODULE |
| 218 | my_c_includes += bionic/libstdc++/include |
| 219 | my_system_shared_libraries += libstdc++ |
| 220 | endif |
| 221 | # Host builds will use GNU libstdc++. |
| 222 | else ifeq ($(my_cxx_stl),none) |
| 223 | ifdef LOCAL_IS_HOST_MODULE |
| 224 | my_cppflags += -nostdinc++ |
| 225 | my_ldflags += -nodefaultlibs -lc -lm |
| 226 | endif |
| 227 | else |
| 228 | $(error $(my_cxx_stl) is not a supported STL.) |
Ying Wang | d90de32 | 2014-05-23 16:42:37 -0700 | [diff] [blame] | 229 | endif |
| 230 | |
Ying Wang | 285045b | 2013-08-13 12:35:10 -0700 | [diff] [blame] | 231 | # Add static HAL libraries |
| 232 | ifdef LOCAL_HAL_STATIC_LIBRARIES |
| 233 | $(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ |
| 234 | $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 235 | $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ |
| 236 | $(eval my_static_libraries += $(lib).default))) |
Ying Wang | 285045b | 2013-08-13 12:35:10 -0700 | [diff] [blame] | 237 | b_lib := |
| 238 | endif |
| 239 | |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 240 | ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 241 | my_clang := true |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 242 | my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS) |
| 243 | my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS) |
| 244 | my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) |
| 245 | my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES) |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 246 | endif |
| 247 | |
Ying Wang | ba8b377 | 2014-03-10 18:23:08 -0700 | [diff] [blame] | 248 | ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 249 | my_clang := |
Mike Lockwood | 051a174 | 2013-06-14 10:52:50 -0700 | [diff] [blame] | 250 | endif |
| 251 | |
Shih-wei Liao | c8dfc16 | 2013-01-27 01:45:59 -0800 | [diff] [blame] | 252 | # Add in libcompiler_rt for all regular device builds |
Mike Lockwood | daf5e22 | 2012-10-18 10:17:47 -0700 | [diff] [blame] | 253 | ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT)) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 254 | my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) |
Stephen Hines | c72f396 | 2012-06-11 14:53:34 -0700 | [diff] [blame] | 255 | endif |
| 256 | |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 257 | my_compiler_dependencies := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 258 | |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 259 | #################################################### |
| 260 | ## Add FDO flags if FDO is turned on and supported |
| 261 | #################################################### |
synergydev | 7c46742 | 2013-08-13 17:41:52 -0700 | [diff] [blame] | 262 | ifneq ($(strip $(LOCAL_FDO_SUPPORT)),) |
synergydev | 4a60576 | 2013-08-05 02:44:37 -0700 | [diff] [blame] | 263 | ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 264 | my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 265 | my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS) |
synergydev | 4a60576 | 2013-08-05 02:44:37 -0700 | [diff] [blame] | 266 | endif |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 267 | endif |
| 268 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 269 | ########################################################### |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 270 | ## Explicitly declare assembly-only __ASSEMBLY__ macro for |
| 271 | ## assembly source |
| 272 | ########################################################### |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 273 | my_asflags += -D__ASSEMBLY__ |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 274 | |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 275 | |
| 276 | ########################################################## |
| 277 | ## Set up installed module dependency |
| 278 | ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for |
| 279 | ## they may cusomize their install path with LOCAL_MODULE_PATH |
| 280 | ########################################################## |
| 281 | # Get the list of INSTALLED libraries as module names. |
| 282 | ifdef LOCAL_SDK_VERSION |
| 283 | installed_shared_library_module_names := \ |
| 284 | $(my_shared_libraries) |
| 285 | else |
| 286 | installed_shared_library_module_names := \ |
| 287 | $(my_system_shared_libraries) $(my_shared_libraries) |
| 288 | endif |
| 289 | installed_shared_library_module_names := $(sort $(installed_shared_library_module_names)) |
| 290 | |
| 291 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 292 | # of the shared libraries are determined. |
| 293 | ifdef LOCAL_INSTALLED_MODULE |
| 294 | ifdef installed_shared_library_module_names |
| 295 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
Ying Wang | e1b867d | 2014-06-10 14:21:20 -0700 | [diff] [blame] | 296 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names)) |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 297 | endif |
| 298 | endif |
| 299 | |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 300 | ########################################################### |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 301 | ## Define PRIVATE_ variables from global vars |
| 302 | ########################################################### |
Ying Wang | 7fff9a1 | 2014-01-09 14:39:41 -0800 | [diff] [blame] | 303 | ifndef LOCAL_IS_HOST_MODULE |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 304 | ifdef LOCAL_SDK_VERSION |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 305 | my_target_project_includes := |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 306 | my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 307 | my_target_global_cppflags := $(my_ndk_stl_cppflags) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 308 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 309 | my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) |
| 310 | my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES) |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 311 | my_target_global_cppflags := |
Ying Wang | f4723fa | 2013-08-15 11:01:10 -0700 | [diff] [blame] | 312 | endif # LOCAL_SDK_VERSION |
| 313 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 314 | ifeq ($(my_clang),true) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 315 | my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 316 | my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 317 | my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) |
Ying Wang | f4723fa | 2013-08-15 11:01:10 -0700 | [diff] [blame] | 318 | my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 319 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 320 | my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) |
Andrew Hsieh | 73d800e | 2014-03-04 17:11:52 +0800 | [diff] [blame] | 321 | my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 322 | my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 323 | endif # my_clang |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 324 | |
Dan Albert | 4bbc6c7 | 2014-09-19 14:25:57 -0700 | [diff] [blame^] | 325 | # If the global flag NATIVE_COVERAGE is set, my_native_coverage will be true |
| 326 | # unless the module explicitly sets my_native_coverage := false. |
| 327 | ifeq ($(NATIVE_COVERAGE),true) |
| 328 | ifeq ($(my_native_coverage),true) |
| 329 | # We can't currently generate coverage for clang binaries for two |
| 330 | # reasons: |
| 331 | # |
| 332 | # 1) b/17574078 We currently don't have a prebuilt |
| 333 | # libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if |
| 334 | # --coverage is passed in the link stage. For now we manually link |
| 335 | # libprofile_rt (which is the name it is built as from |
| 336 | # external/compiler-rt). |
| 337 | # |
| 338 | # 2) b/17583330 Clang doesn't generate .gcno files when using |
| 339 | # -no-integrated-as. Since most of the assembly in our tree is |
| 340 | # incompatible with clang's assembler, we can't turn off this flag. |
| 341 | ifneq ($(my_clang),true) |
| 342 | my_target_global_cflags += --coverage |
| 343 | my_target_global_ldflags += --coverage |
| 344 | endif |
| 345 | endif |
| 346 | else |
| 347 | my_native_coverage := false |
| 348 | endif |
| 349 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 350 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) |
Evgeniy Stepanov | a7095e9 | 2012-03-30 12:18:52 +0400 | [diff] [blame] | 351 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 352 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 353 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) |
| 354 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) |
| 355 | |
Ying Wang | 7fff9a1 | 2014-01-09 14:39:41 -0800 | [diff] [blame] | 356 | else # LOCAL_IS_HOST_MODULE |
| 357 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 358 | ifeq ($(my_clang),true) |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 359 | my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS) |
| 360 | my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS) |
| 361 | my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS) |
| 362 | my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 363 | else |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 364 | my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS) |
| 365 | my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS) |
| 366 | my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS) |
| 367 | my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 368 | endif # my_clang |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 369 | |
| 370 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) |
| 371 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) |
| 372 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) |
| 373 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) |
| 374 | endif # LOCAL_IS_HOST_MODULE |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 375 | |
| 376 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 377 | ## Define PRIVATE_ variables used by multiple module types |
| 378 | ########################################################### |
| 379 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 380 | $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 381 | |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 382 | ifeq ($(strip $(WITH_SYNTAX_CHECK)),) |
| 383 | LOCAL_NO_SYNTAX_CHECK := true |
| 384 | endif |
| 385 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 386 | ifeq ($(strip $(WITH_STATIC_ANALYZER)),) |
| 387 | LOCAL_NO_STATIC_ANALYZER := true |
| 388 | endif |
| 389 | |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 390 | ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) |
| 391 | my_syntax_arch := host |
| 392 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 393 | my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 394 | endif |
| 395 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 396 | ifeq ($(strip $(my_cc)),) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 397 | ifeq ($(my_clang),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 398 | my_cc := $(CLANG) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 399 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 400 | my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 401 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 402 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 403 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 404 | my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)" |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 405 | else |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 406 | ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 407 | my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)" |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 408 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 409 | endif |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 410 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 411 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 412 | ifeq ($(strip $(my_cxx)),) |
Dan Albert | db905e7 | 2014-08-18 11:14:38 -0700 | [diff] [blame] | 413 | ifeq ($(my_clang),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 414 | my_cxx := $(CLANG_CXX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 415 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 416 | my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 417 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 418 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 419 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 420 | my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)" |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 421 | else |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 422 | ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 423 | my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)" |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 424 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 425 | endif |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 426 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) |
Dan Albert | b6bb71b | 2014-08-05 14:44:41 -0700 | [diff] [blame] | 427 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 428 | |
| 429 | # TODO: support a mix of standard extensions so that this isn't necessary |
| 430 | LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) |
| 431 | ifeq ($(LOCAL_CPP_EXTENSION),) |
| 432 | LOCAL_CPP_EXTENSION := .cpp |
| 433 | endif |
| 434 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) |
| 435 | |
| 436 | # Certain modules like libdl have to have symbols resolved at runtime and blow |
| 437 | # up if --no-undefined is passed to the linker. |
| 438 | ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) |
| 439 | ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 440 | my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 441 | endif |
| 442 | endif |
| 443 | |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 444 | ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) |
| 445 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true |
| 446 | else |
| 447 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := |
| 448 | endif |
| 449 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 450 | ########################################################### |
| 451 | ## Define arm-vs-thumb-mode flags. |
| 452 | ########################################################### |
| 453 | LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) |
Colin Cross | 6e087a3 | 2014-01-22 17:36:05 -0800 | [diff] [blame] | 454 | ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 455 | arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) |
| 456 | normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) |
| 457 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 458 | # Read the values from something like TARGET_arm_CFLAGS or |
| 459 | # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't |
| 460 | # actually used (although they are usually empty). |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 461 | arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) |
| 462 | 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] | 463 | ifeq ($(my_clang),true) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 464 | arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) |
| 465 | normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 466 | endif |
| 467 | |
Chih-Wei Huang | 0d09e58 | 2010-07-09 10:07:52 +0800 | [diff] [blame] | 468 | else |
| 469 | arm_objects_mode := |
| 470 | normal_objects_mode := |
| 471 | arm_objects_cflags := |
| 472 | normal_objects_cflags := |
| 473 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 474 | |
| 475 | ########################################################### |
| 476 | ## Define per-module debugging flags. Users can turn on |
| 477 | ## debugging for a particular module by setting DEBUG_MODULE_ModuleName |
| 478 | ## to a non-empty value in their environment or buildspec.mk, |
| 479 | ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the |
| 480 | ## debug flags that they want to use. |
| 481 | ########################################################### |
| 482 | ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) |
| 483 | debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) |
| 484 | else |
| 485 | debug_cflags := |
| 486 | endif |
| 487 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 488 | #################################################### |
| 489 | ## Compile RenderScript with reflected C++ |
| 490 | #################################################### |
| 491 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 492 | renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 493 | |
| 494 | ifneq (,$(renderscript_sources)) |
| 495 | |
| 496 | renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) |
| 497 | RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp |
| 498 | renderscript_intermediate := $(intermediates)/renderscript |
| 499 | |
| 500 | ifeq ($(LOCAL_RENDERSCRIPT_CC),) |
| 501 | LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) |
| 502 | endif |
| 503 | |
| 504 | # Turn on all warnings and warnings as errors for RS compiles. |
| 505 | # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error |
| 506 | renderscript_flags := -Wall -Werror |
| 507 | renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) |
| 508 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 509 | renderscript_includes := \ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 510 | $(TOPDIR)external/clang/lib/Headers \ |
| 511 | $(TOPDIR)frameworks/rs/scriptc \ |
| 512 | $(LOCAL_RENDERSCRIPT_INCLUDES) |
| 513 | |
| 514 | ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 515 | renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 516 | endif |
| 517 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 518 | $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 519 | $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) |
| 520 | $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) |
| 521 | $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) |
| 522 | $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) |
| 523 | $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) |
| 524 | $(transform-renderscripts-to-cpp-and-bc) |
| 525 | |
| 526 | # include the dependency files (.d) generated by llvm-rs-cc. |
| 527 | renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \ |
| 528 | $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) |
| 529 | -include $(renderscript_generated_dep_files) |
| 530 | |
| 531 | LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) |
| 532 | |
| 533 | rs_generated_cpps := $(addprefix \ |
| 534 | $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ |
| 535 | $(notdir $(renderscript_sources))))) |
| 536 | |
Stephen Hines | 8ff9252 | 2014-06-06 12:51:47 -0700 | [diff] [blame] | 537 | # 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] | 538 | $(rs_generated_cpps) : $(RenderScript_file_stamp) |
Ying Wang | 81ab833 | 2014-05-28 16:17:09 -0700 | [diff] [blame] | 539 | @echo "Updated RS generated cpp file $@." |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 540 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 541 | my_c_includes += $(renderscript_intermediate) |
| 542 | my_generated_sources += $(rs_generated_cpps) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 543 | |
| 544 | endif |
| 545 | |
| 546 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 547 | ########################################################### |
| 548 | ## Stuff source generated from one-off tools |
| 549 | ########################################################### |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 550 | $(my_generated_sources): PRIVATE_MODULE := $(my_register_name) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 551 | |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 552 | my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 553 | |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 554 | $(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP) |
| 555 | @echo "Copy: $@" |
| 556 | $(copy-file-to-target) |
| 557 | |
| 558 | my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) |
| 559 | |
| 560 | ALL_GENERATED_SOURCES += $(my_generated_sources) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 561 | |
| 562 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 563 | ## Compile the .proto files to .cc and then to .o |
| 564 | ########################################################### |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 565 | proto_sources := $(filter %.proto,$(my_src_files)) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 566 | proto_generated_objects := |
| 567 | proto_generated_headers := |
| 568 | ifneq ($(proto_sources),) |
| 569 | proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 570 | proto_generated_cc_sources_dir := $(generated_sources_dir)/proto |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 571 | proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 572 | $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath))) |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 573 | proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) |
| 574 | proto_generated_obj_dir := $(intermediates)/proto |
| 575 | proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ |
| 576 | $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 577 | |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 578 | # Ensure the transform-proto-to-cc rule is only defined once in multilib build. |
| 579 | ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 580 | $(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) |
| 581 | $(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir) |
Ying Wang | 33c0d95 | 2010-11-05 11:30:58 -0700 | [diff] [blame] | 582 | $(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 583 | $(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC) |
| 584 | $(transform-proto-to-cc) |
| 585 | |
Stephen Hines | 8ff9252 | 2014-06-06 12:51:47 -0700 | [diff] [blame] | 586 | # This is just a dummy rule to make sure gmake doesn't skip updating the dependents. |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 587 | $(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc |
Ying Wang | 81ab833 | 2014-05-28 16:17:09 -0700 | [diff] [blame] | 588 | @echo "Updated header file $@." |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 589 | |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 590 | $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true |
| 591 | endif # transform-proto-to-cc rule included only once |
| 592 | |
Ying Wang | 022a7b3 | 2012-06-13 11:38:10 -0700 | [diff] [blame] | 593 | $(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 594 | $(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 595 | $(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 596 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 597 | -include $(proto_generated_objects:%.o=%.P) |
| 598 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 599 | my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir) |
| 600 | my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 601 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 602 | my_static_libraries += libprotobuf-cpp-2.3.0-full |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 603 | else |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 604 | my_static_libraries += libprotobuf-cpp-2.3.0-lite |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 605 | endif |
Ying Wang | 031e0fb | 2014-02-25 11:18:40 -0800 | [diff] [blame] | 606 | endif # $(proto_sources) non-empty |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 607 | |
| 608 | |
| 609 | ########################################################### |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 610 | ## YACC: Compile .y and .yy files to .cpp and the to .o. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 611 | ########################################################### |
| 612 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 613 | y_yacc_sources := $(filter %.y,$(my_src_files)) |
| 614 | y_yacc_cpps := $(addprefix \ |
| 615 | $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) |
| 616 | |
| 617 | yy_yacc_sources := $(filter %.yy,$(my_src_files)) |
| 618 | yy_yacc_cpps := $(addprefix \ |
| 619 | $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) |
| 620 | |
| 621 | yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 622 | yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) |
| 623 | yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 624 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 625 | ifneq ($(strip $(y_yacc_cpps)),) |
| 626 | $(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 627 | $(TOPDIR)$(LOCAL_PATH)/%.y \ |
| 628 | $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 629 | $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) |
| 630 | $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 631 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 632 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 633 | ifneq ($(strip $(yy_yacc_cpps)),) |
| 634 | $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 635 | $(TOPDIR)$(LOCAL_PATH)/%.yy \ |
| 636 | $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 637 | $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) |
| 638 | $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 639 | endif |
| 640 | |
| 641 | ifneq ($(strip $(yacc_cpps)),) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 642 | $(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 643 | $(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 644 | $(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 645 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 646 | endif |
| 647 | |
| 648 | ########################################################### |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 649 | ## LEX: Compile .l and .ll files to .cpp and then to .o. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 650 | ########################################################### |
| 651 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 652 | l_lex_sources := $(filter %.l,$(my_src_files)) |
| 653 | l_lex_cpps := $(addprefix \ |
| 654 | $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION))) |
| 655 | |
| 656 | ll_lex_sources := $(filter %.ll,$(my_src_files)) |
| 657 | ll_lex_cpps := $(addprefix \ |
| 658 | $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) |
| 659 | |
| 660 | lex_cpps := $(l_lex_cpps) $(ll_lex_cpps) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 661 | lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 662 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 663 | ifneq ($(strip $(l_lex_cpps)),) |
| 664 | $(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 665 | $(TOPDIR)$(LOCAL_PATH)/%.l |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 666 | $(transform-l-to-cpp) |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 667 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 668 | |
Nicolas Geoffray | 9484e2e | 2014-03-03 15:57:06 +0000 | [diff] [blame] | 669 | ifneq ($(strip $(ll_lex_cpps)),) |
| 670 | $(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 671 | $(TOPDIR)$(LOCAL_PATH)/%.ll |
| 672 | $(transform-l-to-cpp) |
| 673 | endif |
| 674 | |
| 675 | ifneq ($(strip $(lex_cpps)),) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 676 | $(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 677 | $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 678 | $(lex_objects): $(intermediates)/%.o: \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 679 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ |
| 680 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 681 | $(yacc_headers) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 682 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 683 | endif |
| 684 | |
| 685 | ########################################################### |
| 686 | ## C++: Compile .cpp files to .o. |
| 687 | ########################################################### |
| 688 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 689 | # we also do this on host modules, even though |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 690 | # it's not really arm, because there are files that are shared. |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 691 | cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 692 | cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 693 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 694 | cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 695 | cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 696 | |
| 697 | $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 698 | $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 699 | $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 700 | $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 701 | |
| 702 | cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) |
| 703 | |
| 704 | ifneq ($(strip $(cpp_objects)),) |
| 705 | $(cpp_objects): $(intermediates)/%.o: \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 706 | $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 707 | $(yacc_cpps) $(proto_generated_headers) \ |
| 708 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 709 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 710 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 711 | -include $(cpp_objects:%.o=%.P) |
| 712 | endif |
| 713 | |
| 714 | ########################################################### |
| 715 | ## C++: Compile generated .cpp files to .o. |
| 716 | ########################################################### |
| 717 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 718 | 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] | 719 | gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) |
| 720 | |
| 721 | ifneq ($(strip $(gen_cpp_objects)),) |
| 722 | # Compile all generated files as thumb. |
| 723 | # TODO: support compiling certain generated files as arm. |
| 724 | $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 725 | $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 726 | $(gen_cpp_objects): $(intermediates)/%.o: \ |
| 727 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 728 | $(proto_generated_headers) \ |
| 729 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 730 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 731 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 732 | -include $(gen_cpp_objects:%.o=%.P) |
| 733 | endif |
| 734 | |
| 735 | ########################################################### |
| 736 | ## S: Compile generated .S and .s files to .o. |
| 737 | ########################################################### |
| 738 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 739 | gen_S_sources := $(filter %.S,$(my_generated_sources)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 740 | gen_S_objects := $(gen_S_sources:%.S=%.o) |
| 741 | |
| 742 | ifneq ($(strip $(gen_S_sources)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 743 | $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 744 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 745 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 746 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 747 | -include $(gen_S_objects:%.o=%.P) |
| 748 | endif |
| 749 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 750 | gen_s_sources := $(filter %.s,$(my_generated_sources)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 751 | gen_s_objects := $(gen_s_sources:%.s=%.o) |
| 752 | |
| 753 | ifneq ($(strip $(gen_s_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 754 | $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 755 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 756 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 757 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 758 | -include $(gen_s_objects:%.o=%.P) |
| 759 | endif |
| 760 | |
| 761 | gen_asm_objects := $(gen_S_objects) $(gen_s_objects) |
| 762 | |
| 763 | ########################################################### |
Torne (Richard Coles) | aace202 | 2013-02-21 14:01:35 +0000 | [diff] [blame] | 764 | ## o: Include generated .o files in output. |
| 765 | ########################################################### |
| 766 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 767 | gen_o_objects := $(filter %.o,$(my_generated_sources)) |
Torne (Richard Coles) | aace202 | 2013-02-21 14:01:35 +0000 | [diff] [blame] | 768 | |
| 769 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 770 | ## C: Compile .c files to .o. |
| 771 | ########################################################### |
| 772 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 773 | c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 774 | c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) |
| 775 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 776 | c_normal_sources := $(filter %.c,$(my_src_files)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 777 | c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) |
| 778 | |
| 779 | $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 780 | $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 781 | $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 782 | $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 783 | |
| 784 | c_objects := $(c_arm_objects) $(c_normal_objects) |
| 785 | |
| 786 | ifneq ($(strip $(c_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 787 | $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 788 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 789 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 790 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 791 | -include $(c_objects:%.o=%.P) |
| 792 | endif |
| 793 | |
| 794 | ########################################################### |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 795 | ## C: Compile generated .c files to .o. |
| 796 | ########################################################### |
| 797 | |
Ying Wang | ec6d626 | 2014-01-16 16:21:03 -0800 | [diff] [blame] | 798 | gen_c_sources := $(filter %.c,$(my_generated_sources)) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 799 | gen_c_objects := $(gen_c_sources:%.c=%.o) |
| 800 | |
| 801 | ifneq ($(strip $(gen_c_objects)),) |
| 802 | # Compile all generated files as thumb. |
| 803 | # TODO: support compiling certain generated files as arm. |
| 804 | $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 805 | $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 806 | $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 807 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 808 | | $(my_compiler_dependencies) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 809 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 810 | -include $(gen_c_objects:%.o=%.P) |
| 811 | endif |
| 812 | |
| 813 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 814 | ## ObjC: Compile .m files to .o |
| 815 | ########################################################### |
| 816 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 817 | objc_sources := $(filter %.m,$(my_src_files)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 818 | objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) |
| 819 | |
| 820 | ifneq ($(strip $(objc_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 821 | $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 822 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 823 | | $(my_compiler_dependencies) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 824 | $(transform-$(PRIVATE_HOST)m-to-o) |
| 825 | -include $(objc_objects:%.o=%.P) |
| 826 | endif |
| 827 | |
| 828 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 829 | ## AS: Compile .S files to .o. |
| 830 | ########################################################### |
| 831 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 832 | asm_sources_S := $(filter %.S,$(my_src_files)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 833 | asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) |
| 834 | |
| 835 | ifneq ($(strip $(asm_objects_S)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 836 | $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 837 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 838 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 839 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 840 | -include $(asm_objects_S:%.o=%.P) |
| 841 | endif |
| 842 | |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 843 | asm_sources_s := $(filter %.s,$(my_src_files)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 844 | asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) |
| 845 | |
| 846 | ifneq ($(strip $(asm_objects_s)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 847 | $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 848 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 849 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 850 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 851 | -include $(asm_objects_s:%.o=%.P) |
| 852 | endif |
| 853 | |
| 854 | asm_objects := $(asm_objects_S) $(asm_objects_s) |
| 855 | |
| 856 | |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 857 | # .asm for x86 needs to be compiled with yasm. |
| 858 | ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
| 859 | asm_sources_asm := $(filter %.asm,$(my_src_files)) |
| 860 | ifneq ($(strip $(asm_sources_asm)),) |
| 861 | asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) |
| 862 | $(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ |
| 863 | $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 864 | $(transform-asm-to-o) |
| 865 | |
| 866 | asm_objects += $(asm_objects_asm) |
| 867 | endif |
| 868 | endif |
| 869 | |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 870 | #################################################### |
| 871 | ## Import includes |
| 872 | #################################################### |
| 873 | import_includes := $(intermediates)/import_includes |
| 874 | import_includes_deps := $(strip \ |
| 875 | $(foreach l, $(installed_shared_library_module_names), \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 876 | $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 877 | $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 878 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes)) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 879 | $(import_includes) : $(import_includes_deps) |
| 880 | @echo Import includes file: $@ |
| 881 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 882 | ifdef import_includes_deps |
| 883 | $(hide) for f in $^; do \ |
| 884 | cat $$f >> $@; \ |
| 885 | done |
| 886 | else |
| 887 | $(hide) touch $@ |
| 888 | endif |
| 889 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 890 | ########################################################### |
| 891 | ## Common object handling. |
| 892 | ########################################################### |
| 893 | |
| 894 | # some rules depend on asm_objects being first. If your code depends on |
| 895 | # being first, it's reasonable to require it to be assembly |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 896 | normal_objects := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 897 | $(asm_objects) \ |
| 898 | $(cpp_objects) \ |
| 899 | $(gen_cpp_objects) \ |
| 900 | $(gen_asm_objects) \ |
| 901 | $(c_objects) \ |
| 902 | $(gen_c_objects) \ |
| 903 | $(objc_objects) \ |
| 904 | $(yacc_objects) \ |
| 905 | $(lex_objects) \ |
| 906 | $(proto_generated_objects) \ |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 907 | $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) |
| 908 | |
| 909 | all_objects := $(normal_objects) $(gen_o_objects) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 910 | |
Colin Cross | 2d20670 | 2014-02-13 13:41:52 -0800 | [diff] [blame] | 911 | 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] | 912 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 913 | ifndef LOCAL_SDK_VERSION |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 914 | my_c_includes += $(JNI_H_INCLUDE) |
Ying Wang | bce4b75 | 2010-07-22 15:51:56 -0700 | [diff] [blame] | 915 | endif |
| 916 | |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 917 | # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; |
| 918 | # use normal_objects here to avoid creating circular dependencies. This assumes |
| 919 | # that custom build rules which generate .o files don't consume other generated |
| 920 | # 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] | 921 | $(normal_objects) : | $(my_generated_sources) |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 922 | $(all_objects) : | $(import_includes) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 923 | ALL_C_CPP_ETC_OBJECTS += $(all_objects) |
| 924 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 925 | |
| 926 | ########################################################### |
| 927 | # Standard library handling. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 928 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 929 | |
| 930 | ########################################################### |
| 931 | # The list of libraries that this module will link against are in |
| 932 | # these variables. Each is a list of bare module names like "libc libm". |
| 933 | # |
| 934 | # LOCAL_SHARED_LIBRARIES |
| 935 | # LOCAL_STATIC_LIBRARIES |
| 936 | # LOCAL_WHOLE_STATIC_LIBRARIES |
| 937 | # |
| 938 | # We need to convert the bare names into the dependencies that |
| 939 | # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. |
| 940 | # LOCAL_BUILT_MODULE should depend on the BUILT versions of the |
| 941 | # libraries, so that simply building this module doesn't force |
| 942 | # an install of a library. Similarly, LOCAL_INSTALLED_MODULE |
| 943 | # should depend on the INSTALLED versions of the libraries so |
| 944 | # that they get installed when this module does. |
| 945 | ########################################################### |
| 946 | # NOTE: |
| 947 | # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the |
| 948 | # module without leaving anything out, which is useful for turning |
| 949 | # a collection of .a files into a .so file. Linking against a |
| 950 | # normal STATIC_LIBRARY will only pull in code/symbols that are |
| 951 | # referenced by the module. (see gcc/ld's --whole-archive option) |
| 952 | ########################################################### |
| 953 | |
| 954 | # Get the list of BUILT libraries, which are under |
| 955 | # various intermediates directories. |
| 956 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 957 | a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) |
| 958 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 959 | ifdef LOCAL_SDK_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 960 | built_shared_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 961 | $(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] | 962 | $(addsuffix $(so_suffix), \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 963 | $(my_shared_libraries))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 964 | |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 965 | # Add the NDK libraries to the built module dependency |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 966 | my_system_shared_libraries_fullpath := \ |
| 967 | $(my_ndk_stl_shared_lib_fullpath) \ |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 968 | $(addprefix $(my_ndk_sysroot_lib)/, \ |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 969 | $(addsuffix $(so_suffix), $(my_system_shared_libraries))) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 970 | |
| 971 | built_shared_libraries += $(my_system_shared_libraries_fullpath) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 972 | else |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 973 | built_shared_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 974 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 975 | $(addsuffix $(so_suffix), \ |
Ying Wang | d8d3721 | 2014-03-21 16:17:04 -0700 | [diff] [blame] | 976 | $(installed_shared_library_module_names))) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 977 | endif |
| 978 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 979 | built_static_libraries := \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 980 | $(foreach lib,$(my_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 981 | $(call intermediates-dir-for, \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 982 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 983 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 984 | ifdef LOCAL_SDK_VERSION |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 985 | built_static_libraries += $(my_ndk_stl_static_lib) |
| 986 | endif |
| 987 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 988 | built_whole_libraries := \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 989 | $(foreach lib,$(my_whole_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 990 | $(call intermediates-dir-for, \ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 991 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 992 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 993 | # We don't care about installed static libraries, since the |
| 994 | # libraries have already been linked into the module at that point. |
| 995 | # We do, however, care about the NOTICE files for any static |
Steve Block | d14d3b4 | 2012-03-01 11:34:41 +0000 | [diff] [blame] | 996 | # libraries that we use. (see notice_files.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 997 | |
| 998 | installed_static_library_notice_file_targets := \ |
Colin Cross | 90353fe | 2014-02-04 14:53:25 -0800 | [diff] [blame] | 999 | $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1000 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) |
| 1001 | |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1002 | # Default is -fno-rtti. |
Doug Kwan | e3c3c6d | 2011-06-07 10:55:48 -0700 | [diff] [blame] | 1003 | ifeq ($(strip $(LOCAL_RTTI_FLAG)),) |
| 1004 | LOCAL_RTTI_FLAG := -fno-rtti |
| 1005 | endif |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1006 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1007 | ########################################################### |
| 1008 | # Rule-specific variable definitions |
| 1009 | ########################################################### |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1010 | |
Ying Wang | 824344a | 2014-05-27 13:03:36 -0700 | [diff] [blame] | 1011 | ifeq ($(my_clang),true) |
Chih-Hung Hsieh | 9aa69a6 | 2014-09-04 17:15:47 -0700 | [diff] [blame] | 1012 | my_cflags += $(LOCAL_CLANG_CFLAGS) |
| 1013 | my_cpplags += $(LOCAL_CLANG_CPPFLAGS) |
| 1014 | my_asflags += $(LOCAL_CLANG_ASFLAGS) |
| 1015 | my_ldflags += $(LOCAL_CLANG_LDFLAGS) |
Ying Wang | 1f98283 | 2014-02-06 18:08:44 -0800 | [diff] [blame] | 1016 | my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) |
| 1017 | my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) |
| 1018 | my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) |
| 1019 | my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1020 | endif |
| 1021 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1022 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1023 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) |
Ying Wang | 7429e21 | 2012-08-15 10:59:10 -0700 | [diff] [blame] | 1024 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1025 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) |
| 1026 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1027 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1028 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1029 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1030 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1031 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) |
Dan Albert | b05f2ca | 2014-09-12 14:46:57 -0700 | [diff] [blame] | 1032 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 1033 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) |
Ying Wang | d90de32 | 2014-05-23 16:42:37 -0700 | [diff] [blame] | 1034 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1035 | |
| 1036 | # this is really the way to get the files onto the command line instead |
| 1037 | # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work |
| 1038 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) |
| 1039 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) |
| 1040 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) |
| 1041 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) |
| 1042 | |
| 1043 | ########################################################### |
| 1044 | # Define library dependencies. |
| 1045 | ########################################################### |
| 1046 | # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. |
| 1047 | all_libraries := \ |
| 1048 | $(built_shared_libraries) \ |
| 1049 | $(built_static_libraries) \ |
| 1050 | $(built_whole_libraries) |
| 1051 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1052 | # Also depend on the notice files for any static libraries that |
| 1053 | # are linked into this module. This will force them to be installed |
| 1054 | # when this module is. |
| 1055 | $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1056 | |
| 1057 | ########################################################### |
| 1058 | # Export includes |
| 1059 | ########################################################### |
| 1060 | export_includes := $(intermediates)/export_includes |
| 1061 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 1062 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 1063 | @echo Export includes file: $< -- $@ |
| 1064 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 1065 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 1066 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 1067 | echo "-I $$d" >> $@; \ |
| 1068 | done |
| 1069 | else |
| 1070 | $(hide) touch $@ |
| 1071 | endif |
Ying Wang | 616e596 | 2012-04-18 17:35:55 -0700 | [diff] [blame] | 1072 | |
| 1073 | # Make sure export_includes gets generated when you are running mm/mmm |
| 1074 | $(LOCAL_BUILT_MODULE) : | $(export_includes) |