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