OSDN Git Service

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