blob: 5fb0e7532d2549ed51e872804ad40534c1b4a18f [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
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 Wang1a081002010-07-13 14:55:47 -07008######################################
9## Sanity check for LOCAL_NDK_VERSION
10######################################
11my_ndk_version_root :=
Ying Wang75b28572010-07-16 11:34:36 -070012ifeq ($(TARGET_SIMULATOR),true)
13 # NDK does not support sim build.
14 LOCAL_NDK_VERSION :=
15endif
Ying Wang1a081002010-07-13 14:55:47 -070016ifdef 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 Wang02c98132010-09-23 17:59:36 -070031 my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH)
Ying Wang1a081002010-07-13 14:55:47 -070032 ifeq ($(wildcard $(my_ndk_version_root)),)
33 $(error $(LOCAL_PATH): ndk version root does not exist: $(my_ndk_version_root))
34 endif
35endif
36
The Android Open Source Project88b60792009-03-03 19:28:42 -080037#######################################
38include $(BUILD_SYSTEM)/base_rules.mk
39#######################################
40
Jing Yu2dcc8062009-09-21 16:31:50 -070041####################################################
42## Add FDO flags if FDO is turned on and supported
43####################################################
44ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
45 LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS)
46 LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS)
47 LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
48endif
49
The Android Open Source Project88b60792009-03-03 19:28:42 -080050###########################################################
Ying Wang1a081002010-07-13 14:55:47 -070051## Define PRIVATE_ variables from global vars
52###########################################################
53ifdef LOCAL_NDK_VERSION
54my_target_project_includes :=
55my_target_c_inclues := $(my_ndk_version_root)/usr/include
56# TODO: more reliable way to remove platform stuff.
57my_target_global_cflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CFLAGS))
58my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS))
59else
60my_target_project_includes := $(TARGET_PROJECT_INCLUDES)
61my_target_c_inclues := $(TARGET_C_INCLUDES)
62my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS)
63my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS)
64endif
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 Project88b60792009-03-03 19:28:42 -080071## 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
76ifeq ($(strip $(LOCAL_CC)),)
77 LOCAL_CC := $($(my_prefix)CC)
78endif
79$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC)
80
81ifeq ($(strip $(LOCAL_CXX)),)
82 LOCAL_CXX := $($(my_prefix)CXX)
83endif
84$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX)
85
86# TODO: support a mix of standard extensions so that this isn't necessary
87LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
88ifeq ($(LOCAL_CPP_EXTENSION),)
89 LOCAL_CPP_EXTENSION := .cpp
90endif
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.
95ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
96ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
97 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS)
98endif
99endif
100
101###########################################################
102## Define arm-vs-thumb-mode flags.
103###########################################################
104LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
105arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
106normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
107
Dave Bort95282482009-04-23 18:44:55 -0700108# 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).
111arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
112normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800113
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###########################################################
121ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
122 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
123else
124 debug_cflags :=
125endif
126
127###########################################################
128## Stuff source generated from one-off tools
129###########################################################
130$(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE)
131
132ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES)
133
134
135###########################################################
136## YACC: Compile .y files to .cpp and the to .o.
137###########################################################
138
139yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES))
140yacc_cpps := $(addprefix \
141 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
142yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
143yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
144
145ifneq ($(strip $(yacc_cpps)),)
146$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
147 $(TOPDIR)$(LOCAL_PATH)/%.y \
Patrick Scottd033d572009-05-19 18:13:58 -0400148 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149 $(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)
156endif
157
158###########################################################
159## LEX: Compile .l files to .cpp and then to .o.
160###########################################################
161
162lex_sources := $(filter %.l,$(LOCAL_SRC_FILES))
163lex_cpps := $(addprefix \
164 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
165lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
166
167ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400176 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800177 $(yacc_headers)
178 $(transform-$(PRIVATE_HOST)cpp-to-o)
179endif
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.
187cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES)))
188cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
189
190cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES))
191cpp_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
198cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
199
200ifneq ($(strip $(cpp_objects)),)
201$(cpp_objects): $(intermediates)/%.o: \
202 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Patrick Scottd033d572009-05-19 18:13:58 -0400203 $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204 $(transform-$(PRIVATE_HOST)cpp-to-o)
205-include $(cpp_objects:%.o=%.P)
206endif
207
208###########################################################
209## C++: Compile generated .cpp files to .o.
210###########################################################
211
212gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES))
213gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
214
215ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400220$(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800221 $(transform-$(PRIVATE_HOST)cpp-to-o)
222-include $(gen_cpp_objects:%.o=%.P)
223endif
224
225###########################################################
226## S: Compile generated .S and .s files to .o.
227###########################################################
228
229gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES))
230gen_S_objects := $(gen_S_sources:%.S=%.o)
231
232ifneq ($(strip $(gen_S_sources)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400233$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800234 $(transform-$(PRIVATE_HOST)s-to-o)
235-include $(gen_S_objects:%.o=%.P)
236endif
237
238gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES))
239gen_s_objects := $(gen_s_sources:%.s=%.o)
240
241ifneq ($(strip $(gen_s_objects)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400242$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800243 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
244-include $(gen_s_objects:%.o=%.P)
245endif
246
247gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
248
249###########################################################
250## C: Compile .c files to .o.
251###########################################################
252
253c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES)))
254c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
255
256c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES))
257c_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
264c_objects := $(c_arm_objects) $(c_normal_objects)
265
266ifneq ($(strip $(c_objects)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400267$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800268 $(transform-$(PRIVATE_HOST)c-to-o)
269-include $(c_objects:%.o=%.P)
270endif
271
272###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700273## C: Compile generated .c files to .o.
274###########################################################
275
276gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES))
277gen_c_objects := $(gen_c_sources:%.c=%.o)
278
279ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400284$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700285 $(transform-$(PRIVATE_HOST)c-to-o)
286-include $(gen_c_objects:%.o=%.P)
287endif
288
289###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200290## ObjC: Compile .m files to .o
291###########################################################
292
293objc_sources := $(filter %.m,$(LOCAL_SRC_FILES))
294objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
295
296ifneq ($(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)
300endif
301
302###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800303## AS: Compile .S files to .o.
304###########################################################
305
306asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES))
307asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
308
309ifneq ($(strip $(asm_objects_S)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400310$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311 $(transform-$(PRIVATE_HOST)s-to-o)
312-include $(asm_objects_S:%.o=%.P)
313endif
314
315asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES))
316asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
317
318ifneq ($(strip $(asm_objects_s)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400319$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800320 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
321-include $(asm_objects_s:%.o=%.P)
322endif
323
324asm_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
333all_objects := \
334 $(asm_objects) \
335 $(cpp_objects) \
336 $(gen_cpp_objects) \
337 $(gen_asm_objects) \
338 $(c_objects) \
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700339 $(gen_c_objects) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800340 $(yacc_objects) \
341 $(lex_objects) \
342 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
343
344LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates)
345
Ying Wangbce4b752010-07-22 15:51:56 -0700346ifndef LOCAL_NDK_VERSION
347 LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
348endif
349
The Android Open Source Project88b60792009-03-03 19:28:42 -0800350$(all_objects) : | $(LOCAL_GENERATED_SOURCES)
351ALL_C_CPP_ETC_OBJECTS += $(all_objects)
352
353###########################################################
354## Copy headers to the install tree
355###########################################################
356include $(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 Wang1a081002010-07-13 14:55:47 -0700366ifdef LOCAL_IS_HOST_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wang1a081002010-07-13 14:55:47 -0700368 LOCAL_SYSTEM_SHARED_LIBRARIES :=
369 endif
370else
371 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
372 LOCAL_SYSTEM_SHARED_LIBRARIES := $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800373 endif
374endif
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.
383define 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 )
391endef
392ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
393 LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
394endif
395ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
396 LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
397endif
398ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
399 LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES))
400endif
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.
428so_suffix := $($(my_prefix)SHLIB_SUFFIX)
429a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
430
Ying Wang1a081002010-07-13 14:55:47 -0700431ifdef LOCAL_NDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800432built_shared_libraries := \
433 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
434 $(addsuffix $(so_suffix), \
435 $(LOCAL_SHARED_LIBRARIES)))
436
Ying Wang1a081002010-07-13 14:55:47 -0700437# Get the list of INSTALLED libraries. Strip off the various
438# intermediates directories and point to the common lib dirs.
439installed_shared_libraries := \
440 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
441 $(notdir $(built_shared_libraries)))
442
443my_system_shared_libraries_fullpath := $(addprefix $(my_ndk_version_root)/usr/lib/, \
444 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
445
446built_shared_libraries += $(my_system_shared_libraries_fullpath)
447LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
448else
449LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
450built_shared_libraries := \
451 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
452 $(addsuffix $(so_suffix), \
453 $(LOCAL_SHARED_LIBRARIES)))
454
455installed_shared_libraries := \
456 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
457 $(notdir $(built_shared_libraries)))
458endif
459
The Android Open Source Project88b60792009-03-03 19:28:42 -0800460built_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
465built_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 Project88b60792009-03-03 19:28:42 -0800470# 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
475installed_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.
502all_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)