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