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