Makefile.in 38.7 KB
Newer Older
1 2
# Makefile.in

3
# Copyright (C) 2005-2019 Free Software Foundation, Inc.
4 5 6 7 8
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify it under the
# 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 11 12 13 14 15 16 17
# any later version.
#
# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
18 19
# with GCC; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.
20 21 22
#

libgcc_topdir = @libgcc_topdir@
23 24 25
host_subdir = @host_subdir@

gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc
26 27 28 29 30 31 32

srcdir = @srcdir@

prefix = @prefix@

exec_prefix = @exec_prefix@
libdir = @libdir@
33
shlib_slibdir = @slibdir@
34 35 36

SHELL = @SHELL@

37
cpu_type = @cpu_type@
38
enable_shared = @enable_shared@
39
enable_gcov = @enable_gcov@
40 41
double_type_size = @double_type_size@
long_double_type_size = @long_double_type_size@
42
decimal_float = @decimal_float@
43
enable_vtable_verify = @enable_vtable_verify@
44
enable_decimal_float = @enable_decimal_float@
45
fixed_point = @fixed_point@
46
with_aix_soname = @with_aix_soname@
47
solaris_ld_v2_maps = @solaris_ld_v2_maps@
48 49 50 51 52
enable_execute_stack = @enable_execute_stack@
unwind_header = @unwind_header@
md_unwind_header = @md_unwind_header@
sfp_machine_header = @sfp_machine_header@
thread_header = @thread_header@
53 54

host_noncanonical = @host_noncanonical@
55
real_host_noncanonical = @real_host_noncanonical@
56
target_noncanonical = @target_noncanonical@
57 58 59 60 61

# List of extra object files that should be compiled for this target machine.
# The rules for compiling them should be in the t-* file for the machine.
EXTRA_PARTS = @extra_parts@

62 63
FORCE_EXPLICIT_EH_REGISTRY = @force_explicit_eh_registry@

64 65
extra-parts = libgcc-extra-parts

66 67 68 69 70 71 72 73 74 75 76 77
# Multilib support variables.
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
78
INSTALL_PARTS = $(EXTRA_PARTS)
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119

objext = .o

AR = @AR@
AR_FLAGS = rc

CC = @CC@
CFLAGS = @CFLAGS@
RANLIB = @RANLIB@
LN_S = @LN_S@

PWD_COMMAND = $${PWDCMD-pwd}

# Flags to pass to a recursive make.
FLAGS_TO_PASS = \
	"AR=$(AR)" \
	"AR_FLAGS=$(AR_FLAGS)" \
	"CC=$(CC)" \
	"CFLAGS=$(CFLAGS)" \
	"DESTDIR=$(DESTDIR)" \
	"EXTRA_OFILES=$(EXTRA_OFILES)" \
	"HDEFINES=$(HDEFINES)" \
	"INSTALL=$(INSTALL)" \
	"INSTALL_DATA=$(INSTALL_DATA)" \
	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
	"LDFLAGS=$(LDFLAGS)" \
	"LOADLIBES=$(LOADLIBES)" \
	"RANLIB=$(RANLIB)" \
	"SHELL=$(SHELL)" \
	"prefix=$(prefix)" \
	"exec_prefix=$(exec_prefix)" \
	"libdir=$(libdir)" \
	"libsubdir=$(libsubdir)" \
	"tooldir=$(tooldir)"

# Dependencies for "all" are set later in the file.
all: all-multi
	# Now that we have built all the objects, we need to copy
	# them back to the GCC directory.  Too many things (other
	# in-tree libraries, and DejaGNU) know about the layout
	# of the build tree, for now.
120
	$(MAKE) install-leaf DESTDIR=$(gcc_objdir) \
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
	  slibdir= libsubdir= MULTIOSDIR=$(MULTIDIR)

.PHONY: all-multi
all-multi:
	# If this is the top-level multilib, build all the other
	# multilibs.
	@: $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all

.PHONY: check installcheck
check:
installcheck:

.PHONY: all clean

clean:
136 137
	-rm -f libgcc_tm.h libgcc.map
	-rm -f libgcc_tm.stamp stmp-ldirs
138 139 140 141 142 143 144 145
	-rm -f *$(objext)
	-rm -f *.dep
	-rm -f *.a
	-rm -f libunwind$(SHLIB_EXT)
	-rm -f libgcc_s*
	@$(MULTICLEAN) multi-clean DO=clean
distclean: clean
	@$(MULTICLEAN) multi-clean DO=distclean
146 147
	-rm -f auto-target.h
	-rm -f stamp-h
148 149 150 151 152 153 154 155 156
	-rm -f *~ Makefile config.cache config.status multilib.out
	-rm -f config.log
maintainer-clean realclean: distclean

Makefile: $(srcdir)/Makefile.in config.status
	CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status

# Depending on Makefile makes sure that config.status has been re-run
# if needed.  This prevents problems with parallel builds.
157
auto-target.h: stamp-h ; @true
158
stamp-h: $(srcdir)/config.in config.status Makefile
159
	CONFIG_FILES= CONFIG_HEADERS=auto-target.h:$(srcdir)/config.in $(SHELL) ./config.status
160

161
config.status: $(srcdir)/configure $(srcdir)/config.host
162 163
	$(SHELL) ./config.status --recheck

164 165 166 167 168 169
AUTOCONF = autoconf
configure_deps = \
	$(srcdir)/../config/enable.m4 \
	$(srcdir)/../config/tls.m4 \
	$(srcdir)/../config/acx.m4 \
	$(srcdir)/../config/no-executables.m4 \
170
	$(srcdir)/../config/lib-ld.m4 \
171
	$(srcdir)/../config/override.m4 \
172
	$(srcdir)/../config/picflag.m4 \
173
	$(srcdir)/../config/dfp.m4 \
