3 # Copyright (C) 2005, 2006, 2009, 2010, 2011 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)
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
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_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc
31 exec_prefix = @exec_prefix@
33 shlib_slibdir = @slibdir@
38 enable_shared = @enable_shared@
39 double_type_size = @double_type_size@
40 long_double_type_size = @long_double_type_size@
41 decimal_float = @decimal_float@
42 enable_decimal_float = @enable_decimal_float@
43 fixed_point = @fixed_point@
45 host_noncanonical = @host_noncanonical@
46 target_noncanonical = @target_noncanonical@
48 # List of extra object files that should be compiled for this target machine.
49 # The rules for compiling them should be in the t-* file for the machine.
50 EXTRA_PARTS = @extra_parts@
52 extra-parts = libgcc-extra-parts
54 # Multilib support variables.
63 INSTALL_PROGRAM = @INSTALL_PROGRAM@
64 INSTALL_DATA = @INSTALL_DATA@
65 mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
66 INSTALL_PARTS = $(EXTRA_PARTS)
78 PWD_COMMAND = $${PWDCMD-pwd}
80 # Flags to pass to a recursive make.
83 "AR_FLAGS=$(AR_FLAGS)" \
86 "DESTDIR=$(DESTDIR)" \
87 "EXTRA_OFILES=$(EXTRA_OFILES)" \
88 "HDEFINES=$(HDEFINES)" \
89 "INSTALL=$(INSTALL)" \
90 "INSTALL_DATA=$(INSTALL_DATA)" \
91 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
92 "LDFLAGS=$(LDFLAGS)" \
93 "LOADLIBES=$(LOADLIBES)" \
97 "exec_prefix=$(exec_prefix)" \
99 "libsubdir=$(libsubdir)" \
102 # Dependencies for "all" are set later in the file.
104 # Now that we have built all the objects, we need to copy
105 # them back to the GCC directory. Too many things (other
106 # in-tree libraries, and DejaGNU) know about the layout
107 # of the build tree, for now.
108 $(MAKE) install-leaf DESTDIR=$(gcc_objdir) \
109 slibdir= libsubdir= MULTIOSDIR=$(MULTIDIR)
113 # If this is the top-level multilib, build all the other
115 @: $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
117 .PHONY: check installcheck
124 -rm -f config.h stamp-h stmp-ldirs libgcc.map
128 -rm -f libunwind$(SHLIB_EXT)
130 @$(MULTICLEAN) multi-clean DO=clean
132 @$(MULTICLEAN) multi-clean DO=distclean
133 -rm -f *~ Makefile config.cache config.status multilib.out
135 maintainer-clean realclean: distclean
137 Makefile: $(srcdir)/Makefile.in config.status
138 CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
140 # Depending on Makefile makes sure that config.status has been re-run
141 # if needed. This prevents problems with parallel builds.
142 config.h: stamp-h ; @true
143 stamp-h: $(srcdir)/config.in config.status Makefile
144 CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
146 config.status: $(srcdir)/configure $(srcdir)/config.host
147 $(SHELL) ./config.status --recheck
151 $(srcdir)/../config/enable.m4 \
152 $(srcdir)/../config/tls.m4 \
153 $(srcdir)/../config/acx.m4 \
154 $(srcdir)/../config/no-executables.m4 \
155 $(srcdir)/../config/override.m4 \
156 $(srcdir)/../config/dfp.m4 \
158 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(configure_deps)
159 cd $(srcdir) && $(AUTOCONF)
161 include $(gcc_objdir)/libgcc.mvars
163 # Flags to pass to recursive makes.
165 AR_FOR_TARGET = $(AR)
166 AR_FLAGS_FOR_TARGET =
167 AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
168 AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
170 GCC_FOR_TARGET = $(CC)
172 LIPO_FOR_TARGET = $(LIPO)
173 MACHMODE_H = machmode.h mode-classes.def insn-modes.h
175 NM_FOR_TARGET = $(NM)
176 RANLIB_FOR_TARGET = $(RANLIB)
178 STRIP_FOR_TARGET = $(STRIP)
180 # Directory in which the compiler finds libraries etc.
181 libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version)
182 # Used to install the shared libgcc.
184 # Maybe used for DLLs on Windows targets.
185 toolexecdir = @toolexecdir@
186 toolexeclibdir = @toolexeclibdir@
189 export AR_CREATE_FOR_TARGET
190 export AR_FLAGS_FOR_TARGET
191 export AR_EXTRACT_FOR_TARGET
194 export GCC_FOR_TARGET
198 export LIBGCC2_CFLAGS
199 export LIPO_FOR_TARGET
202 export STRIP_FOR_TARGET
203 export RANLIB_FOR_TARGET
207 export toolexeclibdir
209 version := $(shell $(CC) -dumpversion)
211 ifeq ($(decimal_float),yes)
212 ifeq ($(enable_decimal_float),bid)
213 DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT
215 DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \
216 -I$(srcdir)/../libdecnumber
222 # Options to use when compiling libgcc2.a.
224 LIBGCC2_DEBUG_CFLAGS = -g
225 LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
226 $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \
228 -fbuilding-libgcc -fno-stack-protector \
229 $(INHIBIT_LIBC_CFLAGS)
231 # Additional options to use when compiling libgcc2.a.
232 # Some targets override this to -isystem include
235 # Additional target-dependent options for compiling libgcc2.a.
236 HOST_LIBGCC2_CFLAGS =
240 # Defined in libgcc2.c, included only in the static library.
241 LIB2FUNCS_ST = _eprintf __gcc_bcmp
243 # List of functions not to build from libgcc2.c.
246 # These might cause a divide overflow trap and so are compiled with
248 LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
250 # List of extra C and assembler files to add to static and shared libgcc2.
251 # Assembler files should have names ending in `.S'.
254 # List of extra C and assembler files to add to static libgcc2.
255 # Assembler files should have names ending in `.S'.
258 # Specify the directories to be searched for header files.
259 # Both . and srcdir are used, in that order,
260 # so that *config.h will be found in the compilation
261 # subdirectory rather than in the source directory.
262 # -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file
263 # currently being compiled, in both source trees, to be examined as well.
264 INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \
265 -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \
266 -I$(srcdir)/../include $(DECNUMINC)
268 # Forcibly remove any profiling-related flags. There is no point
269 # in supporting profiled bootstrap in this library.
270 override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
272 # CFLAGS first is not perfect; normally setting CFLAGS should override any
273 # options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
274 # will usually contain -g, so for the moment CFLAGS goes first. We must
275 # include CFLAGS - that's where multilib options live.
276 INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
277 $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
279 # Options to use when compiling crtbegin/end.
280 CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
281 -finhibit-size-directive -fno-inline -fno-exceptions \
282 -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
283 -fno-stack-protector \
284 $(INHIBIT_LIBC_CFLAGS)
286 # Extra flags to use when compiling crt{begin,end}.o.
289 MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
290 MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
292 MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi)
293 inst_libdir = $(libsubdir)$(MULTISUBDIR)
294 inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)
296 gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS)
297 compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep
298 gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps)
299 gcc_s_compile = $(gcc_compile) -DSHARED
301 objects = $(filter %$(objext),$^)
303 # Collect any host-specific information from Makefile fragments.
305 LIBGCC_VER_GNU_PREFIX = __
306 LIBGCC_VER_FIXEDPOINT_GNU_PREFIX = __
307 LIBGCC_VER_SYMBOLS_PREFIX =
309 FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
310 _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
311 _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
312 _sf_to_df _sf_to_tf _thenan_sf _sf_to_usi _usi_to_sf
314 DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
315 _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
316 _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
317 _df_to_sf _df_to_tf _thenan_df _df_to_usi _usi_to_df
319 TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
320 _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \
321 _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
322 _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf
324 # Additional sources to handle exceptions; overridden by targets as needed.
325 LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
326 $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
327 LIB2ADDEHSTATIC = $(LIB2ADDEH)
328 LIB2ADDEHSHARED = $(LIB2ADDEH)
330 # nm flags to list global symbols in libgcc object files.
333 # Don't build libunwind by default.
336 SHLIBUNWIND_INSTALL =
338 tmake_file = @tmake_file@
339 include $(srcdir)/empty.mk $(tmake_file)
341 # Only handle shared libraries if both:
342 # - the user requested them
343 # - we know how to build them
344 ifeq ($(SHLIB_LINK),)
348 ifeq ($(enable_shared),yes)
349 iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))
351 install-shared = install-shared
353 ifneq ($(LIBUNWIND),)
354 install-libunwind = install-libunwind
357 # For -fvisibility=hidden. We need both a -fvisibility=hidden on
358 # the command line, and a #define to prevent libgcc2.h etc from
359 # overriding that with #pragmas.
360 vis_hide = @vis_hide@
364 # If we have -fvisibility=hidden, then we need to generate hide
365 # lists for object files implemented in assembly.
366 ASM_HIDDEN_OP = @asm_hidden_op@
370 $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \
372 { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T
376 gen-hide-list = echo > $@
381 iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
383 gen-hide-list = echo > \$@
386 LIB2ADD += enable-execute-stack.c
388 LIB2ADDEH += $(srcdir)/emutls.c
389 LIB2ADDEHSTATIC += $(srcdir)/emutls.c
390 LIB2ADDEHSHARED += $(srcdir)/emutls.c
392 # Library members defined in libgcc2.c.
393 lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \
394 _clear_cache _trampoline __main _absvsi2 \
395 _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \
396 _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \
397 _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \
398 _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \
399 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 \
400 _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2 _clrsbdi2
402 # The floating-point conversion routines that involve a single-word integer.
403 # XX stands for the integer mode.
404 swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf)
406 # Likewise double-word routines.
407 dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \
408 $(patsubst %,_fixuns%XX,sf df xf tf) \
409 $(patsubst %,_floatXX%,sf df xf tf) \
410 $(patsubst %,_floatunXX%,sf df xf tf)
412 ifeq ($(LIB2_SIDITI_CONV_FUNCS),)
413 lib2funcs += $(subst XX,si,$(swfloatfuncs))
414 lib2funcs += $(subst XX,di,$(dwfloatfuncs))
417 # These might cause a divide overflow trap and so are compiled with
419 LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
421 # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
422 # defined as optimized assembly code in LIB1ASMFUNCS or as C code
423 # in LIB2FUNCS_EXCLUDE.
424 lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs))
425 LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
426 $(LIB2_DIVMOD_FUNCS))
428 # Build "libgcc1" (assembly) components.
429 ifeq ($(enable_shared),yes)
431 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
432 $(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC) %.vis
433 $(gcc_compile) -DL$* -xassembler-with-cpp -c $< -include $*.vis
434 $(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext)
436 libgcc-objects += $(lib1asmfuncs-o)
438 lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS))
439 $(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC)
440 $(gcc_s_compile) -DL$* -xassembler-with-cpp -c $<
441 libgcc-s-objects += $(lib1asmfuncs-s-o)
445 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
446 $(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC)
447 $(gcc_compile) -DL$* -xassembler-with-cpp -c $<
448 libgcc-objects += $(lib1asmfuncs-o)
452 # Build lib2funcs. For the static library also include LIB2FUNCS_ST.
453 lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST))
454 $(lib2funcs-o): %$(objext): $(srcdir)/libgcc2.c
455 $(gcc_compile) -DL$* -c $< $(vis_hide)
456 libgcc-objects += $(lib2funcs-o)
458 ifeq ($(enable_shared),yes)
459 lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs))
460 $(lib2funcs-s-o): %_s$(objext): $(srcdir)/libgcc2.c
461 $(gcc_s_compile) -DL$* -c $<
462 libgcc-s-objects += $(lib2funcs-s-o)
465 ifneq ($(LIB2_SIDITI_CONV_FUNCS),)
466 # Build libgcc2.c for each conversion function, with a specific
467 # L<func> definition and LIBGCC2_UNITS_PER_WORD setting. The DImode
468 # functions are built with a wordsize of 4; the TImode functions are
469 # built with the same labels, but a wordsize of 8.
471 sifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,si,$(swfloatfuncs)))
472 difuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,di,$(dwfloatfuncs)))
473 tifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,ti,$(dwfloatfuncs)))
475 iter-items := $(sifuncs) $(difuncs) $(tifuncs)
476 iter-labels := $(sifuncs) $(difuncs) $(difuncs)
477 iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs))
479 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))
481 libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs))
482 ifeq ($(enable_shared),yes)
483 libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs))
487 # Build LIB2_DIVMOD_FUNCS.
488 lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
489 $(lib2-divmod-o): %$(objext): $(srcdir)/libgcc2.c
490 $(gcc_compile) -DL$* -c $< \
491 -fexceptions -fnon-call-exceptions $(vis_hide)
492 libgcc-objects += $(lib2-divmod-o)
494 ifeq ($(enable_shared),yes)
495 lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
496 $(lib2-divmod-s-o): %_s$(objext): $(srcdir)/libgcc2.c
497 $(gcc_s_compile) -DL$* -c $< \
498 -fexceptions -fnon-call-exceptions
499 libgcc-s-objects += $(lib2-divmod-s-o)
503 # _sf_to_tf and _df_to_tf require tp-bit.c being compiled in.
504 FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS))
505 DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
508 fpbit-src := $(srcdir)/fp-bit.c
512 fpbit-o = $(patsubst %,%$(objext),$(FPBIT_FUNCS))
513 $(fpbit-o): %$(objext): $(fpbit-src)
514 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DFLOAT $(FPBIT_CFLAGS) -c $< $(vis_hide)
515 libgcc-objects += $(fpbit-o)
517 ifeq ($(enable_shared),yes)
518 fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS))
519 $(fpbit-s-o): %_s$(objext): $(fpbit-src)
520 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DFLOAT $(FPBIT_CFLAGS) -c $<
521 libgcc-s-objects += $(fpbit-s-o)
527 dpbit-o = $(patsubst %,%$(objext),$(DPBIT_FUNCS))
528 $(dpbit-o): %$(objext): $(fpbit-src)
529 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* $(DPBIT_CFLAGS) -c $< $(vis_hide)
530 libgcc-objects += $(dpbit-o)
532 ifeq ($(enable_shared),yes)
533 dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS))
534 $(dpbit-s-o): %_s$(objext): $(fpbit-src)
535 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* $(DPBIT_CFLAGS) -c $<
536 libgcc-s-objects += $(dpbit-s-o)
542 tpbit-o = $(patsubst %,%$(objext),$(TPBIT_FUNCS))
543 $(tpbit-o): %$(objext): $(fpbit-src)
544 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DTFLOAT $(TPBIT_CFLAGS) -c $< $(vis_hide)
545 libgcc-objects += $(tpbit-o)
547 ifeq ($(enable_shared),yes)
548 tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS))
549 $(tpbit-s-o): %_s$(objext): $(fpbit-src)
550 $(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DTFLOAT $(TPBIT_CFLAGS) -c $<
551 libgcc-s-objects += $(tpbit-s-o)
555 # Build decimal floating point support.
556 ifeq ($(decimal_float),yes)
558 # If $DFP_ENABLE is set, then we want all data type sizes.
559 ifneq ($(DFP_ENABLE),)
566 ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),)
567 ifeq ($(enable_decimal_float),bid)
568 dfp-filenames += bid_decimal_globals bid_decimal_data \
569 bid_binarydecimal bid_convert_data \
570 _isinfd32 _isinfd64 _isinfd128 bid64_noncomp \
571 bid128_noncomp bid128_fma bid_round bid_from_int \
572 bid64_add bid128_add bid64_div bid128_div \
573 bid64_mul bid128_mul bid64_compare bid128_compare \
574 bid128 bid32_to_bid64 bid32_to_bid128 bid64_to_bid128 \
575 bid64_to_int32 bid64_to_int64 \
576 bid64_to_uint32 bid64_to_uint64 \
577 bid128_to_int32 bid128_to_int64 \
578 bid128_to_uint32 bid128_to_uint64
580 dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle
584 dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames))
585 ifeq ($(enable_decimal_float),bid)
586 $(dfp-objects): %$(objext): $(srcdir)/config/libbid/%.c
588 $(dfp-objects): %$(objext): $(srcdir)/../libdecnumber/%.c
591 libgcc-objects += $(dfp-objects)
594 ifneq ($(enable_decimal_float),bid)
596 decbits-filenames += decimal32
600 decbits-filenames += decimal64
604 decbits-filenames += decimal128
608 decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames))
609 ifeq ($(enable_decimal_float),bid)
610 $(decbits-objects): %$(objext): $(srcdir)/config/libbid/%.c
612 $(decbits-objects): %$(objext): $(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c
615 libgcc-objects += $(decbits-objects)
617 # Next build individual support functions.
618 D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \
619 _eq_sd _ne_sd _lt_sd _gt_sd _le_sd _ge_sd \
620 _sd_to_si _sd_to_di _sd_to_usi _sd_to_udi \
621 _si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \
622 _sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \
623 _sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \
624 _sd_to_dd _sd_to_td _unord_sd _conv_sd
626 D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \
627 _eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \
628 _dd_to_si _dd_to_di _dd_to_usi _dd_to_udi \
629 _si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \
630 _dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \
631 _sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \
632 _dd_to_sd _dd_to_td _unord_dd _conv_dd
634 D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \
635 _eq_td _ne_td _lt_td _gt_td _le_td _ge_td \
636 _td_to_si _td_to_di _td_to_usi _td_to_udi \
637 _si_to_td _di_to_td _usi_to_td _udi_to_td \
638 _td_to_sf _td_to_df _td_to_xf _td_to_tf \
639 _sf_to_td _df_to_td _xf_to_td _tf_to_td \
640 _td_to_sd _td_to_dd _unord_td _conv_td
642 ifeq ($(enable_decimal_float),bid)
644 D32PBIT_FUNCS:=$(filter-out _plus_sd _minus_sd _conv_sd, $(D32PBIT_FUNCS))
648 D64PBIT_FUNCS:=$(filter-out _plus_dd _minus_dd _conv_dd, $(D64PBIT_FUNCS))
652 D128PBIT_FUNCS:=$(filter-out _plus_td _minus_td _conv_td, $(D128PBIT_FUNCS))
657 d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS))
658 ifeq ($(enable_decimal_float),bid)
659 $(d32pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
661 $(d32pbit-o): %$(objext): $(srcdir)/dfp-bit.c
663 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $<
664 libgcc-objects += $(d32pbit-o)
668 d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS))
669 ifeq ($(enable_decimal_float),bid)
670 $(d64pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
672 $(d64pbit-o): %$(objext): $(srcdir)/dfp-bit.c
674 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $<
675 libgcc-objects += $(d64pbit-o)
679 d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS))
680 ifeq ($(enable_decimal_float),bid)
681 $(d128pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
683 $(d128pbit-o): %$(objext): $(srcdir)/dfp-bit.c
685 $(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $<
686 libgcc-objects += $(d128pbit-o)
692 libgcc-sync-size-funcs := $(foreach op, add sub or and xor nand, \
693 sync_fetch_and_$(op) \
694 sync_$(op)_and_fetch) \
695 sync_bool_compare_and_swap \
696 sync_val_compare_and_swap \
697 sync_lock_test_and_set
699 libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \
700 $(foreach suffix, 1 2 4 8 16, \
701 $(prefix)_$(suffix)))
703 libgcc-sync-size-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-size-funcs))
704 $(libgcc-sync-size-funcs-o): %$(objext): $(srcdir)/sync.c
705 $(gcc_compile) $(SYNC_CFLAGS) \
706 -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
707 -DSIZE=`echo "$*" | sed 's/.*_//'` \
709 libgcc-objects += $(libgcc-sync-size-funcs-o)
711 libgcc-sync-funcs := sync_synchronize
713 libgcc-sync-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-funcs))
714 $(libgcc-sync-funcs-o): %$(objext): $(srcdir)/sync.c
715 $(gcc_compile) $(SYNC_CFLAGS) \
718 libgcc-objects += $(libgcc-sync-funcs-o)
720 ifeq ($(enable_shared),yes)
721 libgcc-sync-size-funcs-s-o = $(patsubst %,%_s$(objext), \
722 $(libgcc-sync-size-funcs))
723 $(libgcc-sync-size-funcs-s-o): %_s$(objext): $(srcdir)/sync.c
724 $(gcc_s_compile) $(SYNC_CFLAGS) \
725 -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
726 -DSIZE=`echo "$*" | sed 's/.*_//'` \
728 libgcc-s-objects += $(libgcc-sync-size-funcs-s-o)
730 libgcc-sync-funcs-s-o = $(patsubst %,%_s$(objext),$(libgcc-sync-funcs))
731 $(libgcc-sync-funcs-s-o): %_s$(objext): $(srcdir)/sync.c
732 $(gcc_s_compile) $(SYNC_CFLAGS) \
735 libgcc-s-objects += $(libgcc-sync-funcs-s-o)
739 # Build fixed-point support.
740 ifeq ($(fixed_point),yes)
742 # Generate permutations of function name and mode
743 fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels)
744 fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs)
745 fixed-modes := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith modes)
747 # Generate the rules for each arithmetic function
748 iter-items := $(fixed-funcs)
749 iter-labels := $(fixed-labels)
750 iter-from := $(fixed-modes)
751 iter-to := $(fixed-modes)
752 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
754 # Add arithmetic functions to list of objects to be built
755 libgcc-objects += $(patsubst %,%$(objext),$(fixed-funcs))
756 ifeq ($(enable_shared),yes)
757 libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-funcs))
760 # Convert from or to fractional
761 fixed-conv-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv funcs)
762 fixed-conv-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv labels)
763 fixed-conv-from := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv from)
764 fixed-conv-to := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv to)
766 # Generate the make rules for each conversion function
767 iter-items := $(fixed-conv-funcs)
768 iter-labels := $(fixed-conv-labels)
769 iter-from := $(fixed-conv-from)
770 iter-to := $(fixed-conv-to)
771 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
773 # Add conversion functions to list of objects to be built
774 libgcc-objects += $(patsubst %,%$(objext),$(fixed-conv-funcs))
775 ifeq ($(enable_shared),yes)
776 libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-conv-funcs))
781 # Build LIB2ADD and LIB2ADD_ST.
782 ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
783 $(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
786 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
787 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
790 iter-items := $(LIB2ADD) $(LIB2ADD_ST)
793 ifeq ($(enable_shared),yes)
794 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD))))
797 # Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED. If we don't have
798 # libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and
799 # LIB2ADDEHSHARED matter. (Usually all three are identical.)
801 c_flags := -fexceptions
803 ifeq ($(enable_shared),yes)
805 libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC))))
806 libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED))))
808 iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED))
812 # Not shared. LIB2ADDEH are added to libgcc.a.
814 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))
816 iter-items := $(LIB2ADDEH)
823 c_flags := -fexceptions
825 libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
827 ifeq ($(enable_shared),yes)
828 libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND))))
831 iter-items := $(LIBUNWIND)
834 # Build libgcov components.
836 # Defined in libgcov.c, included only in gcov library
837 LIBGCOV = _gcov _gcov_merge_add _gcov_merge_single _gcov_merge_delta \
838 _gcov_fork _gcov_execl _gcov_execlp _gcov_execle \
839 _gcov_execv _gcov_execvp _gcov_execve \
840 _gcov_interval_profiler _gcov_pow2_profiler _gcov_one_value_profiler \
841 _gcov_indirect_call_profiler _gcov_average_profiler _gcov_ior_profiler \
844 libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
846 $(libgcov-objects): %$(objext): $(srcdir)/libgcov.c
847 $(gcc_compile) -DL$* -c $(srcdir)/libgcov.c
851 libgcc.a: $(libgcc-objects)
852 libgcov.a: $(libgcov-objects)
853 libunwind.a: $(libunwind-objects)
854 libgcc_eh.a: $(libgcc-eh-objects)
856 libgcc.a libgcov.a libunwind.a libgcc_eh.a:
859 objects="$(objects)"; \
860 if test -z "$$objects"; then \
861 echo 'int __libgcc_eh_dummy;' > eh_dummy.c; \
862 $(gcc_compile_bare) $(vis_hide) -c eh_dummy.c \
863 -o eh_dummy$(objext); \
864 objects=eh_dummy$(objext); \
866 $(AR_CREATE_FOR_TARGET) $@ $$objects
870 all: libgcc.a libgcov.a
872 ifneq ($(LIBUNWIND),)
874 libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
877 ifeq ($(enable_shared),yes)
878 all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
879 ifneq ($(LIBUNWIND),)
880 all: libunwind$(SHLIB_EXT)
884 ifeq ($(enable_shared),yes)
886 # Map-file generation.
887 ifneq ($(SHLIB_MKMAP),)
888 libgcc.map: $(SHLIB_MKMAP) $(SHLIB_MAPFILES) $(libgcc-s-objects)
889 { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
890 cat $(SHLIB_MAPFILES) \
891 | sed -e '/^[ ]*#/d' \
892 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
893 | $(gcc_compile_bare) -E -xassembler-with-cpp -; \
894 } | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
896 libgcc_s$(SHLIB_EXT): libgcc.map
900 libgcc-std.ver: $(srcdir)/libgcc-std.ver.in
901 sed -e 's/__PFX__/$(LIBGCC_VER_GNU_PREFIX)/g' \
902 -e 's/__FIXPTPFX__/$(LIBGCC_VER_FIXEDPOINT_GNU_PREFIX)/g' < $< > $@
904 libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts)
905 # @multilib_flags@ is still needed because this may use
906 # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
907 # @multilib_dir@ is not really necessary, but sometimes it has
908 # more uses than just a directory name.
909 $(mkinstalldirs) $(MULTIDIR)
910 $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
911 @multilib_dir@,$(MULTIDIR),$(subst \
912 @shlib_objs@,$(objects),$(subst \
913 @shlib_base_name@,libgcc_s,$(subst \
914 @shlib_map_file@,$(mapfile),$(subst \
915 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
916 @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
918 libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
919 # @multilib_flags@ is still needed because this may use
920 # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
921 # @multilib_dir@ is not really necessary, but sometimes it has
922 # more uses than just a directory name.
923 $(mkinstalldirs) $(MULTIDIR)
924 $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
925 @multilib_dir@,$(MULTIDIR),$(subst \
926 @shlib_objs@,$(objects),$(subst \
927 @shlib_base_name@,libunwind,$(subst \
928 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_LINK))))))
932 # Build the standard GCC startfiles and endfiles.
933 ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
934 crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)
936 ifeq ($(CUSTOM_CRTSTUFF),)
937 # Compile two additional files that are linked with every program
938 # linked using GCC on systems using COFF or ELF, for the sake of C++
940 crtbegin$(objext): $(srcdir)/crtstuff.c
941 $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN
943 crtend$(objext): $(srcdir)/crtstuff.c
944 $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END
946 # These are versions of crtbegin and crtend for shared libraries.
947 crtbeginS$(objext): $(srcdir)/crtstuff.c
948 $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_BEGIN -DCRTSTUFFS_O
950 crtendS$(objext): $(srcdir)/crtstuff.c
951 $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_END -DCRTSTUFFS_O
953 # This is a version of crtbegin for -static links.
954 crtbeginT$(objext): $(srcdir)/crtstuff.c
955 $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN -DCRTSTUFFT_O
958 ifeq ($(CUSTOM_CRTIN),)
959 # -x assembler-with-cpp is only needed on case-insensitive filesystem.
960 crti$(objext): $(srcdir)/config/$(cpu_type)/crti.S
961 $(crt_compile) -c -x assembler-with-cpp $<
963 crtn$(objext): $(srcdir)/config/$(cpu_type)/crtn.S
964 $(crt_compile) -c -x assembler-with-cpp $<
967 # Build extra startfiles in the libgcc directory.
968 .PHONY: libgcc-extra-parts
969 libgcc-extra-parts: $(EXTRA_PARTS)
971 # Early copyback; see "all" above for the rationale. The
972 # early copy is necessary so that the gcc -B options find
973 # the right startup files when linking shared libgcc.
974 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
975 parts="$(EXTRA_PARTS)"; \
976 for file in $$parts; do \
977 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
978 $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \
981 $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \
988 dest=$(gcc_objdir)/include/tmp$$$$-unwind.h; \
989 cp unwind.h $$dest; \
991 sh $(srcdir)/../move-if-change $$dest $(gcc_objdir)/include/unwind.h
993 all: install-unwind_h
995 # Documentation targets (empty).
996 .PHONY: info html dvi pdf install-info install-html install-pdf
1006 # Install rules. These do not depend on "all", so that they can be invoked
1007 # recursively from it.
1009 $(mkinstalldirs) $(DESTDIR)$(inst_slibdir)
1011 # NOTE: Maybe this should go into $(inst_libdir), but this
1012 # is where the old mklibgcc.in put it.
1013 $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/
1014 chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a
1015 $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a
1017 $(subst @multilib_dir@,$(MULTIDIR),$(subst \
1018 @shlib_base_name@,libunwind,$(subst \
1019 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))
1022 $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
1024 $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/
1025 chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
1026 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
1028 $(subst @multilib_dir@,$(MULTIDIR),$(subst \
1029 @shlib_base_name@,libgcc_s,$(subst \
1030 @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
1032 install-leaf: $(install-shared) $(install-libunwind)
1033 $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
1035 $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/
1036 chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a
1037 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a
1038 $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/
1039 chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a
1040 $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a
1042 parts="$(INSTALL_PARTS)"; \
1043 for file in $$parts; do \
1044 rm -f $(DESTDIR)$(inst_libdir)/$$file; \
1045 $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/; \
1048 $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \
1052 install: install-leaf
1053 @: $(MAKE) ; $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
1055 install-strip: install
1057 .PHONY: install install-shared install-libunwind install-strip
1059 # Don't export variables to the environment, in order to not confuse
1063 include $(srcdir)/empty.mk $(wildcard *.dep)