Makefile.def (target_modules): Add libgcc.
[gcc.git] / libgcc / Makefile.in
1 # Makefile.in
2
3 # Copyright (C) 2005, 2006 Free Software Foundation
4 #
5 # This file is part of GCC.
6 #
7 # GCC is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU Library General Public License as published by the Free
9 # Software Foundation; either version 2 of the License, or (at your option)
10 # any later version.
11 #
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with GCC; see the file COPYING. If not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
20 # USA.
21 #
22
23 libgcc_topdir = @libgcc_topdir@
24 gcc_srcdir = $(libgcc_topdir)/gcc
25 gcc_objdir = $(MULTIBUILDTOP)../../gcc
26
27 srcdir = @srcdir@
28
29 prefix = @prefix@
30
31 exec_prefix = @exec_prefix@
32 libdir = @libdir@
33
34 SHELL = @SHELL@
35
36 enable_shared = @enable_shared@
37 decimal_float = @decimal_float@
38
39 host_noncanonical = @host_noncanonical@
40
41 # List of extra object files that should be compiled for this target machine.
42 # The rules for compiling them should be in the t-* file for the machine.
43 EXTRA_PARTS = @extra_parts@
44
45 # Multilib support variables.
46 MULTISRCTOP =
47 MULTIBUILDTOP =
48 MULTIDIRS =
49 MULTISUBDIR =
50 MULTIDO = true
51 MULTICLEAN = true
52
53 INSTALL = @INSTALL@
54 INSTALL_PROGRAM = @INSTALL_PROGRAM@
55 INSTALL_DATA = @INSTALL_DATA@
56 mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
57
58 objext = .o
59
60 AR = @AR@
61 AR_FLAGS = rc
62
63 CC = @CC@
64 CFLAGS = @CFLAGS@
65 RANLIB = @RANLIB@
66 MAKEINFO = @MAKEINFO@
67 LN_S = @LN_S@
68 PERL = @PERL@
69
70 PWD_COMMAND = $${PWDCMD-pwd}
71
72 # Flags to pass to a recursive make.
73 FLAGS_TO_PASS = \
74 "AR=$(AR)" \
75 "AR_FLAGS=$(AR_FLAGS)" \
76 "CC=$(CC)" \
77 "CFLAGS=$(CFLAGS)" \
78 "DESTDIR=$(DESTDIR)" \
79 "EXTRA_OFILES=$(EXTRA_OFILES)" \
80 "HDEFINES=$(HDEFINES)" \
81 "INSTALL=$(INSTALL)" \
82 "INSTALL_DATA=$(INSTALL_DATA)" \
83 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
84 "LDFLAGS=$(LDFLAGS)" \
85 "LOADLIBES=$(LOADLIBES)" \
86 "RANLIB=$(RANLIB)" \
87 "SHELL=$(SHELL)" \
88 "prefix=$(prefix)" \
89 "exec_prefix=$(exec_prefix)" \
90 "libdir=$(libdir)" \
91 "libsubdir=$(libsubdir)" \
92 "tooldir=$(tooldir)"
93
94 # Dependencies for "all" are set later in the file.
95 all: all-multi
96 # Now that we have built all the objects, we need to copy
97 # them back to the GCC directory. Too many things (other
98 # in-tree libraries, and DejaGNU) know about the layout
99 # of the build tree, for now.
100 $(MAKE) install DESTDIR=$(gcc_objdir) \
101 slibdir= libsubdir= MULTIOSDIR=$(MULTIDIR)
102
103 .PHONY: all-multi
104 all-multi:
105 # If this is the top-level multilib, build all the other
106 # multilibs.
107 @: $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
108
109 .PHONY: check installcheck
110 check:
111 installcheck:
112
113 .PHONY: all clean
114
115 clean:
116 -rm -f config.h stamp-h stmp-ldirs libgcc.map
117 -rm -f *$(objext)
118 -rm -f *.dep
119 -rm -f *.a
120 -rm -f libunwind$(SHLIB_EXT)
121 -rm -f libgcc_s*
122 @$(MULTICLEAN) multi-clean DO=clean
123 distclean: clean
124 @$(MULTICLEAN) multi-clean DO=distclean
125 -rm -f *~ Makefile config.cache config.status multilib.out
126 -rm -f config.log
127 maintainer-clean realclean: distclean
128
129 Makefile: $(srcdir)/Makefile.in config.status
130 CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
131
132 # Depending on Makefile makes sure that config.status has been re-run
133 # if needed. This prevents problems with parallel builds.
134 config.h: stamp-h ; @true
135 stamp-h: $(srcdir)/config.in config.status Makefile
136 CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
137
138 config.status: $(srcdir)/configure
139 $(SHELL) ./config.status --recheck
140
141 include $(gcc_objdir)/libgcc.mvars
142
143 # Flags to pass to recursive makes.
144
145 AR_FOR_TARGET = $(AR)
146 AR_FLAGS_FOR_TARGET =
147 AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
148 AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
149 AWK = @AWK@
150 GCC_FOR_TARGET = $(CC)
151 LIPO = @LIPO@
152 LIPO_FOR_TARGET = $(LIPO)
153 MACHMODE_H = machmode.h mode-classes.def insn-modes.h
154 NM = @NM@
155 NM_FOR_TARGET = $(NM)
156 RANLIB_FOR_TARGET = $(RANLIB)
157 STRIP = @STRIP@
158 STRIP_FOR_TARGET = $(STRIP)
159
160 # Directory in which the compiler finds libraries etc.
161 libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version)
162 # Used to install the shared libgcc.
163 slibdir = @slibdir@
164
165 export AR_FOR_TARGET
166 export AR_CREATE_FOR_TARGET
167 export AR_FLAGS_FOR_TARGET
168 export AR_EXTRACT_FOR_TARGET
169 export AWK
170 export DESTDIR
171 export GCC_FOR_TARGET
172 export INCLUDES
173 export INSTALL_DATA
174 export LIB1ASMSRC
175 export LIBGCC2_CFLAGS
176 export LIPO_FOR_TARGET
177 export MACHMODE_H
178 export NM_FOR_TARGET
179 export STRIP_FOR_TARGET
180 export RANLIB_FOR_TARGET
181 export libsubdir
182 export slibdir
183
184 DECNUMINC = -I$(srcdir)/../libdecnumber -I$(MULTIBUILDTOP)../../libdecnumber
185
186 # Specify the directories to be searched for header files.
187 # Both . and srcdir are used, in that order,
188 # so that *config.h will be found in the compilation
189 # subdirectory rather than in the source directory.
190 # -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file
191 # currently being compiled, in both source trees, to be examined as well.
192 INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \
193 -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \
194 -I$(srcdir)/../include $(DECNUMINC)
195
196 # CFLAGS first is not perfect; normally setting CFLAGS should override any
197 # options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
198 # will usually contain -g, so for the moment CFLAGS goes first. We must
199 # include CFLAGS - that's where multilib options live.
200 INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) $(INCLUDES)
201
202 MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
203 MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
204
205 MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi)
206 inst_libdir = $(libsubdir)$(MULTISUBDIR)
207 inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)
208
209 gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS)
210 compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep
211 gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps)
212 gcc_s_compile = $(gcc_compile) -DSHARED
213
214 objects = $(filter %$(objext),$^)
215
216 # Collect any host-specific information from Makefile fragments.
217 tmake_file = @tmake_file@
218 include $(srcdir)/empty.mk $(tmake_file)
219
220 # Only handle shared libraries if both:
221 # - the user requested them
222 # - we know how to build them
223 ifeq ($(SHLIB_LINK),)
224 enable_shared := no
225 endif
226
227 ifeq ($(enable_shared),yes)
228 iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))
229
230 install-shared = install-shared
231
232 ifneq ($(LIBUNWIND),)
233 install-libunwind = install-libunwind
234 endif
235
236 # For -fvisibility=hidden. We need both a -fvisibility=hidden on
237 # the command line, and a #define to prevent libgcc2.h etc from
238 # overriding that with #pragmas.
239 vis_hide = @vis_hide@
240
241 ifneq (,$(vis_hide))
242
243 # If we have -fvisibility=hidden, then we need to generate hide
244 # lists for object files implemented in assembly.
245 ASM_HIDDEN_OP = @asm_hidden_op@
246
247 define gen-hide-list
248 $(NM) -pg $< | \
249 $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T
250 mv -f $@T $@
251 endef
252 else
253 gen-hide-list = echo > $@
254 endif
255
256 else
257 # Not enable_shared.
258 iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
259 vis_hide =
260 gen-hide-list = echo > \$@
261 endif
262
263 ifneq ($(EXTRA_PARTS),)
264 extra-parts = libgcc-extra-parts
265 INSTALL_PARTS = $(EXTRA_PARTS)
266 else
267 ifneq ($(GCC_EXTRA_PARTS),)
268 extra-parts = gcc-extra-parts
269 INSTALL_PARTS = $(GCC_EXTRA_PARTS)
270 endif
271 endif
272
273 # Library members defined in libgcc2.c.
274 lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \
275 _clear_cache _enable_execute_stack _trampoline __main _absvsi2 \
276 _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \
277 _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \
278 _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \
279 _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \
280 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 \
281 _divtc3 _bswapsi2 _bswapdi2
282
283 # The floating-point conversion routines that involve a single-word integer.
284 # XX stands for the integer mode.
285 swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf)
286
287 # Likewise double-word routines.
288 dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \
289 $(patsubst %,_fixuns%XX,sf df xf tf) \
290 $(patsubst %,_floatXX%,sf df xf tf) \
291 $(patsubst %,_floatunXX%,sf df xf tf)
292
293 ifeq ($(LIB2_SIDITI_CONV_FUNCS),)
294 lib2funcs += $(subst XX,si,$(swfloatfuncs))
295 lib2funcs += $(subst XX,di,$(dwfloatfuncs))
296 endif
297
298 # These might cause a divide overflow trap and so are compiled with
299 # unwinder info.
300 LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
301
302 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
303 # defined as optimized assembly code in LIB1ASMFUNCS or as C code
304 # in LIB2FUNCS_EXCLUDE.
305 lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs))
306 LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
307 $(LIB2_DIVMOD_FUNCS))
308
309 # Build "libgcc1" (assembly) components.
310 ifeq ($(enable_shared),yes)
311
312 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
313 $(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) %.vis
314 $(gcc_compile) -DL$* -xassembler-with-cpp \
315 -c $(gcc_srcdir)/config/$(LIB1ASMSRC) -include $*.vis
316 $(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext)
317 $(gen-hide-list)
318 libgcc-objects += $(lib1asmfuncs-o)
319
320 lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS))
321 $(lib1asmfuncs-s-o): %_s$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC)
322 $(gcc_s_compile) -DL$* -xassembler-with-cpp \
323 -c $(gcc_srcdir)/config/$(LIB1ASMSRC)
324 libgcc-s-objects += $(lib1asmfuncs-s-o)
325
326 else
327
328 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
329 $(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC)
330 $(gcc_compile) -DL$* -xassembler-with-cpp \
331 -c $(gcc_srcdir)/config/$(LIB1ASMSRC)
332 libgcc-objects += $(lib1asmfuncs-o)
333
334 endif
335
336 # Build lib2funcs. For the static library also include LIB2FUNCS_ST.
337 lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST))
338 $(lib2funcs-o): %$(objext): $(gcc_srcdir)/libgcc2.c
339 $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
340 $(vis_hide)
341 libgcc-objects += $(lib2funcs-o)
342
343 ifeq ($(enable_shared),yes)
344 lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs))
345 $(lib2funcs-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c
346 $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c
347 libgcc-s-objects += $(lib2funcs-s-o)
348 endif
349
350 ifneq ($(LIB2_SIDITI_CONV_FUNCS),)
351 # Build libgcc2.c for each conversion function, with a specific
352 # L<func> definition and LIBGCC2_UNITS_PER_WORD setting. The DImode
353 # functions are built with a wordsize of 4; the TImode functions are
354 # built with the same labels, but a wordsize of 8.
355
356 sifuncs = $(subst XX,si,$(swfloatfuncs))
357 difuncs = $(subst XX,di,$(dwfloatfuncs))
358 tifuncs = $(subst XX,ti,$(dwfloatfuncs))
359
360 iter-items := $(sifuncs) $(difuncs) $(tifuncs)
361 iter-labels := $(sifuncs) $(difuncs) $(difuncs)
362 iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs))
363
364 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))
365
366 libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs))
367 ifeq ($(enable_shared),yes)
368 libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs))
369 endif
370 endif
371
372 # Build LIB2_DIVMOD_FUNCS.
373 lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
374 $(lib2-divmod-o): %$(objext): $(gcc_srcdir)/libgcc2.c
375 $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
376 -fexceptions -fnon-call-exceptions $(vis_hide)
377 libgcc-objects += $(lib2-divmod-o)
378
379 ifeq ($(enable_shared),yes)
380 lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
381 $(lib2-divmod-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c
382 $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
383 -fexceptions -fnon-call-exceptions
384 libgcc-s-objects += $(lib2-divmod-s-o)
385 endif
386
387 # $(FPBIT) et al. are pathnames relative to the GCC build
388 # directory; the supporting files are made by the GCC
389 # Makefile.
390 # FIXME: Soon we will be able to move this logic into this directory.
391
392 ifneq ($(fpbit-in-libgcc),yes)
393 FPBIT:=$(if $(FPBIT),$(gcc_objdir)/$(FPBIT),)
394 DPBIT:=$(if $(DPBIT),$(gcc_objdir)/$(DPBIT),)
395 TPBIT:=$(if $(TPBIT),$(gcc_objdir)/$(TPBIT),)
396 endif
397
398 ifeq ($(TPBIT),)
399 # _sf_to_tf and _df_to_tf require tp-bit.c being compiled in.
400 FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS))
401 DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
402 endif
403
404 # Build FPBIT.
405 ifneq ($(FPBIT),)
406 fpbit-o = $(patsubst %,%$(objext),$(FPBIT_FUNCS))
407 $(fpbit-o): %$(objext): $(FPBIT)
408 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT) $(vis_hide)
409 libgcc-objects += $(fpbit-o)
410
411 ifeq ($(enable_shared),yes)
412 fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS))
413 $(fpbit-s-o): %_s$(objext): $(FPBIT)
414 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT)
415 libgcc-s-objects += $(fpbit-s-o)
416 endif
417 endif
418
419 # Build DPBIT.
420 ifneq ($(DPBIT),)
421 dpbit-o = $(patsubst %,%$(objext),$(DPBIT_FUNCS))
422 $(dpbit-o): %$(objext): $(DPBIT)
423 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT) $(vis_hide)
424 libgcc-objects += $(dpbit-o)
425
426 ifeq ($(enable_shared),yes)
427 dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS))
428 $(dpbit-s-o): %_s$(objext): $(DPBIT)
429 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT)
430 libgcc-s-objects += $(dpbit-s-o)
431 endif
432 endif
433
434 # Build TPBIT.
435 ifneq ($(TPBIT),)
436 tpbit-o = $(patsubst %,%$(objext),$(TPBIT_FUNCS))
437 $(tpbit-o): %$(objext): $(TPBIT)
438 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT) $(vis_hide)
439 libgcc-objects += $(tpbit-o)
440
441 ifeq ($(enable_shared),yes)
442 tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS))
443 $(tpbit-s-o): %_s$(objext): $(TPBIT)
444 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT)
445 libgcc-s-objects += $(tpbit-s-o)
446 endif
447 endif
448
449 # Build decimal floating point support.
450 ifeq ($(decimal_float),yes)
451
452 # If $DFP_ENABLE is set, then we want all data type sizes.
453 ifneq ($(DFP_ENABLE),)
454 D32PBIT = 1
455 D64PBIT = 1
456 D128PBIT = 1
457 endif
458
459 dec-filenames =
460 ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),)
461 dec-filenames += decContext decNumber decRound decLibrary decUtility
462 endif
463
464 ifneq ($(D32PBIT),)
465 dec-filenames += decimal32
466 endif
467
468 ifneq ($(D64PBIT),)
469 dec-filenames += decimal64
470 endif
471
472 ifneq ($(D128PBIT),)
473 dec-filenames += decimal128
474 endif
475
476 dec-objects = $(patsubst %,%$(objext),$(dec-filenames))
477 $(dec-objects): %$(objext): $(srcdir)/../libdecnumber/%.c
478 $(gcc_compile) -c $<
479 libgcc-objects += $(dec-objects)
480
481 # Next build individual support functions.
482 ifneq ($(D32PBIT),)
483 d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS))
484 $(d32pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
485 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $<
486 libgcc-objects += $(d32pbit-o)
487 endif
488
489 ifneq ($(D64PBIT),)
490 d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS))
491 $(d64pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
492 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $<
493 libgcc-objects += $(d64pbit-o)
494 endif
495
496 ifneq ($(D128PBIT),)
497 d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS))
498 $(d128pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
499 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $<
500 libgcc-objects += $(d128pbit-o)
501 endif
502
503 endif
504
505 # Build LIB2ADD and LIB2ADD_ST.
506 ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
507 $(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
508 endif
509
510 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
511 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
512
513 c_flags :=
514 iter-items := $(LIB2ADD) $(LIB2ADD_ST)
515 include $(iterator)
516
517 ifeq ($(enable_shared),yes)
518 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD))))
519 endif
520
521 # Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED. If we don't have
522 # libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and
523 # LIB2ADDEHSHARED matter. (Usually all three are identical.)
524
525 c_flags := -fexceptions
526
527 ifeq ($(enable_shared),yes)
528
529 libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC))))
530 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED))))
531
532 iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED))
533 include $(iterator)
534
535 else
536 # Not shared. LIB2ADDEH are added to libgcc.a.
537
538 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))
539
540 iter-items := $(LIB2ADDEH)
541 include $(iterator)
542
543 endif
544
545 # Build LIBUNWIND.
546
547 c_flags := -fexceptions
548
549 libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
550
551 ifeq ($(enable_shared),yes)
552 libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND))))
553 endif
554
555 iter-items := $(LIBUNWIND)
556 include $(iterator)
557
558 # Build libgcov components.
559 libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
560 $(libgcov-objects): %$(objext): $(gcc_srcdir)/libgcov.c
561 $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcov.c
562
563
564 # Static libraries.
565 libgcc.a: $(libgcc-objects)
566 libgcov.a: $(libgcov-objects)
567 libunwind.a: $(libunwind-objects)
568 libgcc_eh.a: $(libgcc-eh-objects)
569
570 libgcc.a libgcov.a libunwind.a libgcc_eh.a:
571 -rm -f $@
572
573 objects="$(objects)"; \
574 if test -z "$$objects"; then \
575 echo 'int __libgcc_eh_dummy;' > eh_dummy.c; \
576 $(gcc_compile_bare) $(vis_hide) -c eh_dummy.c \
577 -o eh_dummy$(objext); \
578 objects=eh_dummy$(objext); \
579 fi; \
580 $(AR_CREATE_FOR_TARGET) $@ $$objects
581
582 $(RANLIB) $@
583
584 all: libgcc.a libgcov.a
585
586 ifneq ($(LIBUNWIND),)
587 all: libunwind.a
588 endif
589
590 ifeq ($(enable_shared),yes)
591 all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
592 ifneq ($(LIBUNWIND),)
593 all: libunwind$(SHLIB_EXT)
594 endif
595 endif
596
597 ifeq ($(enable_shared),yes)
598
599 # Map-file generation.
600 ifneq ($(SHLIB_MKMAP),)
601 libgcc.map: $(SHLIB_MKMAP) $(SHLIB_MAPFILES) $(libgcc-s-objects)
602 { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
603 cat $(SHLIB_MAPFILES) \
604 | sed -e '/^[ ]*#/d' \
605 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
606 | $(gcc_compile_bare) -E -xassembler-with-cpp -; \
607 } | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
608 mv tmp-$@ $@
609 libgcc_s$(SHLIB_EXT): libgcc.map
610 mapfile = libgcc.map
611 endif
612
613 libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts)
614 # @multilib_flags@ is still needed because this may use
615 # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
616 # @multilib_dir@ is not really necessary, but sometimes it has
617 # more uses than just a directory name.
618 $(mkinstalldirs) $(MULTIDIR)
619 $(subst @multilib_flags@,$(CFLAGS),$(subst \
620 @multilib_dir@,$(MULTIDIR),$(subst \
621 @shlib_objs@,$(objects),$(subst \
622 @shlib_base_name@,libgcc_s,$(subst \
623 @shlib_map_file@,$(mapfile),$(subst \
624 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_LINK)))))))
625
626 libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
627 # @multilib_flags@ is still needed because this may use
628 # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
629 # @multilib_dir@ is not really necessary, but sometimes it has
630 # more uses than just a directory name.
631 $(mkinstalldirs) $(MULTIDIR)
632 $(subst @multilib_flags@,$(CFLAGS),$(subst \
633 @multilib_dir@,$(MULTIDIR),$(subst \
634 @shlib_objs@,$(objects),$(subst \
635 @shlib_base_name@,libunwind,$(subst \
636 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_LINK))))))
637
638 endif
639
640 # Build the standard GCC startfiles and endfiles.
641 ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
642 crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)
643
644 ifeq ($(CUSTOM_CRTSTUFF),)
645 crtbegin$(objext): $(gcc_srcdir)/crtstuff.c
646 $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
647 -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN
648
649 crtend$(objext): $(gcc_srcdir)/crtstuff.c
650 $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
651 -c $(gcc_srcdir)/crtstuff.c -DCRT_END
652
653 # These are versions of crtbegin and crtend for shared libraries.
654 crtbeginS$(objext): $(gcc_srcdir)/crtstuff.c
655 $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
656 -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O
657
658 crtendS$(objext): $(gcc_srcdir)/crtstuff.c
659 $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
660 -c $(gcc_srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O
661
662 # This is a version of crtbegin for -static links.
663 crtbeginT.o: $(gcc_srcdir)/crtstuff.c
664 $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
665 -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O
666 endif
667
668 # Build extra startfiles in the libgcc directory.
669 .PHONY: libgcc-extra-parts
670 libgcc-extra-parts: $(EXTRA_PARTS)
671 ifneq ($(GCC_EXTRA_PARTS),)
672 ifneq ($(sort $(EXTRA_PARTS)),$(GCC_EXTRA_PARTS))
673 # If the gcc directory specifies which extra parts to
674 # build for this target, and the libgcc configuration also
675 # specifies, make sure they match. This can be removed
676 # when the gcc directory no longer holds libgcc configuration;
677 # it is useful when migrating a target.
678 @echo "Configuration mismatch!"
679 @echo "Extra parts from gcc directory: $(GCC_EXTRA_PARTS)"
680 @echo "Extra parts from libgcc: $(EXTRA_PARTS)"
681 exit 1
682 endif
683 endif
684
685 # Early copyback; see "all" above for the rationale. The
686 # early copy is necessary so that the gcc -B options find
687 # the right startup files when linking shared libgcc.
688 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
689 parts="$(EXTRA_PARTS)"; \
690 for file in $$parts; do \
691 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
692 $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \
693 done
694
695 # Build extra startfiles in the gcc directory, for unconverted
696 # targets.
697 .PHONY: gcc-extra-parts
698 gcc-extra-parts:
699 # Recursively invoke make in the GCC directory to build any
700 # startfiles (for now). We must do this just once, passing
701 # it all the GCC_EXTRA_PARTS as simultaneous goal targets,
702 # so that rules which cannot execute simultaneously are properly
703 # serialized. We indirect through T_TARGET in case any multilib
704 # directories contain an equals sign, to prevent make from
705 # interpreting any of the goals as variable assignments.
706
707 # We must use cd && make rather than make -C, or else the stage
708 # number will be embedded in debug information.
709
710 T=`$(PWD_COMMAND)`/ \
711 && cd $(gcc_objdir) \
712 && $(MAKE) GCC_FOR_TARGET="$(CC)" \
713 MULTILIB_CFLAGS="$(CFLAGS)" \
714 T=$$T \
715 T_TARGET="$(patsubst %,$${T}%,$(GCC_EXTRA_PARTS))" \
716 T_TARGET
717
718 # Early copyback; see "all" above for the rationale. The
719 # early copy is necessary so that the gcc -B options find
720 # the right startup files when linking shared libgcc.
721 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
722 parts="$(GCC_EXTRA_PARTS)"; \
723 for file in $$parts; do \
724 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
725 $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \
726 done
727
728 all: $(extra-parts)
729
730 # Install rules. These do not depend on "all", so that they can be invoked
731 # recursively from it.
732 install-libunwind:
733 $(mkinstalldirs) $(DESTDIR)$(inst_slibdir)
734
735 # NOTE: Maybe this should go into $(inst_libdir), but this
736 # is where the old mklibgcc.in put it.
737 $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/
738 chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a
739 $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a
740
741 $(subst @multilib_dir@,$(MULTIDIR),$(subst \
742 @shlib_base_name@,libunwind,$(subst \
743 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))
744
745 install-shared:
746 $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
747
748 $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/
749 chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
750 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
751
752 $(subst @multilib_dir@,$(MULTIDIR),$(subst \
753 @shlib_base_name@,libgcc_s,$(subst \
754 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
755
756 install: $(install-shared) $(install-libunwind)
757 $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
758
759 $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/
760 chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a
761 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a
762 $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/
763 chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a
764 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a
765
766 parts="$(INSTALL_PARTS)"; \
767 for file in $$parts; do \
768 rm -f $(DESTDIR)$(inst_libdir)/$$file; \
769 $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/; \
770 done
771
772 .PHONY: install install-shared install-libunwind
773
774 # Don't export variables to the environment, in order to not confuse
775 # configure.
776 .NOEXPORT:
777
778 include $(srcdir)/empty.mk $(wildcard *.dep)
779
780 # TODO QUEUE:
781 # Garbage collect in gcc/:
782 # $(LIBGCC) settings in t-* are now unused
783 #
784 # Remove use of $(gcc_srcdir). Source files referenced using $(gcc_srcdir)
785 # should move into the libgcc directory.
786