174 175
	$(srcdir)/../config/unwind_ipinfo.m4 \
	$(srcdir)/../config/gthr.m4 \
176 177
	$(srcdir)/../config/sjlj.m4 \
	$(srcdir)/../config/cet.m4
178 179 180 181

$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(configure_deps)
	cd $(srcdir) && $(AUTOCONF)

182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
include $(gcc_objdir)/libgcc.mvars

# Flags to pass to recursive makes.

AR_FOR_TARGET = $(AR)
AR_FLAGS_FOR_TARGET =
AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
AWK = @AWK@
GCC_FOR_TARGET = $(CC)
LIPO = @LIPO@
LIPO_FOR_TARGET = $(LIPO)
MACHMODE_H = machmode.h mode-classes.def insn-modes.h
NM = @NM@
NM_FOR_TARGET = $(NM)
RANLIB_FOR_TARGET = $(RANLIB)
STRIP = @STRIP@
STRIP_FOR_TARGET = $(STRIP)

# Directory in which the compiler finds libraries etc.
202
libsubdir = $(libdir)/gcc/$(real_host_noncanonical)/$(version)@accel_dir_suffix@
203 204
# Used to install the shared libgcc.
slibdir = @slibdir@
205 206 207
# Maybe used for DLLs on Windows targets.
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226

export AR_FOR_TARGET
export AR_CREATE_FOR_TARGET
export AR_FLAGS_FOR_TARGET
export AR_EXTRACT_FOR_TARGET
export AWK
export DESTDIR
export GCC_FOR_TARGET
export INCLUDES
export INSTALL_DATA
export LIB1ASMSRC
export LIBGCC2_CFLAGS
export LIPO_FOR_TARGET
export MACHMODE_H
export NM_FOR_TARGET
export STRIP_FOR_TARGET
export RANLIB_FOR_TARGET
export libsubdir
export slibdir
227 228
export toolexecdir
export toolexeclibdir
229

230
version := $(shell @get_gcc_base_ver@ $(srcdir)/../gcc/BASE-VER)
231

232
ifeq ($(decimal_float),yes)
233 234 235
ifeq ($(enable_decimal_float),bid)
DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT
else
236
DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \
237
	    -I$(srcdir)/../libdecnumber
238
endif
239 240 241
else
DECNUMINC =
endif
242

243 244 245 246
# Options to use when compiling libgcc2.a.
#
LIBGCC2_DEBUG_CFLAGS = -g
LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
247
		 $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
248 249 250 251 252 253 254 255 256 257 258 259
		 -fbuilding-libgcc -fno-stack-protector \
		 $(INHIBIT_LIBC_CFLAGS)

# Additional options to use when compiling libgcc2.a.
# Some targets override this to -isystem include
LIBGCC2_INCLUDES =

# Additional target-dependent options for compiling libgcc2.a.
HOST_LIBGCC2_CFLAGS =

PICFLAG = @PICFLAG@

260 261
CET_FLAGS = @CET_FLAGS@

262 263 264 265 266 267 268 269 270 271 272 273 274 275
# Defined in libgcc2.c, included only in the static library.
LIB2FUNCS_ST = _eprintf __gcc_bcmp

# List of functions not to build from libgcc2.c.
LIB2FUNCS_EXCLUDE =

# List of extra C and assembler files to add to static and shared libgcc2.
# Assembler files should have names ending in `.S'.
LIB2ADD = 

# List of extra C and assembler files to add to static libgcc2.
# Assembler files should have names ending in `.S'.
LIB2ADD_ST =

276 277 278 279 280 281 282 283 284 285
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that *config.h will be found in the compilation
# subdirectory rather than in the source directory.
# -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file
# currently being compiled, in both source trees, to be examined as well.
INCLUDES = -I. -I$(@D) -I$(gcc_objdir) \
	   -I$(srcdir) -I$(srcdir)/$(@D) -I$(srcdir)/../gcc \
	   -I$(srcdir)/../include $(DECNUMINC)

286 287 288 289
# Forcibly remove any profiling-related flags.  There is no point
# in supporting profiled bootstrap in this library.
override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))

290 291 292 293
# CFLAGS first is not perfect; normally setting CFLAGS should override any
# options in LIBGCC2_CFLAGS.  But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
# will usually contain -g, so for the moment CFLAGS goes first.  We must
# include CFLAGS - that's where multilib options live.
294
INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
295
		  $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
296

297 298
# Options to use when compiling crtbegin/end.
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
299
  $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
300
  -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
301
  -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
302 303 304 305 306
  $(INHIBIT_LIBC_CFLAGS)

# Extra flags to use when compiling crt{begin,end}.o.
CRTSTUFF_T_CFLAGS =

307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)

MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); fi)
inst_libdir = $(libsubdir)$(MULTISUBDIR)
inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)

gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS)
compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep
gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps)
gcc_s_compile = $(gcc_compile) -DSHARED

objects = $(filter %$(objext),$^)

# Collect any host-specific information from Makefile fragments.
322 323

LIBGCC_VER_GNU_PREFIX = __
324
LIBGCC_VER_FIXEDPOINT_GNU_PREFIX = __
325 326
LIBGCC_VER_SYMBOLS_PREFIX =

327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
    _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
    _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
    _sf_to_df _sf_to_tf _thenan_sf _sf_to_usi _usi_to_sf

DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
    _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
    _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
    _df_to_sf _df_to_tf _thenan_df _df_to_usi _usi_to_df

TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
    _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \
    _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
    _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf

342 343 344 345 346 347
# Additional sources to handle exceptions; overridden by targets as needed.
LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
  $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
LIB2ADDEHSTATIC = $(LIB2ADDEH)
LIB2ADDEHSHARED = $(LIB2ADDEH)

