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