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