348 349 350
# nm flags to list global symbols in libgcc object files.
SHLIB_NM_FLAGS = -pg

351 352 353 354 355
# Don't build libunwind by default.
LIBUNWIND =
SHLIBUNWIND_LINK =
SHLIBUNWIND_INSTALL =

356

357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
# Create links to files specified in config.host.
LIBGCC_LINKS = enable-execute-stack.c unwind.h md-unwind-support.h \
               sfp-machine.h gthr-default.h

enable-execute-stack.c: $(srcdir)/$(enable_execute_stack)
	-$(LN_S) $< $@
unwind.h: $(srcdir)/$(unwind_header)
	-$(LN_S) $< $@
md-unwind-support.h: $(srcdir)/config/$(md_unwind_header)
	-$(LN_S) $< $@
sfp-machine.h: $(srcdir)/config/$(sfp_machine_header)
	-$(LN_S) $< $@
gthr-default.h: $(srcdir)/$(thread_header)
	-$(LN_S) $< $@

372 373 374
tmake_file = @tmake_file@
include $(srcdir)/empty.mk $(tmake_file)

375 376 377 378 379 380 381 382 383 384
# Collect target defines and headers from config.host.
libgcc_tm_defines = @tm_defines@
libgcc_tm_file = @tm_file@
libgcc_tm.h: libgcc_tm.stamp; @true
libgcc_tm.stamp:
	DEFINES='$(libgcc_tm_defines)' HEADERS='$(libgcc_tm_file)' \
		$(srcdir)/mkheader.sh > tmp-libgcc_tm.h
	$(SHELL) $(srcdir)/../move-if-change tmp-libgcc_tm.h libgcc_tm.h
	echo timestamp > $@

385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
# Only handle shared libraries if both:
#   - the user requested them
#   - we know how to build them
ifeq ($(SHLIB_LINK),)
  enable_shared := no
endif

ifeq ($(enable_shared),yes)
  iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/shared-object.mk,$(iter-items))

  install-shared = install-shared

  ifneq ($(LIBUNWIND),)
    install-libunwind = install-libunwind
  endif
400
endif
401 402 403 404 405 406 407 408 409 410 411 412 413 414

# For -fvisibility=hidden.  We need both a -fvisibility=hidden on
# the command line, and a #define to prevent libgcc2.h etc from
# overriding that with #pragmas.
vis_hide = @vis_hide@

ifneq (,$(vis_hide))

# If we have -fvisibility=hidden, then we need to generate hide
# lists for object files implemented in assembly.
ASM_HIDDEN_OP = @asm_hidden_op@

define gen-hide-list
$(NM) -pg $< | \
415 416 417
  $(AWK) 'NF == 3 && $$2 !~ /^[UN]$$/ && $$3 !~ /.*_compat/ \
         && $$3 !~ /.*@.*/ \
	 { print "\t$(ASM_HIDDEN_OP)", $$3 }' > $@T
418 419 420 421 422 423
mv -f $@T $@
endef
else
gen-hide-list = echo > $@
endif

424
ifneq ($(enable_shared),yes)
425 426 427
iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
endif

428 429
LIB2ADD += enable-execute-stack.c

430 431 432
# While emutls.c has nothing to do with EH, it is in LIB2ADDEH*
# instead of LIB2ADD because that's the way to be sure on some targets
# (e.g. *-*-darwin*) only one copy of it is linked.
433 434 435 436
LIB2ADDEH += $(srcdir)/emutls.c
LIB2ADDEHSTATIC += $(srcdir)/emutls.c
LIB2ADDEHSHARED += $(srcdir)/emutls.c

437 438
# Library members defined in libgcc2.c.
lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2	   \
439
	    _clear_cache _trampoline __main _absvsi2 \
440 441 442 443
	    _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \
	    _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2  \
	    _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2	   \
	    _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2	   \
444 445 446
	    _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3 _divsc3	   \
	    _divdc3 _divxc3 _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2	   \
	    _clrsbdi2
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464

# The floating-point conversion routines that involve a single-word integer.
# XX stands for the integer mode.
swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf)

# Likewise double-word routines.
dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \
	       $(patsubst %,_fixuns%XX,sf df xf tf) \
	       $(patsubst %,_floatXX%,sf df xf tf) \
	       $(patsubst %,_floatunXX%,sf df xf tf)

ifeq ($(LIB2_SIDITI_CONV_FUNCS),)
  lib2funcs += $(subst XX,si,$(swfloatfuncs))
  lib2funcs += $(subst XX,di,$(dwfloatfuncs))
endif

# These might cause a divide overflow trap and so are compiled with
# unwinder info.
465 466
LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _divmoddi4 \
		    _udivdi3 _umoddi3 _udivmoddi4 _udiv_w_sdiv
467 468 469 470 471 472 473 474

# Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
# defined as optimized assembly code in LIB1ASMFUNCS or as C code
# in LIB2FUNCS_EXCLUDE.
lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs))
LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
		       $(LIB2_DIVMOD_FUNCS))

475 476
LIB2FUNCS_ST := $(filter-out $(LIB2FUNCS_EXCLUDE),$(LIB2FUNCS_ST))

477 478 479
# Build "libgcc1" (assembly) components.

lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
480 481
$(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC) %.vis
	$(gcc_compile) -DL$* -xassembler-with-cpp -c $< -include $*.vis
482 483 484 485 486
$(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext)
	$(gen-hide-list)
libgcc-objects += $(lib1asmfuncs-o)

lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS))
487 488
$(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC)
	$(gcc_s_compile) -DL$* -xassembler-with-cpp -c $<
489
ifeq ($(enable_shared),yes)
490

491
libgcc-s-objects += $(lib1asmfuncs-s-o)
492 493 494 495 496

endif

