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