The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 8 | ###################################### |
| 9 | ## Sanity check for LOCAL_NDK_VERSION |
| 10 | ###################################### |
| 11 | my_ndk_version_root := |
Ying Wang | 75b2857 | 2010-07-16 11:34:36 -0700 | [diff] [blame] | 12 | ifeq ($(TARGET_SIMULATOR),true) |
| 13 | # NDK does not support sim build. |
| 14 | LOCAL_NDK_VERSION := |
| 15 | endif |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 16 | ifdef LOCAL_NDK_VERSION |
| 17 | ifdef LOCAL_IS_HOST_MODULE |
| 18 | $(error $(LOCAL_PATH): LOCAL_NDK_VERSION can not be used in host module) |
| 19 | endif |
| 20 | ifneq ($(filter-out SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 21 | $(error $(LOCAL_PATH): LOCAL_NDK_VERSION can only be used to build target shared/static libraries, \ |
| 22 | while your module is of class $(LOCAL_MODULE_CLASS)) |
| 23 | endif |
| 24 | ifeq ($(filter $(LOCAL_NDK_VERSION),$(TARGET_AVAILABLE_NDK_VERSIONS)),) |
| 25 | $(error $(LOCAL_PATH): Invalid LOCAL_NDK_VERSION '$(LOCAL_NDK_VERSION)' \ |
| 26 | Choices are $(TARGET_AVAILABLE_NDK_VERSIONS)) |
| 27 | endif |
| 28 | ifndef LOCAL_SDK_VERSION |
| 29 | $(error $(LOCAL_PATH): LOCAL_NDK_VERSION must be defined with LOCAL_SDK_VERSION) |
| 30 | endif |
Ying Wang | 02c9813 | 2010-09-23 17:59:36 -0700 | [diff] [blame] | 31 | my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 32 | ifeq ($(wildcard $(my_ndk_version_root)),) |
| 33 | $(error $(LOCAL_PATH): ndk version root does not exist: $(my_ndk_version_root)) |
| 34 | endif |
| 35 | endif |
| 36 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 37 | ####################################### |
| 38 | include $(BUILD_SYSTEM)/base_rules.mk |
| 39 | ####################################### |
| 40 | |
Jing Yu | 2dcc806 | 2009-09-21 16:31:50 -0700 | [diff] [blame] | 41 | #################################################### |
| 42 | ## Add FDO flags if FDO is turned on and supported |
| 43 | #################################################### |
| 44 | ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),) |
| 45 | LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS) |
| 46 | LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS) |
| 47 | LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS) |
| 48 | endif |
| 49 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | ########################################################### |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 51 | ## Define PRIVATE_ variables from global vars |
| 52 | ########################################################### |
| 53 | ifdef LOCAL_NDK_VERSION |
| 54 | my_target_project_includes := |
| 55 | my_target_c_inclues := $(my_ndk_version_root)/usr/include |
| 56 | # TODO: more reliable way to remove platform stuff. |
| 57 | my_target_global_cflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CFLAGS)) |
| 58 | my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS)) |
| 59 | else |
| 60 | my_target_project_includes := $(TARGET_PROJECT_INCLUDES) |
| 61 | my_target_c_inclues := $(TARGET_C_INCLUDES) |
| 62 | my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS) |
| 63 | my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS) |
| 64 | endif |
| 65 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) |
| 66 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_inclues) |
| 67 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) |
| 68 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) |
| 69 | |
| 70 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 71 | ## Define PRIVATE_ variables used by multiple module types |
| 72 | ########################################################### |
| 73 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ |
| 74 | $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) |
| 75 | |
| 76 | ifeq ($(strip $(LOCAL_CC)),) |
| 77 | LOCAL_CC := $($(my_prefix)CC) |
| 78 | endif |
| 79 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC) |
| 80 | |
| 81 | ifeq ($(strip $(LOCAL_CXX)),) |
| 82 | LOCAL_CXX := $($(my_prefix)CXX) |
| 83 | endif |
| 84 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX) |
| 85 | |
| 86 | # TODO: support a mix of standard extensions so that this isn't necessary |
| 87 | LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) |
| 88 | ifeq ($(LOCAL_CPP_EXTENSION),) |
| 89 | LOCAL_CPP_EXTENSION := .cpp |
| 90 | endif |
| 91 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION) |
| 92 | |
| 93 | # Certain modules like libdl have to have symbols resolved at runtime and blow |
| 94 | # up if --no-undefined is passed to the linker. |
| 95 | ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) |
| 96 | ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),) |
| 97 | LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS) |
| 98 | endif |
| 99 | endif |
| 100 | |
| 101 | ########################################################### |
| 102 | ## Define arm-vs-thumb-mode flags. |
| 103 | ########################################################### |
| 104 | LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) |
| 105 | arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) |
| 106 | normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) |
| 107 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 108 | # Read the values from something like TARGET_arm_CFLAGS or |
| 109 | # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't |
| 110 | # actually used (although they are usually empty). |
| 111 | arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS) |
| 112 | normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 113 | |
| 114 | ########################################################### |
| 115 | ## Define per-module debugging flags. Users can turn on |
| 116 | ## debugging for a particular module by setting DEBUG_MODULE_ModuleName |
| 117 | ## to a non-empty value in their environment or buildspec.mk, |
| 118 | ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the |
| 119 | ## debug flags that they want to use. |
| 120 | ########################################################### |
| 121 | ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) |
| 122 | debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) |
| 123 | else |
| 124 | debug_cflags := |
| 125 | endif |
| 126 | |
| 127 | ########################################################### |
| 128 | ## Stuff source generated from one-off tools |
| 129 | ########################################################### |
| 130 | $(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 131 | |
| 132 | ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES) |
| 133 | |
| 134 | |
| 135 | ########################################################### |
| 136 | ## YACC: Compile .y files to .cpp and the to .o. |
| 137 | ########################################################### |
| 138 | |
| 139 | yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES)) |
| 140 | yacc_cpps := $(addprefix \ |
| 141 | $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION))) |
| 142 | yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h) |
| 143 | yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 144 | |
| 145 | ifneq ($(strip $(yacc_cpps)),) |
| 146 | $(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 147 | $(TOPDIR)$(LOCAL_PATH)/%.y \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 148 | $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 149 | $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION)) |
| 150 | $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 151 | |
| 152 | $(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 153 | $(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 154 | $(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) |
| 155 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 156 | endif |
| 157 | |
| 158 | ########################################################### |
| 159 | ## LEX: Compile .l files to .cpp and then to .o. |
| 160 | ########################################################### |
| 161 | |
| 162 | lex_sources := $(filter %.l,$(LOCAL_SRC_FILES)) |
| 163 | lex_cpps := $(addprefix \ |
| 164 | $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION))) |
| 165 | lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o) |
| 166 | |
| 167 | ifneq ($(strip $(lex_cpps)),) |
| 168 | $(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ |
| 169 | $(TOPDIR)$(LOCAL_PATH)/%.l |
| 170 | $(transform-l-to-cpp) |
| 171 | |
| 172 | $(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 173 | $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 174 | $(lex_objects): $(intermediates)/%.o: \ |
| 175 | $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 176 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 177 | $(yacc_headers) |
| 178 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 179 | endif |
| 180 | |
| 181 | ########################################################### |
| 182 | ## C++: Compile .cpp files to .o. |
| 183 | ########################################################### |
| 184 | |
| 185 | # we also do this on host modules and sim builds, even though |
| 186 | # it's not really arm, because there are files that are shared. |
| 187 | cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES))) |
| 188 | cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 189 | |
| 190 | cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES)) |
| 191 | cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) |
| 192 | |
| 193 | $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 194 | $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 195 | $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 196 | $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 197 | |
| 198 | cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) |
| 199 | |
| 200 | ifneq ($(strip $(cpp_objects)),) |
| 201 | $(cpp_objects): $(intermediates)/%.o: \ |
| 202 | $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 203 | $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 204 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 205 | -include $(cpp_objects:%.o=%.P) |
| 206 | endif |
| 207 | |
| 208 | ########################################################### |
| 209 | ## C++: Compile generated .cpp files to .o. |
| 210 | ########################################################### |
| 211 | |
| 212 | gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES)) |
| 213 | gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) |
| 214 | |
| 215 | ifneq ($(strip $(gen_cpp_objects)),) |
| 216 | # Compile all generated files as thumb. |
| 217 | # TODO: support compiling certain generated files as arm. |
| 218 | $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 219 | $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 220 | $(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 221 | $(transform-$(PRIVATE_HOST)cpp-to-o) |
| 222 | -include $(gen_cpp_objects:%.o=%.P) |
| 223 | endif |
| 224 | |
| 225 | ########################################################### |
| 226 | ## S: Compile generated .S and .s files to .o. |
| 227 | ########################################################### |
| 228 | |
| 229 | gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES)) |
| 230 | gen_S_objects := $(gen_S_sources:%.S=%.o) |
| 231 | |
| 232 | ifneq ($(strip $(gen_S_sources)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 233 | $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 234 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 235 | -include $(gen_S_objects:%.o=%.P) |
| 236 | endif |
| 237 | |
| 238 | gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES)) |
| 239 | gen_s_objects := $(gen_s_sources:%.s=%.o) |
| 240 | |
| 241 | ifneq ($(strip $(gen_s_objects)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 242 | $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 243 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 244 | -include $(gen_s_objects:%.o=%.P) |
| 245 | endif |
| 246 | |
| 247 | gen_asm_objects := $(gen_S_objects) $(gen_s_objects) |
| 248 | |
| 249 | ########################################################### |
| 250 | ## C: Compile .c files to .o. |
| 251 | ########################################################### |
| 252 | |
| 253 | c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES))) |
| 254 | c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) |
| 255 | |
| 256 | c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES)) |
| 257 | c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) |
| 258 | |
| 259 | $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) |
| 260 | $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) |
| 261 | $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 262 | $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
| 263 | |
| 264 | c_objects := $(c_arm_objects) $(c_normal_objects) |
| 265 | |
| 266 | ifneq ($(strip $(c_objects)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 267 | $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 268 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 269 | -include $(c_objects:%.o=%.P) |
| 270 | endif |
| 271 | |
| 272 | ########################################################### |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 273 | ## C: Compile generated .c files to .o. |
| 274 | ########################################################### |
| 275 | |
| 276 | gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES)) |
| 277 | gen_c_objects := $(gen_c_sources:%.c=%.o) |
| 278 | |
| 279 | ifneq ($(strip $(gen_c_objects)),) |
| 280 | # Compile all generated files as thumb. |
| 281 | # TODO: support compiling certain generated files as arm. |
| 282 | $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) |
| 283 | $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 284 | $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 285 | $(transform-$(PRIVATE_HOST)c-to-o) |
| 286 | -include $(gen_c_objects:%.o=%.P) |
| 287 | endif |
| 288 | |
| 289 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 290 | ## ObjC: Compile .m files to .o |
| 291 | ########################################################### |
| 292 | |
| 293 | objc_sources := $(filter %.m,$(LOCAL_SRC_FILES)) |
| 294 | objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) |
| 295 | |
| 296 | ifneq ($(strip $(objc_objects)),) |
| 297 | $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(PRIVATE_ADDITIONAL_DEPENDENCIES) |
| 298 | $(transform-$(PRIVATE_HOST)m-to-o) |
| 299 | -include $(objc_objects:%.o=%.P) |
| 300 | endif |
| 301 | |
| 302 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 303 | ## AS: Compile .S files to .o. |
| 304 | ########################################################### |
| 305 | |
| 306 | asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES)) |
| 307 | asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) |
| 308 | |
| 309 | ifneq ($(strip $(asm_objects_S)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 310 | $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 311 | $(transform-$(PRIVATE_HOST)s-to-o) |
| 312 | -include $(asm_objects_S:%.o=%.P) |
| 313 | endif |
| 314 | |
| 315 | asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES)) |
| 316 | asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) |
| 317 | |
| 318 | ifneq ($(strip $(asm_objects_s)),) |
Patrick Scott | d033d57 | 2009-05-19 18:13:58 -0400 | [diff] [blame] | 319 | $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 320 | $(transform-$(PRIVATE_HOST)s-to-o-no-deps) |
| 321 | -include $(asm_objects_s:%.o=%.P) |
| 322 | endif |
| 323 | |
| 324 | asm_objects := $(asm_objects_S) $(asm_objects_s) |
| 325 | |
| 326 | |
| 327 | ########################################################### |
| 328 | ## Common object handling. |
| 329 | ########################################################### |
| 330 | |
| 331 | # some rules depend on asm_objects being first. If your code depends on |
| 332 | # being first, it's reasonable to require it to be assembly |
| 333 | all_objects := \ |
| 334 | $(asm_objects) \ |
| 335 | $(cpp_objects) \ |
| 336 | $(gen_cpp_objects) \ |
| 337 | $(gen_asm_objects) \ |
| 338 | $(c_objects) \ |
Jack Palevich | e7b3e2c | 2009-05-04 14:32:44 -0700 | [diff] [blame] | 339 | $(gen_c_objects) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 340 | $(yacc_objects) \ |
| 341 | $(lex_objects) \ |
| 342 | $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) |
| 343 | |
| 344 | LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates) |
| 345 | |
Ying Wang | bce4b75 | 2010-07-22 15:51:56 -0700 | [diff] [blame] | 346 | ifndef LOCAL_NDK_VERSION |
| 347 | LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) |
| 348 | endif |
| 349 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 350 | $(all_objects) : | $(LOCAL_GENERATED_SOURCES) |
| 351 | ALL_C_CPP_ETC_OBJECTS += $(all_objects) |
| 352 | |
| 353 | ########################################################### |
| 354 | ## Copy headers to the install tree |
| 355 | ########################################################### |
| 356 | include $(BUILD_COPY_HEADERS) |
| 357 | |
| 358 | ########################################################### |
| 359 | # Standard library handling. |
| 360 | # |
| 361 | # On the target, we compile with -nostdlib, so we must add in the |
| 362 | # default system shared libraries, unless they have requested not |
| 363 | # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would |
| 364 | # supply that, for example, when building libc itself. |
| 365 | ########################################################### |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 366 | ifdef LOCAL_IS_HOST_MODULE |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 367 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 368 | LOCAL_SYSTEM_SHARED_LIBRARIES := |
| 369 | endif |
| 370 | else |
| 371 | ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) |
| 372 | LOCAL_SYSTEM_SHARED_LIBRARIES := $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 373 | endif |
| 374 | endif |
| 375 | |
| 376 | # Logging used to be part of libcutils (target) and libutils (sim); |
| 377 | # hack modules that use those other libs to also include liblog. |
| 378 | # All of this complexity is to make sure that liblog only appears |
| 379 | # once, and appears just before libcutils or libutils on the link |
| 380 | # line. |
| 381 | # TODO: remove this hack and change all modules to use liblog |
| 382 | # when necessary. |
| 383 | define insert-liblog |
| 384 | $(if $(filter liblog,$(1)),$(1), \ |
| 385 | $(if $(filter libcutils,$(1)), \ |
| 386 | $(patsubst libcutils,liblog libcutils,$(1)) \ |
| 387 | , \ |
| 388 | $(patsubst libutils,liblog libutils,$(1)) \ |
| 389 | ) \ |
| 390 | ) |
| 391 | endef |
| 392 | ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES))) |
| 393 | LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES)) |
| 394 | endif |
| 395 | ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES))) |
| 396 | LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES)) |
| 397 | endif |
| 398 | ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES))) |
| 399 | LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES)) |
| 400 | endif |
| 401 | |
| 402 | ########################################################### |
| 403 | # The list of libraries that this module will link against are in |
| 404 | # these variables. Each is a list of bare module names like "libc libm". |
| 405 | # |
| 406 | # LOCAL_SHARED_LIBRARIES |
| 407 | # LOCAL_STATIC_LIBRARIES |
| 408 | # LOCAL_WHOLE_STATIC_LIBRARIES |
| 409 | # |
| 410 | # We need to convert the bare names into the dependencies that |
| 411 | # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. |
| 412 | # LOCAL_BUILT_MODULE should depend on the BUILT versions of the |
| 413 | # libraries, so that simply building this module doesn't force |
| 414 | # an install of a library. Similarly, LOCAL_INSTALLED_MODULE |
| 415 | # should depend on the INSTALLED versions of the libraries so |
| 416 | # that they get installed when this module does. |
| 417 | ########################################################### |
| 418 | # NOTE: |
| 419 | # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the |
| 420 | # module without leaving anything out, which is useful for turning |
| 421 | # a collection of .a files into a .so file. Linking against a |
| 422 | # normal STATIC_LIBRARY will only pull in code/symbols that are |
| 423 | # referenced by the module. (see gcc/ld's --whole-archive option) |
| 424 | ########################################################### |
| 425 | |
| 426 | # Get the list of BUILT libraries, which are under |
| 427 | # various intermediates directories. |
| 428 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 429 | a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) |
| 430 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 431 | ifdef LOCAL_NDK_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 432 | built_shared_libraries := \ |
| 433 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 434 | $(addsuffix $(so_suffix), \ |
| 435 | $(LOCAL_SHARED_LIBRARIES))) |
| 436 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 437 | # Get the list of INSTALLED libraries. Strip off the various |
| 438 | # intermediates directories and point to the common lib dirs. |
| 439 | installed_shared_libraries := \ |
| 440 | $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \ |
| 441 | $(notdir $(built_shared_libraries))) |
| 442 | |
| 443 | my_system_shared_libraries_fullpath := $(addprefix $(my_ndk_version_root)/usr/lib/, \ |
| 444 | $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES))) |
| 445 | |
| 446 | built_shared_libraries += $(my_system_shared_libraries_fullpath) |
| 447 | LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
| 448 | else |
| 449 | LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES) |
| 450 | built_shared_libraries := \ |
| 451 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 452 | $(addsuffix $(so_suffix), \ |
| 453 | $(LOCAL_SHARED_LIBRARIES))) |
| 454 | |
| 455 | installed_shared_libraries := \ |
| 456 | $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \ |
| 457 | $(notdir $(built_shared_libraries))) |
| 458 | endif |
| 459 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 460 | built_static_libraries := \ |
| 461 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \ |
| 462 | $(call intermediates-dir-for, \ |
| 463 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 464 | |
| 465 | built_whole_libraries := \ |
| 466 | $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 467 | $(call intermediates-dir-for, \ |
| 468 | STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix)) |
| 469 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 470 | # We don't care about installed static libraries, since the |
| 471 | # libraries have already been linked into the module at that point. |
| 472 | # We do, however, care about the NOTICE files for any static |
| 473 | # libraries that we use. (see notice_files.make) |
| 474 | |
| 475 | installed_static_library_notice_file_targets := \ |
| 476 | $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \ |
| 477 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) |
| 478 | |
| 479 | ########################################################### |
| 480 | # Rule-specific variable definitions |
| 481 | ########################################################### |
| 482 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) |
| 483 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS) |
| 484 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS) |
| 485 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS) |
| 486 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) |
| 487 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES) |
| 488 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS) |
| 489 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) |
| 490 | |
| 491 | # this is really the way to get the files onto the command line instead |
| 492 | # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work |
| 493 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) |
| 494 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) |
| 495 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) |
| 496 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) |
| 497 | |
| 498 | ########################################################### |
| 499 | # Define library dependencies. |
| 500 | ########################################################### |
| 501 | # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. |
| 502 | all_libraries := \ |
| 503 | $(built_shared_libraries) \ |
| 504 | $(built_static_libraries) \ |
| 505 | $(built_whole_libraries) |
| 506 | |
| 507 | # Make LOCAL_INSTALLED_MODULE depend on the installed versions of the |
| 508 | # libraries so they get installed along with it. We don't need to |
| 509 | # rebuild it when installing it, though, so this can be an order-only |
| 510 | # dependency. |
| 511 | $(LOCAL_INSTALLED_MODULE): | $(installed_shared_libraries) |
| 512 | |
| 513 | # Also depend on the notice files for any static libraries that |
| 514 | # are linked into this module. This will force them to be installed |
| 515 | # when this module is. |
| 516 | $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) |