# Build lib2funcs.  For the static library also include LIB2FUNCS_ST.
lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST))
497 498
$(lib2funcs-o): %$(objext): $(srcdir)/libgcc2.c
	$(gcc_compile) -DL$* -c $< $(vis_hide)
499 500 501 502
libgcc-objects += $(lib2funcs-o)

ifeq ($(enable_shared),yes)
lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs))
503 504
$(lib2funcs-s-o): %_s$(objext): $(srcdir)/libgcc2.c
	$(gcc_s_compile) -DL$* -c $<
505 506 507 508 509 510 511 512 513
libgcc-s-objects += $(lib2funcs-s-o)
endif

ifneq ($(LIB2_SIDITI_CONV_FUNCS),)
# Build libgcc2.c for each conversion function, with a specific
# L<func> definition and LIBGCC2_UNITS_PER_WORD setting.  The DImode
# functions are built with a wordsize of 4; the TImode functions are
# built with the same labels, but a wordsize of 8.

514 515 516
sifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,si,$(swfloatfuncs)))
difuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,di,$(dwfloatfuncs)))
tifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,ti,$(dwfloatfuncs)))
517 518 519 520 521 522 523 524 525 526 527 528 529

iter-items := $(sifuncs) $(difuncs) $(tifuncs)
iter-labels := $(sifuncs) $(difuncs) $(difuncs)
iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs))

include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))

libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs))
ifeq ($(enable_shared),yes)
libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs))
endif
endif

530 531 532 533 534 535
ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),)
# Provide default flags for compiling divmod functions, if they haven't been
# set already by a target-specific Makefile fragment.
LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions
endif

536 537
# Build LIB2_DIVMOD_FUNCS.
lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
538 539
$(lib2-divmod-o): %$(objext): $(srcdir)/libgcc2.c
	$(gcc_compile) -DL$* -c $< \
540
	  $(LIB2_DIVMOD_EXCEPTION_FLAGS) $(vis_hide)
541 542 543 544
libgcc-objects += $(lib2-divmod-o)

ifeq ($(enable_shared),yes)
lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
545 546
$(lib2-divmod-s-o): %_s$(objext): $(srcdir)/libgcc2.c
	$(gcc_s_compile) -DL$* -c $< \
547
	  $(LIB2_DIVMOD_EXCEPTION_FLAGS)
548 549 550 551 552 553 554 555 556
libgcc-s-objects += $(lib2-divmod-s-o)
endif

ifeq ($(TPBIT),)
# _sf_to_tf and _df_to_tf require tp-bit.c being compiled in.
FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS))
DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
endif

557 558 559 560
FPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(FPBIT_FUNCS))
DPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(DPBIT_FUNCS))
TPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(TPBIT_FUNCS))

561 562
fpbit-src := $(srcdir)/fp-bit.c

563 564 565
# Build FPBIT.
ifneq ($(FPBIT),)
fpbit-o = $(patsubst %,%$(objext),$(FPBIT_FUNCS))
566 567
$(fpbit-o): %$(objext): $(fpbit-src)
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DFLOAT $(FPBIT_CFLAGS) -c $< $(vis_hide)
568 569 570 571
libgcc-objects += $(fpbit-o)

ifeq ($(enable_shared),yes)
fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS))
572 573
$(fpbit-s-o): %_s$(objext): $(fpbit-src)
	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DFLOAT $(FPBIT_CFLAGS)  -c $<
574 575 576 577 578 579 580
libgcc-s-objects += $(fpbit-s-o)
endif
endif

# Build DPBIT.
ifneq ($(DPBIT),)
dpbit-o = $(patsubst %,%$(objext),$(DPBIT_FUNCS))
581 582
$(dpbit-o): %$(objext): $(fpbit-src)
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* $(DPBIT_CFLAGS) -c $< $(vis_hide)
583 584 585 586
libgcc-objects += $(dpbit-o)

ifeq ($(enable_shared),yes)
dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS))
587 588
$(dpbit-s-o): %_s$(objext): $(fpbit-src)
	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* $(DPBIT_CFLAGS) -c $<
589 590 591 592 593 594 595
libgcc-s-objects += $(dpbit-s-o)
endif
endif

# Build TPBIT.
ifneq ($(TPBIT),)
tpbit-o = $(patsubst %,%$(objext),$(TPBIT_FUNCS))
596 597
$(tpbit-o): %$(objext): $(fpbit-src)
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DTFLOAT $(TPBIT_CFLAGS) -c $< $(vis_hide)
598 599 600 601
libgcc-objects += $(tpbit-o)

ifeq ($(enable_shared),yes)
tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS))
602 603
$(tpbit-s-o): %_s$(objext): $(fpbit-src)
	$(gcc_s_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DTFLOAT $(TPBIT_CFLAGS) -c $<
604 605 606 607 608 609 610 611 612 613 614 615 616 617
libgcc-s-objects += $(tpbit-s-o)
endif
endif

# Build decimal floating point support.
ifeq ($(decimal_float),yes)

# If $DFP_ENABLE is set, then we want all data type sizes.
ifneq ($(DFP_ENABLE),)
D32PBIT = 1
D64PBIT = 1
D128PBIT = 1
endif

618
dfp-filenames =
619
ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),)
620
ifeq ($(enable_decimal_float),bid)
621 622 623 624
dfp-filenames += bid_decimal_globals bid_decimal_data \
		 bid_binarydecimal bid_convert_data \
		 _isinfd32 _isinfd64 _isinfd128 bid64_noncomp \
		 bid128_noncomp bid128_fma bid_round bid_from_int \
625 626 627 628 629 630 631 632
		 bid64_add bid128_add bid64_div bid128_div \
		 bid64_mul bid128_mul bid64_compare bid128_compare \
		 bid128 bid32_to_bid64 bid32_to_bid128 bid64_to_bid128 \
		 bid64_to_int32 bid64_to_int64 \
		 bid64_to_uint32 bid64_to_uint64 \
		 bid128_to_int32 bid128_to_int64 \
		 bid128_to_uint32 bid128_to_uint64
