binary.mk revision b1055a195afa118bf8d8ea2a81dc5c6595090291
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 := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES) 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_ldflags := $(LOCAL_LDFLAGS) 44my_ldlibs := $(LOCAL_LDLIBS) 45my_asflags := $(LOCAL_ASFLAGS) 46my_cc := $(LOCAL_CC) 47my_cxx := $(LOCAL_CXX) 48my_c_includes := $(LOCAL_C_INCLUDES) 49my_generated_sources := $(LOCAL_GENERATED_SOURCES) 50my_native_coverage := $(LOCAL_NATIVE_COVERAGE) 51my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) 52 53ifdef LOCAL_IS_HOST_MODULE 54my_allow_undefined_symbols := true 55else 56my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)) 57endif 58 59my_ndk_sysroot := 60my_ndk_sysroot_include := 61my_ndk_sysroot_lib := 62ifdef LOCAL_SDK_VERSION 63 ifdef LOCAL_NDK_VERSION 64 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.) 65 endif 66 ifdef LOCAL_IS_HOST_MODULE 67 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) 68 endif 69 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources 70 my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 71 my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include 72 ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 73 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64 74 else 75 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib 76 endif 77 78 # The bionic linker now has support for gnu style hashes (which are much 79 # faster!), but shipping to older devices requires the old style hash. 80 #ifeq ($(shell expr $(LOCAL_SDK_VERSION) >= FIRST_SUPPORTED_VERSION),0) 81 my_ldflags += -Wl,--hash-style=sysv 82 #endif 83 84 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. 85 # See ndk/docs/CPLUSPLUS-SUPPORT.html 86 my_ndk_stl_include_path := 87 my_ndk_stl_shared_lib_fullpath := 88 my_ndk_stl_shared_lib := 89 my_ndk_stl_static_lib := 90 my_ndk_stl_cppflags := 91 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) 92 ifeq (,$(LOCAL_NDK_STL_VARIANT)) 93 LOCAL_NDK_STL_VARIANT := system 94 endif 95 ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) 96 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) 97 endif 98 ifeq (system,$(LOCAL_NDK_STL_VARIANT)) 99 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include 100 # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default. 101 else # LOCAL_NDK_STL_VARIANT is not system 102 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) 103 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport 104 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) 105 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a 106 else 107 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so 108 my_ndk_stl_shared_lib := -lstlport_shared 109 endif 110 else # LOCAL_NDK_STL_VARIANT is not stlport_* either 111 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) 112 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \ 113 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \ 114 $(my_ndk_source_root)/android/support/include 115 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) 116 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a 117 else 118 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so 119 my_ndk_stl_shared_lib := -lc++_shared 120 endif 121 my_ndk_stl_cppflags := -std=c++11 122 else 123 # LOCAL_NDK_STL_VARIANT is gnustl_static 124 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \ 125 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include 126 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a 127 endif 128 endif 129 endif 130endif 131 132# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because 133# all code is position independent, and then those warnings get promoted to 134# errors. 135ifndef USE_MINGW 136ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) 137my_cflags += -fpie 138else 139my_cflags += -fPIC 140endif 141endif 142 143my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 144my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) 145my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) 146my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) 147my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) 148my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) 149my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) 150my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) 151 152my_clang := $(strip $(LOCAL_CLANG)) 153ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) 154my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) 155endif 156ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 157my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 158endif 159 160# clang is enabled by default for host builds 161# enable it unless we've specifically disabled clang above 162ifdef LOCAL_IS_HOST_MODULE 163 ifneq ($(HOST_OS),windows) 164 ifeq ($(my_clang),) 165 my_clang := true 166 endif 167 endif 168endif 169 170# Add option to make clang the default for device build 171ifeq ($(USE_CLANG_PLATFORM_BUILD),true) 172 ifeq ($(my_clang),) 173 my_clang := true 174 endif 175endif 176 177# arch-specific static libraries go first so that generic ones can depend on them 178my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) 179my_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) 180 181my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags)) 182 183include $(BUILD_SYSTEM)/cxx_stl_setup.mk 184 185# Add static HAL libraries 186ifdef LOCAL_HAL_STATIC_LIBRARIES 187$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ 188 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ 189 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ 190 $(eval my_static_libraries += $(lib).default))) 191b_lib := 192endif 193 194include $(BUILD_SYSTEM)/config_sanitizers.mk 195 196ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) 197 my_clang := 198endif 199 200# Add in libcompiler_rt for all regular device builds 201ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT)) 202 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) 203endif 204 205#################################################### 206## Add FDO flags if FDO is turned on and supported 207#################################################### 208ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true) 209 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),) 210 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS) 211 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS) 212 endif 213endif 214 215########################################################### 216## Explicitly declare assembly-only __ASSEMBLY__ macro for 217## assembly source 218########################################################### 219my_asflags += -D__ASSEMBLY__ 220 221 222########################################################## 223## Set up installed module dependency 224## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for 225## they may cusomize their install path with LOCAL_MODULE_PATH 226########################################################## 227# Get the list of INSTALLED libraries as module names. 228ifdef LOCAL_SDK_VERSION 229 installed_shared_library_module_names := \ 230 $(my_shared_libraries) 231else 232 installed_shared_library_module_names := \ 233 $(my_shared_libraries) $(my_system_shared_libraries) 234endif 235 236# The real dependency will be added after all Android.mks are loaded and the install paths 237# of the shared libraries are determined. 238ifdef LOCAL_INSTALLED_MODULE 239ifdef installed_shared_library_module_names 240$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 241 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names))) 242endif 243endif 244 245########################################################### 246## Define PRIVATE_ variables from global vars 247########################################################### 248ifndef LOCAL_IS_HOST_MODULE 249ifdef LOCAL_SDK_VERSION 250my_target_project_includes := 251my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) 252my_target_global_cppflags := $(my_ndk_stl_cppflags) 253else 254my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) 255my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES) 256my_target_global_cppflags := 257endif # LOCAL_SDK_VERSION 258 259ifeq ($(my_clang),true) 260my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) 261my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS) 262my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) 263my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) 264else 265my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) 266my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS) 267my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) 268my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS) 269endif # my_clang 270 271# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and 272# build with NATIVE_COVERAGE=true in your enviornment. Note that the build 273# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a 274# clean build of your module after toggling it. 275ifeq ($(NATIVE_COVERAGE),true) 276 ifeq ($(my_native_coverage),true) 277 # We can't currently generate coverage for clang binaries for two 278 # reasons: 279 # 280 # 1) b/17574078 We currently don't have a prebuilt 281 # libclang_rt.profile-<ARCH>.a, which clang is hardcoded to link if 282 # --coverage is passed in the link stage. For now we manually link 283 # libprofile_rt (which is the name it is built as from 284 # external/compiler-rt). 285 # 286 # 2) b/17583330 Clang doesn't generate .gcno files when using 287 # -no-integrated-as. Since most of the assembly in our tree is 288 # incompatible with clang's assembler, we can't turn off this flag. 289 ifneq ($(my_clang),true) 290 my_cflags += --coverage -O0 291 my_ldflags += --coverage 292 endif 293 endif 294else 295 my_native_coverage := false 296endif 297 298$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) 299$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) 300$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) 301$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) 302$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) 303$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 304 305else # LOCAL_IS_HOST_MODULE 306 307ifeq ($(my_clang),true) 308my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS) 309my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CONLYFLAGS) 310my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS) 311my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS) 312my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) 313else 314my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS) 315my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CONLYFLAGS) 316my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS) 317my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS) 318my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) 319endif # my_clang 320 321$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) 322$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) 323$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags) 324$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) 325$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) 326endif # LOCAL_IS_HOST_MODULE 327 328########################################################### 329## Define PRIVATE_ variables used by multiple module types 330########################################################### 331$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ 332 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) 333 334ifeq ($(strip $(WITH_SYNTAX_CHECK)),) 335 LOCAL_NO_SYNTAX_CHECK := true 336endif 337 338ifeq ($(strip $(WITH_STATIC_ANALYZER)),) 339 LOCAL_NO_STATIC_ANALYZER := true 340endif 341 342ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) 343 my_syntax_arch := host 344else 345 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 346endif 347 348ifeq ($(strip $(my_cc)),) 349 ifeq ($(my_clang),true) 350 my_cc := $(CLANG) 351 else 352 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) 353 endif 354endif 355ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 356 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)" 357else 358ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 359 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)" 360endif 361endif 362$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) 363 364ifeq ($(strip $(my_cxx)),) 365 ifeq ($(my_clang),true) 366 my_cxx := $(CLANG_CXX) 367 else 368 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) 369 endif 370endif 371ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 372 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)" 373else 374ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 375 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)" 376endif 377endif 378$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) 379$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) 380 381# TODO: support a mix of standard extensions so that this isn't necessary 382LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) 383ifeq ($(LOCAL_CPP_EXTENSION),) 384 LOCAL_CPP_EXTENSION := .cpp 385endif 386$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) 387 388# Certain modules like libdl have to have symbols resolved at runtime and blow 389# up if --no-undefined is passed to the linker. 390ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) 391ifeq ($(my_allow_undefined_symbols),) 392 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS) 393endif 394endif 395 396ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) 397$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true 398else 399$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := 400endif 401 402########################################################### 403## Define arm-vs-thumb-mode flags. 404########################################################### 405LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) 406ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) 407arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) 408normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) 409 410# Read the values from something like TARGET_arm_CFLAGS or 411# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't 412# actually used (although they are usually empty). 413arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) 414normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) 415ifeq ($(my_clang),true) 416arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) 417normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) 418endif 419 420else 421arm_objects_mode := 422normal_objects_mode := 423arm_objects_cflags := 424normal_objects_cflags := 425endif 426 427########################################################### 428## Define per-module debugging flags. Users can turn on 429## debugging for a particular module by setting DEBUG_MODULE_ModuleName 430## to a non-empty value in their environment or buildspec.mk, 431## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the 432## debug flags that they want to use. 433########################################################### 434ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) 435 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) 436else 437 debug_cflags := 438endif 439 440#################################################### 441## Compile RenderScript with reflected C++ 442#################################################### 443 444renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) 445 446ifneq (,$(renderscript_sources)) 447 448renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) 449RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp 450renderscript_intermediate := $(intermediates)/renderscript 451 452ifeq ($(LOCAL_RENDERSCRIPT_CC),) 453LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) 454endif 455 456# Turn on all warnings and warnings as errors for RS compiles. 457# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error 458renderscript_flags := -Wall -Werror 459renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) 460# -m32 or -m64 461renderscript_flags += -m$(my_32_64_bit_suffix) 462 463renderscript_includes := \ 464 $(TOPDIR)external/clang/lib/Headers \ 465 $(TOPDIR)frameworks/rs/scriptc \ 466 $(LOCAL_RENDERSCRIPT_INCLUDES) 467 468ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) 469renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) 470endif 471 472$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) 473$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) 474$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) 475$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) 476$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) 477$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) 478 $(transform-renderscripts-to-cpp-and-bc) 479 480# include the dependency files (.d) generated by llvm-rs-cc. 481renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \ 482 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) 483-include $(renderscript_generated_dep_files) 484 485LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) 486 487rs_generated_cpps := $(addprefix \ 488 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ 489 $(notdir $(renderscript_sources))))) 490 491# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 492$(rs_generated_cpps) : $(RenderScript_file_stamp) 493 @echo "Updated RS generated cpp file $@." 494 495my_c_includes += $(renderscript_intermediate) 496my_generated_sources += $(rs_generated_cpps) 497 498endif 499 500 501########################################################### 502## Stuff source generated from one-off tools 503########################################################### 504$(my_generated_sources): PRIVATE_MODULE := $(my_register_name) 505 506my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) 507 508$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP) 509 @echo "Copy: $@" 510 $(copy-file-to-target) 511 512my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) 513 514ALL_GENERATED_SOURCES += $(my_generated_sources) 515 516########################################################### 517## Compile the .proto files to .cc and then to .o 518########################################################### 519proto_sources := $(filter %.proto,$(my_src_files)) 520proto_generated_objects := 521proto_generated_headers := 522ifneq ($(proto_sources),) 523proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 524proto_generated_cc_sources_dir := $(generated_sources_dir)/proto 525proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \ 526 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath))) 527proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) 528proto_generated_obj_dir := $(intermediates)/proto 529proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ 530 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) 531 532# Auto-export the generated proto source dir. 533LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir) 534 535# Ensure the transform-proto-to-cc rule is only defined once in multilib build. 536ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined 537$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) 538$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir) 539$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) 540$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC) 541 $(transform-proto-to-cc) 542 543# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 544$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc 545 @echo "Updated header file $@." 546 547$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true 548endif # transform-proto-to-cc rule included only once 549 550$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 551$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 552$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers) 553 $(transform-$(PRIVATE_HOST)cpp-to-o) 554-include $(proto_generated_objects:%.o=%.P) 555 556my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir) 557my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI 558ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) 559 ifdef LOCAL_SDK_VERSION 560 my_static_libraries += libprotobuf-cpp-full 561 else 562 my_shared_libraries += libprotobuf-cpp-full 563 endif 564else 565 ifdef LOCAL_SDK_VERSION 566 my_static_libraries += libprotobuf-cpp-lite 567 else 568 my_shared_libraries += libprotobuf-cpp-lite 569 endif 570endif 571endif # $(proto_sources) non-empty 572 573 574########################################################### 575## YACC: Compile .y and .yy files to .cpp and the to .o. 576########################################################### 577 578y_yacc_sources := $(filter %.y,$(my_src_files)) 579y_yacc_cpps := $(addprefix \ 580 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) 581 582yy_yacc_sources := $(filter %.yy,$(my_src_files)) 583yy_yacc_cpps := $(addprefix \ 584 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) 585 586yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps) 587yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) 588yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) 589 590ifneq ($(strip $(y_yacc_cpps)),) 591$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 592 $(TOPDIR)$(LOCAL_PATH)/%.y \ 593 $(lex_cpps) $(my_additional_dependencies) 594 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 595$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 596endif 597 598ifneq ($(strip $(yy_yacc_cpps)),) 599$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 600 $(TOPDIR)$(LOCAL_PATH)/%.yy \ 601 $(lex_cpps) $(my_additional_dependencies) 602 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 603$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 604endif 605 606ifneq ($(strip $(yacc_cpps)),) 607$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 608$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 609$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 610 $(transform-$(PRIVATE_HOST)cpp-to-o) 611endif 612 613########################################################### 614## LEX: Compile .l and .ll files to .cpp and then to .o. 615########################################################### 616 617l_lex_sources := $(filter %.l,$(my_src_files)) 618l_lex_cpps := $(addprefix \ 619 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION))) 620 621ll_lex_sources := $(filter %.ll,$(my_src_files)) 622ll_lex_cpps := $(addprefix \ 623 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) 624 625lex_cpps := $(l_lex_cpps) $(ll_lex_cpps) 626lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) 627 628ifneq ($(strip $(l_lex_cpps)),) 629$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 630 $(TOPDIR)$(LOCAL_PATH)/%.l 631 $(transform-l-to-cpp) 632endif 633 634ifneq ($(strip $(ll_lex_cpps)),) 635$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 636 $(TOPDIR)$(LOCAL_PATH)/%.ll 637 $(transform-l-to-cpp) 638endif 639 640ifneq ($(strip $(lex_cpps)),) 641$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 642$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 643$(lex_objects): $(intermediates)/%.o: \ 644 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ 645 $(my_additional_dependencies) \ 646 $(yacc_headers) 647 $(transform-$(PRIVATE_HOST)cpp-to-o) 648endif 649 650########################################################### 651## C++: Compile .cpp files to .o. 652########################################################### 653 654# we also do this on host modules, even though 655# it's not really arm, because there are files that are shared. 656cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) 657cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) 658 659cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)) 660cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) 661 662$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 663$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 664$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 665$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 666 667cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) 668 669ifneq ($(strip $(cpp_objects)),) 670$(cpp_objects): $(intermediates)/%.o: \ 671 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ 672 $(yacc_cpps) $(proto_generated_headers) \ 673 $(my_additional_dependencies) 674 $(transform-$(PRIVATE_HOST)cpp-to-o) 675-include $(cpp_objects:%.o=%.P) 676endif 677 678########################################################### 679## C++: Compile generated .cpp files to .o. 680########################################################### 681 682gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) 683gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) 684 685ifneq ($(strip $(gen_cpp_objects)),) 686# Compile all generated files as thumb. 687# TODO: support compiling certain generated files as arm. 688$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 689$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 690$(gen_cpp_objects): $(intermediates)/%.o: \ 691 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ 692 $(proto_generated_headers) \ 693 $(my_additional_dependencies) 694 $(transform-$(PRIVATE_HOST)cpp-to-o) 695-include $(gen_cpp_objects:%.o=%.P) 696endif 697 698########################################################### 699## S: Compile generated .S and .s files to .o. 700########################################################### 701 702gen_S_sources := $(filter %.S,$(my_generated_sources)) 703gen_S_objects := $(gen_S_sources:%.S=%.o) 704 705ifneq ($(strip $(gen_S_sources)),) 706$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ 707 $(my_additional_dependencies) 708 $(transform-$(PRIVATE_HOST)s-to-o) 709-include $(gen_S_objects:%.o=%.P) 710endif 711 712gen_s_sources := $(filter %.s,$(my_generated_sources)) 713gen_s_objects := $(gen_s_sources:%.s=%.o) 714 715ifneq ($(strip $(gen_s_objects)),) 716$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ 717 $(my_additional_dependencies) 718 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 719-include $(gen_s_objects:%.o=%.P) 720endif 721 722gen_asm_objects := $(gen_S_objects) $(gen_s_objects) 723 724########################################################### 725## o: Include generated .o files in output. 726########################################################### 727 728gen_o_objects := $(filter %.o,$(my_generated_sources)) 729 730########################################################### 731## C: Compile .c files to .o. 732########################################################### 733 734c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) 735c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) 736 737c_normal_sources := $(filter %.c,$(my_src_files)) 738c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) 739 740$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 741$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 742$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 743$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 744 745c_objects := $(c_arm_objects) $(c_normal_objects) 746 747ifneq ($(strip $(c_objects)),) 748$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \ 749 $(my_additional_dependencies) 750 $(transform-$(PRIVATE_HOST)c-to-o) 751-include $(c_objects:%.o=%.P) 752endif 753 754########################################################### 755## C: Compile generated .c files to .o. 756########################################################### 757 758gen_c_sources := $(filter %.c,$(my_generated_sources)) 759gen_c_objects := $(gen_c_sources:%.c=%.o) 760 761ifneq ($(strip $(gen_c_objects)),) 762# Compile all generated files as thumb. 763# TODO: support compiling certain generated files as arm. 764$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 765$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 766$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ 767 $(my_additional_dependencies) 768 $(transform-$(PRIVATE_HOST)c-to-o) 769-include $(gen_c_objects:%.o=%.P) 770endif 771 772########################################################### 773## ObjC: Compile .m files to .o 774########################################################### 775 776objc_sources := $(filter %.m,$(my_src_files)) 777objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) 778 779ifneq ($(strip $(objc_objects)),) 780$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \ 781 $(my_additional_dependencies) 782 $(transform-$(PRIVATE_HOST)m-to-o) 783-include $(objc_objects:%.o=%.P) 784endif 785 786########################################################### 787## AS: Compile .S files to .o. 788########################################################### 789 790asm_sources_S := $(filter %.S,$(my_src_files)) 791asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) 792 793ifneq ($(strip $(asm_objects_S)),) 794$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ 795 $(my_additional_dependencies) 796 $(transform-$(PRIVATE_HOST)s-to-o) 797-include $(asm_objects_S:%.o=%.P) 798endif 799 800asm_sources_s := $(filter %.s,$(my_src_files)) 801asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) 802 803ifneq ($(strip $(asm_objects_s)),) 804$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ 805 $(my_additional_dependencies) 806 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 807-include $(asm_objects_s:%.o=%.P) 808endif 809 810asm_objects := $(asm_objects_S) $(asm_objects_s) 811 812 813# .asm for x86 needs to be compiled with yasm. 814ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 815asm_sources_asm := $(filter %.asm,$(my_src_files)) 816ifneq ($(strip $(asm_sources_asm)),) 817asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) 818$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ 819 $(my_additional_dependencies) 820 $(transform-asm-to-o) 821 822asm_objects += $(asm_objects_asm) 823endif 824endif 825 826#################################################### 827## Import includes 828#################################################### 829import_includes := $(intermediates)/import_includes 830import_includes_deps := $(strip \ 831 $(foreach l, $(installed_shared_library_module_names), \ 832 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \ 833 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ 834 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes)) 835$(import_includes) : $(import_includes_deps) 836 @echo Import includes file: $@ 837 $(hide) mkdir -p $(dir $@) && rm -f $@ 838ifdef import_includes_deps 839 $(hide) for f in $^; do \ 840 cat $$f >> $@; \ 841 done 842else 843 $(hide) touch $@ 844endif 845 846########################################################### 847## Common object handling. 848########################################################### 849 850# some rules depend on asm_objects being first. If your code depends on 851# being first, it's reasonable to require it to be assembly 852normal_objects := \ 853 $(asm_objects) \ 854 $(cpp_objects) \ 855 $(gen_cpp_objects) \ 856 $(gen_asm_objects) \ 857 $(c_objects) \ 858 $(gen_c_objects) \ 859 $(objc_objects) \ 860 $(yacc_objects) \ 861 $(lex_objects) \ 862 $(proto_generated_objects) \ 863 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) 864 865all_objects := $(normal_objects) $(gen_o_objects) 866 867my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir) 868 869ifndef LOCAL_SDK_VERSION 870 my_c_includes += $(JNI_H_INCLUDE) 871endif 872 873# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; 874# use normal_objects here to avoid creating circular dependencies. This assumes 875# that custom build rules which generate .o files don't consume other generated 876# sources as input (or if they do they take care of that dependency themselves). 877$(normal_objects) : | $(my_generated_sources) 878$(all_objects) : | $(import_includes) 879ALL_C_CPP_ETC_OBJECTS += $(all_objects) 880 881 882########################################################### 883# Standard library handling. 884########################################################### 885 886########################################################### 887# The list of libraries that this module will link against are in 888# these variables. Each is a list of bare module names like "libc libm". 889# 890# LOCAL_SHARED_LIBRARIES 891# LOCAL_STATIC_LIBRARIES 892# LOCAL_WHOLE_STATIC_LIBRARIES 893# 894# We need to convert the bare names into the dependencies that 895# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. 896# LOCAL_BUILT_MODULE should depend on the BUILT versions of the 897# libraries, so that simply building this module doesn't force 898# an install of a library. Similarly, LOCAL_INSTALLED_MODULE 899# should depend on the INSTALLED versions of the libraries so 900# that they get installed when this module does. 901########################################################### 902# NOTE: 903# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the 904# module without leaving anything out, which is useful for turning 905# a collection of .a files into a .so file. Linking against a 906# normal STATIC_LIBRARY will only pull in code/symbols that are 907# referenced by the module. (see gcc/ld's --whole-archive option) 908########################################################### 909 910# Get the list of BUILT libraries, which are under 911# various intermediates directories. 912so_suffix := $($(my_prefix)SHLIB_SUFFIX) 913a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) 914 915ifdef LOCAL_SDK_VERSION 916built_shared_libraries := \ 917 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 918 $(addsuffix $(so_suffix), \ 919 $(my_shared_libraries))) 920 921# Add the NDK libraries to the built module dependency 922my_system_shared_libraries_fullpath := \ 923 $(my_ndk_stl_shared_lib_fullpath) \ 924 $(addprefix $(my_ndk_sysroot_lib)/, \ 925 $(addsuffix $(so_suffix), $(my_system_shared_libraries))) 926 927built_shared_libraries += $(my_system_shared_libraries_fullpath) 928else 929built_shared_libraries := \ 930 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 931 $(addsuffix $(so_suffix), \ 932 $(installed_shared_library_module_names))) 933endif 934 935built_static_libraries := \ 936 $(foreach lib,$(my_static_libraries), \ 937 $(call intermediates-dir-for, \ 938 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) 939 940ifdef LOCAL_SDK_VERSION 941built_static_libraries += $(my_ndk_stl_static_lib) 942endif 943 944built_whole_libraries := \ 945 $(foreach lib,$(my_whole_static_libraries), \ 946 $(call intermediates-dir-for, \ 947 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix)) 948 949# We don't care about installed static libraries, since the 950# libraries have already been linked into the module at that point. 951# We do, however, care about the NOTICE files for any static 952# libraries that we use. (see notice_files.mk) 953 954installed_static_library_notice_file_targets := \ 955 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ 956 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) 957 958# Default is -fno-rtti. 959ifeq ($(strip $(LOCAL_RTTI_FLAG)),) 960LOCAL_RTTI_FLAG := -fno-rtti 961endif 962 963########################################################### 964# Rule-specific variable definitions 965########################################################### 966 967ifeq ($(my_clang),true) 968my_cflags += $(LOCAL_CLANG_CFLAGS) 969my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS) 970my_cppflags += $(LOCAL_CLANG_CPPFLAGS) 971my_asflags += $(LOCAL_CLANG_ASFLAGS) 972my_ldflags += $(LOCAL_CLANG_LDFLAGS) 973my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix)) 974my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix)) 975my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix)) 976my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix)) 977my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix)) 978my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) 979my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) 980my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) 981my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) 982endif 983 984$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) 985$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) 986$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) 987$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) 988$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) 989$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) 990$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) 991$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) 992$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) 993$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) 994$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) 995$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 996 997# this is really the way to get the files onto the command line instead 998# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work 999$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) 1000$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) 1001$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) 1002$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) 1003 1004########################################################### 1005# Define library dependencies. 1006########################################################### 1007# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. 1008all_libraries := \ 1009 $(built_shared_libraries) \ 1010 $(built_static_libraries) \ 1011 $(built_whole_libraries) 1012 1013# Also depend on the notice files for any static libraries that 1014# are linked into this module. This will force them to be installed 1015# when this module is. 1016$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) 1017 1018########################################################### 1019# Export includes 1020########################################################### 1021export_includes := $(intermediates)/export_includes 1022$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) 1023# Make sure .pb.h are already generated before any dependent source files get compiled. 1024$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers) 1025 @echo Export includes file: $< -- $@ 1026 $(hide) mkdir -p $(dir $@) && rm -f $@ 1027ifdef LOCAL_EXPORT_C_INCLUDE_DIRS 1028 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ 1029 echo "-I $$d" >> $@; \ 1030 done 1031else 1032 $(hide) touch $@ 1033endif 1034 1035# Make sure export_includes gets generated when you are running mm/mmm 1036$(LOCAL_BUILT_MODULE) : | $(export_includes) 1037