binary.mk revision 3c8036da538bbbf259ae4d56cc808943398cc45b
1########################################################### 2## Standard rules for building binary object files from 3## asm/c/cpp/yacc/lex/etc source files. 4## 5## The list of object files is exported in $(all_objects). 6########################################################### 7 8####################################### 9include $(BUILD_SYSTEM)/base_rules.mk 10####################################### 11 12################################################## 13# Compute the dependency of the shared libraries 14################################################## 15# On the target, we compile with -nostdlib, so we must add in the 16# default system shared libraries, unless they have requested not 17# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would 18# supply that, for example, when building libc itself. 19ifdef LOCAL_IS_HOST_MODULE 20 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 21 my_system_shared_libraries := 22 else 23 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) 24 endif 25else 26 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 27 my_system_shared_libraries := libc libm 28 else 29 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) 30 endif 31endif 32 33# The following LOCAL_ variables will be modified in this file. 34# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, 35# we can't modify them in place. 36my_src_files := $(LOCAL_SRC_FILES) 37my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE) 38my_static_libraries := $(LOCAL_STATIC_LIBRARIES) 39my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) 40my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) 41my_cflags := $(LOCAL_CFLAGS) 42my_conlyflags := $(LOCAL_CONLYFLAGS) 43my_cppflags := $(LOCAL_CPPFLAGS) 44my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE) 45my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE) 46my_ldflags := $(LOCAL_LDFLAGS) 47my_ldlibs := $(LOCAL_LDLIBS) 48my_asflags := $(LOCAL_ASFLAGS) 49my_cc := $(LOCAL_CC) 50my_cc_wrapper := $(CC_WRAPPER) 51my_cxx := $(LOCAL_CXX) 52my_cxx_wrapper := $(CXX_WRAPPER) 53my_c_includes := $(LOCAL_C_INCLUDES) 54my_generated_sources := $(LOCAL_GENERATED_SOURCES) 55my_native_coverage := $(LOCAL_NATIVE_COVERAGE) 56my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES) 57my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS) 58 59ifdef LOCAL_IS_HOST_MODULE 60my_allow_undefined_symbols := true 61else 62my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)) 63endif 64 65my_ndk_sysroot := 66my_ndk_sysroot_include := 67my_ndk_sysroot_lib := 68ifdef LOCAL_SDK_VERSION 69 ifdef LOCAL_NDK_VERSION 70 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.) 71 endif 72 ifdef LOCAL_IS_HOST_MODULE 73 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) 74 endif 75 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources 76 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 77 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include 78 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 79 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64 80 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) 81 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6 82 else 83 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib 84 endif 85 86 # The bionic linker now has support for packed relocations and gnu style 87 # hashes (which are much faster!), but shipping to older devices requires 88 # the old style hash. Fortunately, we can build with both and it'll work 89 # anywhere. 90 # 91 # This is not currently supported on MIPS architectures. 92 ifeq (,$(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 93 my_ldflags += -Wl,--hash-style=both 94 endif 95 96 # We don't want to expose the relocation packer to the NDK just yet. 97 LOCAL_PACK_MODULE_RELOCATIONS := false 98 99 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. 100 # See ndk/docs/CPLUSPLUS-SUPPORT.html 101 my_ndk_stl_include_path := 102 my_ndk_stl_shared_lib_fullpath := 103 my_ndk_stl_shared_lib := 104 my_ndk_stl_static_lib := 105 my_ndk_stl_cppflags := 106 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) 107 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) 108 my_cpu_variant := mips32r6 109 endif 110 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) 111 ifeq (,$(LOCAL_NDK_STL_VARIANT)) 112 LOCAL_NDK_STL_VARIANT := system 113 endif 114 ifneq (1,$(words $(filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) 115 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) 116 endif 117 ifeq (system,$(LOCAL_NDK_STL_VARIANT)) 118 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include 119 my_system_shared_libraries += libstdc++ 120 else # LOCAL_NDK_STL_VARIANT is not system 121 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) 122 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport 123 my_system_shared_libraries += libstdc++ 124 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) 125 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a 126 else 127 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so 128 my_ndk_stl_shared_lib := -lstlport_shared 129 endif 130 else # LOCAL_NDK_STL_VARIANT is not stlport_* either 131 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) 132 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \ 133 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \ 134 $(my_ndk_source_root)/android/support/include 135 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) 136 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_static.a 137 else 138 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_shared.so 139 my_ndk_stl_shared_lib := -lc++_shared 140 endif 141 my_ndk_stl_cppflags := -std=c++11 142 else # LOCAL_NDK_STL_VARIANT is not c++_* either 143 ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT))) 144 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \ 145 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include 146 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a 147 else # LOCAL_NDK_STL_VARIANT must be none 148 # Do nothing. 149 endif 150 endif 151 endif 152 endif 153endif 154 155# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because 156# all code is position independent, and then those warnings get promoted to 157# errors. 158ifneq ($($(my_prefix)OS),windows) 159ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) 160my_cflags += -fpie 161else 162my_cflags += -fPIC 163endif 164endif 165 166ifdef LOCAL_IS_HOST_MODULE 167my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 168my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS)) 169my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS)) 170my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS)) 171my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS)) 172my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS)) 173my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS)) 174my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS)) 175my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS)) 176my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS)) 177endif 178 179my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 180my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix)) 181my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) 182my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) 183my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) 184my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) 185my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) 186my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) 187my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) 188 189my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude)) 190ifneq ($(my_missing_exclude_files),) 191$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES) 192$(error $(my_missing_exclude_files)) 193endif 194my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files)) 195 196my_clang := $(strip $(LOCAL_CLANG)) 197ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) 198my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) 199endif 200ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 201my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 202endif 203 204# clang is enabled by default for host builds 205# enable it unless we've specifically disabled clang above 206ifdef LOCAL_IS_HOST_MODULE 207 ifneq ($($(my_prefix)OS),windows) 208 ifeq ($(my_clang),) 209 my_clang := true 210 endif 211 endif 212# Add option to make gcc the default for device build 213else ifeq ($(USE_CLANG_PLATFORM_BUILD),false) 214 ifeq ($(my_clang),) 215 my_clang := false 216 endif 217else ifeq ($(my_clang),) 218 my_clang := true 219endif 220 221my_cpp_std_version := -std=gnu++14 222 223ifneq ($(my_clang),true) 224 # GCC uses an invalid C++14 ABI (emits calls to 225 # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI). 226 # http://b/25022512 227 my_cpp_std_version := -std=gnu++11 228endif 229 230ifdef LOCAL_SDK_VERSION 231 # The NDK handles this itself. 232 my_cpp_std_version := 233endif 234 235ifdef LOCAL_IS_HOST_MODULE 236 ifneq ($(my_clang),true) 237 # The host GCC doesn't support C++14 (and is deprecated, so likely 238 # never will). Build these modules with C++11. 239 my_cpp_std_version := -std=gnu++11 240 endif 241endif 242 243my_cppflags := $(my_cpp_std_version) $(my_cppflags) 244 245 246# arch-specific static libraries go first so that generic ones can depend on them 247my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) 248my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries) 249 250include $(BUILD_SYSTEM)/cxx_stl_setup.mk 251 252# Add static HAL libraries 253ifdef LOCAL_HAL_STATIC_LIBRARIES 254$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ 255 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ 256 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ 257 $(eval my_static_libraries += $(lib).default))) 258b_lib := 259endif 260 261ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),) 262 my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER) 263else 264 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER) 265endif 266 267include $(BUILD_SYSTEM)/config_sanitizers.mk 268 269# Add in libcompiler_rt for all regular device builds 270ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT)) 271 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) 272endif 273 274#################################################### 275## Add FDO flags if FDO is turned on and supported 276## Please note that we will do option filtering during FDO build. 277## i.e. Os->O2, remove -fno-early-inline and -finline-limit. 278################################################################## 279my_fdo_build := 280ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),) 281 ifeq ($(BUILD_FDO_INSTRUMENT),true) 282 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS) 283 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS) 284 my_fdo_build := true 285 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),) 286 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS) 287 my_fdo_build := true 288 endif 289 # Disable ccache (or other compiler wrapper) except gomacc, which 290 # can handle -fprofile-use properly. 291 my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper)) 292 my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper)) 293endif 294 295########################################################### 296## Explicitly declare assembly-only __ASSEMBLY__ macro for 297## assembly source 298########################################################### 299my_asflags += -D__ASSEMBLY__ 300 301 302########################################################### 303## Define PRIVATE_ variables from global vars 304########################################################### 305ifndef LOCAL_IS_HOST_MODULE 306ifdef LOCAL_SDK_VERSION 307my_target_project_includes := 308my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) 309my_target_global_cppflags := $(my_ndk_stl_cppflags) 310else 311my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) 312my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES) 313my_target_global_cppflags := 314endif # LOCAL_SDK_VERSION 315 316ifeq ($(my_clang),true) 317my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) 318my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS) 319my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) 320my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) 321else 322my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) 323my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS) 324my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) 325my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS) 326endif # my_clang 327 328$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) 329$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) 330$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) 331$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) 332$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) 333$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 334 335else # LOCAL_IS_HOST_MODULE 336 337ifeq ($(my_clang),true) 338my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) 339my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) 340my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) 341my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) 342my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) 343else 344my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) 345my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) 346my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) 347my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) 348my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) 349endif # my_clang 350 351$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) 352$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) 353$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags) 354$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) 355$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) 356endif # LOCAL_IS_HOST_MODULE 357 358# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and 359# build with NATIVE_COVERAGE=true in your enviornment. Note that the build 360# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a 361# clean build of your module after toggling it. 362ifeq ($(NATIVE_COVERAGE),true) 363 ifeq ($(my_native_coverage),true) 364 # Note that clang coverage doesn't play nicely with acov out of the box. 365 # Clang apparently generates .gcno files that aren't compatible with 366 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov 367 # with `--gcov-tool /usr/bin/gcov-4.6`. 368 # 369 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output 370 my_cflags += --coverage -O0 371 my_ldflags += --coverage 372 endif 373else 374 my_native_coverage := false 375endif 376 377ifeq ($(my_clang),true) 378 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) 379else 380 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) 381endif 382 383$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib) 384 385########################################################### 386## Define PRIVATE_ variables used by multiple module types 387########################################################### 388$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ 389 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) 390 391ifeq ($(strip $(WITH_SYNTAX_CHECK)),) 392 LOCAL_NO_SYNTAX_CHECK := true 393endif 394 395ifeq ($(strip $(WITH_STATIC_ANALYZER)),) 396 LOCAL_NO_STATIC_ANALYZER := true 397endif 398 399ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) 400 my_syntax_arch := host 401else 402 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 403endif 404 405ifeq ($(strip $(my_cc)),) 406 ifeq ($(my_clang),true) 407 my_cc := $(CLANG) 408 else 409 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) 410 endif 411 my_cc := $(my_cc_wrapper) $(my_cc) 412endif 413ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 414 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)" 415else 416ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 417 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)" 418endif 419endif 420$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) 421 422ifeq ($(strip $(my_cxx)),) 423 ifeq ($(my_clang),true) 424 my_cxx := $(CLANG_CXX) 425 else 426 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) 427 endif 428 my_cxx := $(my_cxx_wrapper) $(my_cxx) 429endif 430ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 431 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)" 432else 433ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 434 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)" 435endif 436endif 437$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker) 438$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) 439$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) 440 441# TODO: support a mix of standard extensions so that this isn't necessary 442LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) 443ifeq ($(LOCAL_CPP_EXTENSION),) 444 LOCAL_CPP_EXTENSION := .cpp 445endif 446$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) 447 448# Certain modules like libdl have to have symbols resolved at runtime and blow 449# up if --no-undefined is passed to the linker. 450ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) 451ifeq ($(my_allow_undefined_symbols),) 452 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS) 453endif 454endif 455 456ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) 457$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true 458else 459$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := 460endif 461 462########################################################### 463## Define arm-vs-thumb-mode flags. 464########################################################### 465LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) 466ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) 467arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) 468normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) 469 470# Read the values from something like TARGET_arm_CFLAGS or 471# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't 472# actually used (although they are usually empty). 473arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) 474normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) 475ifeq ($(my_clang),true) 476arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) 477normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) 478endif 479 480else 481arm_objects_mode := 482normal_objects_mode := 483arm_objects_cflags := 484normal_objects_cflags := 485endif 486 487########################################################### 488## Define per-module debugging flags. Users can turn on 489## debugging for a particular module by setting DEBUG_MODULE_ModuleName 490## to a non-empty value in their environment or buildspec.mk, 491## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the 492## debug flags that they want to use. 493########################################################### 494ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) 495 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) 496else 497 debug_cflags := 498endif 499 500#################################################### 501## Compile RenderScript with reflected C++ 502#################################################### 503 504renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) 505 506ifneq (,$(renderscript_sources)) 507 508renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) 509RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp 510renderscript_intermediate := $(intermediates)/renderscript 511 512renderscript_target_api := 513 514ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) 515renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) 516else 517ifneq (,$(LOCAL_SDK_VERSION)) 518# Set target-api for LOCAL_SDK_VERSIONs other than current. 519ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) 520renderscript_target_api := $(LOCAL_SDK_VERSION) 521endif 522endif # LOCAL_SDK_VERSION is set 523endif # LOCAL_RENDERSCRIPT_TARGET_API is set 524 525 526ifeq ($(LOCAL_RENDERSCRIPT_CC),) 527LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) 528endif 529 530# Turn on all warnings and warnings as errors for RS compiles. 531# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error 532renderscript_flags := -Wall -Werror 533renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) 534# -m32 or -m64 535renderscript_flags += -m$(my_32_64_bit_suffix) 536 537renderscript_includes := \ 538 $(TOPDIR)external/clang/lib/Headers \ 539 $(TOPDIR)frameworks/rs/scriptc \ 540 $(LOCAL_RENDERSCRIPT_INCLUDES) 541 542ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) 543renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) 544endif 545 546bc_dep_files := $(addprefix $(renderscript_intermediate)/, \ 547 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) 548 549$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) 550$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) 551$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) 552$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) 553$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) 554$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) 555$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) 556$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) 557 $(transform-renderscripts-to-cpp-and-bc) 558 559# include the dependency files (.d/.P) generated by llvm-rs-cc. 560-include $(bc_dep_files:%.d=%.P) 561 562LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) 563 564rs_generated_cpps := $(addprefix \ 565 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ 566 $(notdir $(renderscript_sources))))) 567 568# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 569$(rs_generated_cpps) : $(RenderScript_file_stamp) 570 @echo "Updated RS generated cpp file $@." 571 $(hide) touch $@ 572 573my_c_includes += $(renderscript_intermediate) 574my_generated_sources += $(rs_generated_cpps) 575 576endif 577 578 579########################################################### 580## Stuff source generated from one-off tools 581########################################################### 582$(my_generated_sources): PRIVATE_MODULE := $(my_register_name) 583 584my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) 585 586$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP) 587 @echo "Copy: $@" 588 $(copy-file-to-target) 589 590my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) 591 592ALL_GENERATED_SOURCES += $(my_generated_sources) 593 594########################################################### 595## Compile the .proto files to .cc (or .c) and then to .o 596########################################################### 597proto_sources := $(filter %.proto,$(my_src_files)) 598proto_generated_objects := 599proto_generated_headers := 600ifneq ($(proto_sources),) 601proto_generated_sources_dir := $(generated_sources_dir)/proto 602proto_generated_obj_dir := $(intermediates)/proto 603 604ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE))) 605my_proto_source_suffix := .c 606my_proto_c_includes := external/nanopb-c 607my_protoc_flags := --nanopb_out=$(proto_generated_sources_dir) \ 608 --plugin=external/nanopb-c/generator/protoc-gen-nanopb 609else 610my_proto_source_suffix := .cc 611my_proto_c_includes := external/protobuf/src 612my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI 613my_protoc_flags := --cpp_out=$(proto_generated_sources_dir) 614endif 615my_proto_c_includes += $(proto_generated_sources_dir) 616 617proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 618proto_generated_sources := $(addprefix $(proto_generated_sources_dir)/, \ 619 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath))) 620proto_generated_headers := $(patsubst %.pb$(my_proto_source_suffix),%.pb.h, $(proto_generated_sources)) 621proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ 622 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) 623 624# Ensure the transform-proto-to-cc rule is only defined once in multilib build. 625ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined 626$(proto_generated_sources): PRIVATE_PROTO_INCLUDES := $(TOP) 627$(proto_generated_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags) 628$(proto_generated_sources): $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix): %.proto $(PROTOC) 629 $(transform-proto-to-cc) 630 631# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 632$(proto_generated_headers): $(proto_generated_sources_dir)/%.pb.h: $(proto_generated_sources_dir)/%.pb$(my_proto_source_suffix) 633 @echo "Updated header file $@." 634 $(hide) touch $@ 635 636$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true 637endif # transform-proto-to-cc rule included only once 638 639$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 640$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 641$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_sources_dir)/%$(my_proto_source_suffix) $(proto_generated_headers) 642ifeq ($(my_proto_source_suffix),.c) 643 $(transform-$(PRIVATE_HOST)c-to-o) 644else 645 $(transform-$(PRIVATE_HOST)cpp-to-o) 646endif 647-include $(proto_generated_objects:%.o=%.P) 648 649my_c_includes += $(my_proto_c_includes) 650# Auto-export the generated proto source dir. 651my_export_c_include_dirs += $(my_proto_c_includes) 652 653ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc) 654 my_static_libraries += libprotobuf-c-nano-enable_malloc 655else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c) 656 my_static_libraries += libprotobuf-c-nano 657else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) 658 ifdef LOCAL_SDK_VERSION 659 my_static_libraries += libprotobuf-cpp-full-ndk 660 else 661 my_shared_libraries += libprotobuf-cpp-full 662 endif 663else 664 ifdef LOCAL_SDK_VERSION 665 my_static_libraries += libprotobuf-cpp-lite-ndk 666 else 667 my_shared_libraries += libprotobuf-cpp-lite 668 endif 669endif 670endif # $(proto_sources) non-empty 671 672########################################################### 673## Compile the .dbus-xml files to c++ headers 674########################################################### 675dbus_definitions := $(filter %.dbus-xml,$(my_src_files)) 676dbus_generated_headers := 677ifneq ($(dbus_definitions),) 678 679dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions)) 680dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files)) 681dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config)) 682 683dbus_gen_dir := $(generated_sources_dir)/dbus_bindings 684 685ifdef LOCAL_DBUS_PROXY_PREFIX 686dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX) 687dbus_headers := dbus-proxies.h 688else 689dbus_header_dir := $(dbus_gen_dir) 690dbus_headers := $(patsubst %.dbus-xml,%.h,$(dbus_definitions)) 691endif 692dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers)) 693 694# Ensure that we only define build rules once in multilib builds. 695ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined 696$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true 697 698$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE) 699$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path) 700$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR) 701ifdef LOCAL_DBUS_PROXY_PREFIX 702$(dbus_generated_headers) : $(dbus_definition_paths) 703 $(generate-dbus-proxies) 704else 705$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus-xml 706 $(generate-dbus-adaptors) 707endif # $(LOCAL_DBUS_PROXY_PREFIX) 708endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined 709 710ifdef LOCAL_DBUS_PROXY_PREFIX 711# Auto-export the generated dbus proxy directory. 712my_export_c_include_dirs += $(dbus_gen_dir)/include 713my_c_includes += $(dbus_gen_dir)/include 714else 715my_export_c_include_dirs += $(dbus_header_dir) 716my_c_includes += $(dbus_header_dir) 717endif # $(LOCAL_DBUS_PROXY_PREFIX) 718 719my_generated_sources += $(dbus_generated_headers) 720 721endif # $(dbus_definitions) non-empty 722 723 724########################################################### 725## AIDL: Compile .aidl files to .cpp and .h files 726########################################################### 727aidl_src := $(strip $(filter %.aidl,$(my_src_files))) 728aidl_gen_cpp := 729ifneq ($(aidl_src),) 730 731aidl_gen_cpp_root := $(intermediates)/aidl-generated/src 732aidl_gen_include_root := $(intermediates)/aidl-generated/include 733 734aidl_gen_cpp := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(aidl_src)) 735aidl_gen_cpp := $(addprefix $(aidl_gen_cpp_root)/,$(aidl_gen_cpp)) 736 737# TODO(wiley): we could pass down a flag here to only generate the server or 738# client side of the binder interface. 739$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) 740$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root) 741$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) 742 743# Multi-architecture builds have distinct intermediates directories. 744# Define rules for both architectures. 745$(aidl_gen_cpp) : $(aidl_gen_cpp_root)/%$(LOCAL_CPP_EXTENSION) : $(LOCAL_PATH)/%.aidl $(AIDL_CPP) 746 $(transform-aidl-to-cpp) 747-include $(addsuffix .P,$(basename $(aidl_gen_cpp))) 748 749# Add generated headers to include paths. 750my_c_includes += $(aidl_gen_include_root) 751my_export_c_include_dirs += $(aidl_gen_include_root) 752# Pick up the generated C++ files later for transformation to .o files. 753my_generated_sources += $(aidl_gen_cpp) 754 755endif # $(aidl_src) non-empty 756 757########################################################### 758## YACC: Compile .y and .yy files to .cpp and the to .o. 759########################################################### 760 761y_yacc_sources := $(filter %.y,$(my_src_files)) 762y_yacc_cpps := $(addprefix \ 763 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) 764 765yy_yacc_sources := $(filter %.yy,$(my_src_files)) 766yy_yacc_cpps := $(addprefix \ 767 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) 768 769yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps) 770yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) 771yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) 772 773ifneq ($(strip $(y_yacc_cpps)),) 774$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 775 $(TOPDIR)$(LOCAL_PATH)/%.y \ 776 $(lex_cpps) $(my_additional_dependencies) 777 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 778$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 779endif 780 781ifneq ($(strip $(yy_yacc_cpps)),) 782$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 783 $(TOPDIR)$(LOCAL_PATH)/%.yy \ 784 $(lex_cpps) $(my_additional_dependencies) 785 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 786$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 787endif 788 789ifneq ($(strip $(yacc_cpps)),) 790$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 791$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 792$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 793 $(transform-$(PRIVATE_HOST)cpp-to-o) 794endif 795 796########################################################### 797## LEX: Compile .l and .ll files to .cpp and then to .o. 798########################################################### 799 800l_lex_sources := $(filter %.l,$(my_src_files)) 801l_lex_cpps := $(addprefix \ 802 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION))) 803 804ll_lex_sources := $(filter %.ll,$(my_src_files)) 805ll_lex_cpps := $(addprefix \ 806 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) 807 808lex_cpps := $(l_lex_cpps) $(ll_lex_cpps) 809lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) 810 811ifneq ($(strip $(l_lex_cpps)),) 812$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 813 $(TOPDIR)$(LOCAL_PATH)/%.l 814 $(transform-l-to-cpp) 815endif 816 817ifneq ($(strip $(ll_lex_cpps)),) 818$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 819 $(TOPDIR)$(LOCAL_PATH)/%.ll 820 $(transform-l-to-cpp) 821endif 822 823ifneq ($(strip $(lex_cpps)),) 824$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 825$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 826$(lex_objects): $(intermediates)/%.o: \ 827 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ 828 $(my_additional_dependencies) \ 829 $(yacc_headers) 830 $(transform-$(PRIVATE_HOST)cpp-to-o) 831endif 832 833########################################################### 834## C++: Compile .cpp files to .o. 835########################################################### 836 837# we also do this on host modules, even though 838# it's not really arm, because there are files that are shared. 839cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) 840dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources)) 841cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources)) 842cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) 843 844# For source files starting with ../, we remove all the ../ in the object file path, 845# to avoid object file escaping the intermediate directory. 846dotdot_arm_objects := 847$(foreach s,$(dotdot_arm_sources),\ 848 $(eval $(call compile-dotdot-cpp-file,$(s),\ 849 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\ 850 dotdot_arm_objects))) 851 852dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files)) 853dotdot_objects := 854$(foreach s,$(dotdot_sources),\ 855 $(eval $(call compile-dotdot-cpp-file,$(s),\ 856 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\ 857 dotdot_objects))) 858 859cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))) 860cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) 861 862$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 863$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 864$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 865$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 866 867cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) 868 869ifneq ($(strip $(cpp_objects)),) 870$(cpp_objects): $(intermediates)/%.o: \ 871 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ 872 $(yacc_cpps) $(proto_generated_headers) \ 873 $(my_additional_dependencies) 874 $(transform-$(PRIVATE_HOST)cpp-to-o) 875-include $(cpp_objects:%.o=%.P) 876endif 877 878cpp_objects += $(dotdot_arm_objects) $(dotdot_objects) 879 880########################################################### 881## C++: Compile generated .cpp files to .o. 882########################################################### 883 884gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) 885gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) 886 887ifneq ($(strip $(gen_cpp_objects)),) 888# Compile all generated files as thumb. 889# TODO: support compiling certain generated files as arm. 890$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 891$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 892$(gen_cpp_objects): $(intermediates)/%.o: \ 893 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ 894 $(proto_generated_headers) \ 895 $(my_additional_dependencies) 896 $(transform-$(PRIVATE_HOST)cpp-to-o) 897-include $(gen_cpp_objects:%.o=%.P) 898endif 899 900########################################################### 901## S: Compile generated .S and .s files to .o. 902########################################################### 903 904gen_S_sources := $(filter %.S,$(my_generated_sources)) 905gen_S_objects := $(gen_S_sources:%.S=%.o) 906 907ifneq ($(strip $(gen_S_sources)),) 908$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ 909 $(my_additional_dependencies) 910 $(transform-$(PRIVATE_HOST)s-to-o) 911-include $(gen_S_objects:%.o=%.P) 912endif 913 914gen_s_sources := $(filter %.s,$(my_generated_sources)) 915gen_s_objects := $(gen_s_sources:%.s=%.o) 916 917ifneq ($(strip $(gen_s_objects)),) 918$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ 919 $(my_additional_dependencies) 920 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 921-include $(gen_s_objects:%.o=%.P) 922endif 923 924gen_asm_objects := $(gen_S_objects) $(gen_s_objects) 925 926########################################################### 927## o: Include generated .o files in output. 928########################################################### 929 930gen_o_objects := $(filter %.o,$(my_generated_sources)) 931 932########################################################### 933## C: Compile .c files to .o. 934########################################################### 935 936c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) 937dotdot_arm_sources := $(filter ../%,$(c_arm_sources)) 938c_arm_sources := $(filter-out ../%,$(c_arm_sources)) 939c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) 940 941# For source files starting with ../, we remove all the ../ in the object file path, 942# to avoid object file escaping the intermediate directory. 943dotdot_arm_objects := 944$(foreach s,$(dotdot_arm_sources),\ 945 $(eval $(call compile-dotdot-c-file,$(s),\ 946 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\ 947 dotdot_arm_objects))) 948 949dotdot_sources := $(filter ../%.c, $(my_src_files)) 950dotdot_objects := 951$(foreach s, $(dotdot_sources),\ 952 $(eval $(call compile-dotdot-c-file,$(s),\ 953 $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\ 954 dotdot_objects))) 955 956c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files))) 957c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) 958 959$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 960$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 961$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 962$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 963 964c_objects := $(c_arm_objects) $(c_normal_objects) 965 966ifneq ($(strip $(c_objects)),) 967$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \ 968 $(my_additional_dependencies) 969 $(transform-$(PRIVATE_HOST)c-to-o) 970-include $(c_objects:%.o=%.P) 971endif 972 973c_objects += $(dotdot_arm_objects) $(dotdot_objects) 974 975########################################################### 976## C: Compile generated .c files to .o. 977########################################################### 978 979gen_c_sources := $(filter %.c,$(my_generated_sources)) 980gen_c_objects := $(gen_c_sources:%.c=%.o) 981 982ifneq ($(strip $(gen_c_objects)),) 983# Compile all generated files as thumb. 984# TODO: support compiling certain generated files as arm. 985$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 986$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 987$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ 988 $(my_additional_dependencies) 989 $(transform-$(PRIVATE_HOST)c-to-o) 990-include $(gen_c_objects:%.o=%.P) 991endif 992 993########################################################### 994## ObjC: Compile .m files to .o 995########################################################### 996 997objc_sources := $(filter %.m,$(my_src_files)) 998objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) 999 1000ifneq ($(strip $(objc_objects)),) 1001$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \ 1002 $(my_additional_dependencies) 1003 $(transform-$(PRIVATE_HOST)m-to-o) 1004-include $(objc_objects:%.o=%.P) 1005endif 1006 1007########################################################### 1008## ObjC++: Compile .mm files to .o 1009########################################################### 1010 1011objcpp_sources := $(filter %.mm,$(my_src_files)) 1012objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o)) 1013 1014ifneq ($(strip $(objcpp_objects)),) 1015$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm $(yacc_cpps) $(proto_generated_headers) \ 1016 $(my_additional_dependencies) 1017 $(transform-$(PRIVATE_HOST)mm-to-o) 1018-include $(objcpp_objects:%.o=%.P) 1019endif 1020 1021########################################################### 1022## AS: Compile .S files to .o. 1023########################################################### 1024 1025asm_sources_S := $(filter %.S,$(my_src_files)) 1026dotdot_sources := $(filter ../%,$(asm_sources_S)) 1027asm_sources_S := $(filter-out ../%,$(asm_sources_S)) 1028asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) 1029 1030dotdot_objects_S := 1031$(foreach s,$(dotdot_sources),\ 1032 $(eval $(call compile-dotdot-s-file,$(s),\ 1033 $(my_additional_dependencies),\ 1034 dotdot_objects_S))) 1035 1036ifneq ($(strip $(asm_objects_S)),) 1037$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ 1038 $(my_additional_dependencies) 1039 $(transform-$(PRIVATE_HOST)s-to-o) 1040-include $(asm_objects_S:%.o=%.P) 1041endif 1042 1043asm_sources_s := $(filter %.s,$(my_src_files)) 1044dotdot_sources := $(filter ../%,$(asm_sources_s)) 1045asm_sources_s := $(filter-out ../%,$(asm_sources_s)) 1046asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) 1047 1048dotdot_objects_s := 1049$(foreach s,$(dotdot_sources),\ 1050 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\ 1051 $(my_additional_dependencies),\ 1052 dotdot_objects_s))) 1053 1054ifneq ($(strip $(asm_objects_s)),) 1055$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ 1056 $(my_additional_dependencies) 1057 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 1058endif 1059 1060asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s) 1061 1062 1063# .asm for x86/x86_64 needs to be compiled with yasm. 1064asm_sources_asm := $(filter %.asm,$(my_src_files)) 1065ifneq ($(strip $(asm_sources_asm)),) 1066asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) 1067$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ 1068 $(my_additional_dependencies) 1069 $(transform-asm-to-o) 1070 1071asm_objects += $(asm_objects_asm) 1072endif 1073 1074 1075########################################################## 1076## Set up installed module dependency 1077## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for 1078## they may cusomize their install path with LOCAL_MODULE_PATH 1079########################################################## 1080# Get the list of INSTALLED libraries as module names. 1081ifdef LOCAL_SDK_VERSION 1082 installed_shared_library_module_names := \ 1083 $(my_shared_libraries) 1084else 1085 installed_shared_library_module_names := \ 1086 $(my_shared_libraries) $(my_system_shared_libraries) 1087endif 1088 1089# The real dependency will be added after all Android.mks are loaded and the install paths 1090# of the shared libraries are determined. 1091ifdef LOCAL_INSTALLED_MODULE 1092ifdef installed_shared_library_module_names 1093$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 1094 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names))) 1095endif 1096endif 1097 1098 1099#################################################### 1100## Import includes 1101#################################################### 1102import_includes := $(intermediates)/import_includes 1103import_includes_deps := $(strip \ 1104 $(foreach l, $(installed_shared_library_module_names), \ 1105 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ 1106 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ 1107 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1108$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) 1109$(import_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(import_includes_deps) 1110 @echo Import includes file: $@ 1111 $(hide) mkdir -p $(dir $@) && rm -f $@ 1112ifdef import_includes_deps 1113 $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \ 1114 cat $$f >> $@; \ 1115 done 1116else 1117 $(hide) touch $@ 1118endif 1119 1120########################################################### 1121## Common object handling. 1122########################################################### 1123 1124# some rules depend on asm_objects being first. If your code depends on 1125# being first, it's reasonable to require it to be assembly 1126normal_objects := \ 1127 $(asm_objects) \ 1128 $(cpp_objects) \ 1129 $(gen_cpp_objects) \ 1130 $(gen_asm_objects) \ 1131 $(c_objects) \ 1132 $(gen_c_objects) \ 1133 $(objc_objects) \ 1134 $(objcpp_objects) \ 1135 $(yacc_objects) \ 1136 $(lex_objects) \ 1137 $(proto_generated_objects) \ 1138 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) 1139 1140all_objects := $(normal_objects) $(gen_o_objects) 1141 1142my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir) 1143 1144ifndef LOCAL_SDK_VERSION 1145 my_c_includes += $(JNI_H_INCLUDE) 1146endif 1147 1148# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; 1149# use normal_objects here to avoid creating circular dependencies. This assumes 1150# that custom build rules which generate .o files don't consume other generated 1151# sources as input (or if they do they take care of that dependency themselves). 1152$(normal_objects) : | $(my_generated_sources) 1153ifeq ($(BUILDING_WITH_NINJA),true) 1154$(all_objects) : $(import_includes) 1155else 1156$(all_objects) : | $(import_includes) 1157endif 1158ALL_C_CPP_ETC_OBJECTS += $(all_objects) 1159 1160 1161########################################################### 1162# Standard library handling. 1163########################################################### 1164 1165########################################################### 1166# The list of libraries that this module will link against are in 1167# these variables. Each is a list of bare module names like "libc libm". 1168# 1169# LOCAL_SHARED_LIBRARIES 1170# LOCAL_STATIC_LIBRARIES 1171# LOCAL_WHOLE_STATIC_LIBRARIES 1172# 1173# We need to convert the bare names into the dependencies that 1174# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. 1175# LOCAL_BUILT_MODULE should depend on the BUILT versions of the 1176# libraries, so that simply building this module doesn't force 1177# an install of a library. Similarly, LOCAL_INSTALLED_MODULE 1178# should depend on the INSTALLED versions of the libraries so 1179# that they get installed when this module does. 1180########################################################### 1181# NOTE: 1182# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the 1183# module without leaving anything out, which is useful for turning 1184# a collection of .a files into a .so file. Linking against a 1185# normal STATIC_LIBRARY will only pull in code/symbols that are 1186# referenced by the module. (see gcc/ld's --whole-archive option) 1187########################################################### 1188 1189# Get the list of BUILT libraries, which are under 1190# various intermediates directories. 1191so_suffix := $($(my_prefix)SHLIB_SUFFIX) 1192a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) 1193 1194ifdef LOCAL_SDK_VERSION 1195built_shared_libraries := \ 1196 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 1197 $(addsuffix $(so_suffix), \ 1198 $(my_shared_libraries))) 1199built_shared_library_tocs := $(addsuffix .toc, $(built_shared_libraries)) 1200 1201# Add the NDK libraries to the built module dependency 1202my_system_shared_libraries_fullpath := \ 1203 $(my_ndk_stl_shared_lib_fullpath) \ 1204 $(addprefix $(my_ndk_sysroot_lib)/, \ 1205 $(addsuffix $(so_suffix), $(my_system_shared_libraries))) 1206 1207built_shared_libraries += $(my_system_shared_libraries_fullpath) 1208else 1209built_shared_libraries := \ 1210 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 1211 $(addsuffix $(so_suffix), \ 1212 $(installed_shared_library_module_names))) 1213built_shared_library_tocs := $(addsuffix .toc, $(built_shared_libraries)) 1214my_system_shared_libraries_fullpath := 1215endif 1216 1217built_static_libraries := \ 1218 $(foreach lib,$(my_static_libraries), \ 1219 $(call intermediates-dir-for, \ 1220 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) 1221 1222ifdef LOCAL_SDK_VERSION 1223built_static_libraries += $(my_ndk_stl_static_lib) 1224endif 1225 1226built_whole_libraries := \ 1227 $(foreach lib,$(my_whole_static_libraries), \ 1228 $(call intermediates-dir-for, \ 1229 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) 1230 1231# We don't care about installed static libraries, since the 1232# libraries have already been linked into the module at that point. 1233# We do, however, care about the NOTICE files for any static 1234# libraries that we use. (see notice_files.mk) 1235 1236installed_static_library_notice_file_targets := \ 1237 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ 1238 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) 1239 1240# Default is -fno-rtti. 1241ifeq ($(strip $(LOCAL_RTTI_FLAG)),) 1242LOCAL_RTTI_FLAG := -fno-rtti 1243endif 1244 1245########################################################### 1246# Rule-specific variable definitions 1247########################################################### 1248 1249ifeq ($(my_clang),true) 1250my_cflags += $(LOCAL_CLANG_CFLAGS) 1251my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS) 1252my_cppflags += $(LOCAL_CLANG_CPPFLAGS) 1253my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE) 1254my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE) 1255my_asflags += $(LOCAL_CLANG_ASFLAGS) 1256my_ldflags += $(LOCAL_CLANG_LDFLAGS) 1257my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix)) 1258my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix)) 1259my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix)) 1260my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix)) 1261my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix)) 1262my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) 1263my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) 1264my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) 1265my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) 1266endif 1267 1268ifeq ($(my_fdo_build), true) 1269 my_cflags := $(patsubst -Os,-O2,$(my_cflags)) 1270 fdo_incompatible_flags := -fno-early-inlining -finline-limit=% 1271 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags)) 1272endif 1273 1274# No one should ever use this flag. On GCC it's mere presence will disable all 1275# warnings, even those that are specified after it (contrary to typical warning 1276# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the 1277# warnings that are *always* bugs. 1278my_illegal_flags := -w 1279my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags)) 1280my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags)) 1281my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags)) 1282 1283$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) 1284$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) 1285$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) 1286$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) 1287$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) 1288$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) 1289$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) 1290$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) 1291$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) 1292$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) 1293$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) 1294$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) 1295$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) 1296 1297# this is really the way to get the files onto the command line instead 1298# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work 1299$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) 1300$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) 1301$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) 1302$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) 1303 1304########################################################### 1305# Define library dependencies. 1306########################################################### 1307# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. 1308all_libraries := \ 1309 $(built_shared_library_tocs) \ 1310 $(my_system_shared_libraries_fullpath) \ 1311 $(built_static_libraries) \ 1312 $(built_whole_libraries) 1313 1314# Also depend on the notice files for any static libraries that 1315# are linked into this module. This will force them to be installed 1316# when this module is. 1317$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) 1318 1319########################################################### 1320# Export includes 1321########################################################### 1322export_includes := $(intermediates)/export_includes 1323$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs) 1324# Make sure .pb.h are already generated before any dependent source files get compiled. 1325# Similarly, the generated DBus headers need to exist before we export their location. 1326# People are not going to consume the aidl generated cpp file, but the cpp file is 1327# generated after the headers, so this is a convenient way to ensure the headers exist. 1328$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers) $(aidl_gen_cpp) 1329 @echo Export includes file: $< -- $@ 1330 $(hide) mkdir -p $(dir $@) && rm -f $@.tmp 1331ifdef my_export_c_include_dirs 1332 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ 1333 echo "-I $$d" >> $@.tmp; \ 1334 done 1335else 1336 $(hide) touch $@.tmp 1337endif 1338ifeq ($(BUILDING_WITH_NINJA),true) 1339 $(hide) if cmp -s $@.tmp $@ ; then \ 1340 rm $@.tmp ; \ 1341 else \ 1342 mv $@.tmp $@ ; \ 1343 fi 1344else 1345 mv $@.tmp $@ ; 1346endif 1347 1348# Kati adds restat=1 to ninja. GNU make does nothing for this. 1349.KATI_RESTAT: $(export_includes) 1350 1351# Make sure export_includes gets generated when you are running mm/mmm 1352$(LOCAL_BUILT_MODULE) : | $(export_includes) 1353