Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / toolchain_build / tc_bionic.mk
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 #
6 # GNU Make based build file.  For details on GNU Make see:
7 #   http://www.gnu.org/software/make/manual/make.html
8 #
9
10 all:
11
12 #MAKEFILE_DEPS:=$(lastword $(MAKEFILE_LIST)) $(TOP_MAKE)
13 MAKEFILE_DEPS:=$(MAKEFILE_LIST) $(TOP_MAKE)
14
15 #
16 # Rules for output directories.
17 #
18 # Output will be places in a directory name based on Toolchain and configuration
19 # be default this will be "newlib/Debug".  We use a python wrapped MKDIR to
20 # proivde a cross platform solution. The use of '|' checks for existance instead
21 # of timestamp, since the directory can update when files change.
22 #
23 %dir.stamp :
24         $(MKDIR) -p $(dir $@)
25         @echo Directory Stamp > $@
26
27 #
28 # Define a LOG macro that allow a command to be run in quiet mode where
29 # the command echoed is not the same as the actual command executed.
30 # The primary use case for this is to avoid echoing the full compiler
31 # and linker command in the default case.  Defining V=1 will restore
32 # the verbose behavior
33 #
34 # $1 = The name of the tool being run
35 # $2 = The target file being built
36 # $3 = The full command to run
37 #
38 ifdef V
39 define LOG
40 $(3)
41 endef
42 else
43 ifeq ($(OSNAME),win)
44 define LOG
45 @echo   $(1) $(2) && $(3)
46 endef
47 else
48 define LOG
49 @echo "  $(1) $(2)" && $(3)
50 endef
51 endif
52 endif
53
54 #
55 # BASIC Macros
56 #
57 # $1 = Output (fully qualified path)
58 # $2 = Input (fully qualified path)
59 # $3 = Tool (fully qualified path)
60 # $4 = PRE ARGS (before output name)
61 # $5 = STD ARGS (before input name)
62 # $6 = POST ARGS (final args)
63 # $7 = Extra Required DEPS
64 # $8 = Add to Depend list
65 # $9 = GROUP Name (compile, lib, link, etc...)
66 #
67 # The standard definition is:
68 # $(1) : $(2) $(7)
69 #    $(3) $(4) $(1) $(5) $(2) $(6)
70 #
71 # a.o : a.c Makefile
72 #    gcc -o a.o -c a.c $(CCFLAGS)
73 #
74 define BASIC_TARGET
75 $(9) : $(1)
76 $(9)_info : $(1)_info
77 $(1)_info :
78         @echo TARGET: $(1)
79         @echo REQUIRES: $(2)
80 ifdef V
81         @echo TOOL: $(3)
82         @echo PRE ARGS: $(4)
83         @echo STD ARGS: $(5)
84         @echo POST ARGS: $(6)
85 endif
86         @echo DEPENDS ON: $(7)
87         @echo DEPEND FOR: $(8)
88         @echo
89
90 ifneq (,$(8))
91 $(8) += $(1)
92 endif
93 endef
94
95 define CLEAN_TARGET
96 .PHONY: $(1)_clean
97 clean: $(1)_clean
98 $(2)_clean: $(1)_clean
99
100 $(1)_clean:
101         rm -fr $(1)
102 endef
103
104 .PHONY : compile compile_info
105 #
106 # Basic Compile Target
107 #
108 define BASIC_COMPILE_TARGET
109 $(call BASIC_TARGET,$(1),$(2),$(3),$(4),$(5),$(6),$(7) $(MAKEFILE_DEPS),$(8),compile)
110
111 -include $(patsubst %.o,%.d,$(1))
112 $(1) : $(2) $(7) $(MAKEFILE_DEPS)
113         mkdir -p $(dir $(1))
114         $(call LOG,$(notdir $(3)),$(1),$(3) $(4) -o $(1) -c $(2) $(5) $(6))
115
116 ifdef E
117 $(basename $(notdir $(1))).txt : $(2) $(7) $(MAKEFILE_DEPS)
118         $(call LOG,$(notdir $(3) -E),$(basename $(notdir $(1))).txt,$(3) $(4) -o $(basename $(notdir $(1))).txt -E $(2) $(5) $(6))
119 endif
120 endef
121
122 .PHONY : lib lib_info lib_clean
123 #
124 # Basic Libarary Target
125 #
126 define BASIC_LIB_TARGET
127 $(call BASIC_TARGET,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),lib)
128 $(call CLEAN_TARGET,$(1),lib)
129
130 all: $(1)
131 $(1): $(2) $(7) | $(dir $(1))dir.stamp
132         $(RM) $(1)
133         $(call LOG,LIB ,$(1),$(3) $(4) -cr $(1) $(2) $(5) $(6))
134 endef
135
136 #
137 # Basic Link Target
138 #
139 .PHONY : link link_info link_clean
140 define BASIC_LINK_TARGET
141 $(call BASIC_TARGET,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),link)
142 $(call CLEAN_TARGET,$(1),link)
143
144 all: $(1)
145 $(1): $(2) $(7) | $(dir $(1))dir.stamp
146         $(call LOG,LINK,$(1),$(3) $(4) -o $(1) $(2) $(5) $(6))
147 endef
148
149 #
150 # Basic Install Target
151 #
152 .PHONY : install_info install_clean
153 define BASIC_INSTALL_TARGET
154 $(call BASIC_TARGET,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),install)
155 $(call CLEAN_TARGET,$(1),install)
156
157 all: $(1)
158 $(1): $(2) $(7) | $(dir $(1))dir.stamp
159         $(call LOG,CP,$(1),$(3) $(4) $(5) $(2) $(1) $(6))
160 endef
161
162 .PHONY : stamp_info stamp_clean
163 #
164 # Basic Stamp Target
165 #
166 define BASIC_STAMP_TARGET
167 $(call BASIC_TARGET,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),stamp)
168 $(call CLEAN_TARGET,$(1),stamp)
169
170 all: $(1)
171 install: $(1)
172 $(1): $(2) $(7) | $(dir $(1))dir.stamp
173         $(call LOG,STAMP,$(1),$(3) $(4) $(5) $(6) > $(1))
174 endef
175
176
177 #
178 # Compile Macro
179 #
180 # $1 = Src File
181 # $2 = Flags
182 # $3 = Output Dir
183 # $4 = Extra Required DEPS
184 # $5 = Add to Depend list
185 define C_COMPILER_RULE
186 ifneq (,$(findstring x86_32,$(ARCHES)))
187 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_x86_32,$(3)),$(1),$(X86_32_CC),$(X86_INCS) $(POSIX_FLAGS),$(2),$(X86_32_CFLAGS) $(X86_32_CCFLAGS),$(4),$(5))
188 endif
189
190 ifneq (,$(findstring x86_64,$(ARCHES)))
191 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_x86_64,$(3)),$(1),$(X86_64_CC),$(X86_INCS) $(POSIX_FLAGS),$(2),$(X86_64_CFLAGS) $(X86_64_CCFLAGS),$(4),$(5))
192 endif
193
194 ifneq (,$(findstring arm,$(ARCHES)))
195 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_arm,$(3)),$(1),$(ARM_CC),$(ARM_INCS) $(POSIX_FLAGS),$(2),$(ARM_CFLAGS) $(ARM_CCFLAGS),$(4),$(5))
196 endif
197 endef
198
199 define CXX_COMPILER_RULE
200 ifneq (,$(findstring x86_32,$(ARCHES)))
201 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_x86_32,$(3)),$(1),$(X86_32_CXX),$(X86_INCS) $(POSIX_FLAGS),$(2),$(X86_32_CFLAGS) $(X86_32_CXXFLAGS),$(4),$(5))
202 endif
203
204 ifneq (,$(findstring x86_64,$(ARCHES)))
205 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_x86_64,$(3)),$(1),$(X86_64_CXX),$(X86_INCS) $(POSIX_FLAGS),$(2),$(X86_64_CFLAGS) $(X86_64_CXXFLAGS),$(4),$(5))
206 endif
207
208 ifneq (,$(findstring arm,$(ARCHES)))
209 $(call BASIC_COMPILE_TARGET,$(call SRC_TO_OBJ,$(1),_arm,$(3)),$(1),$(ARM_CXX),$(ARM_INCS) $(POSIX_FLAGS),$(2),$(ARM_CFLAGS) $(ARM_CXXFLAGS),$(4),$(5))
210 endif
211 endef
212
213 #
214 # $1 = Source Name
215 # $2 = POSIX Compile Flags
216 # $3 = Output Path
217 # $4 = Extra Required DEPS
218 # $5 = Add to Depend list
219 #
220 define COMPILE_RULE
221 ifeq ($(suffix $(1)),.c)
222 $(call C_COMPILER_RULE,$(1),$(2),$(3),$(4),$(5))
223 else
224 $(call CXX_COMPILER_RULE,$(1),$(2),$(3),$(4),$(5))
225 endif
226 endef
227
228
229 #
230 # INSTALL AS
231 #
232 # $1 = Destination
233 # $2 = Source
234 # $3 = Extra Required DEPS
235 # $4 = Add to Depend list
236 #
237 define INSTALL_RULE
238 $(call BASIC_INSTALL_TARGET,$(1),$(2),cp,,,,$(3),$(4))
239 endef
240
241 #
242 # INSTALL LIB
243 #
244 # $1 = Target Name
245 # $2 = Ext
246 # $3 = Input Dir
247 # $4 = Extra Required DEPS
248 # $5 = Defines target
249 define INSTALL_LIB
250 ifneq (,$(findstring x86_32,$(ARCHES)))
251 $(call INSTALL_RULE,$(LIBDIR)/nacl_x86_32/$(CONFIG)/$(1).$(2),$(3)/$(1)_x86_32.$(2),$(4),$(5))
252 endif
253
254 ifneq (,$(findstring x86_64,$(ARCHES)))
255 $(call INSTALL_RULE,$(LIBDIR)/nacl_x86_64/$(CONFIG)/$(1).$(2),$(3)/$(1)_x86_64.$(2),$(4),$(5))
256 endif
257
258 ifneq (,$(findstring arm,$(ARCHES)))
259 $(call INSTALL_RULE,$(LIBDIR)/nacl_arm/$(CONFIG)/$(1).$(2),$(3)/$(1)_arm.$(2),$(4),$(5))
260 endif
261 endef
262
263 #
264 # INSTALL LIB AS
265 #
266 # $1 = Dest Name
267 # $2 = Src Path
268 # $3 = Src Name
269 # $4 = Src Ext
270 # $5 = Extra Required DEPS
271 # $6 = Add to Depend list
272 define INSTALL_LIB_AS
273 ifneq (,$(findstring x86_32,$(ARCHES)))
274 $(call INSTALL_RULE,$(LIBDIR)/nacl_x86_32/$(CONFIG)/$(1),$(2)/$(3)_x86_32.$(4),$(5),$(6))
275 endif
276
277 ifneq (,$(findstring x86_64,$(ARCHES)))
278 $(call INSTALL_RULE,$(LIBDIR)/nacl_x86_64/$(CONFIG)/$(1),$(2)/$(3)_x86_64.$(4),$(5),$(6))
279 endif
280
281 ifneq (,$(findstring arm,$(ARCHES)))
282 $(call INSTALL_RULE,$(LIBDIR)/nacl_arm/$(CONFIG)/$(1),$(2)/$(3)_arm.$(4),$(5),$(6))
283 endif
284 endef
285
286 #
287 # LIB Macro
288 #
289 # $1 = Target Name
290 # $2 = List of Sources
291 # $3 = Output Dir
292 # $4 = Required DEPS
293 # $5 = Defined DEP
294 define LIB_RULE_X86_32
295 ifneq (,$(findstring x86_32,$(ARCHES)))
296 $(call BASIC_LIB_TARGET,$(3)/lib$(1)_x86_32.a,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32,$(3))),$(X86_32_LIB),,,,$(4),$(5))
297 endif
298 endef
299
300 define LIB_RULE_X86_64
301 ifneq (,$(findstring x86_64,$(ARCHES)))
302 $(call BASIC_LIB_TARGET,$(3)/lib$(1)_x86_64.a,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64,$(3))),$(X86_64_LIB),,,,$(4),$(5))
303 endif
304 endef
305
306 define LIB_RULE_ARM
307 ifneq (,$(findstring arm,$(ARCHES)))
308 $(call BASIC_LIB_TARGET,$(3)/lib$(1)_arm.a,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm,$(3))),$(ARM_LIB),,,,$(4),$(5))
309 endif
310 endef
311
312 define LIB_RULE
313 $(call LIB_RULE_X86_32,$(1),$(2),$(3),$(4),$(5))
314 $(call LIB_RULE_X86_64,$(1),$(2),$(3),$(4),$(5))
315 $(call LIB_RULE_ARM,$(1),$(2),$(3),$(4),$(5))
316 endef
317
318 #DEFAULT_STATIC_LIBS ?=-lsupc++ -lc -lgcc_eh
319 #DEFAULT_STATIC_DEPS ?=libsupc++.a libc.a libgcc_eh.a crtbegin_st.o crtend_st.o
320
321 #DEFAULT_DYNAMIC_LIBS ?=-lsupc++ -lc -lgcc_s
322 #DEFAULT_DYNAMIC_DEPS ?=libsupc++.so libc.so libgcc_s.so crtbegin_dy.o crtend_dy.o
323
324 #DEFAULT_SO_LIBS ?=-lsupc++ -lc -lgcc_s -lgcc
325 #DEFAULT_SO_DEPS ?=libsupc++.so libc.so libgcc_s.so crtbegin_so.o crtend_so.o
326
327 DEFAULT_STATIC_LIBS ?=-lsupc++ -lc -lgcc_eh
328 DEFAULT_STATIC_DEPS ?=libsupc++.a libc.a crtbegin_st.o crtend_st.o
329
330 DEFAULT_DYNAMIC_LIBS ?=-lsupc++ -lc -lgcc_s 
331 DEFAULT_DYNAMIC_DEPS ?=libsupc++.so libc.so libgcc_s.so crtbegin_dy.o crtend_dy.o
332
333 DEFAULT_SO_LIBS ?=-lsupc++ -lc -lgcc_s
334 DEFAULT_SO_DEPS ?=libsupc++.so libc.so libgcc_s.so crtbegin_so.o crtend_so.o
335
336 LDFLAGS_STATIC ?= -nostdlib -nostartfiles -static
337 LDFLAGS_DYNAMIC ?= -nostdlib -nostartfiles -Wl,-Ttext-segment,0x1000000 -Wl,--hash-style=sysv
338 LDFLAGS_SO ?= -nostdlib -nostartfiles -shared -fPIC -Wl,--hash-style=sysv -g
339
340 X86_32_LD ?= -L$(X86_32_LIB_PATH)
341 X86_64_LD ?= -L$(X86_64_LIB_PATH)
342 ARM_LD ?= -L$(ARM_LIB_PATH) -mcpu=cortex-a15 -mfloat-abi=hard -mthumb-interwork -Wl,-z,noexecstack -Wl,--fix-cortex-a8 -Wl,-Bsymbolic -Wl,--warn-shared-textrel
343
344 X86_32_LD_HEAD_STATIC ?= $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtbegin_st.o
345 X86_64_LD_HEAD_STATIC ?= $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtbegin_st.o
346 ARM_LD_HEAD_STATIC ?= $(LIBDIR)/nacl_arm/$(CONFIG)/crtbegin_st.o
347
348 X86_32_LD_HEAD_DYNAMIC ?= $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtbegin_dy.o
349 X86_64_LD_HEAD_DYNAMIC ?= $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtbegin_dy.o
350 ARM_LD_HEAD_DYNAMIC ?= $(LIBDIR)/nacl_arm/$(CONFIG)/crtbegin_dy.o
351
352 X86_32_LD_HEAD_SO ?= $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtbegin_so.o
353 X86_64_LD_HEAD_SO ?= $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtbegin_so.o
354 ARM_LD_HEAD_SO ?= $(LIBDIR)/nacl_arm/$(CONFIG)/crtbegin_so.o
355
356 ARM_LIBGCC_A ?= $(ARM_TC)/lib/gcc/arm-nacl/4.8.2/libgcc.a
357 X86_32_LIBGCC_A ?= $(X86_TC)/lib/gcc/x86_64-nacl/4.4.3/32/libgcc.a
358 X86_64_LIBGCC_A ?= $(X86_TC)/lib/gcc/x86_64-nacl/4.4.3/libgcc.a
359
360 X86_32_LD_TAIL_STATIC ?=  -T $(NACL_SDK_ROOT)/arch-x86_32/lib/static.lds $(DEFAULT_STATIC_LIBS) -lgcc_eh $(X86_32_LIBGCC_A) $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtend_st.o
361 X86_64_LD_TAIL_STATIC ?= -T $(NACL_SDK_ROOT)/arch-x86_64/lib/static.lds $(DEFAULT_STATIC_LIBS) -lgcc_eh $(X86_64_LIBGCC_A) $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtend_st.o
362 ARM_LD_TAIL_STATIC ?= -T $(NACL_SDK_ROOT)/arch-arm/lib/static.lds $(DEFAULT_STATIC_LIBS) $(ARM_LIBGCC_A) $(LIBDIR)/nacl_arm/$(CONFIG)/crtend_st.o
363
364 X86_32_LD_TAIL_DYNAMIC ?=  $(DEFAULT_DYNAMIC_LIBS) $(X86_32_LIBGCC_A) $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtend_dy.o
365 X86_64_LD_TAIL_DYNAMIC ?= $(DEFAULT_DYNAMIC_LIBS) $(X86_64_LIBGCC_A) $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtend_dy.o
366 ARM_LD_TAIL_DYNAMIC ?= $(DEFAULT_DYNAMIC_LIBS) $(ARM_LIBGCC_A) $(LIBDIR)/nacl_arm/$(CONFIG)/crtend_dy.o
367
368 X86_32_LD_TAIL_SO ?= $(DEFAULT_SO_LIBS) $(X86_32_LIBGCC_A) $(LIBDIR)/nacl_x86_32/$(CONFIG)/crtend_so.o
369 X86_64_LD_TAIL_SO ?= $(DEFAULT_SO_LIBS) $(X86_64_LIBGCC_A) $(LIBDIR)/nacl_x86_64/$(CONFIG)/crtend_so.o
370 ARM_LD_TAIL_SO ?= $(DEFAULT_SO_LIBS) $(ARM_LIBGCC_A) $(LIBDIR)/nacl_arm/$(CONFIG)/crtend_so.o
371
372 # SO Macro
373 #
374 # As well as building and installing a shared library this rule adds dependencies
375 # on the library's .stamp file in STAMPDIR.  However, the rule for creating the stamp
376 # file is part of LIB_RULE, so users of the DEPS system are currently required to
377 # use the LIB_RULE macro as well as the SO_RULE for each shared library.
378 #
379 # $1 = Target Name
380 # $2 = List of Sources
381 # $3 = Args
382 # $4 = Output Dir
383 # $5 = Required DEPS
384 # $6 = Defined DEPS
385 define SO_LINK_RULE_X86_32
386 ifneq (,$(findstring x86_32,$(ARCHES)))
387 $(call BASIC_LINK_TARGET,$(4)/lib$(1)_x86_32.so,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32,$(4))),$(X86_32_LINK),$(LDFLAGS_SO) $(X86_32_LD) $(X86_32_LD_HEAD_SO),$(3),$(X86_32_LD_TAIL_SO),$(5),$(6))
388 endif
389 endef
390
391 define SO_LINK_RULE_X86_64
392 ifneq (,$(findstring x86_64,$(ARCHES)))
393 $(call BASIC_LINK_TARGET,$(4)/lib$(1)_x86_64.so,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64,$(4))),$(X86_64_LINK),$(LDFLAGS_SO) $(X86_64_LD) $(X86_64_LD_HEAD_SO),$(3),$(X86_64_LD_TAIL_SO),$(5),$(6))
394 endif
395 endef
396
397 define SO_LINK_RULE_ARM
398 ifneq (,$(findstring arm,$(ARCHES)))
399 $(call BASIC_LINK_TARGET,$(4)/lib$(1)_arm.so,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm,$(4))),$(ARM_LINK),$(LDFLAGS_SO) $(ARM_LD) $(ARM_LD_HEAD_SO),$(3),$(ARM_LD_TAIL_SO),$(5),$(6))
400 endif
401 endef
402
403 define SO_LINK_RULE
404 $(call SO_LINK_RULE_X86_32,$(1),$(2),$(3),$(4),$(5) $(foreach src,$(DEFAULT_SO_DEPS),$(LIBDIR)/nacl_x86_32/$(CONFIG)/$(src)),$(6))
405 $(call SO_LINK_RULE_X86_64,$(1),$(2),$(3),$(4),$(5) $(foreach src,$(DEFAULT_SO_DEPS),$(LIBDIR)/nacl_x86_64/$(CONFIG)/$(src)),$(6))
406 $(call SO_LINK_RULE_ARM,$(1),$(2),$(3),$(4),$(5) $(foreach src,$(DEFAULT_SO_DEPS),$(LIBDIR)/nacl_arm/$(CONFIG)/$(src)),$(6))
407 endef
408
409
410 #
411 # Specific Link Macro
412 #
413 # $1 = Target Name
414 # $2 = List of Sources
415 # $3 = Args
416 # $4 = Output Dir
417 # $5 = DEPS
418 #
419 define STATIC_LINK_RULE_X86_32
420 ifneq (,$(findstring x86_32,$(ARCHES)))
421 $(call BASIC_LINK_TARGET,$(4)/$(1)_x86_32.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32,$(4))),$(X86_32_LINK), $(LDFLAGS_STATIC) $(X86_32_LD) $(X86_32_LD_HEAD_STATIC),$(3),$(X86_32_LD_TAIL_STATIC),$(5),$(6))
422 endif
423 endef
424
425 define STATIC_LINK_RULE_X86_64
426 ifneq (,$(findstring x86_64,$(ARCHES)))
427 $(call BASIC_LINK_TARGET,$(4)/$(1)_x86_64.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64,$(4))),$(X86_64_LINK), $(LDFLAGS_STATIC) $(X86_64_LD) $(X86_64_LD_HEAD_STATIC),$(3),$(X86_64_LD_TAIL_STATIC),$(5),$(6))
428 endif
429 endef
430
431 define STATIC_LINK_RULE_ARM
432 ifneq (,$(findstring arm,$(ARCHES)))
433 $(call BASIC_LINK_TARGET,$(4)/$(1)_arm.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm,$(4))),$(ARM_LINK), $(LDFLAGS_STATIC) $(ARM_LD) $(ARM_LD_HEAD_STATIC),$(3),$(ARM_LD_TAIL_STATIC),$(5),$(6))
434 endif
435 endef
436
437 define STATIC_LINK_RULE
438 $(call STATIC_LINK_RULE_X86_32,$(1),$(2),$(3),$(4),$(5))
439 $(call STATIC_LINK_RULE_X86_64,$(1),$(2),$(3),$(4),$(5))
440 $(call STATIC_LINK_RULE_ARM,$(1),$(2),$(3),$(4),$(5))
441 endef
442
443 #
444 # Dynamic Link Macro
445 #
446 # $1 = Target Name
447 # $2 = List of Sources
448 # $3 = Args
449 # $4 = Output Dir
450 # $5 = DEPS
451 #
452 define DYNAMIC_LINK_RULE_X86_32
453 ifneq (,$(findstring x86_32,$(ARCHES)))
454 $(call BASIC_LINK_TARGET,$(4)/$(1)_x86_32.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32,$(4))),$(X86_32_LINK), $(LDFLAGS_DYNAMIC) $(X86_32_LD) $(X86_32_LD_HEAD_DYNAMIC),$(3),$(X86_32_LD_TAIL_DYNAMIC),$(5),$(6))
455 endif
456 endef
457
458 define DYNAMIC_LINK_RULE_X86_64
459 ifneq (,$(findstring x86_64,$(ARCHES)))
460 $(call BASIC_LINK_TARGET,$(4)/$(1)_x86_64.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64,$(4))),$(X86_64_LINK), $(LDFLAGS_DYNAMIC) $(X86_64_LD) $(X86_64_LD_HEAD_DYNAMIC),$(3),$(X86_64_LD_TAIL_DYNAMIC),$(5),$(6))
461 endif
462 endef
463
464 define DYNAMIC_LINK_RULE_ARM
465 ifneq (,$(findstring arm,$(ARCHES)))
466 $(call BASIC_LINK_TARGET,$(4)/$(1)_arm.nexe,$(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm,$(4))),$(ARM_LINK), $(LDFLAGS_DYNAMIC) $(ARM_LD) $(ARM_LD_HEAD_DYNAMIC),$(3),$(ARM_LD_TAIL_DYNAMIC),$(5),$(6))
467 endif
468 endef
469
470 define DYNAMIC_LINK_RULE
471 $(call DYNAMIC_LINK_RULE_X86_32,$(1),$(2),$(3),$(4),$(5))
472 $(call DYNAMIC_LINK_RULE_X86_64,$(1),$(2),$(3),$(4),$(5))
473 $(call DYNAMIC_LINK_RULE_ARM,$(1),$(2),$(3),$(4),$(5))
474 endef
475
476
477 #
478 # Strip Macro for each arch (e.g., each arch supported by LINKER_RULE).
479 #
480 # $1 = Target Name
481 # $2 = Source Name
482 #
483 define STRIP_RULE_x86_32
484 ifneq (,$(findstring x86_32,$(ARCHES)))
485 all: $(OUTDIR)/$(1)_x86_32.nexe
486 $(OUTDIR)/$(1)_x86_32.nexe: $(OUTDIR)/$(2)_x86_32.nexe
487         $(call LOG,STRIP,$$@,$(X86_32_STRIP) -o $$@ $$^)
488 endif
489 endef
490
491 define STRIP_RULE_x86_64
492 ifneq (,$(findstring x86_64,$(ARCHES)))
493 all: $(OUTDIR)/$(1)_x86_64.nexe
494 $(OUTDIR)/$(1)_x86_64.nexe: $(OUTDIR)/$(2)_x86_64.nexe
495         $(call LOG,STRIP,$$@,$(X86_64_STRIP) -o $$@ $$^)
496 endif
497 endef
498
499 define STRIP_RULE_ARM
500 ifneq (,$(findstring arm,$(ARCHES)))
501 all: $(OUTDIR)/$(1)_arm.nexe
502 $(OUTDIR)/$(1)_arm.nexe: $(OUTDIR)/$(2)_arm.nexe
503         $(call LOG,STRIP,$$@,$(ARM_STRIP) -o $$@ $$^)
504 endif
505 endef
506
507 define STRIP_ALL_RULE
508 $(call STRIP_RULE_X86_32,$(1),$(2))
509 $(call STRIP_RULE_X86_64,$(1),$(2))
510 $(call STRIP_RULE_ARM,$(1),$(2))
511 endef
512
513
514 #
515 # Top-level Strip Macro
516 #
517 # $1 = Target Basename
518 # $2 = Source Basename
519 #
520 define STRIP_RULE
521 $(call STRIP_ALL_RULE,$(1),$(2))
522 endef
523
524 #
525 # Strip Macro for each arch (e.g., each arch supported by MAP_RULE).
526 #
527 # $1 = Target Name
528 # $2 = Source Name
529 #
530 define MAP_ALL_RULE
531 ifneq (,$(findstring x86_32,$(ARCHES)))
532 all: $(OUTDIR)/$(1)_x86_32.map
533 $(OUTDIR)/$(1)_x86_32.map: $(OUTDIR)/$(2)_x86_32.nexe
534         $(call LOG,MAP,$$@,$(X86_32_NM) -l $$^ > $$@)
535 endif
536
537 ifneq (,$(findstring x86_64,$(ARCHES)))
538 all: $(OUTDIR)/$(1)_x86_64.map
539 $(OUTDIR)/$(1)_x86_64.map: $(OUTDIR)/$(2)_x86_64.nexe
540         $(call LOG,MAP,$$@,$(X86_64_NM) -l $$^ > $$@)
541 endif
542
543 ifneq (,$(findstring arm,$(ARCHES)))
544 all: $(OUTDIR)/$(1)_arm.map
545 $(OUTDIR)/$(1)_arm.map: $(OUTDIR)/$(2)_arm.nexe
546         $(call LOG,MAP,$$@,$(ARM_NM) -l $$^ > $$@ )
547 endif
548 endef
549
550 #
551 # Top-level MAP Generation Macro
552 #
553 # $1 = Target Basename
554 # $2 = Source Basename
555 #
556 define MAP_RULE
557 $(call MAP_ALL_RULE,$(1),$(2))
558 endef
559
560 #
561 # STAMP Rule
562 #
563 # $1 = Target Basename
564 # $2 = Source Basename
565 # $3 = Message
566 # $4 = Required DEPS
567 # $5 = Defined DEPS
568 #
569 define STAMP_RULE
570 $(call BASIC_STAMP_TARGET,$(1),$(2),echo,$(3),$(4),$(5))
571 endef
572
573 info: compile_info lib_info link_info
574         @echo TOOLCHAIN=$(TOOLCHAIN)
575         @echo CONFIG=$(CONFIG)
576         @echo LIBDIR=$(LIBDIR)
577         @echo ARCHES=$(ARCHES)
578         @echo OUTDIR=$(OUTDIR)
579