else
633
dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle
634
endif
635 636
endif

637 638 639 640 641 642
dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames))
ifeq ($(enable_decimal_float),bid)
$(dfp-objects): %$(objext): $(srcdir)/config/libbid/%.c
else
$(dfp-objects): %$(objext): $(srcdir)/../libdecnumber/%.c
endif
643
	$(gcc_compile) -c $<
644
libgcc-objects += $(dfp-objects)
645 646

decbits-filenames =
647
ifneq ($(enable_decimal_float),bid)
648
ifneq ($(D32PBIT),)
649
decbits-filenames += decimal32
650 651 652
endif

ifneq ($(D64PBIT),)
653
decbits-filenames += decimal64
654 655 656
endif

ifneq ($(D128PBIT),)
657
decbits-filenames += decimal128
658
endif
659 660 661
endif

decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames))
662 663 664
ifeq ($(enable_decimal_float),bid)
$(decbits-objects): %$(objext): $(srcdir)/config/libbid/%.c
else
665
$(decbits-objects): %$(objext): $(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c
666
endif
667
	$(gcc_compile) -c $<
668
libgcc-objects += $(decbits-objects)
669 670

# Next build individual support functions.
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \
	_eq_sd _ne_sd _lt_sd _gt_sd _le_sd _ge_sd \
	_sd_to_si _sd_to_di _sd_to_usi _sd_to_udi \
	_si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \
	_sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \
	_sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \
	_sd_to_dd _sd_to_td _unord_sd _conv_sd

D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \
	_eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \
	_dd_to_si _dd_to_di _dd_to_usi _dd_to_udi \
	_si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \
	_dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \
	_sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \
	_dd_to_sd _dd_to_td _unord_dd _conv_dd

D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \
	_eq_td _ne_td _lt_td _gt_td _le_td _ge_td \
	_td_to_si _td_to_di _td_to_usi _td_to_udi \
	_si_to_td _di_to_td _usi_to_td _udi_to_td \
	_td_to_sf _td_to_df _td_to_xf _td_to_tf \
	_sf_to_td _df_to_td _xf_to_td _tf_to_td \
	_td_to_sd _td_to_dd _unord_td _conv_td

695 696 697 698 699 700 701 702 703 704 705 706 707 708
ifeq ($(enable_decimal_float),bid)
ifneq ($(D32PBIT),)
D32PBIT_FUNCS:=$(filter-out _plus_sd _minus_sd _conv_sd, $(D32PBIT_FUNCS))
endif

ifneq ($(D64PBIT),)
D64PBIT_FUNCS:=$(filter-out _plus_dd _minus_dd _conv_dd, $(D64PBIT_FUNCS))
endif

ifneq ($(D128PBIT),)
D128PBIT_FUNCS:=$(filter-out _plus_td _minus_td _conv_td, $(D128PBIT_FUNCS))
endif
endif

709 710
ifneq ($(D32PBIT),)
d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS))
711 712 713
ifeq ($(enable_decimal_float),bid)
$(d32pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
else
714
$(d32pbit-o): %$(objext): $(srcdir)/dfp-bit.c
715
endif
716 717 718 719 720 721
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $<
libgcc-objects += $(d32pbit-o)
endif

ifneq ($(D64PBIT),)
d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS))
722 723 724
ifeq ($(enable_decimal_float),bid)
$(d64pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
else
725
$(d64pbit-o): %$(objext): $(srcdir)/dfp-bit.c
726
endif
727 728 729 730 731 732
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $<
libgcc-objects += $(d64pbit-o)
endif

ifneq ($(D128PBIT),)
d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS))
733 734 735
ifeq ($(enable_decimal_float),bid)
$(d128pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
else
736
$(d128pbit-o): %$(objext): $(srcdir)/dfp-bit.c
737
endif
738 739 740 741 742 743
	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $<
libgcc-objects += $(d128pbit-o)
endif

endif

Rainer Orth committed
744
ifeq ($(SYNC),yes)
745 746 747 748 749 750 751 752 753 754 755 756
libgcc-sync-size-funcs := $(foreach op, add sub or and xor nand, \
			    sync_fetch_and_$(op) \
			    sync_$(op)_and_fetch) \
			  sync_bool_compare_and_swap \
			  sync_val_compare_and_swap \
			  sync_lock_test_and_set

libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \
			    $(foreach suffix, 1 2 4 8 16, \
			      $(prefix)_$(suffix)))

libgcc-sync-size-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-size-funcs))
Rainer Orth committed
757 758
$(libgcc-sync-size-funcs-o): %$(objext): $(srcdir)/sync.c
	$(gcc_compile) $(SYNC_CFLAGS) \
759 760
	  -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
	  -DSIZE=`echo "$*" | sed 's/.*_//'` \
Rainer Orth committed
761
	  -c $< $(vis_hide)
762 763 764 765 766
libgcc-objects += $(libgcc-sync-size-funcs-o)

libgcc-sync-funcs := sync_synchronize

libgcc-sync-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-funcs))
Rainer Orth committed
767 768
$(libgcc-sync-funcs-o): %$(objext): $(srcdir)/sync.c
	$(gcc_compile) $(SYNC_CFLAGS) \
769
	  -DL$* \
Rainer Orth committed
770
	  -c $< $(vis_hide)
771 772 773 774 775
libgcc-objects += $(libgcc-sync-funcs-o)

ifeq ($(enable_shared),yes)
libgcc-sync-size-funcs-s-o = $(patsubst %,%_s$(objext), \
			       $(libgcc-sync-size-funcs))
