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