blob: 7a17ccdb820298cd758f1ca6c70ab70c495c5bd8 [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 Wang2f76c6d2011-02-23 10:07:03 -080031 my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/sources
Ying Wang02c98132010-09-23 17:59:36 -070032 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 -070033 ifeq ($(wildcard $(my_ndk_version_root)),)
34 $(error $(LOCAL_PATH): ndk version root does not exist: $(my_ndk_version_root))
35 endif
36endif
37
The Android Open Source Project88b60792009-03-03 19:28:42 -080038#######################################
39include $(BUILD_SYSTEM)/base_rules.mk
40#######################################
41
Jing Yu2dcc8062009-09-21 16:31:50 -070042####################################################
43## Add FDO flags if FDO is turned on and supported
44####################################################
45ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
46 LOCAL_CFLAGS += $(TARGET_FDO_CFLAGS)
47 LOCAL_CPPFLAGS += $(TARGET_FDO_CFLAGS)
48 LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
49endif
50
The Android Open Source Project88b60792009-03-03 19:28:42 -080051###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +080052## Explicitly declare assembly-only __ASSEMBLY__ macro for
53## assembly source
54###########################################################
55LOCAL_ASFLAGS += -D__ASSEMBLY__
56
57###########################################################
Ying Wang1a081002010-07-13 14:55:47 -070058## Define PRIVATE_ variables from global vars
59###########################################################
60ifdef LOCAL_NDK_VERSION
61my_target_project_includes :=
62my_target_c_inclues := $(my_ndk_version_root)/usr/include
Ying Wang2f76c6d2011-02-23 10:07:03 -080063# Starting from NDK-r5 the c++ stl headers reside in a separate directory
64my_target_c_inclues += $(my_ndk_source_root)/cxx-stl/system/include
Ying Wang1a081002010-07-13 14:55:47 -070065# TODO: more reliable way to remove platform stuff.
66my_target_global_cflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CFLAGS))
67my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS))
68else
69my_target_project_includes := $(TARGET_PROJECT_INCLUDES)
70my_target_c_inclues := $(TARGET_C_INCLUDES)
71my_target_global_cflags := $(TARGET_GLOBAL_CFLAGS)
72my_target_global_cppflags := $(TARGET_GLOBAL_CPPFLAGS)
73endif
74$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
75$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_inclues)
76$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
77$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
78
79###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -080080## Define PRIVATE_ variables used by multiple module types
81###########################################################
82$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
83 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
84
85ifeq ($(strip $(LOCAL_CC)),)
86 LOCAL_CC := $($(my_prefix)CC)
87endif
88$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC)
89
90ifeq ($(strip $(LOCAL_CXX)),)
91 LOCAL_CXX := $($(my_prefix)CXX)
92endif
93$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX)
94
95# TODO: support a mix of standard extensions so that this isn't necessary
96LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
97ifeq ($(LOCAL_CPP_EXTENSION),)
98 LOCAL_CPP_EXTENSION := .cpp
99endif
100$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
101
102# Certain modules like libdl have to have symbols resolved at runtime and blow
103# up if --no-undefined is passed to the linker.
104ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
105ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
106 LOCAL_LDFLAGS := $(LOCAL_LDFLAGS) $($(my_prefix)NO_UNDEFINED_LDFLAGS)
107endif
108endif
109
110###########################################################
111## Define arm-vs-thumb-mode flags.
112###########################################################
113LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800114ifeq ($(TARGET_ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800115arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
116normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
117
Dave Bort95282482009-04-23 18:44:55 -0700118# Read the values from something like TARGET_arm_CFLAGS or
119# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
120# actually used (although they are usually empty).
121arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
122normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800123else
124arm_objects_mode :=
125normal_objects_mode :=
126arm_objects_cflags :=
127normal_objects_cflags :=
128endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800129
130###########################################################
131## Define per-module debugging flags. Users can turn on
132## debugging for a particular module by setting DEBUG_MODULE_ModuleName
133## to a non-empty value in their environment or buildspec.mk,
134## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
135## debug flags that they want to use.
136###########################################################
137ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
138 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
139else
140 debug_cflags :=
141endif
142
143###########################################################
144## Stuff source generated from one-off tools
145###########################################################
146$(LOCAL_GENERATED_SOURCES): PRIVATE_MODULE := $(LOCAL_MODULE)
147
148ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES)
149
150
151###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700152## Compile the .proto files to .cc and then to .o
153###########################################################
154proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
155proto_generated_objects :=
156proto_generated_headers :=
157ifneq ($(proto_sources),)
158proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
159proto_generated_cc_sources_dir := $(intermediates)/proto
160proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
161 $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
162proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources))
163
164$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
165$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
Ying Wang33c0d952010-11-05 11:30:58 -0700166$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700167$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
168 $(transform-proto-to-cc)
169
170proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
171$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
172
173$(proto_generated_cc_sources): PRIVATE_ARM_MODE := $(normal_objects_mode)
174$(proto_generated_cc_sources): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
175$(proto_generated_objects): $(proto_generated_cc_sources_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc
176 $(transform-$(PRIVATE_HOST)cpp-to-o)
177-include $(proto_generated_objects:%.o=%.P)
178
179LOCAL_C_INCLUDES += external/protobuf/src $(proto_generated_cc_sources_dir)
180LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI
181ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
182LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-full
183else
184LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-lite
185endif
186endif
187
188
189###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800190## YACC: Compile .y files to .cpp and the to .o.
191###########################################################
192
193yacc_sources := $(filter %.y,$(LOCAL_SRC_FILES))
194yacc_cpps := $(addprefix \
195 $(intermediates)/,$(yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
196yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
197yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
198
199ifneq ($(strip $(yacc_cpps)),)
200$(yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
201 $(TOPDIR)$(LOCAL_PATH)/%.y \
Patrick Scottd033d572009-05-19 18:13:58 -0400202 $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800203 $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
204$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
205
206$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
207$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
208$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
209 $(transform-$(PRIVATE_HOST)cpp-to-o)
210endif
211
212###########################################################
213## LEX: Compile .l files to .cpp and then to .o.
214###########################################################
215
216lex_sources := $(filter %.l,$(LOCAL_SRC_FILES))
217lex_cpps := $(addprefix \
218 $(intermediates)/,$(lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
219lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
220
221ifneq ($(strip $(lex_cpps)),)
222$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
223 $(TOPDIR)$(LOCAL_PATH)/%.l
224 $(transform-l-to-cpp)
225
226$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
227$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
228$(lex_objects): $(intermediates)/%.o: \
229 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Patrick Scottd033d572009-05-19 18:13:58 -0400230 $(LOCAL_ADDITIONAL_DEPENDENCIES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800231 $(yacc_headers)
232 $(transform-$(PRIVATE_HOST)cpp-to-o)
233endif
234
235###########################################################
236## C++: Compile .cpp files to .o.
237###########################################################
238
239# we also do this on host modules and sim builds, even though
240# it's not really arm, because there are files that are shared.
241cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES)))
242cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
243
244cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES))
245cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
246
247$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
248$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
249$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
250$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
251
252cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
253
254ifneq ($(strip $(cpp_objects)),)
255$(cpp_objects): $(intermediates)/%.o: \
256 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Ying Wanga5fc87a2010-11-02 18:43:16 -0700257 $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258 $(transform-$(PRIVATE_HOST)cpp-to-o)
259-include $(cpp_objects:%.o=%.P)
260endif
261
262###########################################################
263## C++: Compile generated .cpp files to .o.
264###########################################################
265
266gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_GENERATED_SOURCES))
267gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
268
269ifneq ($(strip $(gen_cpp_objects)),)
270# Compile all generated files as thumb.
271# TODO: support compiling certain generated files as arm.
272$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
273$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700274$(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800275 $(transform-$(PRIVATE_HOST)cpp-to-o)
276-include $(gen_cpp_objects:%.o=%.P)
277endif
278
279###########################################################
280## S: Compile generated .S and .s files to .o.
281###########################################################
282
283gen_S_sources := $(filter %.S,$(LOCAL_GENERATED_SOURCES))
284gen_S_objects := $(gen_S_sources:%.S=%.o)
285
286ifneq ($(strip $(gen_S_sources)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400287$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288 $(transform-$(PRIVATE_HOST)s-to-o)
289-include $(gen_S_objects:%.o=%.P)
290endif
291
292gen_s_sources := $(filter %.s,$(LOCAL_GENERATED_SOURCES))
293gen_s_objects := $(gen_s_sources:%.s=%.o)
294
295ifneq ($(strip $(gen_s_objects)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400296$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800297 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
298-include $(gen_s_objects:%.o=%.P)
299endif
300
301gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
302
303###########################################################
304## C: Compile .c files to .o.
305###########################################################
306
307c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(LOCAL_SRC_FILES)))
308c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
309
310c_normal_sources := $(filter %.c,$(LOCAL_SRC_FILES))
311c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
312
313$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
314$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
315$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
316$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
317
318c_objects := $(c_arm_objects) $(c_normal_objects)
319
320ifneq ($(strip $(c_objects)),)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700321$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800322 $(transform-$(PRIVATE_HOST)c-to-o)
323-include $(c_objects:%.o=%.P)
324endif
325
326###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700327## C: Compile generated .c files to .o.
328###########################################################
329
330gen_c_sources := $(filter %.c,$(LOCAL_GENERATED_SOURCES))
331gen_c_objects := $(gen_c_sources:%.c=%.o)
332
333ifneq ($(strip $(gen_c_objects)),)
334# Compile all generated files as thumb.
335# TODO: support compiling certain generated files as arm.
336$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
337$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700338$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700339 $(transform-$(PRIVATE_HOST)c-to-o)
340-include $(gen_c_objects:%.o=%.P)
341endif
342
343###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200344## ObjC: Compile .m files to .o
345###########################################################
346
347objc_sources := $(filter %.m,$(LOCAL_SRC_FILES))
348objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
349
350ifneq ($(strip $(objc_objects)),)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700351$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) $(PRIVATE_ADDITIONAL_DEPENDENCIES)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200352 $(transform-$(PRIVATE_HOST)m-to-o)
353-include $(objc_objects:%.o=%.P)
354endif
355
356###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800357## AS: Compile .S files to .o.
358###########################################################
359
360asm_sources_S := $(filter %.S,$(LOCAL_SRC_FILES))
361asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
362
363ifneq ($(strip $(asm_objects_S)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400364$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800365 $(transform-$(PRIVATE_HOST)s-to-o)
366-include $(asm_objects_S:%.o=%.P)
367endif
368
369asm_sources_s := $(filter %.s,$(LOCAL_SRC_FILES))
370asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
371
372ifneq ($(strip $(asm_objects_s)),)
Patrick Scottd033d572009-05-19 18:13:58 -0400373$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800374 $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
375-include $(asm_objects_s:%.o=%.P)
376endif
377
378asm_objects := $(asm_objects_S) $(asm_objects_s)
379
380
381###########################################################
382## Common object handling.
383###########################################################
384
385# some rules depend on asm_objects being first. If your code depends on
386# being first, it's reasonable to require it to be assembly
387all_objects := \
388 $(asm_objects) \
389 $(cpp_objects) \
390 $(gen_cpp_objects) \
391 $(gen_asm_objects) \
392 $(c_objects) \
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700393 $(gen_c_objects) \
David 'Digit' Turner5ca286d2011-02-11 16:19:31 +0100394 $(objc_objects) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800395 $(yacc_objects) \
396 $(lex_objects) \
Ying Wanga5fc87a2010-11-02 18:43:16 -0700397 $(proto_generated_objects) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800398 $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
399
400LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates)
401
Ying Wangbce4b752010-07-22 15:51:56 -0700402ifndef LOCAL_NDK_VERSION
403 LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
404endif
405
The Android Open Source Project88b60792009-03-03 19:28:42 -0800406$(all_objects) : | $(LOCAL_GENERATED_SOURCES)
407ALL_C_CPP_ETC_OBJECTS += $(all_objects)
408
409###########################################################
410## Copy headers to the install tree
411###########################################################
412include $(BUILD_COPY_HEADERS)
413
414###########################################################
415# Standard library handling.
416#
417# On the target, we compile with -nostdlib, so we must add in the
418# default system shared libraries, unless they have requested not
419# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
420# supply that, for example, when building libc itself.
421###########################################################
Ying Wang1a081002010-07-13 14:55:47 -0700422ifdef LOCAL_IS_HOST_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800423 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Ying Wang1a081002010-07-13 14:55:47 -0700424 LOCAL_SYSTEM_SHARED_LIBRARIES :=
425 endif
426else
427 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
428 LOCAL_SYSTEM_SHARED_LIBRARIES := $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800429 endif
430endif
431
432# Logging used to be part of libcutils (target) and libutils (sim);
433# hack modules that use those other libs to also include liblog.
434# All of this complexity is to make sure that liblog only appears
435# once, and appears just before libcutils or libutils on the link
436# line.
437# TODO: remove this hack and change all modules to use liblog
438# when necessary.
439define insert-liblog
440 $(if $(filter liblog,$(1)),$(1), \
441 $(if $(filter libcutils,$(1)), \
442 $(patsubst libcutils,liblog libcutils,$(1)) \
443 , \
444 $(patsubst libutils,liblog libutils,$(1)) \
445 ) \
446 )
447endef
448ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
449 LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
450endif
451ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
452 LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
453endif
454ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
455 LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES))
456endif
457
458###########################################################
459# The list of libraries that this module will link against are in
460# these variables. Each is a list of bare module names like "libc libm".
461#
462# LOCAL_SHARED_LIBRARIES
463# LOCAL_STATIC_LIBRARIES
464# LOCAL_WHOLE_STATIC_LIBRARIES
465#
466# We need to convert the bare names into the dependencies that
467# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
468# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
469# libraries, so that simply building this module doesn't force
470# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
471# should depend on the INSTALLED versions of the libraries so
472# that they get installed when this module does.
473###########################################################
474# NOTE:
475# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
476# module without leaving anything out, which is useful for turning
477# a collection of .a files into a .so file. Linking against a
478# normal STATIC_LIBRARY will only pull in code/symbols that are
479# referenced by the module. (see gcc/ld's --whole-archive option)
480###########################################################
481
482# Get the list of BUILT libraries, which are under
483# various intermediates directories.
484so_suffix := $($(my_prefix)SHLIB_SUFFIX)
485a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
486
Ying Wang1a081002010-07-13 14:55:47 -0700487ifdef LOCAL_NDK_VERSION
The Android Open Source Project88b60792009-03-03 19:28:42 -0800488built_shared_libraries := \
489 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
490 $(addsuffix $(so_suffix), \
491 $(LOCAL_SHARED_LIBRARIES)))
492
Ying Wang1a081002010-07-13 14:55:47 -0700493# Get the list of INSTALLED libraries. Strip off the various
494# intermediates directories and point to the common lib dirs.
495installed_shared_libraries := \
496 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
497 $(notdir $(built_shared_libraries)))
498
499my_system_shared_libraries_fullpath := $(addprefix $(my_ndk_version_root)/usr/lib/, \
500 $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
501
502built_shared_libraries += $(my_system_shared_libraries_fullpath)
503LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
504else
505LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
506built_shared_libraries := \
507 $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
508 $(addsuffix $(so_suffix), \
509 $(LOCAL_SHARED_LIBRARIES)))
510
511installed_shared_libraries := \
512 $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
513 $(notdir $(built_shared_libraries)))
514endif
515
The Android Open Source Project88b60792009-03-03 19:28:42 -0800516built_static_libraries := \
517 $(foreach lib,$(LOCAL_STATIC_LIBRARIES), \
518 $(call intermediates-dir-for, \
519 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix))
520
521built_whole_libraries := \
522 $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
523 $(call intermediates-dir-for, \
524 STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix))
525
The Android Open Source Project88b60792009-03-03 19:28:42 -0800526# We don't care about installed static libraries, since the
527# libraries have already been linked into the module at that point.
528# We do, however, care about the NOTICE files for any static
529# libraries that we use. (see notice_files.make)
530
531installed_static_library_notice_file_targets := \
532 $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \
533 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
534
535###########################################################
536# Rule-specific variable definitions
537###########################################################
538$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
539$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS)
540$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
541$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
542$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
543$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
544$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
545$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
Jeff Brown703e7c62011-02-04 20:15:00 -0800546$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(LOCAL_NO_CRT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547
548# this is really the way to get the files onto the command line instead
549# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
550$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
551$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
552$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
553$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
554
555###########################################################
556# Define library dependencies.
557###########################################################
558# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
559all_libraries := \
560 $(built_shared_libraries) \
561 $(built_static_libraries) \
562 $(built_whole_libraries)
563
564# Make LOCAL_INSTALLED_MODULE depend on the installed versions of the
565# libraries so they get installed along with it. We don't need to
566# rebuild it when installing it, though, so this can be an order-only
567# dependency.
568$(LOCAL_INSTALLED_MODULE): | $(installed_shared_libraries)
569
570# Also depend on the notice files for any static libraries that
571# are linked into this module. This will force them to be installed
572# when this module is.
573$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)