Rainer Orth committed
776 777
$(libgcc-sync-size-funcs-s-o): %_s$(objext): $(srcdir)/sync.c
	$(gcc_s_compile) $(SYNC_CFLAGS) \
778 779
	  -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \
	  -DSIZE=`echo "$*" | sed 's/.*_//'` \
Rainer Orth committed
780
	  -c $<
781 782 783
libgcc-s-objects += $(libgcc-sync-size-funcs-s-o)

libgcc-sync-funcs-s-o = $(patsubst %,%_s$(objext),$(libgcc-sync-funcs))
Rainer Orth committed
784 785
$(libgcc-sync-funcs-s-o): %_s$(objext): $(srcdir)/sync.c
	$(gcc_s_compile) $(SYNC_CFLAGS) \
786
	  -DL$*	\
Rainer Orth committed
787
	  -c $<
788 789 790 791
libgcc-s-objects += $(libgcc-sync-funcs-s-o)
endif
endif

792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
# Build fixed-point support.
ifeq ($(fixed_point),yes)

# Generate permutations of function name and mode
fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels)
fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs)
fixed-modes := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith modes)

# Generate the rules for each arithmetic function
iter-items := $(fixed-funcs)
iter-labels := $(fixed-labels)
iter-from := $(fixed-modes)
iter-to := $(fixed-modes)
include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))

# Add arithmetic functions to list of objects to be built
808
libgcc-objects += $(patsubst %,%$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-funcs)))
809
ifeq ($(enable_shared),yes)
810
libgcc-s-objects += $(patsubst %,%_s$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-funcs)))
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
endif

# Convert from or to fractional
fixed-conv-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv funcs)
fixed-conv-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv labels)
fixed-conv-from := $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv from)
fixed-conv-to :=  $(shell $(SHELL) $(srcdir)/gen-fixed.sh conv to)

# Generate the make rules for each conversion function
iter-items := $(fixed-conv-funcs)
iter-labels := $(fixed-conv-labels)
iter-from := $(fixed-conv-from)
iter-to := $(fixed-conv-to)
include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))

# Add conversion functions to list of objects to be built
827
libgcc-objects += $(patsubst %,%$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-conv-funcs)))
828
ifeq ($(enable_shared),yes)
829
libgcc-s-objects += $(patsubst %,%_s$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-conv-funcs)))
830 831 832 833
endif

endif

834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873
# Build LIB2ADD and LIB2ADD_ST.
ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
$(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
endif

libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))

c_flags :=
iter-items := $(LIB2ADD) $(LIB2ADD_ST)
include $(iterator)

ifeq ($(enable_shared),yes)
libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADD))))
endif

# Build LIB2ADDEH, LIB2ADDEHSTATIC, and LIB2ADDEHSHARED.  If we don't have
# libgcc_eh.a, only LIB2ADDEH matters.  If we do, only LIB2ADDEHSTATIC and
# LIB2ADDEHSHARED matter.  (Usually all three are identical.)

c_flags := -fexceptions

ifeq ($(enable_shared),yes)

libgcc-eh-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEHSTATIC))))
libgcc-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIB2ADDEHSHARED))))

iter-items := $(sort $(LIB2ADDEHSTATIC) $(LIB2ADDEHSHARED))
include $(iterator)

else
# Not shared.  LIB2ADDEH are added to libgcc.a.

libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))

iter-items := $(LIB2ADDEH)
include $(iterator)

endif

874 875
# Build LIBUNWIND. Use -fno-exceptions so that the unwind library does
# not generate calls to __gcc_personality_v0.
876

877
c_flags := -fno-exceptions
878 879 880 881 882 883 884 885 886 887 888

libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))

ifeq ($(enable_shared),yes)
libunwind-s-objects += $(addsuffix _s$(objext),$(basename $(notdir $(LIBUNWIND))))
endif

iter-items := $(LIBUNWIND)
include $(iterator)

# Build libgcov components.
889

890
LIBGCOV_MERGE = _gcov_merge_add _gcov_merge_single			\
Rong Xu committed
891
	_gcov_merge_ior _gcov_merge_time_profile _gcov_merge_icall_topn
892 893 894 895
LIBGCOV_PROFILER = _gcov_interval_profiler				\
	_gcov_interval_profiler_atomic					\
	_gcov_pow2_profiler						\
	_gcov_pow2_profiler_atomic					\
896
	_gcov_one_value_profiler					\
897 898 899 900 901
	_gcov_one_value_profiler_atomic					\
	_gcov_average_profiler						\
	_gcov_average_profiler_atomic					\
	_gcov_ior_profiler						\
	_gcov_ior_profiler_atomic					\
902
	_gcov_indirect_call_profiler_v3					\
903
	_gcov_time_profiler						\
Rong Xu committed
904
	_gcov_indirect_call_topn_profiler
905 906
LIBGCOV_INTERFACE = _gcov_dump _gcov_flush _gcov_fork			\
	_gcov_execl _gcov_execlp					\
907
	_gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset
908
LIBGCOV_DRIVER = _gcov
909 910 911 912 913 914 915 916

libgcov-merge-objects = $(patsubst %,%$(objext),$(LIBGCOV_MERGE))
libgcov-profiler-objects = $(patsubst %,%$(objext),$(LIBGCOV_PROFILER))
libgcov-interface-objects = $(patsubst %,%$(objext),$(LIBGCOV_INTERFACE))
libgcov-driver-objects = $(patsubst %,%$(objext),$(LIBGCOV_DRIVER))
libgcov-objects = $(libgcov-merge-objects) $(libgcov-profiler-objects) \
                 $(libgcov-interface-objects) $(libgcov-driver-objects)

917
$(libgcov-merge-objects): %$(objext): $(srcdir)/libgcov-merge.c $(srcdir)/gcov.h $(srcdir)/libgcov.h
918
	$(gcc_compile) -DL$* -c $(srcdir)/libgcov-merge.c
