Merge branch 'vendor/GCC44' into gcc441
[dragonfly.git] / contrib / gcc-4.4 / libgcc / Makefile.in
1 # Makefile.in
2
3 # Copyright (C) 2005, 2006, 2009 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 3 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 COPYING3.  If not see
19 # <http://www.gnu.org/licenses/>.
20 #
21
22 libgcc_topdir = @libgcc_topdir@
23 host_subdir = @host_subdir@
24
25 gcc_srcdir = $(libgcc_topdir)/gcc
26 gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc
27
28 srcdir = @srcdir@
29
30 prefix = @prefix@
31
32 exec_prefix = @exec_prefix@
33 libdir = @libdir@
34 shlib_slibdir = @slibdir@
35
36 SHELL = @SHELL@
37
38 enable_shared = @enable_shared@
39 decimal_float = @decimal_float@
40 enable_decimal_float = @enable_decimal_float@
41 fixed_point = @fixed_point@
42
43 host_noncanonical = @host_noncanonical@
44
45 # List of extra object files that should be compiled for this target machine.
46 # The rules for compiling them should be in the t-* file for the machine.
47 EXTRA_PARTS = @extra_parts@
48
49 # Multilib support variables.
50 MULTISRCTOP =
51 MULTIBUILDTOP =
52 MULTIDIRS =
53 MULTISUBDIR =
54 MULTIDO = true
55 MULTICLEAN = true
56
57 INSTALL = @INSTALL@
58 INSTALL_PROGRAM = @INSTALL_PROGRAM@
59 INSTALL_DATA = @INSTALL_DATA@
60 mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
61
62 objext = .o
63
64 AR = @AR@
65 AR_FLAGS = rc
66
67 CC = @CC@
68 CFLAGS = @CFLAGS@
69 RANLIB = @RANLIB@
70 LN_S = @LN_S@
71
72 PWD_COMMAND = $${PWDCMD-pwd}
73
74 # Flags to pass to a recursive make.
75 FLAGS_TO_PASS = \
76         "AR=$(AR)" \
77         "AR_FLAGS=$(AR_FLAGS)" \
78         "CC=$(CC)" \
79         "CFLAGS=$(CFLAGS)" \
80         "DESTDIR=$(DESTDIR)" \
81         "EXTRA_OFILES=$(EXTRA_OFILES)" \
82         "HDEFINES=$(HDEFINES)" \
83         "INSTALL=$(INSTALL)" \
84         "INSTALL_DATA=$(INSTALL_DATA)" \
85         "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
86         "LDFLAGS=$(LDFLAGS)" \
87         "LOADLIBES=$(LOADLIBES)" \
88         "RANLIB=$(RANLIB)" \
89         "SHELL=$(SHELL)" \
90         "prefix=$(prefix)" \
91         "exec_prefix=$(exec_prefix)" \
92         "libdir=$(libdir)" \
93         "libsubdir=$(libsubdir)" \
94         "tooldir=$(tooldir)"
95
96 # Dependencies for "all" are set later in the file.
97 all: all-multi
98         # Now that we have built all the objects, we need to copy
99         # them back to the GCC directory.  Too many things (other
100         # in-tree libraries, and DejaGNU) know about the layout
101         # of the build tree, for now.
102         $(MAKE) install-leaf DESTDIR=$(gcc_objdir) \
103           slibdir= libsubdir= MULTIOSDIR=$(MULTIDIR)
104
105 .PHONY: all-multi
106 all-multi:
107         # If this is the top-level multilib, build all the other
108         # multilibs.
109         @: $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
110
111 .PHONY: check installcheck
112 check:
113 installcheck:
114
115 .PHONY: all clean
116
117 clean:
118         -rm -f config.h stamp-h stmp-ldirs libgcc.map
119         -rm -f *$(objext)
120         -rm -f *.dep
121         -rm -f *.a
122         -rm -f libunwind$(SHLIB_EXT)
123         -rm -f libgcc_s*
124         @$(MULTICLEAN) multi-clean DO=clean
125 distclean: clean
126         @$(MULTICLEAN) multi-clean DO=distclean
127         -rm -f *~ Makefile config.cache config.status multilib.out
128         -rm -f config.log
129 maintainer-clean realclean: distclean
130
131 Makefile: $(srcdir)/Makefile.in config.status
132         CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
133
134 # Depending on Makefile makes sure that config.status has been re-run
135 # if needed.  This prevents problems with parallel builds.
136 config.h: stamp-h ; @true
137 stamp-h: $(srcdir)/config.in config.status Makefile
138         CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
139
140 config.status: $(srcdir)/configure $(srcdir)/config.host
141         $(SHELL) ./config.status --recheck
142
143 include $(gcc_objdir)/libgcc.mvars
144
145 # Flags to pass to recursive makes.
146
147 AR_FOR_TARGET = $(AR)
148 AR_FLAGS_FOR_TARGET =
149 AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
150 AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
151 AWK = @AWK@
152 GCC_FOR_TARGET = $(CC)
153 LIPO = @LIPO@
154 LIPO_FOR_TARGET = $(LIPO)
155 MACHMODE_H = machmode.h mode-classes.def insn-modes.h
156 NM = @NM@
157 NM_FOR_TARGET = $(NM)
158 RANLIB_FOR_TARGET = $(RANLIB)
159 STRIP = @STRIP@
160 STRIP_FOR_TARGET = $(STRIP)
161
162 # Directory in which the compiler finds libraries etc.
163 libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version)
164 # Used to install the shared libgcc.
165 slibdir = @slibdir@
166
167 export AR_FOR_TARGET
168 export AR_CREATE_FOR_TARGET
169 export AR_FLAGS_FOR_TARGET
170 export AR_EXTRACT_FOR_TARGET
171 export AWK
172 export DESTDIR
173 export GCC_FOR_TARGET
174 export INCLUDES
175 export INSTALL_DATA
176 export LIB1ASMSRC
177 export LIBGCC2_CFLAGS
178 export LIPO_FOR_TARGET
179 export MACHMODE_H
180 export NM_FOR_TARGET
181 export STRIP_FOR_TARGET
182 export RANLIB_FOR_TARGET
183 export libsubdir
184 export slibdir
185
186 version := $(shell $(CC) -dumpversion)
187
188 ifeq ($(decimal_float),yes)
189 ifeq ($(enable_decimal_float),bid)
190 DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT
191 else
192 DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \
193             -I$(srcdir)/../libdecnumber
194 endif
195 else
196 DECNUMINC =
197 endif
198
199 # Specify the directories to be searched for header files.
200 # Both . and srcdir are used, in that order,
201 # so that *config.h will be found in the compilation
202 # subdirectory rather than in the source directory.
203 # -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file
204 # currently being compiled, in both source trees, to be examined as well.
205 INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \
206            -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \
207            -I$(srcdir)/../include $(DECNUMINC)
208
209 # Forcibly remove any profiling-related flags.  There is no point
210 # in supporting profiled bootstrap in this library.
211 override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
212
213 # CFLAGS first is not perfect; normally setting CFLAGS should override any
214 # options in LIBGCC2_CFLAGS.  But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
215 # will usually contain -g, so for the moment CFLAGS goes first.  We must
216 # include CFLAGS - that's where multilib options live.
217 INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
218                   $(INCLUDES) @set_have_cc_tls@
219
220 MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
221 MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
222
223 MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi)
224 inst_libdir = $(libsubdir)$(MULTISUBDIR)
225 inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)
226
227 gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS)
228 compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep
229 gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps)
230 gcc_s_compile = $(gcc_compile) -DSHARED
231
232 objects = $(filter %$(objext),$^)
233
234 # Collect any host-specific information from Makefile fragments.
235 tmake_file = @tmake_file@
236 include $(srcdir)/empty.mk $(tmake_file)
237
238 # Only handle shared libraries if both:
239 #   - the user requested them
240 #   - we know how to build them
241 ifeq ($(SHLIB_LINK),)
242   enable_shared := no
243 endif
244
245 ifeq ($(enable_shared),yes)
246   iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))
247
248   install-shared = install-shared
249
250   ifneq ($(LIBUNWIND),)
251     install-libunwind = install-libunwind
252   endif
253
254 # For -fvisibility=hidden.  We need both a -fvisibility=hidden on
255 # the command line, and a #define to prevent libgcc2.h etc from
256 # overriding that with #pragmas.
257 vis_hide = @vis_hide@
258
259 ifneq (,$(vis_hide))
260
261 # If we have -fvisibility=hidden, then we need to generate hide
262 # lists for object files implemented in assembly.
263 ASM_HIDDEN_OP = @asm_hidden_op@
264
265 define gen-hide-list
266 $(NM) -pg $< | \
267   $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \
268          && $$3 !~ /.*@.*/ \
269          { 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 ifeq ($(LIBGCC_SYNC),yes)
582 libgcc-sync-size-funcs := $(foreach op, add sub or and xor nand, \
583                             sync_fetch_and_$(op) \
584                             sync_$(op)_and_fetch) \
585                           sync_bool_compare_and_swap \
586                           sync_val_compare_and_swap \
587                           sync_lock_test_and_set
588
589 libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \
590                             $(foreach suffix, 1 2 4 8 16, \
591                               $(prefix)_$(suffix)))
592
593 libgcc-sync-size-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-size-funcs))
594 $(libgcc-sync-size-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c
595         $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \
596           -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
597           -DSIZE=`echo "$*" | sed 's/.*_//'` \
598           -c $(gcc_srcdir)/config/sync.c $(vis_hide)
599 libgcc-objects += $(libgcc-sync-size-funcs-o)
600
601 libgcc-sync-funcs := sync_synchronize
602
603 libgcc-sync-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-funcs))
604 $(libgcc-sync-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c
605         $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \
606           -DL$* \
607           -c $(gcc_srcdir)/config/sync.c $(vis_hide)
608 libgcc-objects += $(libgcc-sync-funcs-o)
609
610 ifeq ($(enable_shared),yes)
611 libgcc-sync-size-funcs-s-o = $(patsubst %,%_s$(objext), \
612                                $(libgcc-sync-size-funcs))
613 $(libgcc-sync-size-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c
614         $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \
615           -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
616           -DSIZE=`echo "$*" | sed 's/.*_//'` \
617           -c $(gcc_srcdir)/config/sync.c
618 libgcc-s-objects += $(libgcc-sync-size-funcs-s-o)
619
620 libgcc-sync-funcs-s-o = $(patsubst %,%_s$(objext),$(libgcc-sync-funcs))
621 $(libgcc-sync-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c
622         $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \
623           -DL$* \
624           -c $(gcc_srcdir)/config/sync.c
625 libgcc-s-objects += $(libgcc-sync-funcs-s-o)
626 endif
627 endif
628
629 # Build fixed-point support.
630 ifeq ($(fixed_point),yes)
631
632 # Generate permutations of function name and mode
633 fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels)
634 fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs)
635 fixed-modes := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith modes)
636
637 # Generate the rules for each arithmetic function
638 iter-items := $(fixed-funcs)
639 iter-labels := $(fixed-labels)
640 iter-from := $(fixed-modes)
641 iter-to := $(fixed-modes)
642 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
643
644 # Add arithmetic functions to list of objects to be built
645 libgcc-objects += $(patsubst %,%$(objext),$(fixed-funcs))
646 ifeq ($(enable_shared),yes)
647 libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-funcs))
648 endif
649
650 # Convert from or to fractional
651 fixed-conv-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv funcs)
652 fixed-conv-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv labels)
653 fixed-conv-from := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv from)
654 fixed-conv-to :=  $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv to)
655
656 # Generate the make rules for each conversion function
657 iter-items := $(fixed-conv-funcs)
658 iter-labels := $(fixed-conv-labels)
659 iter-from := $(fixed-conv-from)
660 iter-to := $(fixed-conv-to)
661 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
662
663 # Add conversion functions to list of objects to be built
664 libgcc-objects += $(patsubst %,%$(objext),$(fixed-conv-funcs))
665 ifeq ($(enable_shared),yes)
666 libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-conv-funcs))
667 endif
668
669 endif
670
671 # Build LIB2ADD and LIB2ADD_ST.
672 ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
673 $(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
674 endif
675
676 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
677 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
678
679 c_flags :=
680 iter-items := $(LIB2ADD) $(LIB2ADD_ST)
681 include $(iterator)
682
683 ifeq ($(enable_shared),yes)
684 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD))))
685 endif
686
687 # Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED.  If we don't have
688 # libgcc_eh.a, only LIB2ADDEH matters.  If we do, only LIB2ADDEHSTATIC and
689 # LIB2ADDEHSHARED matter.  (Usually all three are identical.)
690
691 c_flags := -fexceptions
692
693 ifeq ($(enable_shared),yes)
694
695 libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC))))
696 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED))))
697
698 iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED))
699 include $(iterator)
700
701 else
702 # Not shared.  LIB2ADDEH are added to libgcc.a.
703
704 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))
705
706 iter-items := $(LIB2ADDEH)
707 include $(iterator)
708
709 endif
710
711 # Build LIBUNWIND.
712
713 c_flags := -fexceptions
714
715 libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
716
717 ifeq ($(enable_shared),yes)
718 libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND))))
719 endif
720
721 iter-items := $(LIBUNWIND)
722 include $(iterator)
723
724 # Build libgcov components.
725 libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
726 $(libgcov-objects): %$(objext): $(gcc_srcdir)/libgcov.c
727         $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcov.c
728
729
730 # Static libraries.
731 libgcc.a: $(libgcc-objects)
732 libgcov.a: $(libgcov-objects)
733 libunwind.a: $(libunwind-objects)
734 libgcc_eh.a: $(libgcc-eh-objects)
735
736 libgcc.a libgcov.a libunwind.a libgcc_eh.a:
737         -rm -f $@
738
739         objects="$(objects)";                                   \
740         if test -z "$$objects"; then                            \
741           echo 'int __libgcc_eh_dummy;' > eh_dummy.c;           \
742           $(gcc_compile_bare) $(vis_hide) -c eh_dummy.c         \
743              -o eh_dummy$(objext);                              \
744           objects=eh_dummy$(objext);                            \
745         fi;                                                     \
746         $(AR_CREATE_FOR_TARGET) $@ $$objects
747
748         $(RANLIB) $@
749
750 all: libgcc.a libgcov.a
751
752 ifneq ($(LIBUNWIND),)
753 all: libunwind.a
754 libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
755 endif
756
757 ifeq ($(enable_shared),yes)
758 all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
759 ifneq ($(LIBUNWIND),)
760 all: libunwind$(SHLIB_EXT)
761 endif
762 endif
763
764 ifeq ($(enable_shared),yes)
765
766 # Map-file generation.
767 ifneq ($(SHLIB_MKMAP),)
768 libgcc.map: $(SHLIB_MKMAP) $(SHLIB_MAPFILES) $(libgcc-s-objects)
769         { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
770           cat $(SHLIB_MAPFILES) \
771             | sed -e '/^[       ]*#/d' \
772                   -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
773             | $(gcc_compile_bare) -E -xassembler-with-cpp -; \
774         } | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
775         mv tmp-$@ $@
776 libgcc_s$(SHLIB_EXT): libgcc.map
777 mapfile = libgcc.map
778 endif
779
780 libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts)
781         # @multilib_flags@ is still needed because this may use
782         # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
783         # @multilib_dir@ is not really necessary, but sometimes it has
784         # more uses than just a directory name.
785         $(mkinstalldirs) $(MULTIDIR)
786         $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
787                 @multilib_dir@,$(MULTIDIR),$(subst \
788                 @shlib_objs@,$(objects),$(subst \
789                 @shlib_base_name@,libgcc_s,$(subst \
790                 @shlib_map_file@,$(mapfile),$(subst \
791                 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
792                 @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
793
794 libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
795         # @multilib_flags@ is still needed because this may use
796         # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
797         # @multilib_dir@ is not really necessary, but sometimes it has
798         # more uses than just a directory name.
799         $(mkinstalldirs) $(MULTIDIR)
800         $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
801                 @multilib_dir@,$(MULTIDIR),$(subst \
802                 @shlib_objs@,$(objects),$(subst \
803                 @shlib_base_name@,libunwind,$(subst \
804                 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_LINK))))))
805
806 endif
807
808 # Build the standard GCC startfiles and endfiles.
809 ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
810 crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)
811
812 ifeq ($(CUSTOM_CRTSTUFF),)
813 crtbegin$(objext): $(gcc_srcdir)/crtstuff.c
814         $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
815           -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN
816
817 crtend$(objext): $(gcc_srcdir)/crtstuff.c
818         $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
819           -c $(gcc_srcdir)/crtstuff.c -DCRT_END
820
821 # These are versions of crtbegin and crtend for shared libraries.
822 crtbeginS$(objext): $(gcc_srcdir)/crtstuff.c
823         $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
824           -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O
825
826 crtendS$(objext): $(gcc_srcdir)/crtstuff.c
827         $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
828           -c $(gcc_srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O
829
830 # This is a version of crtbegin for -static links.
831 crtbeginT.o: $(gcc_srcdir)/crtstuff.c
832         $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
833           -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O
834 endif
835
836 # Build extra startfiles in the libgcc directory.
837 .PHONY: libgcc-extra-parts
838 libgcc-extra-parts: $(EXTRA_PARTS)
839 ifneq ($(GCC_EXTRA_PARTS),)
840 ifneq ($(sort $(EXTRA_PARTS)),$(GCC_EXTRA_PARTS))
841         # If the gcc directory specifies which extra parts to
842         # build for this target, and the libgcc configuration also
843         # specifies, make sure they match.  This can be removed
844         # when the gcc directory no longer holds libgcc configuration;
845         # it is useful when migrating a target.
846         @echo "Configuration mismatch!"
847         @echo "Extra parts from gcc directory: $(GCC_EXTRA_PARTS)"
848         @echo "Extra parts from libgcc: $(EXTRA_PARTS)"
849         exit 1
850 endif
851 endif
852
853         # Early copyback; see "all" above for the rationale.  The
854         # early copy is necessary so that the gcc -B options find
855         # the right startup files when linking shared libgcc.
856         $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
857         parts="$(EXTRA_PARTS)";                                 \
858         for file in $$parts; do                                 \
859           rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file;             \
860           $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/;  \
861         done
862
863 # Build extra startfiles in the gcc directory, for unconverted
864 # targets.
865 .PHONY: gcc-extra-parts
866 gcc-extra-parts:
867         # Recursively invoke make in the GCC directory to build any
868         # startfiles (for now).  We must do this just once, passing
869         # it all the GCC_EXTRA_PARTS as simultaneous goal targets,
870         # so that rules which cannot execute simultaneously are properly
871         # serialized.  We indirect through T_TARGET in case any multilib
872         # directories contain an equals sign, to prevent make from
873         # interpreting any of the goals as variable assignments.
874
875         # We must use cd && make rather than make -C, or else the stage
876         # number will be embedded in debug information.
877
878         T=`$(PWD_COMMAND)`/ \
879         && cd $(gcc_objdir) \
880         && $(MAKE) GCC_FOR_TARGET="$(CC)" \
881           MULTILIB_CFLAGS="$(CFLAGS)" \
882           T=$$T \
883           T_TARGET="$(patsubst %,$${T}%,$(GCC_EXTRA_PARTS))" \
884           T_TARGET
885
886         # Early copyback; see "all" above for the rationale.  The
887         # early copy is necessary so that the gcc -B options find
888         # the right startup files when linking shared libgcc.
889         $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
890         parts="$(GCC_EXTRA_PARTS)";                             \
891         for file in $$parts; do                                 \
892           rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file;             \
893           $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/;  \
894         done
895
896 all: $(extra-parts)
897
898 # Documentation targets (empty).
899 .PHONY: info html dvi pdf install-info install-html install-pdf
900
901 info:
902 install-info:
903 html:
904 install-html:
905 dvi:
906 pdf:
907 install-pdf:
908
909 # Install rules.  These do not depend on "all", so that they can be invoked
910 # recursively from it.
911 install-libunwind:
912         $(mkinstalldirs) $(DESTDIR)$(inst_slibdir)
913
914         # NOTE: Maybe this should go into $(inst_libdir), but this
915         # is where the old mklibgcc.in put it.
916         $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/
917         chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a
918         $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a
919
920         $(subst @multilib_dir@,$(MULTIDIR),$(subst \
921                 @shlib_base_name@,libunwind,$(subst \
922                 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))
923
924 install-shared:
925         $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
926
927         $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/
928         chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
929         $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
930
931         $(subst @multilib_dir@,$(MULTIDIR),$(subst \
932                 @shlib_base_name@,libgcc_s,$(subst \
933                 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
934
935 install-leaf: $(install-shared) $(install-libunwind)
936         $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
937
938         $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/
939         chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a
940         $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a
941         $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/
942         chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a
943         $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a
944
945         parts="$(INSTALL_PARTS)";                               \
946         for file in $$parts; do                                 \
947           rm -f $(DESTDIR)$(inst_libdir)/$$file;                \
948           $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/;     \
949         done
950
951 install: install-leaf
952         @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
953
954 .PHONY: install install-shared install-libunwind
955
956 # Don't export variables to the environment, in order to not confuse
957 # configure.
958 .NOEXPORT:
959
960 include $(srcdir)/empty.mk $(wildcard *.dep)
961
962 # TODO QUEUE:
963 #   Garbage collect in gcc/:
964 #     $(LIBGCC) settings in t-* are now unused
965 #
966 #   Remove use of $(gcc_srcdir).  Source files referenced using $(gcc_srcdir)
967 #   should move into the libgcc directory.
968