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