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