blob: b8688bbfd0e84cd2457416eb54a14e0ef01d1acc [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 :=
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_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
31endif
32
The Android Open Source Project88b60792009-03-03 19:28:42 -080033#######################################
34include $(BUILD_SYSTEM)/base_rules.mk
35#######################################
36
Jing Yu2dcc8062009-09-21 16:31:50 -070037####################################################
38## Add FDO flags if FDO is turned on and supported
39####################################################
40ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
41 LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS)
42 LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS)
43 LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
44endif
45
The Android Open Source Project88b60792009-03-03 19:28:42 -080046###########################################################
Ying Wang1a081002010-07-13 14:55:47 -070047## Define PRIVATE_ variables from global vars
48###########################################################
49ifdef LOCAL_NDK_VERSION
50my_target_project_includes :=
51my_target_c_inclues := $(my_ndk_version_root)/usr/include
52# TODO: more reliable way to remove platform stuff.
53my_target_global_cflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CFLAGS))
54my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS))
55else
56my_target_project_includes := $(TARGET_PROJECT_INCLUDES)
57my_target_c_inclues := $(TARGET_C_INCLUDES)
58my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS)
59my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS)
60endif
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 Project88b60792009-03-03 19:28:42 -080067## 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
72ifeq ($(strip $(LOCAL_CC)),)
73 LOCAL_CC := $($(my_prefix)CC)
74endif
75$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC)
76
77ifeq ($(strip $(LOCAL_CXX)),)
78 LOCAL_CXX := $($(my_prefix)CXX)
79endif
80$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX)
81
82# TODO: support a mix of standard extensions so that this isn't necessary
83LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
84ifeq ($(LOCAL_CPP_EXTENSION),)
85 LOCAL_CPP_EXTENSION := .cpp
86endif
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.
91ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
92ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
93 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS)
94endif
95endif
96
97###########################################################
98## Define arm-vs-thumb-mode flags.
99###########################################################
100LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800101ifeq ($(TARGET_ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800102arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
103normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
104
Dave Bort95282482009-04-23 18:44:55 -0700105# 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).
108arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
109normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800110else
111arm_objects_mode :=
112normal_objects_mode :=
113arm_objects_cflags :=
114normal_objects_cflags :=
115endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800116
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###########################################################
124ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
125 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
126else
127 debug_cflags :=
128endif
129
130###########################################################
131## Stuff source generated from one-off tools
132###########################################################
133$(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE)
134
135ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES)
136
137
138###########################################################
139## YACC: Compile .y files to .cpp and the to .o.
140###########################################################
141
142yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES))
143yacc_cpps := $(addprefix \
144 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
145yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
146yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
147
148ifneq ($(strip $(yacc_cpps)),)
149$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
150 $(TOPDIR)$(LOCAL_PATH)/%.y \
Patrick Scottd033d572009-05-19 18:13:58 -0400151 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152 $(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)
159endif
160
161###########################################################
162## LEX: Compile .l files to .cpp and then to .o.
163###########################################################
164
165lex_sources := $(filter %.l,$(LOCAL_SRC_FILES))
166lex_cpps := $(addprefix \
167 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
168lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
169
170ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400179 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800180 $(yacc_headers)
181 $(transform-$(PRIVATE_HOST)cpp-to-o)
182endif
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.
190cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES)))
191cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
192
193cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES))
194cpp_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
201cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
202
203ifneq ($(strip $(cpp_objects)),)
204$(cpp_objects): $(intermediates)/%.o: \
205 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Patrick Scottd033d572009-05-19 18:13:58 -0400206 $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207 $(transform-$(PRIVATE_HOST)cpp-to-o)
208-include $(cpp_objects:%.o=%.P)
209endif
210
211###########################################################
212## C++: Compile generated .cpp files to .o.
213###########################################################
214
215gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES))
216gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
217
218ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400223$(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224 $(transform-$(PRIVATE_HOST)cpp-to-o)
225-include $(gen_cpp_objects:%.o=%.P)
226endif
227
228###########################################################
229## S: Compile generated .S and .s files to .o.
230###########################################################
231
232gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES))
233gen_S_objects := $(gen_S_sources:%.S=%.o)
234
235ifneq ($(strip $(gen_S_sources)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400236$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800237 $(transform-$(PRIVATE_HOST)s-to-o)
238-include $(gen_S_objects:%.o=%.P)
239endif
240
241gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES))
242gen_s_objects := $(gen_s_sources:%.s=%.o)
243
244ifneq ($(strip $(gen_s_objects)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400245$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800246 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
247-include $(gen_s_objects:%.o=%.P)
248endif
249
250gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
251
252###########################################################
253## C: Compile .c files to .o.
254###########################################################
255
256c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES)))
257c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
258
259c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES))
260c_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
267c_objects := $(c_arm_objects) $(c_normal_objects)
268
269ifneq ($(strip $(c_objects)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400270$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800271 $(transform-$(PRIVATE_HOST)c-to-o)
272-include $(c_objects:%.o=%.P)
273endif
274
275###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700276## C: Compile generated .c files to .o.
277###########################################################
278
279gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES))
280gen_c_objects := $(gen_c_sources:%.c=%.o)
281
282ifneq ($(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 Scottd033d572009-05-19 18:13:58 -0400287$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700288 $(transform-$(PRIVATE_HOST)c-to-o)
289-include $(gen_c_objects:%.o=%.P)
290endif
291
292###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200293## ObjC: Compile .m files to .o
294###########################################################
295
296objc_sources := $(filter %.m,$(LOCAL_SRC_FILES))
297objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
298
299ifneq ($(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)
303endif
304
305###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800306## AS: Compile .S files to .o.
307###########################################################
308
309asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES))
310asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
311
312ifneq ($(strip $(asm_objects_S)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400313$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800314 $(transform-$(PRIVATE_HOST)s-to-o)
315-include $(asm_objects_S:%.o=%.P)
316endif
317
318asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES))
319asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
320
321ifneq ($(strip $(asm_objects_s)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400322$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
324-include $(asm_objects_s:%.o=%.P)
325endif
326
327asm_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
336all_objects := \
337 $(asm_objects) \
338 $(cpp_objects) \
339 $(gen_cpp_objects) \
340 $(gen_asm_objects) \
341 $(c_objects) \
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700342 $(gen_c_objects) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343 $(yacc_objects) \
344 $(lex_objects) \
345 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
346
347LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates)
348
349$(all_objects) : | $(LOCAL_GENERATED_SOURCES)
350ALL_C_CPP_ETC_OBJECTS += $(all_objects)
351
352###########################################################
353## Copy headers to the install tree
354###########################################################
355include $(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 Wang1a081002010-07-13 14:55:47 -0700365ifdef LOCAL_IS_HOST_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800366 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wang1a081002010-07-13 14:55:47 -0700367 LOCAL_SYSTEM_SHARED_LIBRARIES :=
368 endif
369else
370 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
371 LOCAL_SYSTEM_SHARED_LIBRARIES := $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372 endif
373endif
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.
382define 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 )
390endef
391ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
392 LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
393endif
394ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
395 LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
396endif
397ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
398 LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES))
399endif
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.
427so_suffix := $($(my_prefix)SHLIB_SUFFIX)
428a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
429
Ying Wang1a081002010-07-13 14:55:47 -0700430ifdef LOCAL_NDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800431built_shared_libraries := \
432 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
433 $(addsuffix $(so_suffix), \
434 $(LOCAL_SHARED_LIBRARIES)))
435
Ying Wang1a081002010-07-13 14:55:47 -0700436# Get the list of INSTALLED libraries. Strip off the various
437# intermediates directories and point to the common lib dirs.
438installed_shared_libraries := \
439 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
440 $(notdir $(built_shared_libraries)))
441
442my_system_shared_libraries_fullpath := $(addprefix $(my_ndk_version_root)/usr/lib/, \
443 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
444
445built_shared_libraries += $(my_system_shared_libraries_fullpath)
446LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
447else
448LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
449built_shared_libraries := \
450 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
451 $(addsuffix $(so_suffix), \
452 $(LOCAL_SHARED_LIBRARIES)))
453
454installed_shared_libraries := \
455 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
456 $(notdir $(built_shared_libraries)))
457endif
458
The Android Open Source Project88b60792009-03-03 19:28:42 -0800459built_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
464built_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 Project88b60792009-03-03 19:28:42 -0800469# 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
474installed_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.
501all_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)