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