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 |
| 3 | ## asm/c/cpp/yacc/lex source files. |
| 4 | ## |
| 5 | ## The list of object files is exported in $(all_objects). |
| 6 | ########################################################### |
| 7 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 8 | my_ndk_version_root := |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 9 | ifdef LOCAL_SDK_VERSION |
Ying Wang | fe1bfe7 | 2012-08-14 11:08:03 -0700 | [diff] [blame] | 10 | ifdef LOCAL_NDK_VERSION |
| 11 | $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.) |
| 12 | endif |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 13 | ifdef LOCAL_IS_HOST_MODULE |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 14 | $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 15 | endif |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 16 | my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources |
| 17 | my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 18 | |
| 19 | # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. |
| 20 | # See ndk/docs/CPLUSPLUS-SUPPORT.html |
| 21 | my_ndk_stl_include_path := |
| 22 | my_ndk_stl_shared_lib_fullpath := |
| 23 | my_ndk_stl_shared_lib := |
| 24 | my_ndk_stl_static_lib := |
| 25 | ifeq (,$(LOCAL_NDK_STL_VARIANT)) |
| 26 | LOCAL_NDK_STL_VARIANT := system |
| 27 | endif |
| 28 | ifneq (1,$(words $(filter system stlport_static stlport_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 29 | $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 30 | endif |
| 31 | ifeq (system,$(LOCAL_NDK_STL_VARIANT)) |
| 32 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include |
| 33 | # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default. |
| 34 | else # LOCAL_NDK_STL_VARIANT is not system |
| 35 | ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) |
| 36 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport |
| 37 | ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) |
| 38 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_static.a |
| 39 | else |
| 40 | my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so |
| 41 | my_ndk_stl_shared_lib := -lstlport_shared |
| 42 | endif |
| 43 | else |
| 44 | # LOCAL_NDK_STL_VARIANT is gnustl_static |
Ying Wang | d9020c2 | 2011-09-07 14:31:47 -0700 | [diff] [blame] | 45 | my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/include \ |
| 46 | $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 47 | my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/libgnustl_static.a |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 48 | endif |
| 49 | endif |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 50 | endif |
| 51 | |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 52 | ################################################## |
| 53 | # Compute the dependency of the shared libraries |
| 54 | ################################################## |
| 55 | # On the target, we compile with -nostdlib, so we must add in the |
| 56 | # default system shared libraries, unless they have requested not |
| 57 | # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would |
| 58 | # supply that, for example, when building libc itself. |
| 59 | ifdef LOCAL_IS_HOST_MODULE |
| 60 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
| 61 | LOCAL_SYSTEM_SHARED_LIBRARIES := |
| 62 | endif |
| 63 | else |
| 64 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
| 65 | LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES) |
| 66 | endif |
| 67 | endif |
| 68 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 69 | ifdef LOCAL_SDK_VERSION |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 70 | # Get the list of INSTALLED libraries as module names. |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 71 | # We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 72 | # they may cusomize their install path with LOCAL_MODULE_PATH |
| 73 | installed_shared_library_module_names := \ |
| 74 | $(LOCAL_SHARED_LIBRARIES) |
| 75 | else |
| 76 | installed_shared_library_module_names := \ |
| 77 | $(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES) |
| 78 | endif |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 79 | installed_shared_library_module_names := $(sort $(installed_shared_library_module_names)) |
Ying Wang | 704c0c9 | 2011-09-15 13:50:52 -0700 | [diff] [blame] | 80 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 81 | ####################################### |
| 82 | include $(BUILD_SYSTEM)/base_rules.mk |
| 83 | ####################################### |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 84 | |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 85 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 86 | # of the shared libraries are determined. |
| 87 | ifdef LOCAL_INSTALLED_MODULE |
| 88 | ifdef installed_shared_library_module_names |
Ying Wang | d6b1d61 | 2013-04-15 17:32:21 -0700 | [diff] [blame] | 89 | $(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names)) |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 90 | endif |
| 91 | endif |
| 92 | |
Ying Wang | 285045b | 2013-08-13 12:35:10 -0700 | [diff] [blame] | 93 | # Add static HAL libraries |
| 94 | ifdef LOCAL_HAL_STATIC_LIBRARIES |
| 95 | $(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ |
| 96 | $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ |
| 97 | $(if $(b_lib), $(eval LOCAL_STATIC_LIBRARIES += $(b_lib)),\ |
| 98 | $(eval LOCAL_STATIC_LIBRARIES += $(lib).default))) |
| 99 | b_lib := |
| 100 | endif |
| 101 | |
Evgeniy Stepanov | 6cc9c06 | 2012-03-30 12:15:12 +0400 | [diff] [blame] | 102 | ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true) |
| 103 | LOCAL_CLANG := true |
| 104 | LOCAL_CFLAGS += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS) |
| 105 | LOCAL_LDFLAGS += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS) |
| 106 | LOCAL_SHARED_LIBRARIES += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) |
| 107 | LOCAL_STATIC_LIBRARIES += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES) |
| 108 | endif |
| 109 | |
Mike Lockwood | 051a174 | 2013-06-14 10:52:50 -0700 | [diff] [blame] | 110 | ifeq ($(strip $(WITHOUT_CLANG)),true) |
| 111 | LOCAL_CLANG := |
| 112 | endif |
| 113 | |
Shih-wei Liao | c8dfc16 | 2013-01-27 01:45:59 -0800 | [diff] [blame] | 114 | # Add in libcompiler_rt for all regular device builds |
Mike Lockwood | daf5e22 | 2012-10-18 10:17:47 -0700 | [diff] [blame] | 115 | ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT)) |
Stephen Hines | c72f396 | 2012-06-11 14:53:34 -0700 | [diff] [blame] | 116 | LOCAL_STATIC_LIBRARIES += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) |
| 117 | endif |
| 118 | |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 119 | my_compiler_dependencies := |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 120 | ifeq ($(strip $(LOCAL_CLANG)),true) |
| 121 | LOCAL_CFLAGS += $(CLANG_CONFIG_EXTRA_CFLAGS) |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 122 | LOCAL_ASFLAGS += $(CLANG_CONFIG_EXTRA_ASFLAGS) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 123 | LOCAL_LDFLAGS += $(CLANG_CONFIG_EXTRA_LDFLAGS) |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 124 | my_compiler_dependencies := $(CLANG) $(CLANG_CXX) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 125 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 126 | |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 127 | #################################################### |
| 128 | ## Add FDO flags if FDO is turned on and supported |
| 129 | #################################################### |
synergydev | 7c46742 | 2013-08-13 17:41:52 -0700 | [diff] [blame] | 130 | ifneq ($(strip $(LOCAL_FDO_SUPPORT)),) |
synergydev | 4a60576 | 2013-08-05 02:44:37 -0700 | [diff] [blame] | 131 | ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),) |
| 132 | LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS) |
| 133 | LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS) |
| 134 | LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS) |
| 135 | endif |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 136 | endif |
| 137 | |
Kito Cheng | 70dc3e1 | 2012-06-15 15:15:50 +0800 | [diff] [blame] | 138 | #################################################### |
| 139 | ## Add profiling flags if aprof is turned on |
| 140 | #################################################### |
| 141 | ifeq ($(strip $(LOCAL_ENABLE_APROF)),true) |
| 142 | # -ffunction-sections and -fomit-frame-pointer are conflict with -pg |
| 143 | LOCAL_CFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg |
| 144 | LOCAL_CPPFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg |
| 145 | endif |
| 146 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 147 | ########################################################### |
Jim Huang | 20d1ba6 | 2010-10-14 16:15:56 +0800 | [diff] [blame] | 148 | ## Explicitly declare assembly-only __ASSEMBLY__ macro for |
| 149 | ## assembly source |
| 150 | ########################################################### |
| 151 | LOCAL_ASFLAGS += -D__ASSEMBLY__ |
| 152 | |
| 153 | ########################################################### |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 154 | ## Define PRIVATE_ variables from global vars |
| 155 | ########################################################### |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 156 | ifdef LOCAL_SDK_VERSION |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 157 | my_target_project_includes := |
Evgeniy Stepanov | a7095e9 | 2012-03-30 12:18:52 +0400 | [diff] [blame] | 158 | my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_version_root)/usr/include |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 159 | else |
| 160 | my_target_project_includes := $(TARGET_PROJECT_INCLUDES) |
Evgeniy Stepanov | a7095e9 | 2012-03-30 12:18:52 +0400 | [diff] [blame] | 161 | my_target_c_includes := $(TARGET_C_INCLUDES) |
Ying Wang | f4723fa | 2013-08-15 11:01:10 -0700 | [diff] [blame] | 162 | endif # LOCAL_SDK_VERSION |
| 163 | |
| 164 | ifeq ($(LOCAL_CLANG),true) |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 165 | my_target_global_cflags := $(TARGET_GLOBAL_CLANG_FLAGS) |
Ying Wang | f4723fa | 2013-08-15 11:01:10 -0700 | [diff] [blame] | 166 | my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 167 | else |
| 168 | my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS) |
| 169 | endif # LOCAL_CLANG |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 170 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 171 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) |
Evgeniy Stepanov | a7095e9 | 2012-03-30 12:18:52 +0400 | [diff] [blame] | 172 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 173 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) |
Ying Wang | da4bf42 | 2012-08-16 16:45:01 -0700 | [diff] [blame] | 174 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(TARGET_GLOBAL_CPPFLAGS) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 175 | |
| 176 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 177 | ## Define PRIVATE_ variables used by multiple module types |
| 178 | ########################################################### |
| 179 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 180 | $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 181 | |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 182 | ifeq ($(strip $(WITH_SYNTAX_CHECK)),) |
| 183 | LOCAL_NO_SYNTAX_CHECK := true |
| 184 | endif |
| 185 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 186 | ifeq ($(strip $(WITH_STATIC_ANALYZER)),) |
| 187 | LOCAL_NO_STATIC_ANALYZER := true |
| 188 | endif |
| 189 | |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 190 | ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) |
| 191 | my_syntax_arch := host |
| 192 | else |
| 193 | my_syntax_arch := $(TARGET_ARCH) |
| 194 | endif |
| 195 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 196 | ifeq ($(strip $(LOCAL_CC)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 197 | ifeq ($(strip $(LOCAL_CLANG)),true) |
| 198 | LOCAL_CC := $(CLANG) |
| 199 | else |
| 200 | LOCAL_CC := $($(my_prefix)CC) |
| 201 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 202 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 203 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
| 204 | LOCAL_CC := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(LOCAL_CC)" |
| 205 | else |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 206 | ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) |
| 207 | LOCAL_CC := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(LOCAL_CC)" |
| 208 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 209 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 210 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC) |
| 211 | |
| 212 | ifeq ($(strip $(LOCAL_CXX)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 213 | ifeq ($(strip $(LOCAL_CLANG)),true) |
| 214 | LOCAL_CXX := $(CLANG_CXX) |
| 215 | else |
| 216 | LOCAL_CXX := $($(my_prefix)CXX) |
| 217 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 218 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 219 | ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) |
| 220 | LOCAL_CXX := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(LOCAL_CXX)" |
| 221 | else |
Andrew Hsieh | 6cea59a | 2013-08-27 17:33:06 +0800 | [diff] [blame] | 222 | ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) |
| 223 | LOCAL_CXX := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(LOCAL_CXX)" |
| 224 | endif |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 225 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 226 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX) |
| 227 | |
| 228 | # TODO: support a mix of standard extensions so that this isn't necessary |
| 229 | LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) |
| 230 | ifeq ($(LOCAL_CPP_EXTENSION),) |
| 231 | LOCAL_CPP_EXTENSION := .cpp |
| 232 | endif |
| 233 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) |
| 234 | |
| 235 | # Certain modules like libdl have to have symbols resolved at runtime and blow |
| 236 | # up if --no-undefined is passed to the linker. |
| 237 | ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) |
| 238 | ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) |
| 239 | LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS) |
| 240 | endif |
| 241 | endif |
| 242 | |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 243 | ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) |
| 244 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true |
| 245 | else |
| 246 | $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := |
| 247 | endif |
| 248 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 249 | ########################################################### |
| 250 | ## Define arm-vs-thumb-mode flags. |
| 251 | ########################################################### |
| 252 | LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) |
Chih-Wei Huang | 0d09e58 | 2010-07-09 10:07:52 +0800 | [diff] [blame] | 253 | ifeq ($(TARGET_ARCH),arm) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 254 | arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) |
| 255 | normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) |
| 256 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 257 | # Read the values from something like TARGET_arm_CFLAGS or |
| 258 | # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't |
| 259 | # actually used (although they are usually empty). |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 260 | ifeq ($(strip $(LOCAL_CLANG)),true) |
| 261 | arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CLANG_CFLAGS) |
| 262 | normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CLANG_CFLAGS) |
| 263 | else |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 264 | arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS) |
| 265 | normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS) |
Evgeniy Stepanov | f50f4c5 | 2012-04-05 11:44:37 +0400 | [diff] [blame] | 266 | endif |
| 267 | |
Chih-Wei Huang | 0d09e58 | 2010-07-09 10:07:52 +0800 | [diff] [blame] | 268 | else |
| 269 | arm_objects_mode := |
| 270 | normal_objects_mode := |
| 271 | arm_objects_cflags := |
| 272 | normal_objects_cflags := |
| 273 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 274 | |
| 275 | ########################################################### |
| 276 | ## Define per-module debugging flags. Users can turn on |
| 277 | ## debugging for a particular module by setting DEBUG_MODULE_ModuleName |
| 278 | ## to a non-empty value in their environment or buildspec.mk, |
| 279 | ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the |
| 280 | ## debug flags that they want to use. |
| 281 | ########################################################### |
| 282 | ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) |
| 283 | debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) |
| 284 | else |
| 285 | debug_cflags := |
| 286 | endif |
| 287 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 288 | #################################################### |
| 289 | ## Compile RenderScript with reflected C++ |
| 290 | #################################################### |
| 291 | |
| 292 | renderscript_sources := $(filter %.rs %.fs,$(LOCAL_SRC_FILES)) |
| 293 | |
| 294 | ifneq (,$(renderscript_sources)) |
| 295 | |
| 296 | renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) |
| 297 | RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp |
| 298 | renderscript_intermediate := $(intermediates)/renderscript |
| 299 | |
| 300 | ifeq ($(LOCAL_RENDERSCRIPT_CC),) |
| 301 | LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) |
| 302 | endif |
| 303 | |
| 304 | # Turn on all warnings and warnings as errors for RS compiles. |
| 305 | # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error |
| 306 | renderscript_flags := -Wall -Werror |
| 307 | renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) |
| 308 | |
| 309 | LOCAL_RENDERSCRIPT_INCLUDES := \ |
| 310 | $(TOPDIR)external/clang/lib/Headers \ |
| 311 | $(TOPDIR)frameworks/rs/scriptc \ |
| 312 | $(LOCAL_RENDERSCRIPT_INCLUDES) |
| 313 | |
| 314 | ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) |
| 315 | LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) |
| 316 | endif |
| 317 | |
| 318 | $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) |
| 319 | $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) |
| 320 | $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) |
| 321 | $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) |
| 322 | $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) |
| 323 | $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) |
| 324 | $(transform-renderscripts-to-cpp-and-bc) |
| 325 | |
| 326 | # include the dependency files (.d) generated by llvm-rs-cc. |
| 327 | renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \ |
| 328 | $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) |
| 329 | -include $(renderscript_generated_dep_files) |
| 330 | |
| 331 | LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) |
| 332 | |
| 333 | rs_generated_cpps := $(addprefix \ |
| 334 | $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ |
| 335 | $(notdir $(renderscript_sources))))) |
| 336 | |
| 337 | $(rs_generated_cpps) : $(RenderScript_file_stamp) |
| 338 | |
| 339 | LOCAL_C_INCLUDES += $(renderscript_intermediate) |
| 340 | LOCAL_GENERATED_SOURCES += $(rs_generated_cpps) |
| 341 | |
| 342 | endif |
| 343 | |
| 344 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 345 | ########################################################### |
| 346 | ## Stuff source generated from one-off tools |
| 347 | ########################################################### |
| 348 | $(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 349 | |
| 350 | ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES) |
| 351 | |
| 352 | |
| 353 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 354 | ## Compile the .proto files to .cc and then to .o |
| 355 | ########################################################### |
| 356 | proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) |
| 357 | proto_generated_objects := |
| 358 | proto_generated_headers := |
| 359 | ifneq ($(proto_sources),) |
| 360 | proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) |
| 361 | proto_generated_cc_sources_dir := $(intermediates)/proto |
| 362 | proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 363 | $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath))) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 364 | proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources)) |
| 365 | |
| 366 | $(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) |
| 367 | $(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] | 368 | $(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 369 | $(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC) |
| 370 | $(transform-proto-to-cc) |
| 371 | |
| 372 | proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) |
| 373 | $(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc |
| 374 | |
Ying Wang | 022a7b3 | 2012-06-13 11:38:10 -0700 | [diff] [blame] | 375 | $(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 376 | $(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Narayan Kamath | 2109487 | 2012-04-02 18:19:31 +0100 | [diff] [blame] | 377 | $(proto_generated_objects): $(proto_generated_cc_sources_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 378 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 379 | -include $(proto_generated_objects:%.o=%.P) |
| 380 | |
| 381 | LOCAL_C_INCLUDES += external/protobuf/src $(proto_generated_cc_sources_dir) |
| 382 | LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI |
| 383 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) |
| 384 | LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-full |
| 385 | else |
| 386 | LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-lite |
| 387 | endif |
| 388 | endif |
| 389 | |
| 390 | |
| 391 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 392 | ## YACC: Compile .y files to .cpp and the to .o. |
| 393 | ########################################################### |
| 394 | |
| 395 | yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES)) |
| 396 | yacc_cpps := $(addprefix \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 397 | $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 398 | yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) |
| 399 | yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 400 | |
| 401 | ifneq ($(strip $(yacc_cpps)),) |
| 402 | $(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 403 | $(TOPDIR)$(LOCAL_PATH)/%.y \ |
| 404 | $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 405 | $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) |
| 406 | $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 407 | |
| 408 | $(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 409 | $(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 410 | $(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 411 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 412 | endif |
| 413 | |
| 414 | ########################################################### |
| 415 | ## LEX: Compile .l files to .cpp and then to .o. |
| 416 | ########################################################### |
| 417 | |
| 418 | lex_sources := $(filter %.l,$(LOCAL_SRC_FILES)) |
| 419 | lex_cpps := $(addprefix \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 420 | $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 421 | lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 422 | |
| 423 | ifneq ($(strip $(lex_cpps)),) |
| 424 | $(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 425 | $(TOPDIR)$(LOCAL_PATH)/%.l |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 426 | $(transform-l-to-cpp) |
| 427 | |
| 428 | $(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 429 | $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 430 | $(lex_objects): $(intermediates)/%.o: \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 431 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ |
| 432 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 433 | $(yacc_headers) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 434 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 435 | endif |
| 436 | |
| 437 | ########################################################### |
| 438 | ## C++: Compile .cpp files to .o. |
| 439 | ########################################################### |
| 440 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 441 | # we also do this on host modules, even though |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 442 | # it's not really arm, because there are files that are shared. |
| 443 | cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES))) |
| 444 | cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 445 | |
| 446 | cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES)) |
| 447 | cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 448 | |
| 449 | $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 450 | $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 451 | $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 452 | $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 453 | |
| 454 | cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) |
| 455 | |
| 456 | ifneq ($(strip $(cpp_objects)),) |
| 457 | $(cpp_objects): $(intermediates)/%.o: \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 458 | $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 459 | $(yacc_cpps) $(proto_generated_headers) \ |
| 460 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 461 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 462 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 463 | -include $(cpp_objects:%.o=%.P) |
| 464 | endif |
| 465 | |
| 466 | ########################################################### |
| 467 | ## C++: Compile generated .cpp files to .o. |
| 468 | ########################################################### |
| 469 | |
| 470 | gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES)) |
| 471 | gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) |
| 472 | |
| 473 | ifneq ($(strip $(gen_cpp_objects)),) |
| 474 | # Compile all generated files as thumb. |
| 475 | # TODO: support compiling certain generated files as arm. |
| 476 | $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 477 | $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 478 | $(gen_cpp_objects): $(intermediates)/%.o: \ |
| 479 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 480 | $(proto_generated_headers) \ |
| 481 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 482 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 483 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 484 | -include $(gen_cpp_objects:%.o=%.P) |
| 485 | endif |
| 486 | |
| 487 | ########################################################### |
| 488 | ## S: Compile generated .S and .s files to .o. |
| 489 | ########################################################### |
| 490 | |
| 491 | gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES)) |
| 492 | gen_S_objects := $(gen_S_sources:%.S=%.o) |
| 493 | |
| 494 | ifneq ($(strip $(gen_S_sources)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 495 | $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 496 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 497 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 498 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 499 | -include $(gen_S_objects:%.o=%.P) |
| 500 | endif |
| 501 | |
| 502 | gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES)) |
| 503 | gen_s_objects := $(gen_s_sources:%.s=%.o) |
| 504 | |
| 505 | ifneq ($(strip $(gen_s_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 506 | $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 507 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 508 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 509 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 510 | -include $(gen_s_objects:%.o=%.P) |
| 511 | endif |
| 512 | |
| 513 | gen_asm_objects := $(gen_S_objects) $(gen_s_objects) |
| 514 | |
| 515 | ########################################################### |
Torne (Richard Coles) | aace202 | 2013-02-21 14:01:35 +0000 | [diff] [blame] | 516 | ## o: Include generated .o files in output. |
| 517 | ########################################################### |
| 518 | |
| 519 | gen_o_objects := $(filter %.o,$(LOCAL_GENERATED_SOURCES)) |
| 520 | |
| 521 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 522 | ## C: Compile .c files to .o. |
| 523 | ########################################################### |
| 524 | |
| 525 | c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES))) |
| 526 | c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) |
| 527 | |
| 528 | c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES)) |
| 529 | c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) |
| 530 | |
| 531 | $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 532 | $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 533 | $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 534 | $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 535 | |
| 536 | c_objects := $(c_arm_objects) $(c_normal_objects) |
| 537 | |
| 538 | ifneq ($(strip $(c_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 539 | $(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] | 540 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 541 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 542 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 543 | -include $(c_objects:%.o=%.P) |
| 544 | endif |
| 545 | |
| 546 | ########################################################### |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 547 | ## C: Compile generated .c files to .o. |
| 548 | ########################################################### |
| 549 | |
| 550 | gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES)) |
| 551 | gen_c_objects := $(gen_c_sources:%.c=%.o) |
| 552 | |
| 553 | ifneq ($(strip $(gen_c_objects)),) |
| 554 | # Compile all generated files as thumb. |
| 555 | # TODO: support compiling certain generated files as arm. |
| 556 | $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 557 | $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 558 | $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 559 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 560 | | $(my_compiler_dependencies) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 561 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 562 | -include $(gen_c_objects:%.o=%.P) |
| 563 | endif |
| 564 | |
| 565 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 566 | ## ObjC: Compile .m files to .o |
| 567 | ########################################################### |
| 568 | |
| 569 | objc_sources := $(filter %.m,$(LOCAL_SRC_FILES)) |
| 570 | objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) |
| 571 | |
| 572 | ifneq ($(strip $(objc_objects)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 573 | $(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] | 574 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 575 | | $(my_compiler_dependencies) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 576 | $(transform-$(PRIVATE_HOST)m-to-o) |
| 577 | -include $(objc_objects:%.o=%.P) |
| 578 | endif |
| 579 | |
| 580 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 581 | ## AS: Compile .S files to .o. |
| 582 | ########################################################### |
| 583 | |
| 584 | asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES)) |
| 585 | asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) |
| 586 | |
| 587 | ifneq ($(strip $(asm_objects_S)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 588 | $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 589 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 590 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 591 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 592 | -include $(asm_objects_S:%.o=%.P) |
| 593 | endif |
| 594 | |
| 595 | asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES)) |
| 596 | asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) |
| 597 | |
| 598 | ifneq ($(strip $(asm_objects_s)),) |
Evgeniy Stepanov | b71e2df | 2012-03-20 18:00:16 +0400 | [diff] [blame] | 599 | $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ |
Ying Wang | 9c3aa05 | 2013-02-20 13:34:05 -0800 | [diff] [blame] | 600 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 601 | | $(my_compiler_dependencies) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 602 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 603 | -include $(asm_objects_s:%.o=%.P) |
| 604 | endif |
| 605 | |
| 606 | asm_objects := $(asm_objects_S) $(asm_objects_s) |
| 607 | |
| 608 | |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 609 | #################################################### |
| 610 | ## Import includes |
| 611 | #################################################### |
| 612 | import_includes := $(intermediates)/import_includes |
| 613 | import_includes_deps := $(strip \ |
| 614 | $(foreach l, $(installed_shared_library_module_names), \ |
| 615 | $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE))/export_includes) \ |
| 616 | $(foreach l, $(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 617 | $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE))/export_includes)) |
| 618 | $(import_includes) : $(import_includes_deps) |
| 619 | @echo Import includes file: $@ |
| 620 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 621 | ifdef import_includes_deps |
| 622 | $(hide) for f in $^; do \ |
| 623 | cat $$f >> $@; \ |
| 624 | done |
| 625 | else |
| 626 | $(hide) touch $@ |
| 627 | endif |
| 628 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 629 | ########################################################### |
| 630 | ## Common object handling. |
| 631 | ########################################################### |
| 632 | |
| 633 | # some rules depend on asm_objects being first. If your code depends on |
| 634 | # being first, it's reasonable to require it to be assembly |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 635 | normal_objects := \ |
Ying Wang | dfbe79b | 2012-03-22 11:26:22 -0700 | [diff] [blame] | 636 | $(asm_objects) \ |
| 637 | $(cpp_objects) \ |
| 638 | $(gen_cpp_objects) \ |
| 639 | $(gen_asm_objects) \ |
| 640 | $(c_objects) \ |
| 641 | $(gen_c_objects) \ |
| 642 | $(objc_objects) \ |
| 643 | $(yacc_objects) \ |
| 644 | $(lex_objects) \ |
| 645 | $(proto_generated_objects) \ |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 646 | $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) |
| 647 | |
| 648 | all_objects := $(normal_objects) $(gen_o_objects) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 649 | |
Colin Cross | 9ad36ef | 2012-03-30 19:31:00 -0700 | [diff] [blame] | 650 | LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 651 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 652 | ifndef LOCAL_SDK_VERSION |
Ying Wang | bce4b75 | 2010-07-22 15:51:56 -0700 | [diff] [blame] | 653 | LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) |
| 654 | endif |
| 655 | |
Torne (Richard Coles) | a5afbe8 | 2013-08-29 15:36:34 +0100 | [diff] [blame] | 656 | # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; |
| 657 | # use normal_objects here to avoid creating circular dependencies. This assumes |
| 658 | # that custom build rules which generate .o files don't consume other generated |
| 659 | # sources as input (or if they do they take care of that dependency themselves). |
| 660 | $(normal_objects) : | $(LOCAL_GENERATED_SOURCES) |
| 661 | $(all_objects) : | $(import_includes) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 662 | ALL_C_CPP_ETC_OBJECTS += $(all_objects) |
| 663 | |
| 664 | ########################################################### |
| 665 | ## Copy headers to the install tree |
| 666 | ########################################################### |
| 667 | include $(BUILD_COPY_HEADERS) |
| 668 | |
| 669 | ########################################################### |
| 670 | # Standard library handling. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 671 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 672 | |
| 673 | ########################################################### |
| 674 | # The list of libraries that this module will link against are in |
| 675 | # these variables. Each is a list of bare module names like "libc libm". |
| 676 | # |
| 677 | # LOCAL_SHARED_LIBRARIES |
| 678 | # LOCAL_STATIC_LIBRARIES |
| 679 | # LOCAL_WHOLE_STATIC_LIBRARIES |
| 680 | # |
| 681 | # We need to convert the bare names into the dependencies that |
| 682 | # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. |
| 683 | # LOCAL_BUILT_MODULE should depend on the BUILT versions of the |
| 684 | # libraries, so that simply building this module doesn't force |
| 685 | # an install of a library. Similarly, LOCAL_INSTALLED_MODULE |
| 686 | # should depend on the INSTALLED versions of the libraries so |
| 687 | # that they get installed when this module does. |
| 688 | ########################################################### |
| 689 | # NOTE: |
| 690 | # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the |
| 691 | # module without leaving anything out, which is useful for turning |
| 692 | # a collection of .a files into a .so file. Linking against a |
| 693 | # normal STATIC_LIBRARY will only pull in code/symbols that are |
| 694 | # referenced by the module. (see gcc/ld's --whole-archive option) |
| 695 | ########################################################### |
| 696 | |
| 697 | # Get the list of BUILT libraries, which are under |
| 698 | # various intermediates directories. |
| 699 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 700 | a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) |
| 701 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 702 | ifdef LOCAL_SDK_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 703 | built_shared_libraries := \ |
| 704 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 705 | $(addsuffix $(so_suffix), \ |
| 706 | $(LOCAL_SHARED_LIBRARIES))) |
| 707 | |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 708 | my_system_shared_libraries_fullpath := \ |
| 709 | $(my_ndk_stl_shared_lib_fullpath) \ |
| 710 | $(addprefix $(my_ndk_version_root)/usr/lib/, \ |
| 711 | $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES))) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 712 | |
| 713 | built_shared_libraries += $(my_system_shared_libraries_fullpath) |
| 714 | LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
| 715 | else |
| 716 | LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
| 717 | built_shared_libraries := \ |
| 718 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 719 | $(addsuffix $(so_suffix), \ |
| 720 | $(LOCAL_SHARED_LIBRARIES))) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 721 | endif |
| 722 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 723 | built_static_libraries := \ |
| 724 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \ |
| 725 | $(call intermediates-dir-for, \ |
| 726 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 727 | |
Ying Wang | 848020f | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 728 | ifdef LOCAL_SDK_VERSION |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 729 | built_static_libraries += $(my_ndk_stl_static_lib) |
| 730 | endif |
| 731 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 732 | built_whole_libraries := \ |
| 733 | $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 734 | $(call intermediates-dir-for, \ |
| 735 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 736 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 737 | # We don't care about installed static libraries, since the |
| 738 | # libraries have already been linked into the module at that point. |
| 739 | # We do, however, care about the NOTICE files for any static |
Steve Block | d14d3b4 | 2012-03-01 11:34:41 +0000 | [diff] [blame] | 740 | # libraries that we use. (see notice_files.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 741 | |
| 742 | installed_static_library_notice_file_targets := \ |
| 743 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 744 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) |
| 745 | |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 746 | # Default is -fno-rtti. |
Doug Kwan | e3c3c6d | 2011-06-07 10:55:48 -0700 | [diff] [blame] | 747 | ifeq ($(strip $(LOCAL_RTTI_FLAG)),) |
| 748 | LOCAL_RTTI_FLAG := -fno-rtti |
| 749 | endif |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 750 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 751 | ########################################################### |
| 752 | # Rule-specific variable definitions |
| 753 | ########################################################### |
| 754 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) |
| 755 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS) |
Ying Wang | 7429e21 | 2012-08-15 10:59:10 -0700 | [diff] [blame] | 756 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 757 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS) |
| 758 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS) |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 759 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 760 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) |
| 761 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 762 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 763 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS) |
| 764 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) |
Jeff Brown | 703e7c6 | 2011-02-04 20:15:00 -0800 | [diff] [blame] | 765 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(LOCAL_NO_CRT) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 766 | |
| 767 | # this is really the way to get the files onto the command line instead |
| 768 | # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work |
| 769 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) |
| 770 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) |
| 771 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) |
| 772 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) |
| 773 | |
| 774 | ########################################################### |
| 775 | # Define library dependencies. |
| 776 | ########################################################### |
| 777 | # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. |
| 778 | all_libraries := \ |
| 779 | $(built_shared_libraries) \ |
| 780 | $(built_static_libraries) \ |
| 781 | $(built_whole_libraries) |
| 782 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 783 | # Also depend on the notice files for any static libraries that |
| 784 | # are linked into this module. This will force them to be installed |
| 785 | # when this module is. |
| 786 | $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 787 | |
| 788 | ########################################################### |
| 789 | # Export includes |
| 790 | ########################################################### |
| 791 | export_includes := $(intermediates)/export_includes |
| 792 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 793 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 794 | @echo Export includes file: $< -- $@ |
| 795 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 796 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 797 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 798 | echo "-I $$d" >> $@; \ |
| 799 | done |
| 800 | else |
| 801 | $(hide) touch $@ |
| 802 | endif |
Ying Wang | 616e596 | 2012-04-18 17:35:55 -0700 | [diff] [blame] | 803 | |
| 804 | # Make sure export_includes gets generated when you are running mm/mmm |
| 805 | $(LOCAL_BUILT_MODULE) : | $(export_includes) |