xref: /netbsd-src/external/gpl3/gcc.old/dist/libgcc/Makefile.in (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
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
22libgcc_topdir = @libgcc_topdir@
23host_subdir = @host_subdir@
24
25gcc_srcdir = $(libgcc_topdir)/gcc
26gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc
27
28srcdir = @srcdir@
29
30prefix = @prefix@
31
32exec_prefix = @exec_prefix@
33libdir = @libdir@
34shlib_slibdir = @slibdir@
35
36SHELL = @SHELL@
37
38enable_shared = @enable_shared@
39decimal_float = @decimal_float@
40enable_decimal_float = @enable_decimal_float@
41fixed_point = @fixed_point@
42
43host_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.
47EXTRA_PARTS = @extra_parts@
48
49# Multilib support variables.
50MULTISRCTOP =
51MULTIBUILDTOP =
52MULTIDIRS =
53MULTISUBDIR =
54MULTIDO = true
55MULTICLEAN = true
56
57INSTALL = @INSTALL@
58INSTALL_PROGRAM = @INSTALL_PROGRAM@
59INSTALL_DATA = @INSTALL_DATA@
60mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
61
62objext = .o
63
64AR = @AR@
65AR_FLAGS = rc
66
67CC = @CC@
68CFLAGS = @CFLAGS@
69RANLIB = @RANLIB@
70LN_S = @LN_S@
71
72PWD_COMMAND = $${PWDCMD-pwd}
73
74# Flags to pass to a recursive make.
75FLAGS_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.
97all: 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
106all-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
112check:
113installcheck:
114
115.PHONY: all clean
116
117clean:
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
125distclean: clean
126	@$(MULTICLEAN) multi-clean DO=distclean
127	-rm -f *~ Makefile config.cache config.status multilib.out
128	-rm -f config.log
129maintainer-clean realclean: distclean
130
131Makefile: $(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.
136config.h: stamp-h ; @true
137stamp-h: $(srcdir)/config.in config.status Makefile
138	CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
139
140config.status: $(srcdir)/configure $(srcdir)/config.host
141	$(SHELL) ./config.status --recheck
142
143AUTOCONF = autoconf
144configure_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 \
150
151$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(configure_deps)
152	cd $(srcdir) && $(AUTOCONF)
153
154include $(gcc_objdir)/libgcc.mvars
155
156# Flags to pass to recursive makes.
157
158AR_FOR_TARGET = $(AR)
159AR_FLAGS_FOR_TARGET =
160AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
161AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
162AWK = @AWK@
163GCC_FOR_TARGET = $(CC)
164LIPO = @LIPO@
165LIPO_FOR_TARGET = $(LIPO)
166MACHMODE_H = machmode.h mode-classes.def insn-modes.h
167NM = @NM@
168NM_FOR_TARGET = $(NM)
169RANLIB_FOR_TARGET = $(RANLIB)
170STRIP = @STRIP@
171STRIP_FOR_TARGET = $(STRIP)
172
173# Directory in which the compiler finds libraries etc.
174libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version)
175# Used to install the shared libgcc.
176slibdir = @slibdir@
177
178export AR_FOR_TARGET
179export AR_CREATE_FOR_TARGET
180export AR_FLAGS_FOR_TARGET
181export AR_EXTRACT_FOR_TARGET
182export AWK
183export DESTDIR
184export GCC_FOR_TARGET
185export INCLUDES
186export INSTALL_DATA
187export LIB1ASMSRC
188export LIBGCC2_CFLAGS
189export LIPO_FOR_TARGET
190export MACHMODE_H
191export NM_FOR_TARGET
192export STRIP_FOR_TARGET
193export RANLIB_FOR_TARGET
194export libsubdir
195export slibdir
196
197version := $(shell $(CC) -dumpversion)
198
199ifeq ($(decimal_float),yes)
200ifeq ($(enable_decimal_float),bid)
201DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT
202else
203DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \
204	    -I$(srcdir)/../libdecnumber
205endif
206else
207DECNUMINC =
208endif
209
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.
216INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \
217	   -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \
218	   -I$(srcdir)/../include $(DECNUMINC)
219
220# Forcibly remove any profiling-related flags.  There is no point
221# in supporting profiled bootstrap in this library.
222override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
223
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.
228INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
229		  $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
230
231MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
232MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
233
234MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi)
235inst_libdir = $(libsubdir)$(MULTISUBDIR)
236inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)
237
238gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS)
239compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep
240gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps)
241gcc_s_compile = $(gcc_compile) -DSHARED
242
243objects = $(filter %$(objext),$^)
244
245# Collect any host-specific information from Makefile fragments.
246tmake_file = @tmake_file@
247include $(srcdir)/empty.mk $(tmake_file)
248
249# Only handle shared libraries if both:
250#   - the user requested them
251#   - we know how to build them
252ifeq ($(SHLIB_LINK),)
253  enable_shared := no
254endif
255
256ifeq ($(enable_shared),yes)
257  iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))
258
259  install-shared = install-shared
260
261  ifneq ($(LIBUNWIND),)
262    install-libunwind = install-libunwind
263  endif
264
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.
268vis_hide = @vis_hide@
269
270ifneq (,$(vis_hide))
271
272# If we have -fvisibility=hidden, then we need to generate hide
273# lists for object files implemented in assembly.
274ASM_HIDDEN_OP = @asm_hidden_op@
275
276define gen-hide-list
277$(NM) -pg $< | \
278  $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \
279         && $$3 !~ /.*@.*/ \
280	 { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T
281mv -f $@T $@
282endef
283else
284gen-hide-list = echo > $@
285endif
286
287else
288# Not enable_shared.
289iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
290vis_hide =
291gen-hide-list = echo > \$@
292endif
293
294ifneq ($(EXTRA_PARTS),)
295  extra-parts = libgcc-extra-parts
296  INSTALL_PARTS = $(EXTRA_PARTS)
297else
298ifneq ($(GCC_EXTRA_PARTS),)
299  extra-parts = gcc-extra-parts
300  INSTALL_PARTS = $(GCC_EXTRA_PARTS)
301endif
302endif
303
304# Library members defined in libgcc2.c.
305lib2funcs = _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
313
314# The floating-point conversion routines that involve a single-word integer.
315# XX stands for the integer mode.
316swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf)
317
318# Likewise double-word routines.
319dwfloatfuncs = $(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)
323
324ifeq ($(LIB2_SIDITI_CONV_FUNCS),)
325  lib2funcs += $(subst XX,si,$(swfloatfuncs))
326  lib2funcs += $(subst XX,di,$(dwfloatfuncs))
327endif
328
329# These might cause a divide overflow trap and so are compiled with
330# unwinder info.
331LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
332
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.
336lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs))
337LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
338		       $(LIB2_DIVMOD_FUNCS))
339
340# Build "libgcc1" (assembly) components.
341ifeq ($(enable_shared),yes)
342
343lib1asmfuncs-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)
349libgcc-objects += $(lib1asmfuncs-o)
350
351lib1asmfuncs-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)
355libgcc-s-objects += $(lib1asmfuncs-s-o)
356
357else
358
359lib1asmfuncs-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)
363libgcc-objects += $(lib1asmfuncs-o)
364
365endif
366
367# Build lib2funcs.  For the static library also include LIB2FUNCS_ST.
368lib2funcs-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)
372libgcc-objects += $(lib2funcs-o)
373
374ifeq ($(enable_shared),yes)
375lib2funcs-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
378libgcc-s-objects += $(lib2funcs-s-o)
379endif
380
381ifneq ($(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.
386
387sifuncs = $(subst XX,si,$(swfloatfuncs))
388difuncs = $(subst XX,di,$(dwfloatfuncs))
389tifuncs = $(subst XX,ti,$(dwfloatfuncs))
390
391iter-items := $(sifuncs) $(difuncs) $(tifuncs)
392iter-labels := $(sifuncs) $(difuncs) $(difuncs)
393iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs))
394
395include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))
396
397libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs))
398ifeq ($(enable_shared),yes)
399libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs))
400endif
401endif
402
403# Build LIB2_DIVMOD_FUNCS.
404lib2-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)
408libgcc-objects += $(lib2-divmod-o)
409
410ifeq ($(enable_shared),yes)
411lib2-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
415libgcc-s-objects += $(lib2-divmod-s-o)
416endif
417
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.
422
423ifneq ($(fpbit-in-libgcc),yes)
424FPBIT:=$(if $(FPBIT),$(gcc_objdir)/$(FPBIT),)
425DPBIT:=$(if $(DPBIT),$(gcc_objdir)/$(DPBIT),)
426TPBIT:=$(if $(TPBIT),$(gcc_objdir)/$(TPBIT),)
427endif
428
429ifeq ($(TPBIT),)
430# _sf_to_tf and _df_to_tf require tp-bit.c being compiled in.
431FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS))
432DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
433endif
434
435# Build FPBIT.
436ifneq ($(FPBIT),)
437fpbit-o = $(patsubst %,%$(objext),$(FPBIT_FUNCS))
438$(fpbit-o): %$(objext): $(FPBIT)
439	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT) $(vis_hide)
440libgcc-objects += $(fpbit-o)
441
442ifeq ($(enable_shared),yes)
443fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS))
444$(fpbit-s-o): %_s$(objext): $(FPBIT)
445	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT)
446libgcc-s-objects += $(fpbit-s-o)
447endif
448endif
449
450# Build DPBIT.
451ifneq ($(DPBIT),)
452dpbit-o = $(patsubst %,%$(objext),$(DPBIT_FUNCS))
453$(dpbit-o): %$(objext): $(DPBIT)
454	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT) $(vis_hide)
455libgcc-objects += $(dpbit-o)
456
457ifeq ($(enable_shared),yes)
458dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS))
459$(dpbit-s-o): %_s$(objext): $(DPBIT)
460	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT)
461libgcc-s-objects += $(dpbit-s-o)
462endif
463endif
464
465# Build TPBIT.
466ifneq ($(TPBIT),)
467tpbit-o = $(patsubst %,%$(objext),$(TPBIT_FUNCS))
468$(tpbit-o): %$(objext): $(TPBIT)
469	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT) $(vis_hide)
470libgcc-objects += $(tpbit-o)
471
472ifeq ($(enable_shared),yes)
473tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS))
474$(tpbit-s-o): %_s$(objext): $(TPBIT)
475	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT)
476libgcc-s-objects += $(tpbit-s-o)
477endif
478endif
479
480# Build decimal floating point support.
481ifeq ($(decimal_float),yes)
482
483# If $DFP_ENABLE is set, then we want all data type sizes.
484ifneq ($(DFP_ENABLE),)
485D32PBIT = 1
486D64PBIT = 1
487D128PBIT = 1
488endif
489
490dfp-filenames =
491ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),)
492ifeq ($(enable_decimal_float),bid)
493dfp-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
504else
505dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle
506endif
507endif
508
509dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames))
510ifeq ($(enable_decimal_float),bid)
511$(dfp-objects): %$(objext): $(srcdir)/config/libbid/%.c
512else
513$(dfp-objects): %$(objext): $(srcdir)/../libdecnumber/%.c
514endif
515	$(gcc_compile) -c $<
516libgcc-objects += $(dfp-objects)
517
518decbits-filenames =
519ifneq ($(enable_decimal_float),bid)
520ifneq ($(D32PBIT),)
521decbits-filenames += decimal32
522endif
523
524ifneq ($(D64PBIT),)
525decbits-filenames += decimal64
526endif
527
528ifneq ($(D128PBIT),)
529decbits-filenames += decimal128
530endif
531endif
532
533decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames))
534ifeq ($(enable_decimal_float),bid)
535$(decbits-objects): %$(objext): $(srcdir)/config/libbid/%.c
536else
537$(decbits-objects): %$(objext): $(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c
538endif
539	$(gcc_compile) -c $<
540libgcc-objects += $(decbits-objects)
541
542# Next build individual support functions.
543ifeq ($(enable_decimal_float),bid)
544ifneq ($(D32PBIT),)
545D32PBIT_FUNCS:=$(filter-out _plus_sd _minus_sd _conv_sd, $(D32PBIT_FUNCS))
546endif
547
548ifneq ($(D64PBIT),)
549D64PBIT_FUNCS:=$(filter-out _plus_dd _minus_dd _conv_dd, $(D64PBIT_FUNCS))
550endif
551
552ifneq ($(D128PBIT),)
553D128PBIT_FUNCS:=$(filter-out _plus_td _minus_td _conv_td, $(D128PBIT_FUNCS))
554endif
555endif
556
557ifneq ($(D32PBIT),)
558d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS))
559ifeq ($(enable_decimal_float),bid)
560$(d32pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
561else
562$(d32pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
563endif
564	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $<
565libgcc-objects += $(d32pbit-o)
566endif
567
568ifneq ($(D64PBIT),)
569d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS))
570ifeq ($(enable_decimal_float),bid)
571$(d64pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
572else
573$(d64pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
574endif
575	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $<
576libgcc-objects += $(d64pbit-o)
577endif
578
579ifneq ($(D128PBIT),)
580d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS))
581ifeq ($(enable_decimal_float),bid)
582$(d128pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
583else
584$(d128pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
585endif
586	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $<
587libgcc-objects += $(d128pbit-o)
588endif
589
590endif
591
592ifeq ($(LIBGCC_SYNC),yes)
593libgcc-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
599
600libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \
601			    $(foreach suffix, 1 2 4 8 16, \
602			      $(prefix)_$(suffix)))
603
604libgcc-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)
610libgcc-objects += $(libgcc-sync-size-funcs-o)
611
612libgcc-sync-funcs := sync_synchronize
613
614libgcc-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)
619libgcc-objects += $(libgcc-sync-funcs-o)
620
621ifeq ($(enable_shared),yes)
622libgcc-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
629libgcc-s-objects += $(libgcc-sync-size-funcs-s-o)
630
631libgcc-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
636libgcc-s-objects += $(libgcc-sync-funcs-s-o)
637endif
638endif
639
640# Build fixed-point support.
641ifeq ($(fixed_point),yes)
642
643# Generate permutations of function name and mode
644fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels)
645fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs)
646fixed-modes := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith modes)
647
648# Generate the rules for each arithmetic function
649iter-items := $(fixed-funcs)
650iter-labels := $(fixed-labels)
651iter-from := $(fixed-modes)
652iter-to := $(fixed-modes)
653include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
654
655# Add arithmetic functions to list of objects to be built
656libgcc-objects += $(patsubst %,%$(objext),$(fixed-funcs))
657ifeq ($(enable_shared),yes)
658libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-funcs))
659endif
660
661# Convert from or to fractional
662fixed-conv-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv funcs)
663fixed-conv-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv labels)
664fixed-conv-from := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv from)
665fixed-conv-to :=  $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv to)
666
667# Generate the make rules for each conversion function
668iter-items := $(fixed-conv-funcs)
669iter-labels := $(fixed-conv-labels)
670iter-from := $(fixed-conv-from)
671iter-to := $(fixed-conv-to)
672include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
673
674# Add conversion functions to list of objects to be built
675libgcc-objects += $(patsubst %,%$(objext),$(fixed-conv-funcs))
676ifeq ($(enable_shared),yes)
677libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-conv-funcs))
678endif
679
680endif
681
682# Build LIB2ADD and LIB2ADD_ST.
683ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
684$(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
685endif
686
687libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
688libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
689
690c_flags :=
691iter-items := $(LIB2ADD) $(LIB2ADD_ST)
692include $(iterator)
693
694ifeq ($(enable_shared),yes)
695libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD))))
696endif
697
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.)
701
702c_flags := -fexceptions
703
704ifeq ($(enable_shared),yes)
705
706libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC))))
707libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED))))
708
709iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED))
710include $(iterator)
711
712else
713# Not shared.  LIB2ADDEH are added to libgcc.a.
714
715libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))
716
717iter-items := $(LIB2ADDEH)
718include $(iterator)
719
720endif
721
722# Build LIBUNWIND.
723
724c_flags := -fexceptions
725
726libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
727
728ifeq ($(enable_shared),yes)
729libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND))))
730endif
731
732iter-items := $(LIBUNWIND)
733include $(iterator)
734
735# Build libgcov components.
736libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
737$(libgcov-objects): %$(objext): $(gcc_srcdir)/libgcov.c
738	$(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcov.c
739
740
741# Static libraries.
742libgcc.a: $(libgcc-objects)
743libgcov.a: $(libgcov-objects)
744libunwind.a: $(libunwind-objects)
745libgcc_eh.a: $(libgcc-eh-objects)
746
747libgcc.a libgcov.a libunwind.a libgcc_eh.a:
748	-rm -f $@
749
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
758
759	$(RANLIB) $@
760
761all: libgcc.a libgcov.a
762
763ifneq ($(LIBUNWIND),)
764all: libunwind.a
765libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
766endif
767
768ifeq ($(enable_shared),yes)
769all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
770ifneq ($(LIBUNWIND),)
771all: libunwind$(SHLIB_EXT)
772endif
773endif
774
775ifeq ($(enable_shared),yes)
776
777# Map-file generation.
778ifneq ($(SHLIB_MKMAP),)
779libgcc.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-$@ $@
787libgcc_s$(SHLIB_EXT): libgcc.map
788mapfile = libgcc.map
789endif
790
791libgcc_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))))))))
804
805libunwind$(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))))))
816
817endif
818
819# Build the standard GCC startfiles and endfiles.
820ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
821crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)
822
823ifeq ($(CUSTOM_CRTSTUFF),)
824crtbegin$(objext): $(gcc_srcdir)/crtstuff.c
825	$(crt_compile) $(CRTSTUFF_T_CFLAGS) \
826	  -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN
827
828crtend$(objext): $(gcc_srcdir)/crtstuff.c
829	$(crt_compile) $(CRTSTUFF_T_CFLAGS) \
830	  -c $(gcc_srcdir)/crtstuff.c -DCRT_END
831
832# These are versions of crtbegin and crtend for shared libraries.
833crtbeginS$(objext): $(gcc_srcdir)/crtstuff.c
834	$(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
835	  -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O
836
837crtendS$(objext): $(gcc_srcdir)/crtstuff.c
838	$(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
839	  -c $(gcc_srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O
840
841# This is a version of crtbegin for -static links.
842crtbeginT.o: $(gcc_srcdir)/crtstuff.c
843	$(crt_compile) $(CRTSTUFF_T_CFLAGS) \
844	  -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O
845endif
846
847# Build extra startfiles in the libgcc directory.
848.PHONY: libgcc-extra-parts
849libgcc-extra-parts: $(EXTRA_PARTS)
850ifneq ($(GCC_EXTRA_PARTS),)
851ifneq ($(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
861endif
862endif
863
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
873
874# Build extra startfiles in the gcc directory, for unconverted
875# targets.
876.PHONY: gcc-extra-parts
877gcc-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.
885
886	# We must use cd && make rather than make -C, or else the stage
887	# number will be embedded in debug information.
888
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
896
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
906
907all: $(extra-parts)
908
909# Documentation targets (empty).
910.PHONY: info html dvi pdf install-info install-html install-pdf
911
912info:
913install-info:
914html:
915install-html:
916dvi:
917pdf:
918install-pdf:
919
920# Install rules.  These do not depend on "all", so that they can be invoked
921# recursively from it.
922install-libunwind:
923	$(mkinstalldirs) $(DESTDIR)$(inst_slibdir)
924
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
930
931	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
932		@shlib_base_name@,libunwind,$(subst \
933		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))
934
935install-shared:
936	$(mkinstalldirs) $(DESTDIR)$(inst_libdir)
937
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
941
942	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
943		@shlib_base_name@,libgcc_s,$(subst \
944		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
945
946install-leaf: $(install-shared) $(install-libunwind)
947	$(mkinstalldirs) $(DESTDIR)$(inst_libdir)
948
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
955
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
961
962install: install-leaf
963	@: $(MAKE) ; $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
964
965.PHONY: install install-shared install-libunwind
966
967# Don't export variables to the environment, in order to not confuse
968# configure.
969.NOEXPORT:
970
971include $(srcdir)/empty.mk $(wildcard *.dep)
972
973# TODO QUEUE:
974#   Garbage collect in gcc/:
975#     $(LIBGCC) settings in t-* are now unused
976#
977#   Remove use of $(gcc_srcdir).  Source files referenced using $(gcc_srcdir)
978#   should move into the libgcc directory.
979
980