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