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