binary.mk revision b05f2ca150dddf2a2a5ef0ae683181e3b979ef2d
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) 116 117# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because 118# all code is position independent, and then those warnings get promoted to 119# errors. 120ifndef USE_MINGW 121ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) 122my_cflags += -fpie 123else 124my_cflags += -fPIC 125endif 126endif 127 128my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 129my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) 130my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) 131my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) 132my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) 133my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) 134my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) 135my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) 136 137my_clang := $(strip $(LOCAL_CLANG)) 138ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) 139my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) 140endif 141ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 142my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 143endif 144 145# clang is enabled by default for host builds 146# enable it unless we've specifically disabled clang above 147ifdef LOCAL_IS_HOST_MODULE 148 ifneq ($(HOST_OS),windows) 149 ifeq ($(my_clang),) 150 my_clang := true 151 endif 152 endif 153endif 154 155# Add option to make clang the default for device build 156ifeq ($(USE_CLANG_PLATFORM_BUILD),true) 157 ifeq ($(my_clang),) 158 my_clang := true 159 endif 160endif 161 162# arch-specific static libraries go first so that generic ones can depend on them 163my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) 164my_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) 165 166my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags)) 167 168# Only around for development purposes. Will be removed soon. 169my_libcxx_is_default := false 170 171# Select the appropriate C++ STL 172ifeq ($(strip $(LOCAL_CXX_STL)),default) 173 ifndef LOCAL_SDK_VERSION 174 ifeq ($(strip $(my_libcxx_is_default)),true) 175 # Platform code. Select the appropriate STL. 176 my_cxx_stl := libc++ 177 else 178 my_cxx_stl := bionic 179 endif 180 else 181 my_cxx_stl := ndk 182 endif 183else 184 my_cxx_stl := $(strip $(LOCAL_CXX_STL)) 185endif 186 187ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),) 188 my_cflags += -D_USING_LIBCXX 189 my_c_includes += external/libcxx/include 190 ifeq ($(my_cxx_stl),libc++) 191 my_shared_libraries += libc++ 192 else 193 my_static_libraries += libc++_static 194 endif 195 196 ifdef LOCAL_IS_HOST_MODULE 197 my_cppflags += -nostdinc++ 198 my_ldflags += -nodefaultlibs 199 my_ldlibs += -lc -lm 200 endif 201else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),) 202 my_c_includes += external/stlport/stlport bionic/libstdc++/include bionic 203 ifeq ($(my_cxx_stl),stlport) 204 my_shared_libraries += libstdc++ libstlport 205 else 206 my_static_libraries += libstdc++ libstlport_static 207 endif 208else ifeq ($(my_cxx_stl),ndk) 209 # Using an NDK STL. Handled farther up in this file. 210 ifndef LOCAL_IS_HOST_MODULE 211 my_system_shared_libraries += libstdc++ 212 endif 213else ifeq ($(my_cxx_stl),bionic) 214 # Using bionic's basic libstdc++. Not actually an STL. Only around until the 215 # tree is in good enough shape to not need it. 216 ifndef LOCAL_IS_HOST_MODULE 217 my_c_includes += bionic/libstdc++/include 218 my_system_shared_libraries += libstdc++ 219 endif 220 # Host builds will use GNU libstdc++. 221else ifeq ($(my_cxx_stl),none) 222 ifdef LOCAL_IS_HOST_MODULE 223 my_cppflags += -nostdinc++ 224 my_ldflags += -nodefaultlibs -lc -lm 225 endif 226else 227 $(error $(my_cxx_stl) is not a supported STL.) 228endif 229 230# Add static HAL libraries 231ifdef LOCAL_HAL_STATIC_LIBRARIES 232$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ 233 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ 234 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ 235 $(eval my_static_libraries += $(lib).default))) 236b_lib := 237endif 238 239ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true) 240 my_clang := true 241 my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS) 242 my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS) 243 my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) 244 my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES) 245endif 246 247ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) 248 my_clang := 249endif 250 251# Add in libcompiler_rt for all regular device builds 252ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT)) 253 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) 254endif 255 256my_compiler_dependencies := 257 258#################################################### 259## Add FDO flags if FDO is turned on and supported 260#################################################### 261ifneq ($(strip $(LOCAL_FDO_SUPPORT)),) 262 ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),) 263 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS) 264 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS) 265 endif 266endif 267 268########################################################### 269## Explicitly declare assembly-only __ASSEMBLY__ macro for 270## assembly source 271########################################################### 272my_asflags += -D__ASSEMBLY__ 273 274 275########################################################## 276## Set up installed module dependency 277## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for 278## they may cusomize their install path with LOCAL_MODULE_PATH 279########################################################## 280# Get the list of INSTALLED libraries as module names. 281ifdef LOCAL_SDK_VERSION 282 installed_shared_library_module_names := \ 283 $(my_shared_libraries) 284else 285 installed_shared_library_module_names := \ 286 $(my_system_shared_libraries) $(my_shared_libraries) 287endif 288installed_shared_library_module_names := $(sort $(installed_shared_library_module_names)) 289 290# The real dependency will be added after all Android.mks are loaded and the install paths 291# of the shared libraries are determined. 292ifdef LOCAL_INSTALLED_MODULE 293ifdef installed_shared_library_module_names 294$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 295 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names)) 296endif 297endif 298 299########################################################### 300## Define PRIVATE_ variables from global vars 301########################################################### 302ifndef LOCAL_IS_HOST_MODULE 303ifdef LOCAL_SDK_VERSION 304my_target_project_includes := 305my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) 306my_target_global_cppflags := $(my_ndk_stl_cppflags) 307else 308my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) 309my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES) 310my_target_global_cppflags := 311endif # LOCAL_SDK_VERSION 312 313ifeq ($(my_clang),true) 314my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) 315my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) 316my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) 317my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES) 318else 319my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) 320my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) 321my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS) 322endif # my_clang 323 324$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) 325$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) 326$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) 327$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) 328$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 329 330else # LOCAL_IS_HOST_MODULE 331 332ifeq ($(my_clang),true) 333my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS) 334my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS) 335my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS) 336my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES) 337else 338my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS) 339my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS) 340my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS) 341my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) 342endif # my_clang 343 344$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) 345$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) 346$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) 347$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) 348endif # LOCAL_IS_HOST_MODULE 349 350########################################################### 351## Define PRIVATE_ variables used by multiple module types 352########################################################### 353$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ 354 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) 355 356ifeq ($(strip $(WITH_SYNTAX_CHECK)),) 357 LOCAL_NO_SYNTAX_CHECK := true 358endif 359 360ifeq ($(strip $(WITH_STATIC_ANALYZER)),) 361 LOCAL_NO_STATIC_ANALYZER := true 362endif 363 364ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) 365 my_syntax_arch := host 366else 367 my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 368endif 369 370ifeq ($(strip $(my_cc)),) 371 ifeq ($(my_clang),true) 372 my_cc := $(CLANG) 373 else 374 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) 375 endif 376endif 377ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 378 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)" 379else 380ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 381 my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)" 382endif 383endif 384$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) 385 386ifeq ($(strip $(my_cxx)),) 387 ifeq ($(my_clang),true) 388 my_cxx := $(CLANG_CXX) 389 else 390 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) 391 endif 392endif 393ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 394 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)" 395else 396ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) 397 my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)" 398endif 399endif 400$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) 401$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) 402 403# TODO: support a mix of standard extensions so that this isn't necessary 404LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) 405ifeq ($(LOCAL_CPP_EXTENSION),) 406 LOCAL_CPP_EXTENSION := .cpp 407endif 408$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) 409 410# Certain modules like libdl have to have symbols resolved at runtime and blow 411# up if --no-undefined is passed to the linker. 412ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) 413ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) 414 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS) 415endif 416endif 417 418ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) 419$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true 420else 421$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := 422endif 423 424########################################################### 425## Define arm-vs-thumb-mode flags. 426########################################################### 427LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) 428ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) 429arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) 430normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) 431 432# Read the values from something like TARGET_arm_CFLAGS or 433# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't 434# actually used (although they are usually empty). 435arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) 436normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) 437ifeq ($(my_clang),true) 438arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) 439normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) 440endif 441 442else 443arm_objects_mode := 444normal_objects_mode := 445arm_objects_cflags := 446normal_objects_cflags := 447endif 448 449########################################################### 450## Define per-module debugging flags. Users can turn on 451## debugging for a particular module by setting DEBUG_MODULE_ModuleName 452## to a non-empty value in their environment or buildspec.mk, 453## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the 454## debug flags that they want to use. 455########################################################### 456ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) 457 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) 458else 459 debug_cflags := 460endif 461 462#################################################### 463## Compile RenderScript with reflected C++ 464#################################################### 465 466renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) 467 468ifneq (,$(renderscript_sources)) 469 470renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) 471RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp 472renderscript_intermediate := $(intermediates)/renderscript 473 474ifeq ($(LOCAL_RENDERSCRIPT_CC),) 475LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) 476endif 477 478# Turn on all warnings and warnings as errors for RS compiles. 479# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error 480renderscript_flags := -Wall -Werror 481renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) 482 483renderscript_includes := \ 484 $(TOPDIR)external/clang/lib/Headers \ 485 $(TOPDIR)frameworks/rs/scriptc \ 486 $(LOCAL_RENDERSCRIPT_INCLUDES) 487 488ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) 489renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) 490endif 491 492$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) 493$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) 494$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) 495$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) 496$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) 497$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) 498 $(transform-renderscripts-to-cpp-and-bc) 499 500# include the dependency files (.d) generated by llvm-rs-cc. 501renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \ 502 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) 503-include $(renderscript_generated_dep_files) 504 505LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) 506 507rs_generated_cpps := $(addprefix \ 508 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ 509 $(notdir $(renderscript_sources))))) 510 511# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 512$(rs_generated_cpps) : $(RenderScript_file_stamp) 513 @echo "Updated RS generated cpp file $@." 514 515my_c_includes += $(renderscript_intermediate) 516my_generated_sources += $(rs_generated_cpps) 517 518endif 519 520 521########################################################### 522## Stuff source generated from one-off tools 523########################################################### 524$(my_generated_sources): PRIVATE_MODULE := $(my_register_name) 525 526my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) 527 528$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP) 529 @echo "Copy: $@" 530 $(copy-file-to-target) 531 532my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) 533 534ALL_GENERATED_SOURCES += $(my_generated_sources) 535 536########################################################### 537## Compile the .proto files to .cc and then to .o 538########################################################### 539proto_sources := $(filter %.proto,$(my_src_files)) 540proto_generated_objects := 541proto_generated_headers := 542ifneq ($(proto_sources),) 543proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 544proto_generated_cc_sources_dir := $(generated_sources_dir)/proto 545proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \ 546 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath))) 547proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) 548proto_generated_obj_dir := $(intermediates)/proto 549proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \ 550 $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath))) 551 552# Ensure the transform-proto-to-cc rule is only defined once in multilib build. 553ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined 554$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) 555$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir) 556$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) 557$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC) 558 $(transform-proto-to-cc) 559 560# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 561$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc 562 @echo "Updated header file $@." 563 564$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true 565endif # transform-proto-to-cc rule included only once 566 567$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 568$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 569$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers) 570 $(transform-$(PRIVATE_HOST)cpp-to-o) 571-include $(proto_generated_objects:%.o=%.P) 572 573my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir) 574my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI 575ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) 576my_static_libraries += libprotobuf-cpp-2.3.0-full 577else 578my_static_libraries += libprotobuf-cpp-2.3.0-lite 579endif 580endif # $(proto_sources) non-empty 581 582 583########################################################### 584## YACC: Compile .y and .yy files to .cpp and the to .o. 585########################################################### 586 587y_yacc_sources := $(filter %.y,$(my_src_files)) 588y_yacc_cpps := $(addprefix \ 589 $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) 590 591yy_yacc_sources := $(filter %.yy,$(my_src_files)) 592yy_yacc_cpps := $(addprefix \ 593 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) 594 595yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps) 596yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) 597yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) 598 599ifneq ($(strip $(y_yacc_cpps)),) 600$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 601 $(TOPDIR)$(LOCAL_PATH)/%.y \ 602 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) 603 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 604$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 605endif 606 607ifneq ($(strip $(yy_yacc_cpps)),) 608$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 609 $(TOPDIR)$(LOCAL_PATH)/%.yy \ 610 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) 611 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 612$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 613endif 614 615ifneq ($(strip $(yacc_cpps)),) 616$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 617$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 618$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 619 $(transform-$(PRIVATE_HOST)cpp-to-o) 620endif 621 622########################################################### 623## LEX: Compile .l and .ll files to .cpp and then to .o. 624########################################################### 625 626l_lex_sources := $(filter %.l,$(my_src_files)) 627l_lex_cpps := $(addprefix \ 628 $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION))) 629 630ll_lex_sources := $(filter %.ll,$(my_src_files)) 631ll_lex_cpps := $(addprefix \ 632 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) 633 634lex_cpps := $(l_lex_cpps) $(ll_lex_cpps) 635lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) 636 637ifneq ($(strip $(l_lex_cpps)),) 638$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 639 $(TOPDIR)$(LOCAL_PATH)/%.l 640 $(transform-l-to-cpp) 641endif 642 643ifneq ($(strip $(ll_lex_cpps)),) 644$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 645 $(TOPDIR)$(LOCAL_PATH)/%.ll 646 $(transform-l-to-cpp) 647endif 648 649ifneq ($(strip $(lex_cpps)),) 650$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 651$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 652$(lex_objects): $(intermediates)/%.o: \ 653 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ 654 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 655 $(yacc_headers) 656 $(transform-$(PRIVATE_HOST)cpp-to-o) 657endif 658 659########################################################### 660## C++: Compile .cpp files to .o. 661########################################################### 662 663# we also do this on host modules, even though 664# it's not really arm, because there are files that are shared. 665cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) 666cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) 667 668cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)) 669cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) 670 671$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 672$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 673$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 674$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 675 676cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) 677 678ifneq ($(strip $(cpp_objects)),) 679$(cpp_objects): $(intermediates)/%.o: \ 680 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ 681 $(yacc_cpps) $(proto_generated_headers) \ 682 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 683 | $(my_compiler_dependencies) 684 $(transform-$(PRIVATE_HOST)cpp-to-o) 685-include $(cpp_objects:%.o=%.P) 686endif 687 688########################################################### 689## C++: Compile generated .cpp files to .o. 690########################################################### 691 692gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) 693gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) 694 695ifneq ($(strip $(gen_cpp_objects)),) 696# Compile all generated files as thumb. 697# TODO: support compiling certain generated files as arm. 698$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 699$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 700$(gen_cpp_objects): $(intermediates)/%.o: \ 701 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ 702 $(proto_generated_headers) \ 703 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 704 | $(my_compiler_dependencies) 705 $(transform-$(PRIVATE_HOST)cpp-to-o) 706-include $(gen_cpp_objects:%.o=%.P) 707endif 708 709########################################################### 710## S: Compile generated .S and .s files to .o. 711########################################################### 712 713gen_S_sources := $(filter %.S,$(my_generated_sources)) 714gen_S_objects := $(gen_S_sources:%.S=%.o) 715 716ifneq ($(strip $(gen_S_sources)),) 717$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ 718 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 719 | $(my_compiler_dependencies) 720 $(transform-$(PRIVATE_HOST)s-to-o) 721-include $(gen_S_objects:%.o=%.P) 722endif 723 724gen_s_sources := $(filter %.s,$(my_generated_sources)) 725gen_s_objects := $(gen_s_sources:%.s=%.o) 726 727ifneq ($(strip $(gen_s_objects)),) 728$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ 729 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 730 | $(my_compiler_dependencies) 731 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 732-include $(gen_s_objects:%.o=%.P) 733endif 734 735gen_asm_objects := $(gen_S_objects) $(gen_s_objects) 736 737########################################################### 738## o: Include generated .o files in output. 739########################################################### 740 741gen_o_objects := $(filter %.o,$(my_generated_sources)) 742 743########################################################### 744## C: Compile .c files to .o. 745########################################################### 746 747c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) 748c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) 749 750c_normal_sources := $(filter %.c,$(my_src_files)) 751c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) 752 753$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 754$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 755$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 756$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 757 758c_objects := $(c_arm_objects) $(c_normal_objects) 759 760ifneq ($(strip $(c_objects)),) 761$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \ 762 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 763 | $(my_compiler_dependencies) 764 $(transform-$(PRIVATE_HOST)c-to-o) 765-include $(c_objects:%.o=%.P) 766endif 767 768########################################################### 769## C: Compile generated .c files to .o. 770########################################################### 771 772gen_c_sources := $(filter %.c,$(my_generated_sources)) 773gen_c_objects := $(gen_c_sources:%.c=%.o) 774 775ifneq ($(strip $(gen_c_objects)),) 776# Compile all generated files as thumb. 777# TODO: support compiling certain generated files as arm. 778$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 779$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 780$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ 781 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 782 | $(my_compiler_dependencies) 783 $(transform-$(PRIVATE_HOST)c-to-o) 784-include $(gen_c_objects:%.o=%.P) 785endif 786 787########################################################### 788## ObjC: Compile .m files to .o 789########################################################### 790 791objc_sources := $(filter %.m,$(my_src_files)) 792objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) 793 794ifneq ($(strip $(objc_objects)),) 795$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \ 796 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 797 | $(my_compiler_dependencies) 798 $(transform-$(PRIVATE_HOST)m-to-o) 799-include $(objc_objects:%.o=%.P) 800endif 801 802########################################################### 803## AS: Compile .S files to .o. 804########################################################### 805 806asm_sources_S := $(filter %.S,$(my_src_files)) 807asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) 808 809ifneq ($(strip $(asm_objects_S)),) 810$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ 811 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 812 | $(my_compiler_dependencies) 813 $(transform-$(PRIVATE_HOST)s-to-o) 814-include $(asm_objects_S:%.o=%.P) 815endif 816 817asm_sources_s := $(filter %.s,$(my_src_files)) 818asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) 819 820ifneq ($(strip $(asm_objects_s)),) 821$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ 822 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 823 | $(my_compiler_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 $(LOCAL_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 := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) 991my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) 992my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) 993my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) 994endif 995 996$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) 997$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) 998$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS) 999$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) 1000$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) 1001$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) 1002$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) 1003$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) 1004$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) 1005$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) 1006$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) 1007$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 1008$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx) 1009 1010# this is really the way to get the files onto the command line instead 1011# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work 1012$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) 1013$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) 1014$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) 1015$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) 1016 1017########################################################### 1018# Define library dependencies. 1019########################################################### 1020# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. 1021all_libraries := \ 1022 $(built_shared_libraries) \ 1023 $(built_static_libraries) \ 1024 $(built_whole_libraries) 1025 1026# Also depend on the notice files for any static libraries that 1027# are linked into this module. This will force them to be installed 1028# when this module is. 1029$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) 1030 1031########################################################### 1032# Export includes 1033########################################################### 1034export_includes := $(intermediates)/export_includes 1035$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) 1036$(export_includes) : $(LOCAL_MODULE_MAKEFILE) 1037 @echo Export includes file: $< -- $@ 1038 $(hide) mkdir -p $(dir $@) && rm -f $@ 1039ifdef LOCAL_EXPORT_C_INCLUDE_DIRS 1040 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ 1041 echo "-I $$d" >> $@; \ 1042 done 1043else 1044 $(hide) touch $@ 1045endif 1046 1047# Make sure export_includes gets generated when you are running mm/mmm 1048$(LOCAL_BUILT_MODULE) : | $(export_includes) 1049