OSDN Git Service

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