919
$(libgcov-profiler-objects): %$(objext): $(srcdir)/libgcov-profiler.c $(srcdir)/gcov.h $(srcdir)/libgcov.h
920
	$(gcc_compile) -DL$* -c $(srcdir)/libgcov-profiler.c
921
$(libgcov-interface-objects): %$(objext): $(srcdir)/libgcov-interface.c $(srcdir)/gcov.h $(srcdir)/libgcov.h
922 923
	$(gcc_compile) -DL$* -c $(srcdir)/libgcov-interface.c
$(libgcov-driver-objects): %$(objext): $(srcdir)/libgcov-driver.c \
924
  $(srcdir)/libgcov-driver-system.c $(srcdir)/gcov.h $(srcdir)/libgcov.h
925
	$(gcc_compile) -DL$* -c $(srcdir)/libgcov-driver.c
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947


# Static libraries.
libgcc.a: $(libgcc-objects)
libgcov.a: $(libgcov-objects)
libunwind.a: $(libunwind-objects)
libgcc_eh.a: $(libgcc-eh-objects)

libgcc.a libgcov.a libunwind.a libgcc_eh.a:
	-rm -f $@

	objects="$(objects)";					\
	if test -z "$$objects"; then				\
	  echo 'int __libgcc_eh_dummy;' > eh_dummy.c;		\
	  $(gcc_compile_bare) $(vis_hide) -c eh_dummy.c		\
	     -o eh_dummy$(objext);				\
	  objects=eh_dummy$(objext);				\
	fi;							\
	$(AR_CREATE_FOR_TARGET) $@ $$objects

	$(RANLIB) $@

948 949 950 951
all: libgcc.a
ifeq ($(enable_gcov),yes)
all: libgcov.a
endif
952 953 954 955 956 957 958 959 960

ifneq ($(LIBUNWIND),)
all: libunwind.a
endif

ifeq ($(enable_shared),yes)
all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
ifneq ($(LIBUNWIND),)
all: libunwind$(SHLIB_EXT)
961
libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
962 963 964 965
endif

# Map-file generation.
ifneq ($(SHLIB_MKMAP),)
966 967
libgcc.map.in: $(SHLIB_MAPFILES)
	{ cat $(SHLIB_MAPFILES) \
968 969 970
	    | sed -e '/^[ 	]*#/d' \
		  -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
	    | $(gcc_compile_bare) -E -xassembler-with-cpp -; \
971 972 973 974 975
	} > tmp-$@
	mv tmp-$@ $@
libgcc.map: $(SHLIB_MKMAP) libgcc.map.in $(libgcc-s-objects)
	{ $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
	  cat libgcc.map.in; \
976 977 978 979 980 981
	} | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
	mv tmp-$@ $@
libgcc_s$(SHLIB_EXT): libgcc.map
mapfile = libgcc.map
endif

982
libgcc-std.ver: $(srcdir)/libgcc-std.ver.in
983 984
	sed -e 's/__PFX__/$(LIBGCC_VER_GNU_PREFIX)/g' \
	    -e 's/__FIXPTPFX__/$(LIBGCC_VER_FIXEDPOINT_GNU_PREFIX)/g' < $< > $@
985

986
libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts) libgcc.a
987 988 989 990 991
	# @multilib_flags@ is still needed because this may use
	# $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
	# @multilib_dir@ is not really necessary, but sometimes it has
	# more uses than just a directory name.
	$(mkinstalldirs) $(MULTIDIR)
