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