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