OSDN Git Service

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