992
	$(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
993
		@multilib_dir@,$(MULTIDIR),$(subst \
994
		@shlib_objs@,$(objects) libgcc.a,$(subst \
995 996
		@shlib_base_name@,libgcc_s,$(subst \
		@shlib_map_file@,$(mapfile),$(subst \
997 998
		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
		@shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
999 1000 1001 1002 1003 1004 1005

libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
	# @multilib_flags@ is still needed because this may use
	# $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
	# @multilib_dir@ is not really necessary, but sometimes it has
	# more uses than just a directory name.
	$(mkinstalldirs) $(MULTIDIR)
1006
	$(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
		@multilib_dir@,$(MULTIDIR),$(subst \
		@shlib_objs@,$(objects),$(subst \
		@shlib_base_name@,libunwind,$(subst \
		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_LINK))))))

endif

# Build the standard GCC startfiles and endfiles.
ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)

ifeq ($(CUSTOM_CRTSTUFF),)
1019 1020 1021 1022 1023
# Compile two additional files that are linked with every program
# linked using GCC on systems using COFF or ELF, for the sake of C++
# constructors.
crtbegin$(objext): $(srcdir)/crtstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN
1024

1025 1026
crtend$(objext): $(srcdir)/crtstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END
1027 1028

# These are versions of crtbegin and crtend for shared libraries.
1029 1030
crtbeginS$(objext): $(srcdir)/crtstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_BEGIN -DCRTSTUFFS_O
1031

1032 1033
crtendS$(objext): $(srcdir)/crtstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_END -DCRTSTUFFS_O
1034 1035

# This is a version of crtbegin for -static links.
1036 1037
crtbeginT$(objext): $(srcdir)/crtstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN -DCRTSTUFFT_O
1038

1039
# crtoffloadbegin and crtoffloadend contain symbols, that mark the begin and
1040 1041
# the end of tables with addresses, required for offloading.  crtoffloadtable
# contains the array with addresses of those symbols.
1042 1043 1044 1045 1046
crtoffloadbegin$(objext): $(srcdir)/offloadstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN

crtoffloadend$(objext): $(srcdir)/offloadstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END
1047 1048 1049

crtoffloadtable$(objext): $(srcdir)/offloadstuff.c
	$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_TABLE
1050
endif
1051

1052 1053 1054
ifeq ($(enable_vtable_verify),yes)
# These are used in vtable verification; see comments in source files for
# more details.
Rainer Orth committed
1055 1056 1057 1058 1059

# Override -finhibit-size-directive to avoid mismatch between libgcc and libvtv
# compilations.
VTV_CFLAGS = $(CRTSTUFF_T_CFLAGS_S) -fno-inhibit-size-directive

1060
vtv_start$(objext): $(srcdir)/vtv_start.c
Rainer Orth committed
1061
	$(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_start.c
1062 1063

vtv_end$(objext): $(srcdir)/vtv_end.c
Rainer Orth committed
1064
	$(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_end.c
1065 1066

vtv_start_preinit$(objext): $(srcdir)/vtv_start_preinit.c
Rainer Orth committed
1067
	$(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_start_preinit.c
1068 1069

vtv_end_preinit$(objext): $(srcdir)/vtv_end_preinit.c
Rainer Orth committed
1070
	$(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_end_preinit.c
1071
endif
1072 1073 1074 1075 1076 1077 1078 1079

ifeq ($(CUSTOM_CRTIN),)
# -x assembler-with-cpp is only needed on case-insensitive filesystem.
crti$(objext): $(srcdir)/config/$(cpu_type)/crti.S
	$(crt_compile) -c -x assembler-with-cpp $<

crtn$(objext): $(srcdir)/config/$(cpu_type)/crtn.S
	$(crt_compile) -c -x assembler-with-cpp $<
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
endif

# Build extra startfiles in the libgcc directory.
.PHONY: libgcc-extra-parts
libgcc-extra-parts: $(EXTRA_PARTS)

	# Early copyback; see "all" above for the rationale.  The
	# early copy is necessary so that the gcc -B options find
	# the right startup files when linking shared libgcc.
	$(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
	parts="$(EXTRA_PARTS)";					\
	for file in $$parts; do					\
	  rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file;		\
	  $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/;	\
1094 1095 1096 1097
	  case $$file in 					\
	    *.a)						\
	      $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;;	\
	  esac;							\
1098 1099 1100 1101
	done

all: $(extra-parts)

1102 1103 1104
$(libgcc-objects) $(libgcc-s-objects) $(libgcc-eh-objects) \
	$(libgcov-objects) \
	$(libunwind-objects) $(libunwind-s-objects) \
1105
	$(EXTRA_PARTS): $(LIBGCC_LINKS) libgcc_tm.h
1106

1107
# Copy unwind.h to the place where gcc will look for it at build-time
1108
install-unwind_h-forbuild: unwind.h
1109 1110 1111 1112
	dest=$(gcc_objdir)/include/tmp$$$$-unwind.h; \
	cp unwind.h $$dest; \
	chmod a+r $$dest; \
	sh $(srcdir)/../move-if-change $$dest $(gcc_objdir)/include/unwind.h
1113

1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
# Copy unwind.h to the place where gcc will look at run-time, once installed
#
# This is redundant with the internal copy above when using a regular toplevel
# "install" target, because gcc's install will copy to the destination as well.
#
# This is however useful for "install-no-fixincludes" case, when only the gcc
# internal headers are copied by gcc's install.
install-unwind_h:
	$(mkinstalldirs) $(DESTDIR)$(libsubdir)/include
	$(INSTALL_DATA) unwind.h $(DESTDIR)$(libsubdir)/include

all: install-unwind_h-forbuild
1126

1127 1128 1129 1130
install-gcov_h:
	$(mkinstalldirs) $(DESTDIR)$(libsubdir)/include
	$(INSTALL_DATA) $(srcdir)/gcov.h $(DESTDIR)$(libsubdir)/include

1131
# Documentation targets (empty).
1132
.PHONY: info html dvi pdf install-info install-html install-pdf
1133

1134
info:
1135
install-info:
1136
html:
1137
install-html:
1138 1139
dvi:
pdf:
1140
install-pdf:
1141

1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
# Install rules.  These do not depend on "all", so that they can be invoked
# recursively from it.
install-libunwind:
	$(mkinstalldirs) $(DESTDIR)$(inst_slibdir)

	# NOTE: Maybe this should go into $(inst_libdir), but this
	# is where the old mklibgcc.in put it.
	$(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/
	chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a
	$(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a

	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
		@shlib_base_name@,libunwind,$(subst \
		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))

install-shared:
	$(mkinstalldirs) $(DESTDIR)$(inst_libdir)

	$(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/
	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a

	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
		@shlib_base_name@,libgcc_s,$(subst \
		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))

1168
install-leaf: $(install-shared) $(install-libunwind)
1169 1170 1171 1172 1173
	$(mkinstalldirs) $(DESTDIR)$(inst_libdir)

	$(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/
	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a
	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a
1174
ifeq ($(enable_gcov),yes)
1175 1176 1177
	$(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/
	chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a
	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a
1178
endif
1179 1180 1181 1182 1183

	parts="$(INSTALL_PARTS)";				\
	for file in $$parts; do					\
	  rm -f $(DESTDIR)$(inst_libdir)/$$file;		\
	  $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/;	\
1184 1185 1186 1187
	  case $$file in 					\
	    *.a)						\
	      $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;;	\
	  esac;							\
1188 1189
	done

1190
install: install-leaf install-unwind_h install-gcov_h
1191
	@: $(MAKE) ; $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
1192

1193 1194 1195
install-strip: install

.PHONY: install install-shared install-libunwind install-strip
1196
.PHONY: install-unwind_h install-unwind_h-forbuild
1197
.PHONY: install-gcov_h
1198 1199 1200 1201 1202 1203

# Don't export variables to the environment, in order to not confuse
# configure.
.NOEXPORT:

include $(srcdir)/empty.mk $(wildcard *.dep)