binary.mk revision b71e2df30a2a24d5566734b3c41716bee9351fd1
1########################################################### 2## Standard rules for building binary object files from 3## asm/c/cpp/yacc/lex source files. 4## 5## The list of object files is exported in $(all_objects). 6########################################################### 7 8###################################### 9## Sanity check for LOCAL_NDK_VERSION 10###################################### 11my_ndk_version_root := 12ifdef LOCAL_NDK_VERSION 13 ifdef LOCAL_IS_HOST_MODULE 14 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION can not be used in host module) 15 endif 16 ifneq ($(filter-out SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 17 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION can only be used to build target shared/static libraries, \ 18 while your module is of class $(LOCAL_MODULE_CLASS)) 19 endif 20 ifeq ($(filter $(LOCAL_NDK_VERSION),$(TARGET_AVAILABLE_NDK_VERSIONS)),) 21 $(error $(LOCAL_PATH): Invalid LOCAL_NDK_VERSION '$(LOCAL_NDK_VERSION)' \ 22 Choices are $(TARGET_AVAILABLE_NDK_VERSIONS)) 23 endif 24 ifndef LOCAL_SDK_VERSION 25 $(error $(LOCAL_PATH): LOCAL_NDK_VERSION must be defined with LOCAL_SDK_VERSION) 26 endif 27 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/sources 28 my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH) 29 ifeq ($(wildcard $(my_ndk_version_root)),) 30 $(error $(LOCAL_PATH): ndk version root does not exist: $(my_ndk_version_root)) 31 endif 32 33 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. 34 # See ndk/docs/CPLUSPLUS-SUPPORT.html 35 my_ndk_stl_include_path := 36 my_ndk_stl_shared_lib_fullpath := 37 my_ndk_stl_shared_lib := 38 my_ndk_stl_static_lib := 39 ifeq (,$(LOCAL_NDK_STL_VARIANT)) 40 LOCAL_NDK_STL_VARIANT := system 41 endif 42 ifneq (1,$(words $(filter system stlport_static stlport_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) 43 $(error $(LOCAL_PATH): Unkown 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_CPU_ABI)/libstlport_static.a 53 else 54 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so 55 my_ndk_stl_shared_lib := -lstlport_shared 56 endif 57 else 58 # LOCAL_NDK_STL_VARIANT is gnustl_static 59 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/include \ 60 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include 61 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/libstdc++.a 62 endif 63 endif 64endif 65 66################################################## 67# Compute the dependency of the shared libraries 68################################################## 69# On the target, we compile with -nostdlib, so we must add in the 70# default system shared libraries, unless they have requested not 71# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would 72# supply that, for example, when building libc itself. 73ifdef LOCAL_IS_HOST_MODULE 74 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 75 LOCAL_SYSTEM_SHARED_LIBRARIES := 76 endif 77else 78 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 79 LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES) 80 endif 81endif 82 83# Logging used to be part of libcutils (target) and libutils (sim); 84# hack modules that use those other libs to also include liblog. 85# All of this complexity is to make sure that liblog only appears 86# once, and appears just before libcutils or libutils on the link 87# line. 88# TODO: remove this hack and change all modules to use liblog 89# when necessary. 90define insert-liblog 91 $(if $(filter liblog,$(1)),$(1), \ 92 $(if $(filter libcutils,$(1)), \ 93 $(patsubst libcutils,liblog libcutils,$(1)) \ 94 , \ 95 $(patsubst libutils,liblog libutils,$(1)) \ 96 ) \ 97 ) 98endef 99ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES))) 100 LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES)) 101endif 102ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES))) 103 LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES)) 104endif 105ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES))) 106 LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES)) 107endif 108 109ifdef LOCAL_NDK_VERSION 110 # Get the list of INSTALLED libraries as module names. 111 # We can not compute the full path of the LOCAL_SHARED_LIBRARIES for 112 # they may cusomize their install path with LOCAL_MODULE_PATH 113 installed_shared_library_module_names := \ 114 $(LOCAL_SHARED_LIBRARIES) 115else 116 installed_shared_library_module_names := \ 117 $(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES) 118endif 119# The real dependency will be added after all Android.mks are loaded and the install paths 120# of the shared libraries are determined. 121LOCAL_REQUIRED_MODULES += $(installed_shared_library_module_names) 122 123####################################### 124include $(BUILD_SYSTEM)/base_rules.mk 125####################################### 126ifeq ($(strip $(LOCAL_CLANG)),true) 127 LOCAL_CFLAGS += $(CLANG_CONFIG_EXTRA_CFLAGS) 128 LOCAL_LDFLAGS += $(CLANG_CONFIG_EXTRA_LDFLAGS) 129 LOCAL_C_INCLUDES += $(CLANG_CONFIG_EXTRA_C_INCLUDES) 130 LOCAL_COMPILER_DEPENDENCIES := $(CLANG) $(CLANG_CXX) 131endif 132 133#################################################### 134## Add FDO flags if FDO is turned on and supported 135#################################################### 136ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),) 137 LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS) 138 LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS) 139 LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS) 140endif 141 142########################################################### 143## Explicitly declare assembly-only __ASSEMBLY__ macro for 144## assembly source 145########################################################### 146LOCAL_ASFLAGS += -D__ASSEMBLY__ 147 148########################################################### 149## Define PRIVATE_ variables from global vars 150########################################################### 151ifeq ($(strip $(LOCAL_CLANG)),true) 152my_target_global_cflags := $(TARGET_GLOBAL_CLANG_FLAGS) 153else 154my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS) 155endif 156 157ifdef LOCAL_NDK_VERSION 158my_target_project_includes := 159my_target_c_inclues := $(my_ndk_stl_include_path) $(my_ndk_version_root)/usr/include 160# TODO: more reliable way to remove platform stuff. 161my_target_global_cflags := $(filter-out -include -I system/%, $(my_target_global_cflags)) 162my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS)) 163else 164my_target_project_includes := $(TARGET_PROJECT_INCLUDES) 165my_target_c_inclues := $(TARGET_C_INCLUDES) 166my_target_global_cflags := $(my_target_global_cflags) 167my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS) 168endif 169$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) 170$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_inclues) 171$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) 172$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) 173 174########################################################### 175## Define PRIVATE_ variables used by multiple module types 176########################################################### 177$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ 178 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) 179 180ifeq ($(strip $(LOCAL_CC)),) 181 ifeq ($(strip $(LOCAL_CLANG)),true) 182 LOCAL_CC := $(CLANG) 183 else 184 LOCAL_CC := $($(my_prefix)CC) 185 endif 186endif 187$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC) 188 189ifeq ($(strip $(LOCAL_CXX)),) 190 ifeq ($(strip $(LOCAL_CLANG)),true) 191 LOCAL_CXX := $(CLANG_CXX) 192 else 193 LOCAL_CXX := $($(my_prefix)CXX) 194 endif 195endif 196$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX) 197 198# TODO: support a mix of standard extensions so that this isn't necessary 199LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) 200ifeq ($(LOCAL_CPP_EXTENSION),) 201 LOCAL_CPP_EXTENSION := .cpp 202endif 203$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) 204 205# Certain modules like libdl have to have symbols resolved at runtime and blow 206# up if --no-undefined is passed to the linker. 207ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) 208ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) 209 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS) 210endif 211endif 212 213ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) 214$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true 215else 216$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := 217endif 218 219########################################################### 220## Define arm-vs-thumb-mode flags. 221########################################################### 222LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) 223ifeq ($(TARGET_ARCH),arm) 224arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) 225normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) 226 227# Read the values from something like TARGET_arm_CFLAGS or 228# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't 229# actually used (although they are usually empty). 230arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS) 231normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS) 232else 233arm_objects_mode := 234normal_objects_mode := 235arm_objects_cflags := 236normal_objects_cflags := 237endif 238 239########################################################### 240## Define per-module debugging flags. Users can turn on 241## debugging for a particular module by setting DEBUG_MODULE_ModuleName 242## to a non-empty value in their environment or buildspec.mk, 243## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the 244## debug flags that they want to use. 245########################################################### 246ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) 247 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) 248else 249 debug_cflags := 250endif 251 252########################################################### 253## Stuff source generated from one-off tools 254########################################################### 255$(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE) 256 257ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES) 258 259 260########################################################### 261## Compile the .proto files to .cc and then to .o 262########################################################### 263proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) 264proto_generated_objects := 265proto_generated_headers := 266ifneq ($(proto_sources),) 267proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 268proto_generated_cc_sources_dir := $(intermediates)/proto 269proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \ 270 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath))) 271proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources)) 272 273$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP) 274$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir) 275$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) 276$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC) 277 $(transform-proto-to-cc) 278 279proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources)) 280$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc 281 282$(proto_generated_cc_sources): PRIVATE_ARM_MODE := $(normal_objects_mode) 283$(proto_generated_cc_sources): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 284$(proto_generated_objects): $(proto_generated_cc_sources_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc 285 $(transform-$(PRIVATE_HOST)cpp-to-o) 286-include $(proto_generated_objects:%.o=%.P) 287 288LOCAL_C_INCLUDES += external/protobuf/src $(proto_generated_cc_sources_dir) 289LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI 290ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) 291LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-full 292else 293LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-lite 294endif 295endif 296 297 298########################################################### 299## YACC: Compile .y files to .cpp and the to .o. 300########################################################### 301 302yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES)) 303yacc_cpps := $(addprefix \ 304 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) 305yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) 306yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) 307 308ifneq ($(strip $(yacc_cpps)),) 309$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 310 $(TOPDIR)$(LOCAL_PATH)/%.y \ 311 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) 312 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) 313$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 314 315$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 316$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 317$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) 318 $(transform-$(PRIVATE_HOST)cpp-to-o) 319endif 320 321########################################################### 322## LEX: Compile .l files to .cpp and then to .o. 323########################################################### 324 325lex_sources := $(filter %.l,$(LOCAL_SRC_FILES)) 326lex_cpps := $(addprefix \ 327 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION))) 328lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) 329 330ifneq ($(strip $(lex_cpps)),) 331$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 332 $(TOPDIR)$(LOCAL_PATH)/%.l 333 $(transform-l-to-cpp) 334 335$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 336$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 337$(lex_objects): $(intermediates)/%.o: \ 338 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ 339 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 340 $(yacc_headers) 341 $(transform-$(PRIVATE_HOST)cpp-to-o) 342endif 343 344########################################################### 345## C++: Compile .cpp files to .o. 346########################################################### 347 348# we also do this on host modules, even though 349# it's not really arm, because there are files that are shared. 350cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES))) 351cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) 352 353cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES)) 354cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) 355 356$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 357$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 358$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 359$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 360 361cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) 362 363ifneq ($(strip $(cpp_objects)),) 364$(cpp_objects): $(intermediates)/%.o: \ 365 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ 366 $(yacc_cpps) $(proto_generated_headers) $(LOCAL_COMPILER_DEPENDENCIES) \ 367 $(LOCAL_ADDITIONAL_DEPENDENCIES) 368 $(transform-$(PRIVATE_HOST)cpp-to-o) 369-include $(cpp_objects:%.o=%.P) 370endif 371 372########################################################### 373## C++: Compile generated .cpp files to .o. 374########################################################### 375 376gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES)) 377gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) 378 379ifneq ($(strip $(gen_cpp_objects)),) 380# Compile all generated files as thumb. 381# TODO: support compiling certain generated files as arm. 382$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 383$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 384$(gen_cpp_objects): $(intermediates)/%.o: \ 385 $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \ 386 $(proto_generated_headers) $(LOCAL_COMPILER_DEPENDENCIES) \ 387 $(LOCAL_ADDITIONAL_DEPENDENCIES) 388 $(transform-$(PRIVATE_HOST)cpp-to-o) 389-include $(gen_cpp_objects:%.o=%.P) 390endif 391 392########################################################### 393## S: Compile generated .S and .s files to .o. 394########################################################### 395 396gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES)) 397gen_S_objects := $(gen_S_sources:%.S=%.o) 398 399ifneq ($(strip $(gen_S_sources)),) 400$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ 401 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 402 $(transform-$(PRIVATE_HOST)s-to-o) 403-include $(gen_S_objects:%.o=%.P) 404endif 405 406gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES)) 407gen_s_objects := $(gen_s_sources:%.s=%.o) 408 409ifneq ($(strip $(gen_s_objects)),) 410$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ 411 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 412 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 413-include $(gen_s_objects:%.o=%.P) 414endif 415 416gen_asm_objects := $(gen_S_objects) $(gen_s_objects) 417 418########################################################### 419## C: Compile .c files to .o. 420########################################################### 421 422c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES))) 423c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) 424 425c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES)) 426c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) 427 428$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 429$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 430$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 431$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 432 433c_objects := $(c_arm_objects) $(c_normal_objects) 434 435ifneq ($(strip $(c_objects)),) 436$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \ 437 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 438 $(transform-$(PRIVATE_HOST)c-to-o) 439-include $(c_objects:%.o=%.P) 440endif 441 442########################################################### 443## C: Compile generated .c files to .o. 444########################################################### 445 446gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES)) 447gen_c_objects := $(gen_c_sources:%.c=%.o) 448 449ifneq ($(strip $(gen_c_objects)),) 450# Compile all generated files as thumb. 451# TODO: support compiling certain generated files as arm. 452$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 453$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 454$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ 455 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 456 $(transform-$(PRIVATE_HOST)c-to-o) 457-include $(gen_c_objects:%.o=%.P) 458endif 459 460########################################################### 461## ObjC: Compile .m files to .o 462########################################################### 463 464objc_sources := $(filter %.m,$(LOCAL_SRC_FILES)) 465objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) 466 467ifneq ($(strip $(objc_objects)),) 468$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \ 469 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 470 $(transform-$(PRIVATE_HOST)m-to-o) 471-include $(objc_objects:%.o=%.P) 472endif 473 474########################################################### 475## AS: Compile .S files to .o. 476########################################################### 477 478asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES)) 479asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) 480 481ifneq ($(strip $(asm_objects_S)),) 482$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ 483 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 484 $(transform-$(PRIVATE_HOST)s-to-o) 485-include $(asm_objects_S:%.o=%.P) 486endif 487 488asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES)) 489asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) 490 491ifneq ($(strip $(asm_objects_s)),) 492$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ 493 $(LOCAL_COMPILER_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES) 494 $(transform-$(PRIVATE_HOST)s-to-o-no-deps) 495-include $(asm_objects_s:%.o=%.P) 496endif 497 498asm_objects := $(asm_objects_S) $(asm_objects_s) 499 500 501########################################################### 502## Common object handling. 503########################################################### 504 505# some rules depend on asm_objects being first. If your code depends on 506# being first, it's reasonable to require it to be assembly 507all_objects := \ 508 $(asm_objects) \ 509 $(cpp_objects) \ 510 $(gen_cpp_objects) \ 511 $(gen_asm_objects) \ 512 $(c_objects) \ 513 $(gen_c_objects) \ 514 $(objc_objects) \ 515 $(yacc_objects) \ 516 $(lex_objects) \ 517 $(proto_generated_objects) \ 518 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) 519 520LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates) 521 522ifndef LOCAL_NDK_VERSION 523 LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) 524endif 525 526$(all_objects) : | $(LOCAL_GENERATED_SOURCES) 527ALL_C_CPP_ETC_OBJECTS += $(all_objects) 528 529########################################################### 530## Copy headers to the install tree 531########################################################### 532include $(BUILD_COPY_HEADERS) 533 534########################################################### 535# Standard library handling. 536########################################################### 537 538########################################################### 539# The list of libraries that this module will link against are in 540# these variables. Each is a list of bare module names like "libc libm". 541# 542# LOCAL_SHARED_LIBRARIES 543# LOCAL_STATIC_LIBRARIES 544# LOCAL_WHOLE_STATIC_LIBRARIES 545# 546# We need to convert the bare names into the dependencies that 547# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. 548# LOCAL_BUILT_MODULE should depend on the BUILT versions of the 549# libraries, so that simply building this module doesn't force 550# an install of a library. Similarly, LOCAL_INSTALLED_MODULE 551# should depend on the INSTALLED versions of the libraries so 552# that they get installed when this module does. 553########################################################### 554# NOTE: 555# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the 556# module without leaving anything out, which is useful for turning 557# a collection of .a files into a .so file. Linking against a 558# normal STATIC_LIBRARY will only pull in code/symbols that are 559# referenced by the module. (see gcc/ld's --whole-archive option) 560########################################################### 561 562# Get the list of BUILT libraries, which are under 563# various intermediates directories. 564so_suffix := $($(my_prefix)SHLIB_SUFFIX) 565a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) 566 567ifdef LOCAL_NDK_VERSION 568built_shared_libraries := \ 569 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 570 $(addsuffix $(so_suffix), \ 571 $(LOCAL_SHARED_LIBRARIES))) 572 573my_system_shared_libraries_fullpath := \ 574 $(my_ndk_stl_shared_lib_fullpath) \ 575 $(addprefix $(my_ndk_version_root)/usr/lib/, \ 576 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES))) 577 578built_shared_libraries += $(my_system_shared_libraries_fullpath) 579LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) 580else 581LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) 582built_shared_libraries := \ 583 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 584 $(addsuffix $(so_suffix), \ 585 $(LOCAL_SHARED_LIBRARIES))) 586endif 587 588built_static_libraries := \ 589 $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \ 590 $(call intermediates-dir-for, \ 591 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) 592 593ifdef LOCAL_NDK_VERSION 594built_static_libraries += $(my_ndk_stl_static_lib) 595endif 596 597built_whole_libraries := \ 598 $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ 599 $(call intermediates-dir-for, \ 600 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) 601 602# We don't care about installed static libraries, since the 603# libraries have already been linked into the module at that point. 604# We do, however, care about the NOTICE files for any static 605# libraries that we use. (see notice_files.mk) 606 607installed_static_library_notice_file_targets := \ 608 $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \ 609 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) 610 611# Default is -fno-rtti. 612ifeq ($(strip $(LOCAL_RTTI_FLAG)),) 613LOCAL_RTTI_FLAG := -fno-rtti 614endif 615 616########################################################### 617# Rule-specific variable definitions 618########################################################### 619$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) 620$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS) 621$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS) 622$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS) 623$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) 624$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) 625$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES) 626$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS) 627$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) 628$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(LOCAL_NO_CRT) 629 630# this is really the way to get the files onto the command line instead 631# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work 632$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) 633$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) 634$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) 635$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) 636 637########################################################### 638# Define library dependencies. 639########################################################### 640# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. 641all_libraries := \ 642 $(built_shared_libraries) \ 643 $(built_static_libraries) \ 644 $(built_whole_libraries) 645 646# Also depend on the notice files for any static libraries that 647# are linked into this module. This will force them to be installed 648# when this module is. 649$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) 650