]> git.ipfire.org Git - thirdparty/gcc.git/blame - configure.ac
Sync with binutils: GCC: Pass --plugin to AR and RANLIB
[thirdparty/gcc.git] / configure.ac
CommitLineData
beeaf216 1# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
ec8fd1c0 2# 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
88252529 3# 2014, 2015, 2016, 2019, 2022 Free Software Foundation, Inc.
6599da04
JM
4#
5# This file is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License as published by
309c24a9 7# the Free Software Foundation; either version 3 of the License, or
6599da04
JM
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
309c24a9
JJ
16# along with this program; see the file COPYING3. If not see
17# <http://www.gnu.org/licenses/>.
6599da04
JM
18
19##############################################################################
671aa708
NN
20### WARNING: this file contains embedded tabs. Do not run untabify on this file.
21
7142fb32
PB
22m4_include(config/acx.m4)
23m4_include(config/override.m4)
38d24731 24m4_include(config/proginstall.m4)
7413962d 25m4_include(config/elf.m4)
ffac9597 26m4_include(config/ax_cxx_compile_stdcxx.m4)
126f707e 27m4_include(config/gcc-plugin.m4)
592c90ff
KG
28m4_include([libtool.m4])
29m4_include([ltoptions.m4])
30m4_include([ltsugar.m4])
31m4_include([ltversion.m4])
32m4_include([lt~obsolete.m4])
33ad93b9 33m4_include([config/isl.m4])
ad6717df 34
671aa708 35AC_INIT(move-if-change)
0115d4a3 36AC_DISABLE_OPTION_CHECKING
1c710c3c 37
ad33ff57
RW
38progname=$0
39# if PWD already has a value, it is probably wrong.
40if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi
41
42# Export original configure arguments for use by sub-configures.
43# Quote arguments with shell meta charatcers.
44TOPLEVEL_CONFIGURE_ARGUMENTS=
45set -- "$progname" "$@"
46for ac_arg
47do
48 case "$ac_arg" in
49 *" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
50 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
51 # if the argument is of the form -foo=baz, quote the baz part only
52 ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
53 *) ;;
54 esac
55 # Add the quoted argument to the list.
56 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
57done
58if test "$silent" = yes; then
59 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
60fi
61# Remove the initial space we just introduced and, as these will be
62# expanded by make, quote '$'.
63TOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
64AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
65
1c710c3c
DJ
66# Find the build, host, and target systems.
67ACX_NONCANONICAL_BUILD
68ACX_NONCANONICAL_HOST
69ACX_NONCANONICAL_TARGET
70
71dnl Autoconf 2.5x and later will set a default program prefix if
72dnl --target was used, even if it was the same as --host. Disable
73dnl that behavior. This must be done before AC_CANONICAL_SYSTEM
74dnl to take effect.
75test "$host_noncanonical" = "$target_noncanonical" &&
76 test "$program_prefix$program_suffix$program_transform_name" = \
77 NONENONEs,x,x, &&
78 program_transform_name=s,y,y,
79
671aa708
NN
80AC_CANONICAL_SYSTEM
81AC_ARG_PROGRAM
82
1c710c3c 83m4_pattern_allow([^AS_FOR_TARGET$])dnl
0999159b 84m4_pattern_allow([^AS_FOR_BUILD$])dnl
1c710c3c 85
775956d0
NN
86# Get 'install' or 'install-sh' and its variants.
87AC_PROG_INSTALL
ad6717df 88ACX_PROG_LN
148907ea 89AC_PROG_LN_S
87264276
PB
90AC_PROG_SED
91AC_PROG_AWK
775956d0 92
fc45f3fe
DJ
93srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
94
95# We pass INSTALL explicitly to sub-makes. Make sure that it is not
96# a relative path.
97if test "$INSTALL" = "${srcdir}/install-sh -c"; then
98 INSTALL="${srcpwd}/install-sh -c"
99fi
100
671aa708
NN
101# Set srcdir to "." if that's what it is.
102# This is important for multilib support.
103pwd=`${PWDCMD-pwd}`
671aa708
NN
104if test "${pwd}" = "${srcpwd}" ; then
105 srcdir=.
106fi
107
108topsrcdir=$srcpwd
6599da04 109
4977bab6 110extra_host_args=
afabd8e6 111
6599da04
JM
112### To add a new directory to the tree, first choose whether it is a target
113### or a host dependent tool. Then put it into the appropriate list
4977bab6
ZW
114### (library or tools, host or target), doing a dependency sort.
115
116# Subdirs will be configured in the order listed in build_configdirs,
117# configdirs, or target_configdirs; see the serialization section below.
118
119# Dependency sorting is only needed when *configuration* must be done in
120# a particular order. In all cases a dependency should be specified in
121# the Makefile, whether or not it's implicitly specified here.
6599da04 122
4977bab6
ZW
123# Double entries in build_configdirs, configdirs, or target_configdirs may
124# cause circular dependencies and break everything horribly.
6599da04 125
23f6b2f9
PB
126# these library is used by various programs built for the build
127# environment
128#
929315a9 129build_libs="build-libiberty build-libcpp"
23f6b2f9
PB
130
131# these tools are built for the build environment
85bfb75e 132build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
23f6b2f9 133
6599da04 134# these libraries are used by various programs built for the host environment
eae1a5d4 135#f
3de627ff 136host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libcody libdecnumber gmp mpfr mpc isl libiconv libctf libsframe"
6599da04 137
6599da04
JM
138# these tools are built for the host environment
139# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
140# know that we are building the simulator.
4977bab6
ZW
141# binutils, gas and ld appear in that order because it makes sense to run
142# "make check" in that particular order.
38e3d868 143# If --enable-gold is used, "gold" may replace "ld".
1eee94d3 144host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
5d4a5ee6 145
6599da04
JM
146# these libraries are built for the target environment, and are built after
147# the host libraries and the host tools (which may be a cross compiler)
8499116a 148# Note that libiberty is not a target library.
291f172e 149target_libraries="target-libgcc \
eff02e4f 150 target-libbacktrace \
5d4a5ee6
JL
151 target-libgloss \
152 target-newlib \
6d3b5aea 153 target-libgomp \
48310492 154 target-libatomic \
0a35513e 155 target-libitm \
cb543528 156 target-libstdc++-v3 \
f35db108 157 target-libsanitizer \
2077db1b 158 target-libvtv \
77008252 159 target-libssp \
1ec601bf 160 target-libquadmath \
6de9cd9a 161 target-libgfortran \
012447ea 162 target-libffi \
d9cdb878 163 target-libobjc \
632e2a07 164 target-libada \
1eee94d3 165 target-libgm2 \
b4c522fa 166 target-libgo \
bb50312e
IB
167 target-libphobos \
168 target-zlib"
6599da04 169
4dbda6f0
NN
170# these tools are built using the target libraries, and are intended to
171# run only in the target environment
6599da04 172#
4dbda6f0 173# note: any program that *uses* libraries that are in the "target_libraries"
1bcce263 174# list belongs in this list.
6599da04 175#
85bfb75e 176target_tools="target-rda"
6599da04
JM
177
178################################################################################
179
6599da04
JM
180## All tools belong in one of the four categories, and are assigned above
181## We assign ${configdirs} this way to remove all embedded newlines. This
182## is important because configure will choke if they ever get through.
183## ${configdirs} is directories we build using the host tools.
184## ${target_configdirs} is directories we build using the target tools.
6599da04 185configdirs=`echo ${host_libs} ${host_tools}`
4dbda6f0 186target_configdirs=`echo ${target_libraries} ${target_tools}`
71b5d516 187build_configdirs=`echo ${build_libs} ${build_tools}`
8b87bb96 188
ac9e6043 189m4_divert_text([PARSE_ARGS],
87841584
AM
190[case $srcdir in
191 *" "*)
192m4_pushdef([AS_MESSAGE_LOG_FD], [])dnl
193 AC_MSG_ERROR([path to source, $srcdir, contains spaces])
194m4_popdef([AS_MESSAGE_LOG_FD])dnl
195 ;;
196esac
197ac_subdirs_all=`cd $srcdir && echo */configure | sed 's,/configure,,g'`
ac9e6043
RW
198])
199
6599da04
JM
200################################################################################
201
6599da04
JM
202srcname="gnu development package"
203
204# This gets set non-empty for some net releases of packages.
205appdirs=""
206
e1848dde
NN
207# Define is_cross_compiler to save on calls to 'test'.
208is_cross_compiler=
209if test x"${host}" = x"${target}" ; then
210 is_cross_compiler=no
211else
212 is_cross_compiler=yes
213fi
214
b4acb5ef 215# Find the build and target subdir names.
8b87bb96 216GCC_TOPLEV_SUBDIRS
0db770bd
RW
217# Be sure to cover against remnants of an in-tree build.
218if test $srcdir != . && test -d $srcdir/host-${host_noncanonical}; then
219 AC_MSG_ERROR([building out of tree but $srcdir contains host-${host_noncanonical}.
220Use a pristine source tree when building in a separate tree])
221fi
f653f0ab 222
55380b08
NN
223# Skipdirs are removed silently.
224skipdirs=
225# Noconfigdirs are removed loudly.
226noconfigdirs=""
6599da04 227
55380b08
NN
228use_gnu_ld=
229# Make sure we don't let GNU ld be added if we didn't want it.
230if test x$with_gnu_ld = xno ; then
231 use_gnu_ld=no
5afab7ad 232 noconfigdirs="$noconfigdirs ld gold"
6599da04
JM
233fi
234
55380b08
NN
235use_gnu_as=
236# Make sure we don't let GNU as be added if we didn't want it.
237if test x$with_gnu_as = xno ; then
238 use_gnu_as=no
239 noconfigdirs="$noconfigdirs gas"
6599da04
JM
240fi
241
d7f09764 242use_included_zlib=
a05c2c75
L
243AC_ARG_WITH(system-zlib,
244[AS_HELP_STRING([--with-system-zlib], [use installed libz])])
d7f09764
DN
245# Make sure we don't let ZLIB be added if we didn't want it.
246if test x$with_system_zlib = xyes ; then
247 use_included_zlib=no
248 noconfigdirs="$noconfigdirs zlib"
249fi
250
36ba9851
ДП
251# Don't compile the bundled readline/libreadline.a if --with-system-readline
252# is provided.
253if test x$with_system_readline = xyes ; then
254 noconfigdirs="$noconfigdirs readline"
255fi
256
55380b08
NN
257# some tools are so dependent upon X11 that if we're not building with X,
258# it's not even worth trying to configure, much less build, that tool.
6599da04 259
55380b08
NN
260case ${with_x} in
261 yes | "") ;; # the default value for this tree is that X11 is available
423ce3eb 262 no)
b4f96efe 263 skipdirs="${skipdirs} tk itcl libgui"
423ce3eb
NN
264 # We won't be able to build gdbtk without X.
265 enable_gdbtk=no
266 ;;
55380b08
NN
267 *) echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2 ;;
268esac
6599da04 269
1bcce263 270# Some are only suitable for cross toolchains.
95ddd785
NN
271# Remove these if host=target.
272cross_only="target-libgloss target-newlib target-opcodes"
6599da04 273
55380b08
NN
274case $is_cross_compiler in
275 no) skipdirs="${skipdirs} ${cross_only}" ;;
55380b08 276esac
6599da04 277
0c639b89
DD
278# If both --with-headers and --with-libs are specified, default to
279# --without-newlib.
9082a750
MR
280if test x"${with_headers}" != x && test x"${with_headers}" != xno \
281 && test x"${with_libs}" != x && test x"${with_libs}" != xno ; then
0c639b89
DD
282 if test x"${with_newlib}" = x ; then
283 with_newlib=no
284 fi
285fi
286
287# Recognize --with-newlib/--without-newlib.
288case ${with_newlib} in
289 no) skipdirs="${skipdirs} target-newlib" ;;
290 yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
291esac
292
85c64bbe
BS
293AC_ARG_ENABLE(as-accelerator-for,
294[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
295 [build as offload target compiler.
4b4f2e35 296 Specify offload host triple by ARG])])
85c64bbe
BS
297
298AC_ARG_ENABLE(offload-targets,
299[AS_HELP_STRING([--enable-offload-targets=LIST],
300 [enable offloading to devices from comma-separated LIST of
301 TARGET[=DIR]. Use optional path to find offload target compiler
302 during the build])],
303[
304 if test x"$enable_offload_targets" = x; then
305 AC_MSG_ERROR([no offload targets specified])
306 fi
307], [enable_offload_targets=])
308
fe5bfa67
TB
309AC_ARG_ENABLE(offload-defaulted,
310[AS_HELP_STRING([--enable-offload-defaulted]
311 [If enabled, configured but not installed offload compilers and
312 libgomp plugins are silently ignored. Useful for distribution
313 compilers where those are in separate optional packages.])],
314[enable_offload_defaulted=$enableval],
315[enable_offload_defaulted=])
316
21539e2e
MK
317# Handle --enable-gold, --enable-ld.
318# --disable-gold [--enable-ld]
319# Build only ld. Default option.
9580395f
L
320# --enable-gold [--enable-ld]
321# Build both gold and ld. Install gold as "ld.gold", install ld
322# as "ld.bfd" and "ld".
323# --enable-gold=default [--enable-ld]
21539e2e
MK
324# Build both gold and ld. Install gold as "ld.gold" and "ld",
325# install ld as "ld.bfd".
326# --enable-gold[=default] --disable-ld
327# Build only gold, which is then installed as both "ld.gold" and "ld".
328# --enable-gold --enable-ld=default
9580395f
L
329# Build both gold (installed as "ld.gold") and ld (installed as "ld"
330# and ld.bfd).
21539e2e
MK
331# In other words, ld is default
332# --enable-gold=default --enable-ld=default
333# Error.
334
335default_ld=
5afab7ad 336AC_ARG_ENABLE(gold,
33e39b66
AS
337[AS_HELP_STRING([[--enable-gold[=ARG]]],
338 [build gold @<:@ARG={default,yes,no}@:>@])],
5afab7ad
ILT
339ENABLE_GOLD=$enableval,
340ENABLE_GOLD=no)
21539e2e
MK
341case "${ENABLE_GOLD}" in
342 yes|default)
38e3d868
RM
343 # Check for ELF target.
344 is_elf=no
345 case "${target}" in
346 *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
0e76460f 347 | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
8c6d158a 348 | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
ff4b7a7e 349 | *-*-solaris2* | *-*-nto* | *-*-nacl*)
38e3d868
RM
350 case "${target}" in
351 *-*-linux*aout* | *-*-linux*oldld*)
352 ;;
353 *)
354 is_elf=yes
355 ;;
356 esac
357 esac
358
359 if test "$is_elf" = "yes"; then
360 # Check for target supported by gold.
5afab7ad 361 case "${target}" in
7705dfd1 362 i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
fc259b52 363 | aarch64*-*-* | mips*-*-* | s390*-*-* | loongarch*-*-*)
21539e2e
MK
364 configdirs="$configdirs gold"
365 if test x${ENABLE_GOLD} = xdefault; then
366 default_ld=gold
367 fi
38e3d868 368 ENABLE_GOLD=yes
5afab7ad
ILT
369 ;;
370 esac
38e3d868
RM
371 fi
372 ;;
373 no)
374 ;;
375 *)
376 AC_MSG_ERROR([invalid --enable-gold argument])
377 ;;
21539e2e
MK
378esac
379
380AC_ARG_ENABLE(ld,
33e39b66
AS
381[AS_HELP_STRING([[--enable-ld[=ARG]]],
382 [build ld @<:@ARG={default,yes,no}@:>@])],
21539e2e
MK
383ENABLE_LD=$enableval,
384ENABLE_LD=yes)
385
386case "${ENABLE_LD}" in
387 default)
9580395f 388 if test x${default_ld} != x; then
21539e2e
MK
389 AC_MSG_ERROR([either gold or ld can be the default ld])
390 fi
391 ;;
392 yes)
393 ;;
394 no)
395 if test x${ENABLE_GOLD} != xyes; then
396 AC_MSG_WARN([neither ld nor gold are enabled])
397 fi
398 configdirs=`echo " ${configdirs} " | sed -e 's/ ld / /'`
399 ;;
400 *)
401 AC_MSG_ERROR([invalid --enable-ld argument])
402 ;;
403esac
5afab7ad 404
78edb32f
L
405# PR gas/19109
406# Decide the default method for compressing debug sections.
407# Provide a configure time option to override our default.
408AC_ARG_ENABLE(compressed_debug_sections,
324402a0 409[AS_HELP_STRING([--enable-compressed-debug-sections={all,gas,gold,ld,none}],
78edb32f
L
410 [Enable compressed debug sections for gas, gold or ld by
411 default])],
412[
413 if test x"$enable_compressed_debug_sections" = xyes; then
414 AC_MSG_ERROR([no program with compressed debug sections specified])
415 fi
416], [enable_compressed_debug_sections=])
417
6599da04
JM
418# Configure extra directories which are host specific
419
420case "${host}" in
55380b08 421 *-cygwin*)
4977bab6 422 configdirs="$configdirs libtermcap" ;;
6599da04
JM
423esac
424
4fab7234
HPN
425# A target can indicate whether a language isn't supported for some reason.
426# Only spaces may be used in this macro; not newlines or tabs.
427unsupported_languages=
428
6599da04
JM
429# Remove more programs from consideration, based on the host or
430# target this usually means that a port of the program doesn't
431# exist yet.
432
6599da04 433case "${host}" in
111eeb6e 434 i[[3456789]]86-*-msdosdjgpp*)
c9bdb152 435 noconfigdirs="$noconfigdirs tcl tk itcl"
5d4a5ee6 436 ;;
6599da04
JM
437esac
438
6de9cd9a 439
87e6d9dc
TB
440AC_ARG_ENABLE(libquadmath,
441AS_HELP_STRING([--disable-libquadmath],
442 [do not build libquadmath directory]),
443ENABLE_LIBQUADMATH=$enableval,
444ENABLE_LIBQUADMATH=yes)
445if test "${ENABLE_LIBQUADMATH}" = "no" ; then
446 noconfigdirs="$noconfigdirs target-libquadmath"
447fi
448
449
450AC_ARG_ENABLE(libquadmath-support,
451AS_HELP_STRING([--disable-libquadmath-support],
452 [disable libquadmath support for Fortran]),
453ENABLE_LIBQUADMATH_SUPPORT=$enableval,
454ENABLE_LIBQUADMATH_SUPPORT=yes)
455enable_libquadmath_support=
456if test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
457 enable_libquadmath_support=no
458fi
459
460
d9cdb878 461AC_ARG_ENABLE(libada,
33e39b66 462[AS_HELP_STRING([--enable-libada], [build libada directory])],
d9cdb878
AC
463ENABLE_LIBADA=$enableval,
464ENABLE_LIBADA=yes)
465if test "${ENABLE_LIBADA}" != "yes" ; then
5395b47b 466 noconfigdirs="$noconfigdirs gnattools"
d9cdb878
AC
467fi
468
1eee94d3
GM
469AC_ARG_ENABLE(libgm2,
470[AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
471ENABLE_LIBGM2=$enableval,
472ENABLE_LIBGM2=no)
473if test "${ENABLE_LIBGM2}" != "yes" ; then
474 noconfigdirs="$noconfigdirs gm2tools"
475fi
476
ef0087a7 477AC_ARG_ENABLE(libssp,
33e39b66 478[AS_HELP_STRING([--enable-libssp], [build libssp directory])],
ef0087a7
KH
479ENABLE_LIBSSP=$enableval,
480ENABLE_LIBSSP=yes)
ef0087a7 481
2588b26e
RM
482AC_ARG_ENABLE(libstdcxx,
483AS_HELP_STRING([--disable-libstdcxx],
484 [do not build libstdc++-v3 directory]),
485ENABLE_LIBSTDCXX=$enableval,
486ENABLE_LIBSTDCXX=default)
487[if test "${ENABLE_LIBSTDCXX}" = "no" ; then
1007a55c 488 noconfigdirs="$noconfigdirs target-libstdc++-v3"
2588b26e
RM
489fi]
490
44a7d18d 491# Enable libgomp by default on hosted POSIX systems, and a few others.
27079765 492if test x$enable_libgomp = x ; then
953ff289 493 case "${target}" in
416ac4d4 494 *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
953ff289 495 ;;
8c6d158a 496 *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly*)
953ff289 497 ;;
b24513a1 498 *-*-solaris2* | *-*-hpux11*)
953ff289 499 ;;
cac90078 500 *-*-darwin* | *-*-aix*)
953ff289 501 ;;
29b1533a 502 nvptx*-*-* | amdgcn*-*-*)
44a7d18d 503 ;;
953ff289
DN
504 *)
505 noconfigdirs="$noconfigdirs target-libgomp"
506 ;;
507 esac
27079765 508fi
953ff289 509
48310492
RH
510# Disable libatomic on unsupported systems.
511if test -d ${srcdir}/libatomic; then
512 if test x$enable_libatomic = x; then
513 AC_MSG_CHECKING([for libatomic support])
514 if (srcdir=${srcdir}/libatomic; \
515 . ${srcdir}/configure.tgt; \
516 test -n "$UNSUPPORTED")
517 then
518 AC_MSG_RESULT([no])
519 noconfigdirs="$noconfigdirs target-libatomic"
520 else
521 AC_MSG_RESULT([yes])
522 fi
523 fi
524fi
525
e948157d
RH
526# Disable libitm on unsupported systems.
527if test -d ${srcdir}/libitm; then
528 if test x$enable_libitm = x; then
529 AC_MSG_CHECKING([for libitm support])
530 if (srcdir=${srcdir}/libitm; \
531 . ${srcdir}/configure.tgt; \
532 test -n "$UNSUPPORTED")
533 then
534 AC_MSG_RESULT([no])
535 noconfigdirs="$noconfigdirs target-libitm"
536 else
537 AC_MSG_RESULT([yes])
538 fi
539 fi
0a35513e
AH
540fi
541
93bf5390
RH
542# Disable libsanitizer on unsupported systems.
543if test -d ${srcdir}/libsanitizer; then
544 if test x$enable_libsanitizer = x; then
545 AC_MSG_CHECKING([for libsanitizer support])
546 if (srcdir=${srcdir}/libsanitizer; \
547 . ${srcdir}/configure.tgt; \
548 test -n "$UNSUPPORTED")
549 then
550 AC_MSG_RESULT([no])
551 noconfigdirs="$noconfigdirs target-libsanitizer"
552 else
553 AC_MSG_RESULT([yes])
554 fi
555 fi
556fi
557
2077db1b
CT
558# Disable libvtv on unsupported systems.
559if test -d ${srcdir}/libvtv; then
560 if test x$enable_libvtv = x; then
561 AC_MSG_CHECKING([for libvtv support])
562 if (srcdir=${srcdir}/libvtv; \
563 . ${srcdir}/configure.tgt; \
1e74b850 564 test "$VTV_SUPPORTED" != "yes")
2077db1b
CT
565 then
566 AC_MSG_RESULT([no])
567 noconfigdirs="$noconfigdirs target-libvtv"
568 else
569 AC_MSG_RESULT([yes])
570 fi
571 fi
572fi
573
d7a29167
DE
574# Disable libquadmath for some systems.
575case "${target}" in
e7fae550
DE
576 avr-*-*)
577 noconfigdirs="$noconfigdirs target-libquadmath"
578 ;;
d7a29167
DE
579 # libquadmath is unused on AIX and libquadmath build process use of
580 # LD_LIBRARY_PATH can break AIX bootstrap.
581 powerpc-*-aix* | rs6000-*-aix*)
582 noconfigdirs="$noconfigdirs target-libquadmath"
583 ;;
584esac
585
1e9e0e23
JM
586# Disable libssp for some systems.
587case "${target}" in
588 avr-*-*)
b318fb4b 589 # No hosted I/O support.
1e9e0e23
JM
590 noconfigdirs="$noconfigdirs target-libssp"
591 ;;
91dfef96
JM
592 bpf-*-*)
593 noconfigdirs="$noconfigdirs target-libssp"
594 ;;
1e9e0e23
JM
595 powerpc-*-aix* | rs6000-*-aix*)
596 noconfigdirs="$noconfigdirs target-libssp"
597 ;;
8d2af3a2
DD
598 pru-*-*)
599 # No hosted I/O support.
600 noconfigdirs="$noconfigdirs target-libssp"
601 ;;
85b8555e
DD
602 rl78-*-*)
603 # libssp uses a misaligned load to trigger a fault, but the RL78
604 # doesn't fault for those - instead, it gives a build-time error
605 # for explicit misaligned loads.
606 noconfigdirs="$noconfigdirs target-libssp"
607 ;;
0969ec7d
EB
608 visium-*-*)
609 # No hosted I/O support.
610 noconfigdirs="$noconfigdirs target-libssp"
611 ;;
1e9e0e23
JM
612esac
613
1e9e0e23 614# Disable libstdc++-v3 for some systems.
67a1cb2a 615# Allow user to override this if they pass --enable-libstdcxx
2588b26e
RM
616if test "${ENABLE_LIBSTDCXX}" = "default" ; then
617 case "${target}" in
618 *-*-vxworks*)
619 # VxWorks uses the Dinkumware C++ library.
620 noconfigdirs="$noconfigdirs target-libstdc++-v3"
621 ;;
afa3d80e
TS
622 amdgcn*-*-*)
623 # Not ported/fails to build when using newlib.
624 noconfigdirs="$noconfigdirs target-libstdc++-v3"
625 ;;
2588b26e
RM
626 arm*-wince-pe*)
627 # the C++ libraries don't build on top of CE's C libraries
628 noconfigdirs="$noconfigdirs target-libstdc++-v3"
629 ;;
630 avr-*-*)
631 noconfigdirs="$noconfigdirs target-libstdc++-v3"
632 ;;
91dfef96
JM
633 bpf-*-*)
634 noconfigdirs="$noconfigdirs target-libstdc++-v3"
635 ;;
fef939d6
JB
636 ft32-*-*)
637 noconfigdirs="$noconfigdirs target-libstdc++-v3"
638 ;;
2588b26e
RM
639 esac
640fi
1e9e0e23 641
91dfef96
JM
642# Disable C++ on systems where it is known to not work.
643# For testing, you can override this with --enable-languages=c++.
644case ,${enable_languages}, in
645 *,c++,*)
646 ;;
647 *)
648 case "${target}" in
649 bpf-*-*)
650 unsupported_languages="$unsupported_languages c++"
651 ;;
652 esac
653 ;;
654esac
655
656# Disable Objc on systems where it is known to not work.
657# For testing, you can override this with --enable-languages=objc.
658case ,${enable_languages}, in
659 *,objc,*)
660 ;;
661 *)
662 case "${target}" in
663 bpf-*-*)
664 unsupported_languages="$unsupported_languages objc"
665 ;;
666 esac
667 ;;
668esac
669
260eedb9
IB
670# Disable D on systems where it is known to not work.
671# For testing, you can override this with --enable-languages=d.
672case ,${enable_languages}, in
673 *,d,*)
674 ;;
675 *)
676 case "${target}" in
91dfef96 677 bpf-*-*)
260eedb9
IB
678 unsupported_languages="$unsupported_languages d"
679 ;;
680 esac
681 ;;
682esac
683
684# Disable libphobos on unsupported systems.
685# For testing, you can override this with --enable-libphobos.
686if test -d ${srcdir}/libphobos; then
687 if test x$enable_libphobos = x; then
688 AC_MSG_CHECKING([for libphobos support])
689 if (srcdir=${srcdir}/libphobos; \
690 . ${srcdir}/configure.tgt; \
7d31d331 691 test "$LIBPHOBOS_SUPPORTED" != "yes")
260eedb9
IB
692 then
693 AC_MSG_RESULT([no])
694 noconfigdirs="$noconfigdirs target-libphobos"
695 else
696 AC_MSG_RESULT([yes])
697 fi
698 fi
699fi
700
1e9e0e23
JM
701# Disable Fortran for some systems.
702case "${target}" in
703 mmix-*-*)
704 # See <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00572.html>.
705 unsupported_languages="$unsupported_languages fortran"
706 ;;
91dfef96
JM
707 bpf-*-*)
708 unsupported_languages="$unsupported_languages fortran"
709 ;;
1e9e0e23
JM
710esac
711
012447ea
JJ
712# Disable libffi for some systems.
713case "${target}" in
714 powerpc-*-darwin*)
715 ;;
716 i[[3456789]]86-*-darwin*)
717 ;;
718 x86_64-*-darwin[[912]]*)
719 ;;
720 *-*-darwin*)
721 noconfigdirs="$noconfigdirs target-libffi"
722 ;;
723 *-*-netware*)
724 noconfigdirs="$noconfigdirs target-libffi"
725 ;;
726 *-*-phoenix*)
727 noconfigdirs="$noconfigdirs target-libffi"
728 ;;
729 *-*-rtems*)
730 noconfigdirs="$noconfigdirs target-libffi"
731 ;;
732 *-*-tpf*)
733 noconfigdirs="$noconfigdirs target-libffi"
734 ;;
735 *-*-uclinux*)
736 noconfigdirs="$noconfigdirs target-libffi"
737 ;;
738 *-*-vxworks*)
739 noconfigdirs="$noconfigdirs target-libffi"
740 ;;
b20e7532
AT
741 aarch64*-*-freebsd*)
742 noconfigdirs="$noconfigdirs target-libffi"
743 ;;
012447ea
JJ
744 alpha*-*-*vms*)
745 noconfigdirs="$noconfigdirs target-libffi"
746 ;;
747 arm*-*-freebsd*)
748 noconfigdirs="$noconfigdirs target-libffi"
749 ;;
750 arm-wince-pe)
751 noconfigdirs="$noconfigdirs target-libffi"
752 ;;
753 arm*-*-symbianelf*)
754 noconfigdirs="$noconfigdirs target-libffi"
755 ;;
91dfef96
JM
756 bpf-*-*)
757 noconfigdirs="$noconfigdirs target-libffi"
758 ;;
012447ea
JJ
759 cris-*-* | crisv32-*-*)
760 case "${target}" in
761 *-*-linux*)
762 ;;
763 *) # See PR46792 regarding target-libffi.
764 noconfigdirs="$noconfigdirs target-libffi";;
765 esac
766 ;;
767 hppa*64*-*-hpux*)
768 noconfigdirs="$noconfigdirs target-libffi"
769 ;;
012447ea
JJ
770 ia64*-*-*vms*)
771 noconfigdirs="$noconfigdirs target-libffi"
772 ;;
773 i[[3456789]]86-w64-mingw*)
774 noconfigdirs="$noconfigdirs target-libffi"
775 ;;
776 i[[3456789]]86-*-mingw*)
777 noconfigdirs="$noconfigdirs target-libffi"
778 ;;
779 x86_64-*-mingw*)
780 noconfigdirs="$noconfigdirs target-libffi"
781 ;;
782 mmix-*-*)
783 noconfigdirs="$noconfigdirs target-libffi"
784 ;;
785 powerpc-*-aix*)
012447ea
JJ
786 ;;
787 rs6000-*-aix*)
012447ea
JJ
788 ;;
789 ft32-*-*)
790 noconfigdirs="$noconfigdirs target-libffi"
791 ;;
792 *-*-lynxos*)
793 noconfigdirs="$noconfigdirs target-libffi"
794 ;;
795esac
796
797# Disable the go frontend on systems where it is known to not work. Please keep
798# this in sync with contrib/config-list.mk.
799case "${target}" in
91dfef96 800*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* )
012447ea
JJ
801 unsupported_languages="$unsupported_languages go"
802 ;;
803esac
804
f9d09df0
TT
805# Only allow gdbserver on some systems.
806if test -d ${srcdir}/gdbserver; then
807 if test x$enable_gdbserver = x; then
808 AC_MSG_CHECKING([for gdbserver support])
809 if (srcdir=${srcdir}/gdbserver; \
810 . ${srcdir}/configure.srv; \
811 test -n "$UNSUPPORTED")
812 then
813 AC_MSG_RESULT([no])
814 noconfigdirs="$noconfigdirs gdbserver"
815 else
816 AC_MSG_RESULT([yes])
817 fi
818 fi
819fi
820
cdbc9e92
ILT
821# Disable libgo for some systems where it is known to not work.
822# For testing, you can easily override this with --enable-libgo.
823if test x$enable_libgo = x; then
824 case "${target}" in
825 *-*-darwin*)
826 # PR 46986
827 noconfigdirs="$noconfigdirs target-libgo"
828 ;;
829 *-*-cygwin* | *-*-mingw*)
830 noconfigdirs="$noconfigdirs target-libgo"
831 ;;
91dfef96
JM
832 bpf-*-*)
833 noconfigdirs="$noconfigdirs target-libgo"
834 ;;
cdbc9e92
ILT
835 esac
836fi
837
c03353e2
RIL
838# Default libgloss CPU subdirectory.
839libgloss_dir="$target_cpu"
6de9cd9a 840
fbcf0dca
JM
841case "${target}" in
842 sh*-*-pe|mips*-*-pe|*arm-wince-pe)
843 libgloss_dir=wince
844 ;;
4dddfc74
YZ
845 aarch64*-*-* )
846 libgloss_dir=aarch64
847 ;;
fbcf0dca
JM
848 arm*-*-*)
849 libgloss_dir=arm
850 ;;
851 cris-*-* | crisv32-*-*)
852 libgloss_dir=cris
853 ;;
854 hppa*-*-*)
855 libgloss_dir=pa
856 ;;
857 i[[3456789]]86-*-*)
858 libgloss_dir=i386
859 ;;
c6c0594e 860 loongarch*-*-*)
861 libgloss_dir=loongarch
862 ;;
fbcf0dca
JM
863 m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
864 libgloss_dir=m68hc11
865 ;;
866 m68*-*-* | fido-*-*)
867 libgloss_dir=m68k
868 ;;
869 mips*-*-*)
870 libgloss_dir=mips
871 ;;
872 powerpc*-*-*)
873 libgloss_dir=rs6000
874 ;;
8d2af3a2
DD
875 pru-*-*)
876 libgloss_dir=pru
877 ;;
fbcf0dca
JM
878 sparc*-*-*)
879 libgloss_dir=sparc
880 ;;
881esac
882
6a789d5e 883# Disable newlib and libgloss for various target OSes.
6599da04 884case "${target}" in
6a789d5e
JM
885 alpha*-dec-osf*)
886 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
887 ;;
888 i[[3456789]]86-*-linux*)
889 # This section makes it possible to build newlib natively on linux.
890 # If we are using a cross compiler then don't configure newlib.
891 if test x${is_cross_compiler} != xno ; then
892 noconfigdirs="$noconfigdirs target-newlib"
893 fi
894 noconfigdirs="$noconfigdirs target-libgloss"
895 # If we are not using a cross compiler, do configure newlib.
896 # Note however, that newlib will only be configured in this situation
897 # if the --with-newlib option has been given, because otherwise
898 # 'target-newlib' will appear in skipdirs.
899 ;;
900 i[[3456789]]86-*-rdos*)
901 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
902 ;;
903 sh*-*-pe|mips*-*-pe|arm-wince-pe)
904 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
905 ;;
906 sparc-*-sunos4*)
907 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
908 ;;
91dfef96
JM
909 bpf-*-*)
910 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
911 ;;
6a789d5e
JM
912 *-*-aix*)
913 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
914 ;;
915 *-*-beos*)
916 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
917 ;;
3fa03ff9 918 *-*-chorusos)
0036370f 919 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
3fa03ff9 920 ;;
6a789d5e
JM
921 *-*-dragonfly*)
922 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
923 ;;
924 *-*-freebsd*)
925 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
926 ;;
927 *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
928 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
929 ;;
930 *-*-lynxos*)
931 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
932 ;;
933 *-*-mingw*)
934 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
935 ;;
936 *-*-netbsd*)
937 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
938 ;;
939 *-*-netware*)
940 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
941 ;;
942 *-*-tpf*)
943 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
944 ;;
945 *-*-uclinux*)
946 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
947 ;;
948 *-*-vxworks*)
949 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
950 ;;
951esac
952
953case "${target}" in
954 *-*-chorusos)
955 ;;
3be96231
TG
956 aarch64-*-darwin*)
957 noconfigdirs="$noconfigdirs ld gas gdb gprof"
958 noconfigdirs="$noconfigdirs sim target-rda"
959 ;;
7431c1a1
AS
960 amdgcn*-*-*)
961 ;;
3be96231
TG
962 arm-*-darwin*)
963 noconfigdirs="$noconfigdirs ld gas gdb gprof"
964 noconfigdirs="$noconfigdirs sim target-rda"
965 ;;
75eeae1a 966 powerpc-*-darwin*)
e1514c3f 967 noconfigdirs="$noconfigdirs ld gas gdb gprof"
9c8f9ec2 968 noconfigdirs="$noconfigdirs sim target-rda"
940cde4d 969 ;;
354ebf88
RW
970 i[[3456789]]86-*-darwin*)
971 noconfigdirs="$noconfigdirs ld gprof"
972 noconfigdirs="$noconfigdirs sim target-rda"
973 ;;
974 x86_64-*-darwin[[912]]*)
0db3a858
TG
975 noconfigdirs="$noconfigdirs ld gas gprof"
976 noconfigdirs="$noconfigdirs sim target-rda"
977 ;;
42c1cd8a
AT
978 *-*-darwin*)
979 noconfigdirs="$noconfigdirs ld gas gdb gprof"
980 noconfigdirs="$noconfigdirs sim target-rda"
42c1cd8a 981 ;;
8c6d158a 982 *-*-dragonfly*)
8c6d158a 983 ;;
c3f84f61 984 *-*-freebsd*)
88252529 985 if test "x$with_gmp" = x \
c0d0a722 986 && ! test -d ${srcdir}/gmp \
6de9cd9a
DN
987 && test -f /usr/local/include/gmp.h; then
988 with_gmp=/usr/local
989 fi
6de9cd9a 990 ;;
ef4e7569
US
991 *-*-kaos*)
992 # Remove unsupported stuff on all kaOS configurations.
ef4e7569
US
993 noconfigdirs="$noconfigdirs target-libgloss"
994 ;;
51584787 995 *-*-netbsd*)
51584787 996 ;;
61fec9ff 997 *-*-netware*)
6599da04 998 ;;
fd6487af
JS
999 *-*-phoenix*)
1000 noconfigdirs="$noconfigdirs target-libgloss"
1001 ;;
3fbc0b70 1002 *-*-rtems*)
2909494b 1003 noconfigdirs="$noconfigdirs target-libgloss"
3fbc0b70 1004 ;;
a8ba31f2
EC
1005 # The tpf target doesn't support gdb yet.
1006 *-*-tpf*)
6a789d5e 1007 noconfigdirs="$noconfigdirs gdb tcl tk libgui itcl"
a8ba31f2 1008 ;;
5785c0ed 1009 *-*-uclinux*)
6a789d5e 1010 noconfigdirs="$noconfigdirs target-rda"
5785c0ed 1011 ;;
6599da04 1012 *-*-vxworks*)
6599da04 1013 ;;
b104e095 1014 alpha*-dec-osf*)
603606e7 1015 # ld works, but does not support shared libraries.
6599da04 1016 # gas doesn't generate exception information.
6a789d5e 1017 noconfigdirs="$noconfigdirs gas ld"
6599da04
JM
1018 ;;
1019 alpha*-*-*vms*)
2909494b 1020 noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
6599da04
JM
1021 ;;
1022 alpha*-*-*)
1023 # newlib is not 64 bit ready
2909494b 1024 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
6599da04 1025 ;;
91dfef96
JM
1026 bpf-*-*)
1027 noconfigdirs="$noconfigdirs target-libobjc target-libbacktrace"
1028 ;;
3a685f6f 1029 sh*-*-pe|mips*-*-pe|*arm-wince-pe)
b4f96efe 1030 noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
3a685f6f 1031 ;;
2fd88f4f
AK
1032 arc*-*-*)
1033 noconfigdirs="$noconfigdirs sim"
1034 ;;
6599da04 1035 arm-*-pe*)
2909494b 1036 noconfigdirs="$noconfigdirs target-libgloss"
6599da04 1037 ;;
5d4a5ee6 1038 arm-*-riscix*)
0036370f 1039 noconfigdirs="$noconfigdirs ld target-libgloss"
5d4a5ee6 1040 ;;
b588ae30
GJL
1041 avr-*-*)
1042 if test x${with_avrlibc} != xno; then
1043 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
1044 fi
1045 ;;
a5a438f5 1046 c4x-*-* | tic4x-*-*)
0036370f 1047 noconfigdirs="$noconfigdirs target-libgloss"
ab50d72b 1048 ;;
0036370f
JM
1049 tic54x-*-*)
1050 noconfigdirs="$noconfigdirs target-libgloss gdb"
ab50d72b 1051 ;;
6599da04 1052 d10v-*-*)
0036370f 1053 noconfigdirs="$noconfigdirs target-libgloss"
d207ebef
JM
1054 ;;
1055 d30v-*-*)
0036370f 1056 noconfigdirs="$noconfigdirs gdb"
6599da04 1057 ;;
09b5f8bf 1058 fr30-*-elf*)
2909494b 1059 noconfigdirs="$noconfigdirs gdb"
09b5f8bf 1060 ;;
a05c2c75
L
1061 ft32-*-*)
1062 noconfigdirs="$noconfigdirs target-rda gprof"
1063 ;;
55f2d967 1064 moxie-*-*)
a05c2c75 1065 noconfigdirs="$noconfigdirs"
55f2d967 1066 ;;
ab50d72b 1067 h8300*-*-*)
2909494b 1068 noconfigdirs="$noconfigdirs target-libgloss"
ab50d72b 1069 ;;
6599da04 1070 h8500-*-*)
0036370f 1071 noconfigdirs="$noconfigdirs target-libgloss"
6599da04 1072 ;;
a05c2c75
L
1073 hppa*64*-*-hpux*)
1074 noconfigdirs="$noconfigdirs gdb"
1075 ;;
4569f85e 1076 hppa*64*-*-linux*)
cdbff0ab 1077 ;;
56f8587a 1078 hppa*-*-linux*)
3e732ba0 1079 ;;
6599da04 1080 hppa*-*-*elf* | \
bae29210 1081 hppa*-*-lites* | \
66350331 1082 hppa*-*-openbsd* | \
bae29210 1083 hppa*64*-*-*)
6599da04 1084 ;;
c03353e2 1085 hppa*-*-pro*)
c03353e2 1086 ;;
6599da04 1087 hppa*-*-*)
2909494b 1088 noconfigdirs="$noconfigdirs ld"
d207ebef 1089 ;;
fb87ad5d 1090 i960-*-*)
0036370f 1091 noconfigdirs="$noconfigdirs gdb"
fb87ad5d 1092 ;;
d207ebef
JM
1093 ia64*-*-elf*)
1094 # No gdb support yet.
1bcce263 1095 noconfigdirs="$noconfigdirs readline libgui itcl gdb"
d207ebef 1096 ;;
ab50d72b 1097 ia64*-**-hpux*)
5a2931d1 1098 # No ld support yet.
a05c2c75 1099 noconfigdirs="$noconfigdirs gdb libgui itcl ld"
ab50d72b 1100 ;;
52535a64 1101 ia64*-*-*vms*)
091fe9ca
TG
1102 # No ld support yet.
1103 noconfigdirs="$noconfigdirs libgui itcl ld"
52535a64 1104 ;;
ef4c4300 1105 i[[3456789]]86-w64-mingw*)
ef4c4300
KT
1106 ;;
1107 i[[3456789]]86-*-mingw*)
b91f0a41 1108 target_configdirs="$target_configdirs target-winsup"
5d571eaa 1109 ;;
d207ebef
JM
1110 *-*-cygwin*)
1111 target_configdirs="$target_configdirs target-libtermcap target-winsup"
1bcce263 1112 noconfigdirs="$noconfigdirs target-libgloss"
801e2270 1113 # always build newlib if winsup directory is present.
b91f0a41 1114 if test -d "$srcdir/winsup/cygwin"; then
801e2270 1115 skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
c8e6cd41 1116 elif test -d "$srcdir/newlib"; then
b91f0a41 1117 echo "Warning: winsup/cygwin is missing so newlib can't be built."
801e2270 1118 fi
5d571eaa 1119 ;;
f2a0e225 1120 i[[3456789]]86-*-pe)
ebb9f8b0 1121 noconfigdirs="$noconfigdirs target-libgloss"
6599da04 1122 ;;
f2a0e225 1123 i[[3456789]]86-*-sco3.2v5*)
6599da04
JM
1124 # The linker does not yet know about weak symbols in COFF,
1125 # and is not configured to handle mixed ELF and COFF.
0036370f 1126 noconfigdirs="$noconfigdirs ld target-libgloss"
6599da04 1127 ;;
f2a0e225 1128 i[[3456789]]86-*-sco*)
0036370f 1129 noconfigdirs="$noconfigdirs gprof target-libgloss"
6599da04 1130 ;;
fbdd5d87 1131 i[[3456789]]86-*-solaris2* | x86_64-*-solaris2.1[[0-9]]*)
7c01b2b5 1132 noconfigdirs="$noconfigdirs target-libgloss"
6599da04 1133 ;;
f2a0e225 1134 i[[3456789]]86-*-sysv4*)
0036370f 1135 noconfigdirs="$noconfigdirs target-libgloss"
6599da04 1136 ;;
f2a0e225 1137 i[[3456789]]86-*-beos*)
6a789d5e 1138 noconfigdirs="$noconfigdirs gdb"
3aa83176 1139 ;;
d1f8db0c 1140 i[[3456789]]86-*-rdos*)
6a789d5e 1141 noconfigdirs="$noconfigdirs gdb"
c03353e2 1142 ;;
d344dce9 1143 mmix-*-*)
2909494b 1144 noconfigdirs="$noconfigdirs gdb"
d344dce9 1145 ;;
ab34901f 1146 mt-*-*)
79dd769c
AH
1147 noconfigdirs="$noconfigdirs sim"
1148 ;;
58b40a67
FT
1149 nfp-*-*)
1150 noconfigdirs="$noconfigdirs ld gas gdb gprof sim"
1151 noconfigdirs="$noconfigdirs $target_libraries"
1152 ;;
e6cbe965
SC
1153 pdp11-*-*)
1154 noconfigdirs="$noconfigdirs gdb gprof"
1155 ;;
6599da04
JM
1156 powerpc-*-aix*)
1157 # copied from rs6000-*-* entry
6a789d5e 1158 noconfigdirs="$noconfigdirs gprof"
6599da04 1159 ;;
4569f85e 1160 powerpc*-*-winnt* | powerpc*-*-pe*)
6599da04 1161 target_configdirs="$target_configdirs target-winsup"
0036370f 1162 noconfigdirs="$noconfigdirs gdb tcl tk target-libgloss itcl"
6599da04
JM
1163 # always build newlib.
1164 skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
1165 ;;
1166 # This is temporary until we can link against shared libraries
1167 powerpcle-*-solaris*)
0036370f 1168 noconfigdirs="$noconfigdirs gdb sim tcl tk itcl"
6599da04 1169 ;;
0da3b5a7 1170 powerpc-*-beos*)
6a789d5e 1171 noconfigdirs="$noconfigdirs gdb"
d207ebef 1172 ;;
6599da04 1173 rs6000-*-lynxos*)
6a789d5e 1174 noconfigdirs="$noconfigdirs gprof"
6599da04
JM
1175 ;;
1176 rs6000-*-aix*)
6a789d5e 1177 noconfigdirs="$noconfigdirs gprof"
6599da04
JM
1178 ;;
1179 rs6000-*-*)
2909494b 1180 noconfigdirs="$noconfigdirs gprof"
6599da04
JM
1181 ;;
1182 m68k-apollo-*)
0036370f 1183 noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss"
6599da04 1184 ;;
ca9fe997 1185 microblaze*)
2909494b 1186 noconfigdirs="$noconfigdirs gprof"
ca9fe997 1187 ;;
74ae587e 1188 mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
d9dced13
RS
1189 if test x$with_newlib = xyes; then
1190 noconfigdirs="$noconfigdirs gprof"
1191 fi
d9dced13 1192 ;;
6599da04 1193 mips*-*-irix5*)
0036370f 1194 noconfigdirs="$noconfigdirs gprof target-libgloss"
6599da04
JM
1195 ;;
1196 mips*-*-irix6*)
2909494b 1197 noconfigdirs="$noconfigdirs gprof target-libgloss"
6599da04 1198 ;;
6599da04 1199 mips*-*-bsd*)
bc98bcc4 1200 noconfigdirs="$noconfigdirs ld gas gprof target-libgloss"
6599da04 1201 ;;
9bec4bf0 1202 mips*-*-linux*)
9bec4bf0 1203 ;;
bc98bcc4
JBG
1204 mips*-*-ultrix* | mips*-*-osf* | mips*-*-ecoff* | mips*-*-pe* \
1205 | mips*-*-irix* | mips*-*-lnews* | mips*-*-riscos*)
1206 noconfigdirs="$noconfigdirs ld gas gprof"
1207 ;;
6599da04 1208 mips*-*-*)
2909494b 1209 noconfigdirs="$noconfigdirs gprof"
6599da04 1210 ;;
738f2522 1211 nvptx*-*-*)
738f2522
BS
1212 noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
1213 ;;
bc6d9014 1214 sh-*-*)
ea2002ba
CB
1215 case "${target}" in
1216 sh*-*-elf)
2909494b 1217 ;;
ea2002ba 1218 *)
2909494b 1219 noconfigdirs="$noconfigdirs target-libgloss" ;;
ea2002ba 1220 esac
6599da04
JM
1221 ;;
1222 sparc-*-sunos4*)
6a789d5e 1223 if test x${is_cross_compiler} = xno ; then
6599da04
JM
1224 use_gnu_ld=no
1225 fi
1226 ;;
b42f0d7e 1227 tic6x-*-*)
0d557ff8 1228 noconfigdirs="$noconfigdirs sim"
b42f0d7e 1229 ;;
6599da04 1230 v810-*-*)
0036370f 1231 noconfigdirs="$noconfigdirs bfd binutils gas gdb ld opcodes target-libgloss"
6599da04
JM
1232 ;;
1233 vax-*-*)
2909494b 1234 noconfigdirs="$noconfigdirs target-newlib target-libgloss"
6599da04 1235 ;;
1fc1d82e
MR
1236 wasm32-*-*)
1237 noconfigdirs="$noconfigdirs ld"
1238 ;;
c6c0594e 1239 loongarch*-*-linux*)
1240 ;;
1241 loongarch*-*-*)
1242 noconfigdirs="$noconfigdirs gprof"
1243 ;;
6599da04
JM
1244esac
1245
6599da04
JM
1246# If we aren't building newlib, then don't build libgloss, since libgloss
1247# depends upon some newlib header files.
1248case "${noconfigdirs}" in
1249 *target-libgloss*) ;;
1250 *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;;
55380b08 1251esac
6599da04 1252
55380b08 1253# Work in distributions that contain no compiler tools, like Autoconf.
671aa708 1254host_makefile_frag=/dev/null
55380b08
NN
1255if test -d ${srcdir}/config ; then
1256case "${host}" in
f2a0e225 1257 i[[3456789]]86-*-msdosdjgpp*)
55380b08
NN
1258 host_makefile_frag="config/mh-djgpp"
1259 ;;
1260 *-cygwin*)
2a79c47f 1261 ACX_CHECK_CYGWIN_CAT_WORKS
55380b08
NN
1262 host_makefile_frag="config/mh-cygwin"
1263 ;;
c53a18d3 1264 *-mingw*)
1f5a6b84 1265 host_makefile_frag="config/mh-mingw"
738a52d3 1266 ;;
cabb9d59 1267 alpha*-linux*)
13be44ed
UB
1268 host_makefile_frag="config/mh-alpha-linux"
1269 ;;
111eeb6e 1270 hppa*-hp-hpux*)
00afcaa0
PB
1271 host_makefile_frag="config/mh-pa"
1272 ;;
1273 hppa*-*)
1274 host_makefile_frag="config/mh-pa"
1275 ;;
54258e22 1276 i?86-*-darwin[[89]]* | i?86-*-darwin1[[0-7]]* | powerpc*-*-darwin*)
d8ed14ce 1277 host_makefile_frag="config/mh-darwin"
be8fff81 1278 ;;
d19bca38
PB
1279 powerpc-*-aix*)
1280 host_makefile_frag="config/mh-ppc-aix"
1281 ;;
1282 rs6000-*-aix*)
1283 host_makefile_frag="config/mh-ppc-aix"
1284 ;;
55380b08
NN
1285esac
1286fi
1287
e4c9c075 1288if test "${build}" != "${host}" ; then
0999159b
PB
1289 AR_FOR_BUILD=${AR_FOR_BUILD-ar}
1290 AS_FOR_BUILD=${AS_FOR_BUILD-as}
e4c9c075 1291 CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
c841dc0a 1292 CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CC_FOR_BUILD) -E}"
0999159b 1293 CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
3b5e8ee4 1294 DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
0999159b 1295 GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
632e2a07 1296 GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
b4c522fa 1297 GDC_FOR_BUILD=${GDC_FOR_BUILD-gdc}
0999159b
PB
1298 DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool}
1299 LD_FOR_BUILD=${LD_FOR_BUILD-ld}
1300 NM_FOR_BUILD=${NM_FOR_BUILD-nm}
1301 RANLIB_FOR_BUILD=${RANLIB_FOR_BUILD-ranlib}
1302 WINDRES_FOR_BUILD=${WINDRES_FOR_BUILD-windres}
1303 WINDMC_FOR_BUILD=${WINDMC_FOR_BUILD-windmc}
e4c9c075 1304else
0999159b
PB
1305 AR_FOR_BUILD="\$(AR)"
1306 AS_FOR_BUILD="\$(AS)"
e4c9c075 1307 CC_FOR_BUILD="\$(CC)"
0999159b 1308 CXX_FOR_BUILD="\$(CXX)"
3b5e8ee4 1309 DSYMUTIL_FOR_BUILD="\$(DSYMUTIL)"
0999159b 1310 GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
632e2a07 1311 GOC_FOR_BUILD="\$(GOC)"
b4c522fa 1312 GDC_FOR_BUILD="\$(GDC)"
0999159b
PB
1313 DLLTOOL_FOR_BUILD="\$(DLLTOOL)"
1314 LD_FOR_BUILD="\$(LD)"
1315 NM_FOR_BUILD="\$(NM)"
1316 RANLIB_FOR_BUILD="\$(RANLIB)"
1317 WINDRES_FOR_BUILD="\$(WINDRES)"
1318 WINDMC_FOR_BUILD="\$(WINDMC)"
c3a86da9 1319fi
e4c9c075 1320
91743432 1321AC_PROG_CC_C99
c3a86da9
DJ
1322AC_PROG_CXX
1323
1324# We must set the default linker to the linker used by gcc for the correct
1325# operation of libtool. If LD is not defined and we are using gcc, try to
1326# set the LD default to the ld used by gcc.
1327if test -z "$LD"; then
1328 if test "$GCC" = yes; then
1329 case $build in
1330 *-*-mingw*)
1331 gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
1332 *)
1333 gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
1334 esac
1335 case $gcc_prog_ld in
1336 # Accept absolute paths.
1337 [[\\/]* | [A-Za-z]:[\\/]*)]
1338 LD="$gcc_prog_ld" ;;
1339 esac
1340 fi
e4c9c075
PB
1341fi
1342
0b21f5d3
EB
1343# Check whether -static-libstdc++ -static-libgcc is supported.
1344have_static_libs=no
1345if test "$GCC" = yes; then
1346 saved_LDFLAGS="$LDFLAGS"
1347
1348 LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
1349 AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
1350 AC_LANG_PUSH(C++)
22e05272 1351 AC_LINK_IFELSE([AC_LANG_SOURCE([
0d6414b2
EB
1352#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
1353#error -static-libstdc++ not implemented
1354#endif
22e05272 1355int main() {}])],
0b21f5d3
EB
1356 [AC_MSG_RESULT([yes]); have_static_libs=yes],
1357 [AC_MSG_RESULT([no])])
1358 AC_LANG_POP(C++)
1359
1360 LDFLAGS="$saved_LDFLAGS"
1361fi
1362
e4c9c075 1363ACX_PROG_GNAT
5fee5ec3 1364ACX_PROG_GDC
a76494aa 1365ACX_PROG_CMP_IGNORE_INITIAL
e4c9c075 1366
ff3ac0f4
ILT
1367AC_ARG_ENABLE([bootstrap],
1368[AS_HELP_STRING([--enable-bootstrap],
1369 [enable bootstrapping @<:@yes if native build@:>@])],,
1370enable_bootstrap=default)
1371
1372# Issue errors and warnings for invalid/strange bootstrap combinations.
bf03b9ff
ILT
1373if test -r $srcdir/gcc/configure; then
1374 have_compiler=yes
1375else
1376 have_compiler=no
1377fi
ff3ac0f4
ILT
1378
1379case "$have_compiler:$host:$target:$enable_bootstrap" in
1380 *:*:*:no) ;;
1381
1382 # Default behavior. Enable bootstrap if we have a compiler
1383 # and we are in a native configuration.
1384 yes:$build:$build:default)
1385 enable_bootstrap=yes ;;
1386
1387 *:*:*:default)
1388 enable_bootstrap=no ;;
1389
1390 # We have a compiler and we are in a native configuration, bootstrap is ok
1391 yes:$build:$build:yes)
1392 ;;
1393
1394 # Other configurations, but we have a compiler. Assume the user knows
1395 # what he's doing.
1396 yes:*:*:yes)
1397 AC_MSG_WARN([trying to bootstrap a cross compiler])
1398 ;;
1399
1400 # No compiler: if they passed --enable-bootstrap explicitly, fail
1401 no:*:*:yes)
1402 AC_MSG_ERROR([cannot bootstrap without a compiler]) ;;
1403
1404 # Fail if wrong command line
1405 *)
1406 AC_MSG_ERROR([invalid option for --enable-bootstrap])
1407 ;;
1408esac
1409
5329b59a 1410# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a
ffac9597
JM
1411# C++11 compiler can still start the bootstrap. Otherwise, if building GCC,
1412# require C++11 (or higher).
46070488 1413if test "$enable_bootstrap:$GXX" = "yes:yes"; then
5329b59a 1414 CXX="$CXX -std=c++11"
ffac9597
JM
1415elif test "$have_compiler" = yes; then
1416 AX_CXX_COMPILE_STDCXX(11)
7ffcf5d6
TB
1417
1418 if test "${build}" != "${host}"; then
1419 AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD])
1420 fi
46070488
JM
1421fi
1422
4a5e71f2
L
1423AC_ARG_ENABLE([pgo-build],
1424[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
1425 [enable the PGO build])],
1426[enable_pgo_build=$enableval],
1427[enable_pgo_build=no])
1428
1429# Issue errors and warnings for invalid/strange PGO build combinations.
1430case "$have_compiler:$host:$target:$enable_pgo_build" in
1431 *:*:*:no) ;;
1432
1433 # Allow the PGO build only if we aren't building a compiler and
1434 # we are in a native configuration.
1435 no:$build:$build:yes | no:$build:$build:lto) ;;
1436
1437 # Disallow the PGO bootstrap if we are building a compiler.
1438 yes:*:*:yes | yes:*:*:lto)
1439 AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;
1440
1441 *)
1442 AC_MSG_ERROR([invalid option for --enable-pgo-build])
1443 ;;
1444esac
1445
1446if test "$enable_pgo_build" != "no"; then
1447 AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
1448 old_CFLAGS="$CFLAGS"
1449 PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
1450 CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
1451 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
1452 [PGO_BUILD_GEN_CFLAGS=])
1453 CFLAGS="$old_CFLAGS"
1454 if test -n "$PGO_BUILD_GEN_CFLAGS"; then
1455 AC_MSG_RESULT([yes])
1456 PGO_BUILD_USE_CFLAGS="-fprofile-use"
1457 else
1458 AC_MSG_RESULT([no])
1459 AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
1460 fi
1461
1462 if test "$enable_pgo_build" = "lto"; then
1463 AC_MSG_CHECKING([whether the compiler supports -flto=jobserver -ffat-lto-objects])
1464 old_CFLAGS="$CFLAGS"
1465 PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
1466 CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
1467 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
1468 [PGO_BUILD_LTO_CFLAGS=])
1469 CFLAGS="$old_CFLAGS"
1470 if test -n "$PGO_BUILD_LTO_CFLAGS"; then
1471 AC_MSG_RESULT([yes])
1472 else
1473 AC_MSG_RESULT([no])
1474 AC_MSG_WARN([LTO is disabled for the PGO build])
1475 fi
1476 fi
1477fi
1478AC_SUBST(PGO_BUILD_GEN_CFLAGS)
1479AC_SUBST(PGO_BUILD_USE_CFLAGS)
1480AC_SUBST(PGO_BUILD_LTO_CFLAGS)
1481
592c90ff
KG
1482# Used for setting $lt_cv_objdir
1483_LT_CHECK_OBJDIR
1484
acd26225 1485# Check for GMP, MPFR and MPC
91e0d220
AP
1486require_gmp=no
1487require_mpc=no
1488if test -d ${srcdir}/gcc ; then
1489 require_gmp=yes
1490 require_mpc=yes
1491fi
1492if test -d ${srcdir}/gdb ; then
5977d14a
CC
1493 if test "x$enable_gdb" != xno; then
1494 require_gmp=yes
1495 fi
91e0d220
AP
1496fi
1497
1498gmplibs="-lmpfr -lgmp"
1499if test x"$require_mpc" = "xyes" ; then
1500 gmplibs="-lmpc $gmplibs"
1501fi
6de9cd9a 1502gmpinc=
e69bf64b 1503have_gmp=no
acd26225
KG
1504
1505# Specify a location for mpc
1506# check for this first so it ends up on the link line before mpfr.
33e39b66
AS
1507AC_ARG_WITH(mpc,
1508[AS_HELP_STRING([--with-mpc=PATH],
1509 [specify prefix directory for installed MPC package.
1510 Equivalent to --with-mpc-include=PATH/include
1511 plus --with-mpc-lib=PATH/lib])])
1512AC_ARG_WITH(mpc-include,
1513[AS_HELP_STRING([--with-mpc-include=PATH],
1514 [specify directory for installed MPC include files])])
1515AC_ARG_WITH(mpc-lib,
1516[AS_HELP_STRING([--with-mpc-lib=PATH],
1517 [specify directory for the installed MPC library])])
acd26225
KG
1518
1519if test "x$with_mpc" != x; then
3a5729ea
KG
1520 gmplibs="-L$with_mpc/lib $gmplibs"
1521 gmpinc="-I$with_mpc/include $gmpinc"
acd26225
KG
1522fi
1523if test "x$with_mpc_include" != x; then
3a5729ea 1524 gmpinc="-I$with_mpc_include $gmpinc"
acd26225
KG
1525fi
1526if test "x$with_mpc_lib" != x; then
3a5729ea 1527 gmplibs="-L$with_mpc_lib $gmplibs"
acd26225
KG
1528fi
1529if test "x$with_mpc$with_mpc_include$with_mpc_lib" = x && test -d ${srcdir}/mpc; then
592c90ff 1530 gmplibs='-L$$r/$(HOST_SUBDIR)/mpc/src/'"$lt_cv_objdir $gmplibs"
3a5729ea 1531 gmpinc='-I$$s/mpc/src '"$gmpinc"
acd26225
KG
1532 # Do not test the mpc version. Assume that it is sufficient, since
1533 # it is in the source tree, and the library has not been built yet
1534 # but it would be included on the link line in the version check below
1535 # hence making the test fail.
3a5729ea 1536 have_gmp=yes
acd26225 1537fi
e69bf64b 1538
bebf829d
PB
1539# Specify a location for mpfr
1540# check for this first so it ends up on the link line before gmp.
33e39b66
AS
1541AC_ARG_WITH(mpfr,
1542[AS_HELP_STRING([--with-mpfr=PATH],
1543 [specify prefix directory for installed MPFR package.
1544 Equivalent to --with-mpfr-include=PATH/include
1545 plus --with-mpfr-lib=PATH/lib])])
1546AC_ARG_WITH(mpfr-include,
1547[AS_HELP_STRING([--with-mpfr-include=PATH],
1548 [specify directory for installed MPFR include files])])
1549AC_ARG_WITH(mpfr-lib,
1550[AS_HELP_STRING([--with-mpfr-lib=PATH],
1551 [specify directory for the installed MPFR library])])
bebf829d
PB
1552
1553if test "x$with_mpfr" != x; then
1554 gmplibs="-L$with_mpfr/lib $gmplibs"
3a5729ea 1555 gmpinc="-I$with_mpfr/include $gmpinc"
bebf829d 1556fi
8a877c9c 1557if test "x$with_mpfr_include" != x; then
3a5729ea 1558 gmpinc="-I$with_mpfr_include $gmpinc"
8a877c9c
KG
1559fi
1560if test "x$with_mpfr_lib" != x; then
1561 gmplibs="-L$with_mpfr_lib $gmplibs"
1562fi
e69bf64b 1563if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
8f3675f8
MR
1564 # MPFR v3.1.0 moved the sources into a src sub-directory.
1565 if ! test -d ${srcdir}/mpfr/src; then
1566 AC_MSG_ERROR([dnl
1567Building GCC with MPFR in the source tree is only handled for MPFR 3.1.0+.])
1568 fi
00f35794
BE
1569 gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs"
1570 gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc"
1571 extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir"
e69bf64b
PB
1572 # Do not test the mpfr version. Assume that it is sufficient, since
1573 # it is in the source tree, and the library has not been built yet
1574 # but it would be included on the link line in the version check below
1575 # hence making the test fail.
1576 have_gmp=yes
1577fi
bebf829d 1578
6de9cd9a 1579# Specify a location for gmp
33e39b66
AS
1580AC_ARG_WITH(gmp,
1581[AS_HELP_STRING([--with-gmp=PATH],
1582 [specify prefix directory for the installed GMP package.
1583 Equivalent to --with-gmp-include=PATH/include
1584 plus --with-gmp-lib=PATH/lib])])
1585AC_ARG_WITH(gmp-include,
1586[AS_HELP_STRING([--with-gmp-include=PATH],
1587 [specify directory for installed GMP include files])])
1588AC_ARG_WITH(gmp-lib,
1589[AS_HELP_STRING([--with-gmp-lib=PATH],
1590 [specify directory for the installed GMP library])])
6de9cd9a 1591
6de9cd9a 1592
bebf829d
PB
1593if test "x$with_gmp" != x; then
1594 gmplibs="-L$with_gmp/lib $gmplibs"
1595 gmpinc="-I$with_gmp/include $gmpinc"
6de9cd9a 1596fi
8a877c9c
KG
1597if test "x$with_gmp_include" != x; then
1598 gmpinc="-I$with_gmp_include $gmpinc"
1599fi
1600if test "x$with_gmp_lib" != x; then
1601 gmplibs="-L$with_gmp_lib $gmplibs"
1602fi
e69bf64b 1603if test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
592c90ff 1604 gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir $gmplibs"
e69bf64b 1605 gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
9183bdcf 1606 extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
592c90ff 1607 extra_mpc_gmp_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
0ff2d841 1608 extra_isl_gmp_configure_flags='--with-gmp-builddir=$$r/$(HOST_SUBDIR)/gmp'
e69bf64b
PB
1609 # Do not test the gmp version. Assume that it is sufficient, since
1610 # it is in the source tree, and the library has not been built yet
1611 # but it would be included on the link line in the version check below
1612 # hence making the test fail.
1613 have_gmp=yes
1614fi
6de9cd9a 1615
91e0d220 1616if test "x$require_gmp" = xyes && test "x$have_gmp" = xno; then
e69bf64b
PB
1617 have_gmp=yes
1618 saved_CFLAGS="$CFLAGS"
1619 CFLAGS="$CFLAGS $gmpinc"
362c6d2f
KG
1620 # Check for the recommended and required versions of GMP.
1621 AC_MSG_CHECKING([for the correct version of gmp.h])
e69bf64b 1622 AC_TRY_COMPILE([#include "gmp.h"],[
362c6d2f
KG
1623 #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1624 #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
385c0681 1625 #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,2,3)
e48d66a9 1626 choke me
e69bf64b 1627 #endif
e8fd69bb 1628 ], [AC_TRY_COMPILE([#include <gmp.h>],[
362c6d2f
KG
1629 #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1630 #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
1631 #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
1632 choke me
1633 #endif
e8fd69bb 1634 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
362c6d2f 1635 [AC_MSG_RESULT([no]); have_gmp=no])
e69bf64b 1636
acd26225 1637 # If we have GMP, check the MPFR version.
e69bf64b 1638 if test x"$have_gmp" = xyes; then
362c6d2f
KG
1639 # Check for the recommended and required versions of MPFR.
1640 AC_MSG_CHECKING([for the correct version of mpfr.h])
acd26225 1641 AC_TRY_COMPILE([#include <gmp.h>
e69bf64b 1642 #include <mpfr.h>],[
8be34204 1643 #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,0)
e69bf64b
PB
1644 choke me
1645 #endif
e8fd69bb 1646 ], [AC_TRY_COMPILE([#include <gmp.h>
acd26225 1647 #include <mpfr.h>],[
8be34204 1648 #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,6)
acd26225
KG
1649 choke me
1650 #endif
e8fd69bb 1651 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
acd26225
KG
1652 [AC_MSG_RESULT([no]); have_gmp=no])
1653 fi
1654
1655 # Check for the MPC header version.
91e0d220 1656 if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes ; then
362c6d2f 1657 # Check for the recommended and required versions of MPC.
acd26225
KG
1658 AC_MSG_CHECKING([for the correct version of mpc.h])
1659 AC_TRY_COMPILE([#include <mpc.h>],[
362c6d2f 1660 #if MPC_VERSION < MPC_VERSION_NUM(0,8,0)
acd26225
KG
1661 choke me
1662 #endif
e8fd69bb 1663 ], [AC_TRY_COMPILE([#include <mpc.h>],[
362c6d2f
KG
1664 #if MPC_VERSION < MPC_VERSION_NUM(0,8,1)
1665 choke me
1666 #endif
e8fd69bb 1667 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
362c6d2f 1668 [AC_MSG_RESULT([no]); have_gmp=no])
acd26225
KG
1669 fi
1670
1671 # Now check the MPFR library.
1672 if test x"$have_gmp" = xyes; then
1673 saved_LIBS="$LIBS"
1674 LIBS="$LIBS $gmplibs"
91e0d220
AP
1675 AC_MSG_CHECKING([for the correct version of the gmp/mpfr libraries])
1676 AC_TRY_LINK([#include <mpfr.h>],[
54e433bc
MK
1677 mpfr_t n;
1678 mpfr_t x;
e69bf64b 1679 int t;
54e433bc
MK
1680 mpfr_init (n);
1681 mpfr_init (x);
90ca6847
TB
1682 mpfr_atan2 (n, n, x, MPFR_RNDN);
1683 mpfr_erfc (n, x, MPFR_RNDN);
1684 mpfr_subnormalize (x, t, MPFR_RNDN);
3a5729ea
KG
1685 mpfr_clear(n);
1686 mpfr_clear(x);
91e0d220
AP
1687 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
1688 LIBS="$saved_LIBS"
1689 fi
1690
1691 # Now check the MPC library
1692 if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes; then
1693 saved_LIBS="$LIBS"
1694 LIBS="$LIBS $gmplibs"
1695 AC_MSG_CHECKING([for the correct version of the mpc libraries])
1696 AC_TRY_LINK([#include <mpc.h>],[
1697 mpc_t c;
3a5729ea
KG
1698 mpc_init2 (c, 53);
1699 mpc_set_ui_ui (c, 1, 1, MPC_RNDNN);
1700 mpc_cosh (c, c, MPC_RNDNN);
1701 mpc_pow (c, c, c, MPC_RNDNN);
1702 mpc_acosh (c, c, MPC_RNDNN);
1703 mpc_clear (c);
acd26225
KG
1704 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
1705 LIBS="$saved_LIBS"
e69bf64b 1706 fi
acd26225 1707
e69bf64b 1708 CFLAGS="$saved_CFLAGS"
6de9cd9a 1709
362c6d2f
KG
1710# The library versions listed in the error message below should match
1711# the HARD-minimums enforced above.
e69bf64b 1712 if test x$have_gmp != xyes; then
91e0d220
AP
1713 if test -d ${srcdir}/gcc ; then
1714 AC_MSG_ERROR([Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
3a5729ea
KG
1715Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
1716their locations. Source code for these libraries can be found at
1717their respective hosting sites as well as at
aeebd94c 1718https://gcc.gnu.org/pub/gcc/infrastructure/. See also
45ab87d4 1719http://gcc.gnu.org/install/prerequisites.html for additional info. If
3a5729ea
KG
1720you obtained GMP, MPFR and/or MPC from a vendor distribution package,
1721make sure that you have installed both the libraries and the header
1722files. They may be located in separate packages.])
91e0d220
AP
1723 else
1724 AC_MSG_ERROR([Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
1725Try the --with-gmp and/or --with-mpfr options to specify
1726their locations. If you obtained GMP and/or MPFR from a vendor
1727distribution package, make sure that you have installed both the libraries
1728and the header files. They may be located in separate packages.])
1729 fi
e69bf64b 1730 fi
70ec446f
KG
1731fi
1732
acd26225 1733# Flags needed for both GMP, MPFR and/or MPC.
6de9cd9a
DN
1734AC_SUBST(gmplibs)
1735AC_SUBST(gmpinc)
9e3eba15 1736AC_SUBST(extra_mpfr_configure_flags)
acd26225
KG
1737AC_SUBST(extra_mpc_gmp_configure_flags)
1738AC_SUBST(extra_mpc_mpfr_configure_flags)
0ff2d841 1739AC_SUBST(extra_isl_gmp_configure_flags)
6de9cd9a 1740
00020c16
ILT
1741# Libraries to use for stage1 or when not bootstrapping.
1742AC_ARG_WITH(stage1-libs,
33e39b66 1743[AS_HELP_STRING([--with-stage1-libs=LIBS], [libraries for stage1])],
00020c16
ILT
1744[if test "$withval" = "no" -o "$withval" = "yes"; then
1745 stage1_libs=
1746 else
1747 stage1_libs=$withval
1748 fi],
5dc85f7e 1749[stage1_libs=])
00020c16
ILT
1750AC_SUBST(stage1_libs)
1751
aac9103b
TT
1752# Whether or not to use -static-libstdc++ and -static-libgcc. The
1753# default is yes if gcc is being built; no otherwise. The reason for
1754# this default is that gdb is sometimes linked against GNU Source
1755# Highlight, which is a shared library that uses C++ exceptions. In
1756# this case, -static-libstdc++ will cause crashes.
1757AC_ARG_WITH(static-standard-libraries,
1758[AS_HELP_STRING([--with-static-standard-libraries],
1759 [use -static-libstdc++ and -static-libgcc (default=auto)])],
1760[], [with_static_standard_libraries=auto])
1761if test "$with_static_standard_libraries" = auto; then
1762 with_static_standard_libraries=$have_compiler
1763fi
1764
0b21f5d3
EB
1765# Linker flags to use for stage1 or when not bootstrapping.
1766AC_ARG_WITH(stage1-ldflags,
1767[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
1768[if test "$withval" = "no" -o "$withval" = "yes"; then
1769 stage1_ldflags=
1770 else
1771 stage1_ldflags=$withval
1772 fi],
1773[stage1_ldflags=
1774 # In stage 1, default to linking libstdc++ and libgcc statically with GCC
1775 # if supported. But if the user explicitly specified the libraries to use,
1776 # trust that they are doing what they want.
aac9103b
TT
1777 if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
1778 -a "$have_static_libs" = yes; then
0b21f5d3
EB
1779 stage1_ldflags="-static-libstdc++ -static-libgcc"
1780 fi])
1781AC_SUBST(stage1_ldflags)
1782
5dc85f7e 1783# Libraries to use for stage2 and later builds.
00020c16 1784AC_ARG_WITH(boot-libs,
33e39b66 1785[AS_HELP_STRING([--with-boot-libs=LIBS], [libraries for stage2 and later])],
00020c16
ILT
1786[if test "$withval" = "no" -o "$withval" = "yes"; then
1787 poststage1_libs=
1788 else
e90e6bd7 1789 poststage1_libs=$withval
00020c16 1790 fi],
5dc85f7e 1791[poststage1_libs=])
00020c16
ILT
1792AC_SUBST(poststage1_libs)
1793
ed2eaa9f
ILT
1794# Linker flags to use for stage2 and later builds.
1795AC_ARG_WITH(boot-ldflags,
33e39b66
AS
1796[AS_HELP_STRING([--with-boot-ldflags=FLAGS],
1797 [linker flags for stage2 and later])],
ed2eaa9f
ILT
1798[if test "$withval" = "no" -o "$withval" = "yes"; then
1799 poststage1_ldflags=
1800 else
1801 poststage1_ldflags=$withval
1802 fi],
1803[poststage1_ldflags=
bec93d73
ILT
1804 # In stages 2 and 3, default to linking libstdc++ and libgcc
1805 # statically. But if the user explicitly specified the libraries to
1806 # use, trust that they are doing what they want.
1807 if test "$poststage1_libs" = ""; then
ed2eaa9f
ILT
1808 poststage1_ldflags="-static-libstdc++ -static-libgcc"
1809 fi])
1810AC_SUBST(poststage1_ldflags)
1811
e357a5e0 1812# GCC GRAPHITE dependency isl.
4a9bb2aa 1813# Basic setup is inlined here, actual checks are in config/isl.m4
625afa23 1814
625afa23
RG
1815AC_ARG_WITH(isl,
1816 [AS_HELP_STRING(
1817 [--with-isl=PATH],
e357a5e0 1818 [Specify prefix directory for the installed isl package.
625afa23
RG
1819 Equivalent to --with-isl-include=PATH/include
1820 plus --with-isl-lib=PATH/lib])])
1821
eae1a5d4 1822# Treat --without-isl as a request to disable
625afa23 1823# GRAPHITE support and skip all following checks.
eae1a5d4 1824if test "x$with_isl" != "xno"; then
e357a5e0 1825 # Check for isl
625afa23
RG
1826 dnl Provide configure switches and initialize islinc & isllibs
1827 dnl with user input.
1828 ISL_INIT_FLAGS
e357a5e0 1829 dnl The versions of isl that work for Graphite
e0c0c325 1830 ISL_CHECK_VERSION()
e357a5e0 1831 dnl Only execute fail-action, if isl has been requested.
33ad93b9 1832 ISL_IF_FAILED([
e357a5e0 1833 AC_MSG_ERROR([Unable to find a usable isl. See config.log for details.])])
f8bf9252 1834fi
f8bf9252 1835
e357a5e0 1836# If the isl check failed, disable builds of in-tree variant of isl
625afa23 1837if test "x$with_isl" = xno ||
625afa23 1838 test "x$gcc_cv_isl" = xno; then
4a9bb2aa 1839 noconfigdirs="$noconfigdirs isl"
625afa23 1840 islinc=
eae1a5d4
RG
1841fi
1842
1843AC_SUBST(isllibs)
625afa23 1844AC_SUBST(islinc)
625afa23 1845
d7f09764
DN
1846# Check for LTO support.
1847AC_ARG_ENABLE(lto,
33e39b66 1848[AS_HELP_STRING([--enable-lto], [enable link time optimization support])],
d7f09764
DN
1849enable_lto=$enableval,
1850enable_lto=yes; default_enable_lto=yes)
1851
48215350
DK
1852ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
1853 build_lto_plugin=yes
1854],[if test x"$default_enable_lto" = x"yes" ; then
bb79486c 1855 case $target in
deeba76a 1856 *-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;;
48215350 1857 # On other non-ELF platforms, LTO has yet to be validated.
bb79486c
JH
1858 *) enable_lto=no ;;
1859 esac
3bec79c5 1860 else
db50fe7d
IS
1861 # Apart from ELF platforms, only Windows and Darwin support LTO so far.
1862 # It would also be nice to check the binutils support, but we don't
3bec79c5
DK
1863 # have gcc_GAS_CHECK_FEATURE available here. For now, we'll just
1864 # warn during gcc/ subconfigure; unless you're bootstrapping with
1865 # -flto it won't be needed until after installation anyway.
1866 case $target in
9e530bcd 1867 *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
3bec79c5
DK
1868 *) if test x"$enable_lto" = x"yes"; then
1869 AC_MSG_ERROR([LTO support is not enabled for this target.])
1870 fi
1871 ;;
1872 esac
1873 fi
1cd0b716 1874 # Among non-ELF, only Windows platforms support the lto-plugin so far.
48215350 1875 # Build it unless LTO was explicitly disabled.
1cd0b716 1876 case $target in
48215350 1877 *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;;
1cd0b716
DK
1878 *) ;;
1879 esac
48215350 1880])
d7f09764 1881
45b3824d
TS
1882AC_ARG_ENABLE(linker-plugin-configure-flags,
1883 [AS_HELP_STRING([[--enable-linker-plugin-configure-flags=FLAGS]],
1884 [additional flags for configuring linker plugins @<:@none@:>@])],
1885 extra_linker_plugin_configure_flags=$enableval,
1886 extra_linker_plugin_configure_flags=)
1887AC_SUBST(extra_linker_plugin_configure_flags)
1888AC_ARG_ENABLE(linker-plugin-flags,
1889 [AS_HELP_STRING([[--enable-linker-plugin-flags=FLAGS]],
1890 [additional flags for configuring and building linker plugins @<:@none@:>@])],
1891 extra_linker_plugin_flags=$enableval,
1892 extra_linker_plugin_flags=)
1893AC_SUBST(extra_linker_plugin_flags)
1894
c1fecabe
IS
1895# Handle --enable-host-pie
1896# If host PIE executables are the default (or must be forced on) for some host,
1897# we must pass that configuration to the gcc directory.
1898gcc_host_pie=
b6cb10af
MP
1899AC_ARG_ENABLE(host-pie,
1900[AS_HELP_STRING([--enable-host-pie],
1901 [build position independent host executables])],
1902[host_pie=$enableval
1903 case $host in
c1fecabe 1904 *-*-darwin2*)
b6cb10af 1905 if test x$host_pie != xyes ; then
c1fecabe
IS
1906 # for Darwin20+ this is required.
1907 AC_MSG_WARN([PIE executables are required for the configured host, host-pie setting ignored.])
b6cb10af 1908 host_pie=yes
c1fecabe 1909 gcc_host_pie=--enable-host-pie
b6cb10af
MP
1910 fi ;;
1911 *) ;;
1912 esac],
1913[case $host in
c1fecabe
IS
1914 *-*-darwin2*)
1915 # Default to PIE (mandatory for aarch64).
1916 host_pie=yes
1917 gcc_host_pie=--enable-host-pie
1918 ;;
b6cb10af
MP
1919 *) host_pie=no ;;
1920 esac])
1921
1922AC_SUBST(host_pie)
c1fecabe 1923AC_SUBST(gcc_host_pie)
b6cb10af 1924
cdfee50a
NS
1925# Enable --enable-host-shared.
1926# Checked early to determine whether jit is an 'all' language
1927AC_ARG_ENABLE(host-shared,
1928[AS_HELP_STRING([--enable-host-shared],
1929 [build host code as shared libraries])],
a1d2b162 1930[host_shared=$enableval
1edfc8f2 1931 case $host in
a1d2b162
IS
1932 x86_64-*-darwin* | aarch64-*-darwin*)
1933 if test x$host_shared != xyes ; then
1934 # PIC is the default, and actually cannot be switched off.
c1fecabe 1935 AC_MSG_WARN([PIC code is required for the configured host; host-shared setting ignored.])
a1d2b162
IS
1936 host_shared=yes
1937 fi ;;
b6cb10af 1938 *-*-darwin*)
c1fecabe
IS
1939 if test x$host_pie = xyes -a x$host_shared != xyes ; then
1940 AC_MSG_WARN([PIC code is required for PIE host executables host-shared setting ignored.])
b6cb10af
MP
1941 host_shared=yes
1942 fi ;;
a1d2b162
IS
1943 *) ;;
1944 esac],
1edfc8f2 1945[case $host in
c1fecabe 1946 # 64B x86_64 and Aarch64 Darwin default to PIC.
a1d2b162 1947 x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
c1fecabe
IS
1948 # 32B and powerpc64 Darwin must use PIC to link PIE exes.
1949 *-*-darwin*) host_shared=$host_pie ;;
b6cb10af 1950 *) host_shared=no;;
a1d2b162 1951 esac])
05048fc2 1952
cdfee50a 1953AC_SUBST(host_shared)
f8bf9252 1954
b6cb10af 1955if test x$host_shared = xyes; then
c1fecabe
IS
1956 case $host in
1957 *-*-darwin*)
1958 # Since host shared is the default for 64b Darwin, and also enabled for
1959 # host_pie, ensure that we present the PIE flag when host_pie is active.
1960 if test x$host_pie = xyes; then
1961 PICFLAG=-fPIE
1962 fi
1963 ;;
1964 *)
1965 PICFLAG=-fPIC
1966 ;;
1967 esac
b6cb10af
MP
1968elif test x$host_pie = xyes; then
1969 PICFLAG=-fPIE
1970else
1971 PICFLAG=
1972fi
1973
1974AC_SUBST(PICFLAG)
1975
05048fc2
IS
1976# If we are building PIC/PIE host executables, and we are building dependent
1977# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
1978# code.
1979host_libs_picflag=
b6cb10af 1980if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
05048fc2
IS
1981host_libs_picflag='--with-pic'
1982fi
1983AC_SUBST(host_libs_picflag)
1984
0823efed 1985# By default, C and C++ are the only stage 1 languages.
e1888513 1986stage1_languages=,c,
2805b53a 1987
00020c16 1988# Target libraries that we bootstrap.
ad1e5170 1989bootstrap_target_libs=,target-libgcc,
00020c16 1990
e4c9c075
PB
1991# Figure out what language subdirectories are present.
1992# Look if the user specified --enable-languages="..."; if not, use
1993# the environment variable $LANGUAGES if defined. $LANGUAGES might
1994# go away some day.
1995# NB: embedded tabs in this IF block -- do not untabify
1996if test -d ${srcdir}/gcc; then
1997 if test x"${enable_languages+set}" != xset; then
1998 if test x"${LANGUAGES+set}" = xset; then
1999 enable_languages="${LANGUAGES}"
6b1786aa 2000 echo configure.ac: warning: setting LANGUAGES is deprecated, use --enable-languages instead 1>&2
e4c9c075 2001 else
cdfee50a 2002 enable_languages=default
e4c9c075
PB
2003 fi
2004 else
2005 if test x"${enable_languages}" = x ||
2006 test x"${enable_languages}" = xyes;
2007 then
6b1786aa 2008 echo configure.ac: --enable-languages needs at least one language argument 1>&2
e4c9c075
PB
2009 exit 1
2010 fi
2011 fi
2012 enable_languages=`echo "${enable_languages}" | sed -e 's/[[ ,]][[ ,]]*/,/g' -e 's/,$//'`
2013
7f26dfa3
FXC
2014 # 'f95' is the old name for the 'fortran' language. We issue a warning
2015 # and make the substitution.
2016 case ,${enable_languages}, in
2017 *,f95,*)
6b1786aa 2018 echo configure.ac: warning: 'f95' as language name is deprecated, use 'fortran' instead 1>&2
7f26dfa3
FXC
2019 enable_languages=`echo "${enable_languages}" | sed -e 's/f95/fortran/g'`
2020 ;;
2021 esac
2022
0823efed
DN
2023 # If bootstrapping, C++ must be enabled.
2024 case ",$enable_languages,:$enable_bootstrap" in
2025 *,c++,*:*) ;;
2026 *:yes)
ff3ac0f4
ILT
2027 if test -f ${srcdir}/gcc/cp/config-lang.in; then
2028 enable_languages="${enable_languages},c++"
2029 else
0823efed 2030 AC_MSG_ERROR([bootstrapping requires c++ sources])
ff3ac0f4
ILT
2031 fi
2032 ;;
2033 esac
2034
e4c9c075
PB
2035 # First scan to see if an enabled language requires some other language.
2036 # We assume that a given config-lang.in will list all the language
2037 # front ends it requires, even if some are required indirectly.
2038 for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
2039 case ${lang_frag} in
2040 ..) ;;
2041 # The odd quoting in the next line works around
2042 # an apparent bug in bash 1.12 on linux.
2043 ${srcdir}/gcc/[[*]]/config-lang.in) ;;
2044 *)
69ecd18f
ILT
2045 # From the config-lang.in, get $language, $lang_requires, and
2046 # $lang_requires_boot_languages.
e4c9c075
PB
2047 language=
2048 lang_requires=
69ecd18f 2049 lang_requires_boot_languages=
d4360477
NS
2050 # set srcdir during sourcing lang_frag to the gcc dir.
2051 # Sadly overriding srcdir on the . line doesn't work in plain sh as it
2052 # polutes this shell
2053 saved_srcdir=${srcdir}
2054 srcdir=${srcdir}/gcc . ${lang_frag}
2055 srcdir=${saved_srcdir}
69ecd18f 2056 for other in ${lang_requires} ${lang_requires_boot_languages}; do
e4c9c075
PB
2057 case ,${enable_languages}, in
2058 *,$other,*) ;;
cdfee50a 2059 *,default,*) ;;
e4c9c075
PB
2060 *,all,*) ;;
2061 *,$language,*)
2062 echo " \`$other' language required by \`$language'; enabling" 1>&2
2063 enable_languages="${enable_languages},${other}"
2064 ;;
2065 esac
2066 done
69ecd18f
ILT
2067 for other in ${lang_requires_boot_languages} ; do
2068 if test "$other" != "c"; then
2069 case ,${enable_stage1_languages}, in
2070 *,$other,*) ;;
cdfee50a 2071 *,default,*) ;;
69ecd18f
ILT
2072 *,all,*) ;;
2073 *)
2074 case ,${enable_languages}, in
2075 *,$language,*)
2076 echo " '$other' language required by '$language' in stage 1; enabling" 1>&2
2077 enable_stage1_languages="$enable_stage1_languages,${other}"
2078 ;;
2079 esac
2080 ;;
2081 esac
2082 fi
2083 done
e4c9c075
PB
2084 ;;
2085 esac
2086 done
2087
e1888513 2088 new_enable_languages=,c,
d7f09764
DN
2089
2090 # If LTO is enabled, add the LTO front end.
d7f09764 2091 if test "$enable_lto" = "yes" ; then
e4c5bd48
RW
2092 case ,${enable_languages}, in
2093 *,lto,*) ;;
2094 *) enable_languages="${enable_languages},lto" ;;
2095 esac
1cd0b716 2096 if test "${build_lto_plugin}" = "yes" ; then
d7f09764 2097 configdirs="$configdirs lto-plugin"
d7f09764
DN
2098 fi
2099 fi
d7f09764 2100
426c1eb0
TS
2101 # If we're building an offloading compiler, add the LTO front end.
2102 if test x"$enable_as_accelerator_for" != x ; then
2103 case ,${enable_languages}, in
2104 *,lto,*) ;;
2105 *) enable_languages="${enable_languages},lto" ;;
2106 esac
2107 fi
2108
cdfee50a 2109 missing_languages=`echo ",$enable_languages," | sed -e s/,default,/,/ -e s/,all,/,/ -e s/,c,/,/ `
e1888513 2110 potential_languages=,c,
e4c9c075 2111
4da3b0f8
ILT
2112 enabled_target_libs=
2113 disabled_target_libs=
2114
e4c9c075
PB
2115 for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
2116 case ${lang_frag} in
2117 ..) ;;
2118 # The odd quoting in the next line works around
2119 # an apparent bug in bash 1.12 on linux.
2120 ${srcdir}/gcc/[[*]]/config-lang.in) ;;
2121 *)
2122 # From the config-lang.in, get $language, $target_libs,
2805b53a 2123 # $lang_dirs, $boot_language, and $build_by_default
e4c9c075
PB
2124 language=
2125 target_libs=
2126 lang_dirs=
1546bb64 2127 subdir_requires=
e1888513
PB
2128 boot_language=no
2129 build_by_default=yes
d4360477
NS
2130 # set srcdir during sourcing. See above about save & restore
2131 saved_srcdir=${srcdir}
2132 srcdir=${srcdir}/gcc . ${lang_frag}
2133 srcdir=${saved_srcdir}
e1888513
PB
2134 if test x${language} = x; then
2135 echo "${lang_frag} doesn't set \$language." 1>&2
2136 exit 1
2137 fi
2138
78767fd9 2139 if test "$language" = "c++"; then
0823efed 2140 boot_language=yes
00020c16
ILT
2141 fi
2142
178f875a 2143 add_this_lang=no
cdfee50a
NS
2144 # C is always enabled, so no need to add it again
2145 if test "$language" != "c"; then
2146 case ,${enable_languages}, in
2147 *,${language},*)
2148 # Language was explicitly selected; include it
d4a10d0a 2149 add_this_lang=yes
cdfee50a
NS
2150 ;;
2151 *,all,*)
2152 # All languages are enabled
2153 add_this_lang=all
2154 ;;
2155 *,default,*)
2156 # 'default' was selected, select it if it is a default language
178f875a 2157 add_this_lang=${build_by_default}
cdfee50a
NS
2158 ;;
2159 esac
2160 fi
6de9cd9a 2161
1546bb64 2162 # Disable languages that need other directories if these aren't available.
95695ad3 2163 for i in $subdir_requires; do
b6348cb3 2164 test -f "$srcdir/gcc/$i/config-lang.in" && continue
cdfee50a
NS
2165 case ${add_this_lang} in
2166 yes)
1546bb64
PB
2167 # Specifically requested language; tell them.
2168 AC_MSG_ERROR([The gcc/$i directory contains parts of $language but is missing])
2169 ;;
cdfee50a
NS
2170 all)
2171 AC_MSG_WARN([The gcc/$i directory contains parts of $language but is missing])
2172 add_this_lang=unsupported
2173 ;;
1546bb64
PB
2174 *)
2175 # Silently disable.
e1888513 2176 add_this_lang=unsupported
1546bb64
PB
2177 ;;
2178 esac
2179 done
2180
e1888513 2181 # Disable Ada if no preexisting GNAT is available.
cdfee50a
NS
2182 case ${add_this_lang}:${language}:${have_gnat} in
2183 yes:ada:no)
e1888513
PB
2184 # Specifically requested language; tell them.
2185 AC_MSG_ERROR([GNAT is required to build $language])
2186 ;;
cdfee50a
NS
2187 all:ada:no)
2188 AC_MSG_WARN([GNAT is required to build $language])
2189 add_this_lang=unsupported
2190 ;;
e1888513
PB
2191 *:ada:no)
2192 # Silently disable.
2193 add_this_lang=unsupported
2194 ;;
2195 esac
2196
5fee5ec3
IB
2197 # Disable D if no preexisting GDC is available.
2198 case ${add_this_lang}:${language}:${have_gdc} in
2199 yes:d:no)
2200 # Specifically requested language; tell them.
2201 AC_MSG_ERROR([GDC is required to build $language])
2202 ;;
2203 all:d:no)
2204 AC_MSG_WARN([GDC is required to build $language])
2205 add_this_lang=unsupported
2206 ;;
2207 *:d:no)
2208 # Silently disable.
2209 add_this_lang=unsupported
2210 ;;
2211 esac
2212
cdfee50a 2213 # Disable jit if -enable-host-shared not specified
c83027f3
NB
2214 # but not if building for Mingw. All code in Windows
2215 # is position independent code (PIC).
2216 case $target in
2217 *mingw*) ;;
2218 *)
2219 case ${add_this_lang}:${language}:${host_shared} in
2220 yes:jit:no)
2221 # PR jit/64780: explicitly specify --enable-host-shared
cdfee50a
NS
2222 AC_MSG_ERROR([
2223Enabling language "jit" requires --enable-host-shared.
2224
2225--enable-host-shared typically slows the rest of the compiler down by
2226a few %, so you must explicitly enable it.
2227
2228If you want to build both the jit and the regular compiler, it is often
2229best to do this via two separate configure/builds, in separate
2230directories, to avoid imposing the performance cost of
2231--enable-host-shared on the regular compiler.])
c83027f3
NB
2232 ;;
2233 all:jit:no)
2234 AC_MSG_WARN([--enable-host-shared required to build $language])
2235 add_this_lang=unsupported
2236 ;;
2237 *:jit:no)
2238 # Silently disable.
2239 add_this_lang=unsupported
2240 ;;
2241 esac
2242 ;;
2243 esac
cdfee50a
NS
2244
2245 # Disable a language that is unsupported by the target.
2246 case "${add_this_lang}: $unsupported_languages " in
2247 no:*) ;;
2248 unsupported:*) ;;
2249 *:*" $language "*)
2250 AC_MSG_WARN([${language} not supported for this target])
e1888513 2251 add_this_lang=unsupported
4fab7234
HPN
2252 ;;
2253 esac
2254
6de9cd9a 2255 case $add_this_lang in
e1888513 2256 unsupported)
e4c9c075 2257 # Remove language-dependent dirs.
4da3b0f8
ILT
2258 disabled_target_libs="$disabled_target_libs $target_libs"
2259 noconfigdirs="$noconfigdirs $lang_dirs"
2805b53a 2260 ;;
e1888513
PB
2261 no)
2262 # Remove language-dependent dirs; still show language as supported.
4da3b0f8
ILT
2263 disabled_target_libs="$disabled_target_libs $target_libs"
2264 noconfigdirs="$noconfigdirs $lang_dirs"
e1888513
PB
2265 potential_languages="${potential_languages}${language},"
2266 ;;
cdfee50a 2267 all|yes)
e1888513
PB
2268 new_enable_languages="${new_enable_languages}${language},"
2269 potential_languages="${potential_languages}${language},"
2805b53a 2270 missing_languages=`echo "$missing_languages" | sed "s/,$language,/,/"`
4da3b0f8 2271 enabled_target_libs="$enabled_target_libs $target_libs"
ab9dcd0c
RW
2272 case "${boot_language}:,$enable_stage1_languages," in
2273 yes:* | *:*,$language,* | *:*,yes, | *:*,all,)
340de83f 2274 # Add to (comma-separated) list of stage 1 languages.
ab9dcd0c
RW
2275 case ",$stage1_languages," in
2276 *,$language,* | ,yes, | ,all,) ;;
2277 *) stage1_languages="${stage1_languages}${language}," ;;
2278 esac
00020c16 2279 # We need to bootstrap any supporting libraries.
5fee5ec3 2280 bootstrap_target_libs=`echo "${bootstrap_target_libs}${target_libs}," | sed "s/ /,/g"`
2805b53a
NN
2281 ;;
2282 esac
2283 ;;
e4c9c075
PB
2284 esac
2285 ;;
2286 esac
2287 done
2288
4da3b0f8
ILT
2289 # Add target libraries which are only needed for disabled languages
2290 # to noconfigdirs.
2291 if test -n "$disabled_target_libs"; then
2292 for dir in $disabled_target_libs; do
2293 case " $enabled_target_libs " in
2294 *" ${dir} "*) ;;
2295 *) noconfigdirs="$noconfigdirs $dir" ;;
2296 esac
2297 done
2298 fi
2299
e1888513 2300 AC_ARG_ENABLE(stage1-languages,
33e39b66
AS
2301 [AS_HELP_STRING([[--enable-stage1-languages[=all]]],
2302 [choose additional languages to build during
2303 stage1. Mostly useful for compiler development])],
e1888513
PB
2304 [case ,${enable_stage1_languages}, in
2305 ,no,|,,)
2306 # Set it to something that will have no effect in the loop below
2307 enable_stage1_languages=c ;;
2308 ,yes,)
2309 enable_stage1_languages=`echo $new_enable_languages | \
2310 sed -e "s/^,//" -e "s/,$//" ` ;;
2311 *,all,*)
2312 enable_stage1_languages=`echo ,$enable_stage1_languages, | \
2313 sed -e "s/,all,/$new_enable_languages/" -e "s/^,//" -e "s/,$//" ` ;;
2314 esac
2315
2316 # Add "good" languages from enable_stage1_languages to stage1_languages,
2317 # while "bad" languages go in missing_languages. Leave no duplicates.
2318 for i in `echo $enable_stage1_languages | sed 's/,/ /g' `; do
2319 case $potential_languages in
2320 *,$i,*)
2321 case $stage1_languages in
2322 *,$i,*) ;;
2323 *) stage1_languages="$stage1_languages$i," ;;
2324 esac ;;
2325 *)
2326 case $missing_languages in
2327 *,$i,*) ;;
2328 *) missing_languages="$missing_languages$i," ;;
2329 esac ;;
2330 esac
2331 done])
2332
2333 # Remove leading/trailing commas that were added for simplicity
2334 potential_languages=`echo "$potential_languages" | sed -e "s/^,//" -e "s/,$//"`
79b4b7d2 2335 missing_languages=`echo "$missing_languages" | sed -e "s/^,//" -e "s/,$//"`
e1888513
PB
2336 stage1_languages=`echo "$stage1_languages" | sed -e "s/^,//" -e "s/,$//"`
2337 new_enable_languages=`echo "$new_enable_languages" | sed -e "s/^,//" -e "s/,$//"`
2338
e4c9c075
PB
2339 if test "x$missing_languages" != x; then
2340 AC_MSG_ERROR([
0cf085e4 2341The following requested languages could not be built: ${missing_languages}
e1888513 2342Supported languages are: ${potential_languages}])
e4c9c075 2343 fi
e4c9c075
PB
2344 if test "x$new_enable_languages" != "x$enable_languages"; then
2345 echo The following languages will be built: ${new_enable_languages}
e1888513 2346 enable_languages="$new_enable_languages"
e4c9c075 2347 fi
e1888513
PB
2348
2349 AC_SUBST(stage1_languages)
b2eaac4a 2350 ac_configure_args=`echo " $ac_configure_args" | sed -e "s/ '--enable-languages=[[^ ]]*'//g" -e "s/$/ '--enable-languages="$enable_languages"'/" `
e4c9c075
PB
2351fi
2352
27079765
AH
2353# Handle --disable-<component> generically.
2354for dir in $configdirs $build_configdirs $target_configdirs ; do
2355 dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g`
ac9e6043
RW
2356 varname=`echo $dirname | sed -e s/+/_/g`
2357 if eval test x\${enable_${varname}} "=" xno ; then
27079765
AH
2358 noconfigdirs="$noconfigdirs $dir"
2359 fi
2360done
2361
43c40f3e
RO
2362# Check for Boehm's garbage collector
2363AC_ARG_ENABLE(objc-gc,
2364[AS_HELP_STRING([--enable-objc-gc],
2365 [enable use of Boehm's garbage collector with the
114bf3f1
MK
2366 GNU Objective-C runtime])])
2367AC_ARG_WITH([target-bdw-gc],
2368[AS_HELP_STRING([--with-target-bdw-gc=PATHLIST],
2369 [specify prefix directory for installed bdw-gc package.
2370 Equivalent to --with-target-bdw-gc-include=PATH/include
2371 plus --with-target-bdw-gc-lib=PATH/lib])])
2372AC_ARG_WITH([target-bdw-gc-include],
2373[AS_HELP_STRING([--with-target-bdw-gc-include=PATHLIST],
2374 [specify directories for installed bdw-gc include files])])
2375AC_ARG_WITH([target-bdw-gc-lib],
2376[AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
2377 [specify directories for installed bdw-gc library])])
2378
2379case ,${enable_languages},:${enable_objc_gc} in *,objc,*:yes|*,objc,*:auto)
2380 AC_MSG_CHECKING([for bdw garbage collector])
2381 if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
825fba52
MK
2382 dnl no bdw-gw options, assume default locations
2383 AC_MSG_RESULT([using bdw-gc in default locations])
114bf3f1
MK
2384 else
2385 dnl bdw-gw options, first error checking, complete checking in libobjc
2386 if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
2387 AC_MSG_ERROR([found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing])
2388 elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
2389 AC_MSG_ERROR([found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing])
2390 else
2391 AC_MSG_RESULT([using paths configured with --with-target-bdw-gc options])
2392 fi
2393 fi
43c40f3e
RO
2394esac
2395
e4cba494 2396# Disable libitm, libsanitizer, libvtv if we're not building C++
99776ebd 2397case ,${enable_languages}, in
1007a55c 2398 *,c++,*)
5e9d6aa4 2399 # Disable libitm, libsanitizer if we're not building libstdc++
1007a55c
JW
2400 case "${noconfigdirs}" in
2401 *target-libstdc++-v3*)
5e9d6aa4 2402 noconfigdirs="$noconfigdirs target-libitm target-libsanitizer"
1007a55c
JW
2403 ;;
2404 *) ;;
2405 esac
2406 ;;
99776ebd 2407 *)
e4cba494 2408 noconfigdirs="$noconfigdirs target-libitm target-libsanitizer target-libvtv"
99776ebd
RH
2409 ;;
2410esac
7cd0cf9c 2411
dc614a83
AB
2412# If gcc/ is not in the source tree then we'll not be building a
2413# target compiler, assume in that case we don't want to build any
2414# target libraries or tools.
2415#
2416# This was added primarily for the benefit for binutils-gdb who reuse
2417# this configure script, but don't always have target tools available.
2418if test ! -d ${srcdir}/gcc; then
2419 skipdirs="${skipdirs} ${target_configdirs}"
2420fi
2421
9d069a4f
PB
2422# Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
2423# $build_configdirs and $target_configdirs.
e4c9c075
PB
2424# If we have the source for $noconfigdirs entries, add them to $notsupp.
2425
2426notsupp=""
2427for dir in . $skipdirs $noconfigdirs ; do
9d069a4f 2428 dirname=`echo $dir | sed -e s/target-//g -e s/build-//g`
e4c9c075
PB
2429 if test $dir != . && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2430 configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
2431 if test -r $srcdir/$dirname/configure ; then
2432 if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2433 true
2434 else
2435 notsupp="$notsupp $dir"
2436 fi
2437 fi
2438 fi
9d069a4f
PB
2439 if test $dir != . && echo " ${build_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2440 build_configdirs=`echo " ${build_configdirs} " | sed -e "s/ ${dir} / /"`
2441 if test -r $srcdir/$dirname/configure ; then
2442 if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2443 true
2444 else
2445 notsupp="$notsupp $dir"
2446 fi
2447 fi
2448 fi
e4c9c075
PB
2449 if test $dir != . && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2450 target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
2451 if test -r $srcdir/$dirname/configure ; then
2452 if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2453 true
2454 else
2455 notsupp="$notsupp $dir"
2456 fi
2457 fi
2458 fi
2459done
2460
e4c9c075
PB
2461# Quietly strip out all directories which aren't configurable in this tree.
2462# This relies on all configurable subdirectories being autoconfiscated, which
2463# is now the case.
23f6b2f9
PB
2464build_configdirs_all="$build_configdirs"
2465build_configdirs=
2466for i in ${build_configdirs_all} ; do
2467 j=`echo $i | sed -e s/build-//g`
2468 if test -f ${srcdir}/$j/configure ; then
2469 build_configdirs="${build_configdirs} $i"
2470 fi
2471done
2472
e4c9c075
PB
2473configdirs_all="$configdirs"
2474configdirs=
2475for i in ${configdirs_all} ; do
2476 if test -f ${srcdir}/$i/configure ; then
2477 configdirs="${configdirs} $i"
2478 fi
2479done
23f6b2f9 2480
e4c9c075
PB
2481target_configdirs_all="$target_configdirs"
2482target_configdirs=
2483for i in ${target_configdirs_all} ; do
2484 j=`echo $i | sed -e s/target-//g`
2485 if test -f ${srcdir}/$j/configure ; then
2486 target_configdirs="${target_configdirs} $i"
2487 fi
2488done
2489
45b3824d
TS
2490# libiberty-linker-plugin is special: it doesn't have its own source directory,
2491# so we have to add it after the preceding checks.
2492if test x"$extra_linker_plugin_flags$extra_linker_plugin_configure_flags" != x
2493then
2494 case " $configdirs " in
2495 *" libiberty "*)
2496 # If we can build libiberty, we can also build libiberty-linker-plugin.
2497 configdirs="$configdirs libiberty-linker-plugin"
2498 extra_linker_plugin_configure_flags="$extra_linker_plugin_configure_flags \
2499 --with-libiberty=../libiberty-linker-plugin";;
2500 *)
2501 AC_MSG_ERROR([libiberty missing]);;
2502 esac
2503fi
2504
fca38047
TS
2505# Sometimes we have special requirements for the host libiberty.
2506extra_host_libiberty_configure_flags=
2507case " $configdirs " in
15368960 2508 *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
fca38047
TS
2509 # When these are to be built as shared libraries, the same applies to
2510 # libiberty.
2511 extra_host_libiberty_configure_flags=--enable-shared
2512 ;;
04bb15e4
TV
2513esac
2514AC_SUBST(extra_host_libiberty_configure_flags)
2515
2516# Sometimes we have special requirements for the host zlib.
2517extra_host_zlib_configure_flags=
2518case " $configdirs " in
1c01ebf6
L
2519 *" bfd "*)
2520 # When bfd is to be built as a shared library, the same applies to
2521 # zlib.
2522 if test "$enable_shared" = "yes"; then
2523 extra_host_zlib_configure_flags=--enable-host-shared
2524 fi
2525 ;;
fca38047 2526esac
1c01ebf6 2527AC_SUBST(extra_host_zlib_configure_flags)
fca38047 2528
e4c9c075
PB
2529# Produce a warning message for the subdirs we can't configure.
2530# This isn't especially interesting in the Cygnus tree, but in the individual
2531# FSF releases, it's important to let people know when their machine isn't
2532# supported by the one or two programs in a package.
2533
2534if test -n "${notsupp}" && test -z "${norecursion}" ; then
2535 # If $appdirs is non-empty, at least one of those directories must still
2536 # be configured, or we error out. (E.g., if the gas release supports a
2537 # specified target in some subdirs but not the gas subdir, we shouldn't
2538 # pretend that all is well.)
2539 if test -n "$appdirs" ; then
2540 for dir in $appdirs ; do
2541 if test -r $dir/Makefile.in ; then
2542 if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2543 appdirs=""
2544 break
2545 fi
23f6b2f9 2546 if echo " ${target_configdirs} " | grep " target-${dir} " >/dev/null 2>&1; then
e4c9c075
PB
2547 appdirs=""
2548 break
2549 fi
2550 fi
2551 done
2552 if test -n "$appdirs" ; then
2553 echo "*** This configuration is not supported by this package." 1>&2
2554 exit 1
2555 fi
2556 fi
2557 # Okay, some application will build, or we don't care to check. Still
2558 # notify of subdirs not getting built.
2559 echo "*** This configuration is not supported in the following subdirectories:" 1>&2
2560 echo " ${notsupp}" 1>&2
2561 echo " (Any other directories should still work fine.)" 1>&2
2562fi
2563
2564case "$host" in
2565 *msdosdjgpp*)
2566 enable_gdbtk=no ;;
2567esac
2568
c3a86da9
DJ
2569# To find our prefix, in gcc_cv_tool_prefix.
2570ACX_TOOL_DIRS
2571
e4c9c075
PB
2572copy_dirs=
2573
526635cb 2574AC_ARG_WITH([build-sysroot],
33e39b66
AS
2575 [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
2576 [use sysroot as the system root during the build])],
526635cb
MM
2577 [if test x"$withval" != x ; then
2578 SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
2579 fi],
2580 [SYSROOT_CFLAGS_FOR_TARGET=])
2581AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
2582
c8aea42c 2583AC_ARG_WITH([debug-prefix-map],
33e39b66
AS
2584 [AS_HELP_STRING([--with-debug-prefix-map='A=B C=D ...'],
2585 [map A to B, C to D ... in debug information])],
c8aea42c
PB
2586 [if test x"$withval" != x; then
2587 DEBUG_PREFIX_CFLAGS_FOR_TARGET=
2588 for debug_map in $withval; do
2589 DEBUG_PREFIX_CFLAGS_FOR_TARGET="$DEBUG_PREFIX_CFLAGS_FOR_TARGET -fdebug-prefix-map=$debug_map"
2590 done
2591 fi],
2592 [DEBUG_PREFIX_CFLAGS_FOR_TARGET=])
2593AC_SUBST(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
2594
1c8bd6a3
PB
2595# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
2596# might be empty or "-g". We don't require a C++ compiler, so CXXFLAGS
2597# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
2598# We want to ensure that TARGET libraries (which we know are built with
2599# gcc) are built with "-O2 -g", so include those options when setting
2600# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
2601if test "x$CFLAGS_FOR_TARGET" = x; then
fc30054e
AH
2602 if test "x${is_cross_compiler}" = xyes; then
2603 CFLAGS_FOR_TARGET="-g -O2"
2604 else
2605 CFLAGS_FOR_TARGET=$CFLAGS
2606 case " $CFLAGS " in
2607 *" -O2 "*) ;;
2608 *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
2609 esac
2610 case " $CFLAGS " in
2611 *" -g "* | *" -g3 "*) ;;
2612 *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
2613 esac
2614 fi
1c8bd6a3
PB
2615fi
2616AC_SUBST(CFLAGS_FOR_TARGET)
2617
2618if test "x$CXXFLAGS_FOR_TARGET" = x; then
fc30054e
AH
2619 if test "x${is_cross_compiler}" = xyes; then
2620 CXXFLAGS_FOR_TARGET="-g -O2"
2621 else
2622 CXXFLAGS_FOR_TARGET=$CXXFLAGS
2623 case " $CXXFLAGS " in
2624 *" -O2 "*) ;;
2625 *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
2626 esac
2627 case " $CXXFLAGS " in
2628 *" -g "* | *" -g3 "*) ;;
2629 *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
2630 esac
2631 fi
1c8bd6a3
PB
2632fi
2633AC_SUBST(CXXFLAGS_FOR_TARGET)
2634
6f57bdf6
DK
2635AC_SUBST(LDFLAGS_FOR_TARGET)
2636
e4c9c075
PB
2637# Handle --with-headers=XXX. If the value is not "yes", the contents of
2638# the named directory are copied to $(tooldir)/sys-include.
2639if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
2640 if test x${is_cross_compiler} = xno ; then
2641 echo 1>&2 '***' --with-headers is only supported when cross compiling
2642 exit 1
2643 fi
2644 if test x"${with_headers}" != xyes ; then
c3a86da9 2645 x=${gcc_cv_tool_prefix}
1c710c3c 2646 copy_dirs="${copy_dirs} ${with_headers} $x/${target_noncanonical}/sys-include"
e4c9c075
PB
2647 fi
2648fi
2649
2650# Handle --with-libs=XXX. If the value is not "yes", the contents of
2651# the name directories are copied to $(tooldir)/lib. Multiple directories
2652# are permitted.
2653if test x"${with_libs}" != x && test x"${with_libs}" != xno ; then
2654 if test x${is_cross_compiler} = xno ; then
2655 echo 1>&2 '***' --with-libs is only supported when cross compiling
2656 exit 1
2657 fi
2658 if test x"${with_libs}" != xyes ; then
2659 # Copy the libraries in reverse order, so that files in the first named
2660 # library override files in subsequent libraries.
c3a86da9 2661 x=${gcc_cv_tool_prefix}
e4c9c075 2662 for l in ${with_libs}; do
1c710c3c 2663 copy_dirs="$l $x/${target_noncanonical}/lib ${copy_dirs}"
e4c9c075
PB
2664 done
2665 fi
2666fi
2667
d7f09764 2668# Set with_gnu_as, with_gnu_ld, and with_system_zlib as appropriate.
e8b05380
PB
2669#
2670# This is done by determining whether or not the appropriate directory
2671# is available, and by checking whether or not specific configurations
2672# have requested that this magic not happen.
2673#
2674# The command line options always override the explicit settings in
6b1786aa 2675# configure.ac, and the settings in configure.ac override this magic.
e8b05380
PB
2676#
2677# If the default for a toolchain is to use GNU as and ld, and you don't
2678# want to do that, then you should use the --without-gnu-as and
d7f09764
DN
2679# --without-gnu-ld options for the configure script. Similarly, if
2680# the default is to use the included zlib and you don't want to do that,
2681# you should use the --with-system-zlib option for the configure script.
e8b05380
PB
2682
2683if test x${use_gnu_as} = x &&
2684 echo " ${configdirs} " | grep " gas " > /dev/null 2>&1 ; then
2685 with_gnu_as=yes
2686 extra_host_args="$extra_host_args --with-gnu-as"
2687fi
2688
2689if test x${use_gnu_ld} = x &&
5afab7ad 2690 echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
e8b05380
PB
2691 with_gnu_ld=yes
2692 extra_host_args="$extra_host_args --with-gnu-ld"
2693fi
2694
d7f09764
DN
2695if test x${use_included_zlib} = x &&
2696 echo " ${configdirs} " | grep " zlib " > /dev/null 2>&1 ; then
2697 :
2698else
2699 with_system_zlib=yes
2700 extra_host_args="$extra_host_args --with-system-zlib"
2701fi
2702
e8b05380
PB
2703# If using newlib, add --with-newlib to the extra_host_args so that gcc/configure
2704# can detect this case.
2705
2706if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 ; then
2707 with_newlib=yes
2708 extra_host_args="$extra_host_args --with-newlib"
2709fi
2710
e4c9c075
PB
2711# Handle ${copy_dirs}
2712set fnord ${copy_dirs}
2713shift
2714while test $# != 0 ; do
2715 if test -f $2/COPIED && test x"`cat $2/COPIED`" = x"$1" ; then
2716 :
2717 else
2718 echo Copying $1 to $2
2719
2720 # Use the install script to create the directory and all required
2721 # parent directories.
2722 if test -d $2 ; then
2723 :
2724 else
2725 echo >config.temp
2726 ${srcdir}/install-sh -c -m 644 config.temp $2/COPIED
2727 fi
2728
2729 # Copy the directory, assuming we have tar.
2730 # FIXME: Should we use B in the second tar? Not all systems support it.
2731 (cd $1; tar -cf - .) | (cd $2; tar -xpf -)
2732
2733 # It is the responsibility of the user to correctly adjust all
2734 # symlinks. If somebody can figure out how to handle them correctly
2735 # here, feel free to add the code.
2736
2737 echo $1 > $2/COPIED
2738 fi
2739 shift; shift
2740done
2741
e8b05380
PB
2742# Determine a target-dependent exec_prefix that the installed
2743# gcc will search in. Keep this list sorted by triplet, with
2744# the *-*-osname triplets last.
2745md_exec_prefix=
2746case "${target}" in
30b74385 2747 i[[34567]]86-pc-msdosdjgpp*)
e8b05380
PB
2748 md_exec_prefix=/dev/env/DJDIR/bin
2749 ;;
e8b05380 2750 *-*-hpux* | \
e8b05380 2751 *-*-nto-qnx* | \
6de66370 2752 *-*-solaris2*)
e8b05380
PB
2753 md_exec_prefix=/usr/ccs/bin
2754 ;;
2755esac
2756
4977bab6
ZW
2757extra_arflags_for_target=
2758extra_nmflags_for_target=
2a726918 2759extra_ranlibflags_for_target=
671aa708 2760target_makefile_frag=/dev/null
55380b08 2761case "${target}" in
58e24147
AM
2762 spu-*-*)
2763 target_makefile_frag="config/mt-spu"
2764 ;;
74ae587e 2765 mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
4bf6c438
RS
2766 target_makefile_frag="config/mt-sde"
2767 ;;
1ec3b87b
RS
2768 mipsisa*-*-elfoabi*)
2769 target_makefile_frag="config/mt-mips-elfoabi"
2770 ;;
08d0963a
RS
2771 mips*-*-*linux* | mips*-*-gnu*)
2772 target_makefile_frag="config/mt-mips-gnu"
2773 ;;
707f1839
SL
2774 nios2-*-elf*)
2775 target_makefile_frag="config/mt-nios2-elf"
2776 ;;
76052545
EB
2777 *-*-linux-android*)
2778 target_makefile_frag="config/mt-android"
2779 ;;
416ac4d4 2780 *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
98a5bb3b 2781 target_makefile_frag="config/mt-gnu"
55380b08 2782 ;;
671aa708 2783 *-*-aix4.[[3456789]]* | *-*-aix[[56789]].*)
4977bab6
ZW
2784 # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm
2785 # commands to handle both 32-bit and 64-bit objects. These flags are
2786 # harmless if we're using GNU nm or ar.
2787 extra_arflags_for_target=" -X32_64"
2788 extra_nmflags_for_target=" -B -X32_64"
55380b08 2789 ;;
c3b7d169
NN
2790esac
2791
671aa708 2792alphaieee_frag=/dev/null
c3b7d169
NN
2793case $target in
2794 alpha*-*-*)
2795 # This just makes sure to use the -mieee option to build target libs.
2796 # This should probably be set individually by each library.
2797 alphaieee_frag="config/mt-alphaieee"
55380b08
NN
2798 ;;
2799esac
701afd4d 2800
55380b08
NN
2801# If --enable-target-optspace always use -Os instead of -O2 to build
2802# the target libraries, similarly if it is not specified, use -Os
2803# on selected platforms.
671aa708 2804ospace_frag=/dev/null
55380b08
NN
2805case "${enable_target_optspace}:${target}" in
2806 yes:*)
c3b7d169 2807 ospace_frag="config/mt-ospace"
55380b08
NN
2808 ;;
2809 :d30v-*)
c3b7d169 2810 ospace_frag="config/mt-d30v"
55380b08 2811 ;;
d9063947 2812 :m32r-* | :d10v-* | :fr30-* | :i?86*-*-elfiamcu)
c3b7d169 2813 ospace_frag="config/mt-ospace"
55380b08
NN
2814 ;;
2815 no:* | :*)
2816 ;;
2817 *)
2818 echo "*** bad value \"${enable_target_optspace}\" for --enable-target-optspace flag; ignored" 1>&2
2819 ;;
2820esac
6599da04 2821
671aa708
NN
2822# Some systems (e.g., one of the i386-aix systems the gas testers are
2823# using) don't handle "\$" correctly, so don't use it here.
1c710c3c 2824tooldir='${exec_prefix}'/${target_noncanonical}
671aa708
NN
2825build_tooldir=${tooldir}
2826
671aa708
NN
2827# Create a .gdbinit file which runs the one in srcdir
2828# and tells GDB to look there for source files.
2829
2830if test -r ${srcdir}/.gdbinit ; then
2831 case ${srcdir} in
2832 .) ;;
2833 *) cat > ./.gdbinit <<EOF
2834# ${NO_EDIT}
2835dir ${srcdir}
2836dir .
2837source ${srcdir}/.gdbinit
2838EOF
2839 ;;
2840 esac
2841fi
2842
6599da04
JM
2843# Make sure that the compiler is able to generate an executable. If it
2844# can't, we are probably in trouble. We don't care whether we can run the
2845# executable--we might be using a cross compiler--we only care whether it
2846# can be created. At this point the main configure script has set CC.
aeaa0f2f 2847we_are_ok=no
6599da04
JM
2848echo "int main () { return 0; }" > conftest.c
2849${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
aeaa0f2f
NN
2850if test $? = 0 ; then
2851 if test -s conftest || test -s conftest.exe ; then
2852 we_are_ok=yes
2853 fi
2854fi
2855case $we_are_ok in
2856 no)
2857 echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
2858 echo 1>&2 "*** You must set the environment variable CC to a working compiler."
2859 rm -f conftest*
2860 exit 1
2861 ;;
2862esac
6599da04
JM
2863rm -f conftest*
2864
d89f0ad6 2865# Decide which environment variable is used to find dynamic libraries.
fe3d5b7f
NN
2866case "${host}" in
2867 *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
111eeb6e 2868 *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
d89f0ad6 2869 *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
fe3d5b7f
NN
2870 *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
2871esac
fe3d5b7f 2872
d89f0ad6
AL
2873# On systems where the dynamic library environment variable is PATH,
2874# gcc/ will put dynamic libraries into a subdirectory to avoid adding
2875# built executables to PATH.
2876if test "$RPATH_ENVVAR" = PATH; then
2877 GCC_SHLIB_SUBDIR=/shlib
2878else
2879 GCC_SHLIB_SUBDIR=
2880fi
2881
beeda1d9
JJ
2882# Adjust the toplevel makefile according to whether bootstrap was selected.
2883case $enable_bootstrap in
2884 yes)
2885 bootstrap_suffix=bootstrap
2886 BUILD_CONFIG=bootstrap-debug
2887 ;;
2888 no)
2889 bootstrap_suffix=no-bootstrap
2890 BUILD_CONFIG=
2891 ;;
2892esac
2893
2894AC_MSG_CHECKING(for default BUILD_CONFIG)
2895
2896AC_ARG_WITH([build-config],
2897 [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
2898 [use config/NAME.mk build configuration])],
2899 [case $with_build_config in
2900 yes) with_build_config= ;;
2901 no) with_build_config= BUILD_CONFIG= ;;
2902 esac])
2903
2904if test "x${with_build_config}" != x; then
2905 BUILD_CONFIG=$with_build_config
2906else
2907 case $BUILD_CONFIG in
2908 bootstrap-debug)
2909 if echo "int f (void) { return 0; }" > conftest.c &&
2910 ${CC} -c conftest.c &&
2911 mv conftest.o conftest.o.g0 &&
2912 ${CC} -c -g conftest.c &&
2913 mv conftest.o conftest.o.g &&
2914 ${srcdir}/contrib/compare-debug conftest.o.g0 conftest.o.g > /dev/null 2>&1; then
2915 :
2916 else
2917 BUILD_CONFIG=
2918 fi
2919 rm -f conftest.c conftest.o conftest.o.g0 conftest.o.g
2920 ;;
2921 esac
2922fi
2923AC_MSG_RESULT($BUILD_CONFIG)
2924AC_SUBST(BUILD_CONFIG)
2925
2926# Use same top-level configure hooks in libgcc/libstdc++/libvtv.
2927AC_MSG_CHECKING([for --enable-vtable-verify])
2928AC_ARG_ENABLE(vtable-verify,
318a4e6d
MF
2929[AS_HELP_STRING([--enable-vtable-verify],
2930 [Enable vtable verification feature])],
beeda1d9
JJ
2931[case "$enableval" in
2932 yes) enable_vtable_verify=yes ;;
2933 no) enable_vtable_verify=no ;;
2934 *) enable_vtable_verify=no;;
2935 esac],
2936[enable_vtable_verify=no])
2937AC_MSG_RESULT($enable_vtable_verify)
2938
4977bab6
ZW
2939# Record target_configdirs and the configure arguments for target and
2940# build configuration in Makefile.
2941target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
23f6b2f9 2942build_configdirs=`echo "${build_configdirs}" | sed -e 's/build-//g'`
9e1c8fc1 2943bootstrap_fixincludes=no
4977bab6 2944
ad1e5170
JR
2945# If we are building libgomp, bootstrap it.
2946if echo " ${target_configdirs} " | grep " libgomp " > /dev/null 2>&1 ; then
2947 bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
2948fi
2949
beeda1d9
JJ
2950# If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
2951# or bootstrap-ubsan, bootstrap it.
2952if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
2953 case "$BUILD_CONFIG" in
170e618e 2954 *bootstrap-hwasan* | *bootstrap-asan* | *bootstrap-ubsan* )
beeda1d9 2955 bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
9e1c8fc1 2956 bootstrap_fixincludes=yes
beeda1d9
JJ
2957 ;;
2958 esac
ac8701fe
L
2959fi
2960
beeda1d9
JJ
2961# If we are building libvtv and --enable-vtable-verify, bootstrap it.
2962if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 &&
2963 test "$enable_vtable_verify" != no; then
2077db1b
CT
2964 bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
2965fi
2966
5fee5ec3
IB
2967# If we are building libatomic and the list of enabled languages includes the
2968# D frontend, bootstrap it.
2969if echo " ${target_configdirs} " | grep " libatomic " > /dev/null 2>&1; then
2970 case ,${enable_languages}, in
2971 *,d,*)
2972 bootstrap_target_libs=${bootstrap_target_libs}target-libatomic,
2973 ;;
2974 esac
2975fi
2976
4977bab6
ZW
2977# Determine whether gdb needs tk/tcl or not.
2978# Use 'maybe' since enable_gdbtk might be true even if tk isn't available
2979# and in that case we want gdb to be built without tk. Ugh!
2980# In fact I believe gdb is the *only* package directly dependent on tk,
2981# so we should be able to put the 'maybe's in unconditionally and
2982# leave out the maybe dependencies when enable_gdbtk is false. I'm not
2983# 100% sure that that's safe though.
e914a571 2984
b4f96efe 2985gdb_tk="maybe-all-tcl maybe-all-tk maybe-all-itcl maybe-all-libgui"
4977bab6
ZW
2986case "$enable_gdbtk" in
2987 no)
2988 GDB_TK="" ;;
e914a571
AC
2989 yes)
2990 GDB_TK="${gdb_tk}" ;;
4977bab6 2991 *)
e914a571
AC
2992 # Only add the dependency on gdbtk when GDBtk is part of the gdb
2993 # distro. Eventually someone will fix this and move Insight, nee
2994 # gdbtk to a separate directory.
2995 if test -d ${srcdir}/gdb/gdbtk ; then
2996 GDB_TK="${gdb_tk}"
2997 else
2998 GDB_TK=""
2999 fi
3000 ;;
4977bab6 3001esac
ef9db8d5
DJ
3002CONFIGURE_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-configure-/g`
3003INSTALL_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-install-/g`
4977bab6 3004
f9d09df0
TT
3005# gdb and gdbserver depend on gnulib and gdbsupport, but as nothing
3006# else does, only include them if one of these is built. The Makefile
3007# provides the ordering, so it's enough here to add to the list.
3008case " ${configdirs} " in
3009 *\ gdb\ *)
3010 configdirs="${configdirs} gnulib gdbsupport"
3011 ;;
3012 *\ gdbserver\ *)
3013 configdirs="${configdirs} gnulib gdbsupport"
3014 ;;
f14c9bd4
MF
3015 *\ sim\ *)
3016 configdirs="${configdirs} gnulib"
3017 ;;
f9d09df0 3018esac
98e5be21 3019
60975492 3020# Strip out unwanted targets.
8b87bb96
NN
3021
3022# While at that, we remove Makefiles if we were started for recursive
3023# configuration, so that the top-level Makefile reconfigures them,
3024# like we used to do when configure itself was recursive.
8b87bb96 3025
3e54529c
RW
3026# Loop over modules. We used to use the "$extrasub" feature from Autoconf
3027# but now we're fixing up the Makefile ourselves with the additional
3028# commands passed to AC_CONFIG_FILES. Use separate variables
3029# extrasub-{build,host,target} not because there is any reason to split
3030# the substitutions up that way, but only to remain below the limit of
3031# 99 commands in a script, for HP-UX sed.
da34ca3f
AO
3032
3033# Do not nest @if/@endif or @unless/@endunless pairs, because
3034# configure will not warn you at all.
8b87bb96 3035
79cd2b23
RW
3036case "$enable_bootstrap:$ENABLE_GOLD: $configdirs :,$stage1_languages," in
3037 yes:yes:*\ gold\ *:*,c++,*) ;;
3038 yes:yes:*\ gold\ *:*)
3039 AC_MSG_ERROR([in a combined tree, bootstrapping with --enable-gold requires c++ in stage1_languages])
3040 ;;
3041esac
3042
3e54529c 3043extrasub_build=
23f6b2f9 3044for module in ${build_configdirs} ; do
8b87bb96
NN
3045 if test -z "${no_recursion}" \
3046 && test -f ${build_subdir}/${module}/Makefile; then
3047 echo 1>&2 "*** removing ${build_subdir}/${module}/Makefile to force reconfigure"
3048 rm -f ${build_subdir}/${module}/Makefile
3049 fi
3e54529c 3050 extrasub_build="$extrasub_build
60975492 3051/^@if build-$module\$/d
5607edfd 3052/^@endif build-$module\$/d
da34ca3f 3053/^@unless build-$module\$/,/^@endunless build-$module\$/d
5607edfd 3054/^@if build-$module-$bootstrap_suffix\$/d
da34ca3f
AO
3055/^@endif build-$module-$bootstrap_suffix\$/d
3056/^@unless build-$module-$bootstrap_suffix\$/,/^@endunless build-$module-$bootstrap_suffix\$/d"
8b87bb96 3057done
3e54529c 3058extrasub_host=
8b87bb96 3059for module in ${configdirs} ; do
a6fbc1e2 3060 if test -z "${no_recursion}"; then
f063a9ed 3061 for file in stage*-${module}/Makefile prev-${module}/Makefile ${module}/Makefile; do
a6fbc1e2
AS
3062 if test -f ${file}; then
3063 echo 1>&2 "*** removing ${file} to force reconfigure"
3064 rm -f ${file}
3065 fi
3066 done
8b87bb96 3067 fi
9e1c8fc1
JJ
3068 case ${module},${bootstrap_fixincludes} in
3069 fixincludes,no) host_bootstrap_suffix=no-bootstrap ;;
3070 *) host_bootstrap_suffix=$bootstrap_suffix ;;
3071 esac
3e54529c 3072 extrasub_host="$extrasub_host
60975492 3073/^@if $module\$/d
5607edfd 3074/^@endif $module\$/d
da34ca3f 3075/^@unless $module\$/,/^@endunless $module\$/d
9e1c8fc1 3076/^@if $module-$host_bootstrap_suffix\$/d
da34ca3f
AO
3077/^@endif $module-$host_bootstrap_suffix\$/d
3078/^@unless $module-$host_bootstrap_suffix\$/,/^@endunless $module-$host_bootstrap_suffix\$/d"
8b87bb96 3079done
3e54529c 3080extrasub_target=
8b87bb96
NN
3081for module in ${target_configdirs} ; do
3082 if test -z "${no_recursion}" \
3083 && test -f ${target_subdir}/${module}/Makefile; then
3084 echo 1>&2 "*** removing ${target_subdir}/${module}/Makefile to force reconfigure"
3085 rm -f ${target_subdir}/${module}/Makefile
3086 fi
00020c16
ILT
3087
3088 # We only bootstrap target libraries listed in bootstrap_target_libs.
3089 case $bootstrap_target_libs in
3090 *,target-$module,*) target_bootstrap_suffix=$bootstrap_suffix ;;
3091 *) target_bootstrap_suffix=no-bootstrap ;;
3092 esac
3093
3e54529c 3094 extrasub_target="$extrasub_target
60975492 3095/^@if target-$module\$/d
5607edfd 3096/^@endif target-$module\$/d
da34ca3f 3097/^@unless target-$module\$/,/^@endunless target-$module\$/d
00020c16 3098/^@if target-$module-$target_bootstrap_suffix\$/d
da34ca3f
AO
3099/^@endif target-$module-$target_bootstrap_suffix\$/d
3100/^@unless target-$module-$target_bootstrap_suffix\$/,/^@endunless target-$module-$target_bootstrap_suffix\$/d"
4977bab6 3101done
f516a7da 3102
3e54529c
RW
3103# Do the final fixup along with target modules.
3104extrasub_target="$extrasub_target
da34ca3f
AO
3105/^@if /,/^@endif /d
3106/^@unless /d
3107/^@endunless /d"
4977bab6 3108
4a5e71f2
L
3109if test "$enable_pgo_build" != "no"; then
3110 extrasub_build="$extrasub_build
3111/^@if pgo-build\$/d
3112/^@endif pgo-build\$/d"
3113fi
3114
4977bab6
ZW
3115# Create the serialization dependencies. This uses a temporary file.
3116
ade82b16 3117AC_ARG_ENABLE([serial-configure],
33e39b66
AS
3118[AS_HELP_STRING([[--enable-serial-[{host,target,build}-]configure]],
3119 [force sequential configuration of
3120 sub-packages for the host, target or build
3121 machine, or all sub-packages])])
bf1d3e81
NN
3122
3123case ${enable_serial_configure} in
3124 yes)
3125 enable_serial_build_configure=yes
3126 enable_serial_host_configure=yes
3127 enable_serial_target_configure=yes
3128 ;;
3129esac
ade82b16 3130
4977bab6
ZW
3131# These force 'configure's to be done one at a time, to avoid problems
3132# with contention over a shared config.cache.
3133rm -f serdep.tmp
7d115e01 3134if test "x${enable_serial_build_configure}" = xyes || test "x${enable_serial_host_configure}" = xyes || test "x${enable_serial_target_configure}" = xyes; then
ade82b16 3135echo '# serdep.tmp' > serdep.tmp
7d115e01 3136fi
4977bab6 3137olditem=
bf1d3e81 3138test "x${enable_serial_build_configure}" = xyes &&
4977bab6
ZW
3139for item in ${build_configdirs} ; do
3140 case ${olditem} in
3141 "") ;;
ade82b16 3142 *) echo "configure-build-${item}: configure-build-${olditem}" >> serdep.tmp ;;
4977bab6
ZW
3143 esac
3144 olditem=${item}
3145done
3146olditem=
bf1d3e81 3147test "x${enable_serial_host_configure}" = xyes &&
4977bab6
ZW
3148for item in ${configdirs} ; do
3149 case ${olditem} in
3150 "") ;;
ade82b16 3151 *) echo "configure-${item}: configure-${olditem}" >> serdep.tmp ;;
4977bab6
ZW
3152 esac
3153 olditem=${item}
3154done
3155olditem=
bf1d3e81 3156test "x${enable_serial_target_configure}" = xyes &&
4977bab6
ZW
3157for item in ${target_configdirs} ; do
3158 case ${olditem} in
3159 "") ;;
ade82b16 3160 *) echo "configure-target-${item}: configure-target-${olditem}" >> serdep.tmp ;;
4977bab6
ZW
3161 esac
3162 olditem=${item}
3163done
671aa708
NN
3164serialization_dependencies=serdep.tmp
3165AC_SUBST_FILE(serialization_dependencies)
fe3d5b7f 3166
ade82b16 3167# Base args. Strip norecursion, cache-file, srcdir, host, build,
1c710c3c 3168# target, nonopt, and variable assignments. These are the ones we
f1a036e4
NC
3169# might not want to pass down to subconfigures. The exception being
3170# --cache-file=/dev/null, which is used to turn off the use of cache
3171# files altogether, and which should be passed on to subconfigures.
3172# Also strip program-prefix, program-suffix, and program-transform-name,
3173# so that we can pass down a consistent program-transform-name.
1c710c3c 3174baseargs=
29a63921 3175tbaseargs=
1c710c3c
DJ
3176keep_next=no
3177skip_next=no
3178eval "set -- $ac_configure_args"
44bfc3ac
DJ
3179for ac_arg
3180do
1c710c3c
DJ
3181 if test X"$skip_next" = X"yes"; then
3182 skip_next=no
3183 continue
3184 fi
3185 if test X"$keep_next" = X"yes"; then
3186 case $ac_arg in
3187 *\'*)
3188 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
3189 esac
3190 baseargs="$baseargs '$ac_arg'"
29a63921 3191 tbaseargs="$tbaseargs '$ac_arg'"
1c710c3c
DJ
3192 keep_next=no
3193 continue
3194 fi
3195
3196 # Handle separated arguments. Based on the logic generated by
3197 # autoconf 2.59.
3198 case $ac_arg in
3199 *=* | --config-cache | -C | -disable-* | --disable-* \
3200 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
3201 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
3202 | -with-* | --with-* | -without-* | --without-* | --x)
3203 separate_arg=no
3204 ;;
3205 -*)
3206 separate_arg=yes
3207 ;;
3208 *)
3209 separate_arg=no
3210 ;;
3211 esac
3212
29a63921
AO
3213 skip_targ=no
3214 case $ac_arg in
3215changequote(,)
3216 --with-* | --without-*)
3217 libopt=`echo "$ac_arg" | sed -e 's,^--[^-_]*[-_],,' -e 's,=.*$,,'`
3218
3219 case $libopt in
3220 *[-_]include)
3221 lib=`echo "$libopt" | sed 's,[-_]include$,,'`
3222 ;;
3223 *[-_]lib)
3224 lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
3225 ;;
3226 *)
3227 lib=$libopt
3228 ;;
3229 esac
3230changequote([,])
3231
3232 case $lib in
4a9bb2aa 3233 mpc | mpfr | gmp | isl)
29a63921
AO
3234 # If we're processing --with-$lib, --with-$lib-include or
3235 # --with-$lib-lib, for one of the libs above, and target is
3236 # different from host, don't pass the current argument to any
3237 # target library's configure.
3238 if test x$is_cross_compiler = xyes; then
3239 skip_targ=yes
3240 fi
3241 ;;
3242 esac
3243 ;;
3244 esac
3245
1c710c3c 3246 case "$ac_arg" in
f1a036e4
NC
3247 --cache-file=/dev/null | \
3248 -cache-file=/dev/null )
3249 # Handled here to avoid the test to skip args below.
3250 baseargs="$baseargs '$ac_arg'"
29a63921 3251 tbaseargs="$tbaseargs '$ac_arg'"
f1a036e4
NC
3252 # Assert: $separate_arg should always be no.
3253 keep_next=$separate_arg
3254 ;;
1c710c3c
DJ
3255 --no*)
3256 continue
3257 ;;
3258 --c* | \
3259 --sr* | \
3260 --ho* | \
3261 --bu* | \
3262 --t* | \
3263 --program-* | \
3264 -cache_file* | \
3265 -srcdir* | \
3266 -host* | \
3267 -build* | \
3268 -target* | \
3269 -program-prefix* | \
3270 -program-suffix* | \
3271 -program-transform-name* )
3272 skip_next=$separate_arg
3273 continue
3274 ;;
3275 -*)
3276 # An option. Add it.
3277 case $ac_arg in
3278 *\'*)
3279 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
3280 esac
3281 baseargs="$baseargs '$ac_arg'"
29a63921
AO
3282 if test X"$skip_targ" = Xno; then
3283 tbaseargs="$tbaseargs '$ac_arg'"
3284 fi
1c710c3c
DJ
3285 keep_next=$separate_arg
3286 ;;
3287 *)
3288 # Either a variable assignment, or a nonopt (triplet). Don't
3289 # pass it down; let the Makefile handle this.
3290 continue
3291 ;;
3292 esac
3293done
3294# Remove the initial space we just introduced and, as these will be
3295# expanded by make, quote '$'.
3296baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
6599da04 3297
43bb47c2
DJ
3298# Add in --program-transform-name, after --program-prefix and
3299# --program-suffix have been applied to it. Autoconf has already
3300# doubled dollar signs and backslashes in program_transform_name; we want
3301# the backslashes un-doubled, and then the entire thing wrapped in single
3302# quotes, because this will be expanded first by make and then by the shell.
3303# Also, because we want to override the logic in subdir configure scripts to
3304# choose program_transform_name, replace any s,x,x, with s,y,y,.
3305sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
3306${program_transform_name}
3307EOF_SED
3308gcc_transform_name=`cat conftestsed.out`
3309rm -f conftestsed.out
3310baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
29a63921 3311tbaseargs="$tbaseargs --program-transform-name='${gcc_transform_name}'"
d9acb717
RW
3312if test "$silent" = yes; then
3313 baseargs="$baseargs --silent"
29a63921 3314 tbaseargs="$tbaseargs --silent"
d9acb717 3315fi
0115d4a3 3316baseargs="$baseargs --disable-option-checking"
29a63921 3317tbaseargs="$tbaseargs --disable-option-checking"
43bb47c2 3318
ffedf511
RW
3319# Record and document user additions to sub configure arguments.
3320AC_ARG_VAR([build_configargs],
3321 [additional configure arguments for build directories])
3322AC_ARG_VAR([host_configargs],
3323 [additional configure arguments for host directories])
3324AC_ARG_VAR([target_configargs],
3325 [additional configure arguments for target directories])
3326
e490616e
ZW
3327# For the build-side libraries, we just need to pretend we're native,
3328# and not use the same cache file. Multilibs are neither needed nor
3d96b0d0
HPN
3329# desired. We can't even use the same cache file for all build-side
3330# libraries, as they're compiled differently; some with C, some with
3331# C++ or with different feature-enabling options.
3332build_configargs="$build_configargs --cache-file=./config.cache ${baseargs}"
e254d6b5 3333
4977bab6
ZW
3334# For host modules, accept cache file option, or specification as blank.
3335case "${cache_file}" in
3336"") # empty
3337 cache_file_option="" ;;
671aa708 3338/* | [[A-Za-z]]:[[\\/]]* ) # absolute path
4977bab6
ZW
3339 cache_file_option="--cache-file=${cache_file}" ;;
3340*) # relative path
3341 cache_file_option="--cache-file=../${cache_file}" ;;
3342esac
3343
09438bde
NN
3344# Host dirs don't like to share a cache file either, horribly enough.
3345# This seems to be due to autoconf 2.5x stupidity.
ffedf511 3346host_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${baseargs}"
4977bab6 3347
29a63921 3348target_configargs="$target_configargs ${tbaseargs}"
e490616e 3349
6599da04
JM
3350# Passing a --with-cross-host argument lets the target libraries know
3351# whether they are being built with a cross-compiler or being built
3352# native. However, it would be better to use other mechanisms to make the
3353# sorts of decisions they want to make on this basis. Please consider
3354# this option to be deprecated. FIXME.
aeaa0f2f 3355if test x${is_cross_compiler} = xyes ; then
1c710c3c 3356 target_configargs="--with-cross-host=${host_noncanonical} ${target_configargs}"
6599da04
JM
3357fi
3358
79e0604d
FXC
3359# Special user-friendly check for native x86_64-linux build, if
3360# multilib is not explicitly enabled.
3361case "$target:$have_compiler:$host:$target:$enable_multilib" in
3362 x86_64-*linux*:yes:$build:$build:)
e640447c 3363 # Make sure we have a development environment that handles 32-bit
79e0604d
FXC
3364 dev64=no
3365 echo "int main () { return 0; }" > conftest.c
3366 ${CC} -m32 -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
3367 if test $? = 0 ; then
3368 if test -s conftest || test -s conftest.exe ; then
3369 dev64=yes
3370 fi
3371 fi
3372 rm -f conftest*
3373 if test x${dev64} != xyes ; then
e640447c 3374 AC_MSG_ERROR([I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.])
79e0604d
FXC
3375 fi
3376 ;;
3377esac
3378
dc683a3f
RW
3379# Default to --enable-multilib.
3380if test x${enable_multilib} = x ; then
3fedb745 3381 target_configargs="--enable-multilib ${target_configargs}"
dc683a3f 3382fi
6599da04 3383
5d4a5ee6
JL
3384# Pass --with-newlib if appropriate. Note that target_configdirs has
3385# changed from the earlier setting of with_newlib.
aeaa0f2f 3386if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then
3fedb745 3387 target_configargs="--with-newlib ${target_configargs}"
5d4a5ee6
JL
3388fi
3389
6b9eb62c
NN
3390# Different target subdirs use different values of certain variables
3391# (notably CXX). Worse, multilibs use *lots* of different values.
3392# Worse yet, autoconf 2.5x makes some of these 'precious', meaning that
3393# it doesn't automatically accept command-line overrides of them.
3394# This means it's not safe for target subdirs to share a cache file,
3395# which is disgusting, but there you have it. Hopefully this can be
3396# fixed in future. It's still worthwhile to use a cache file for each
3397# directory. I think.
3398
bebcd931
MS
3399# Pass the appropriate --build, --host, --target and --cache-file arguments.
3400# We need to pass --target, as newer autoconf's requires consistency
3401# for target_alias and gcc doesn't manage it consistently.
e69bf64b 3402target_configargs="--cache-file=./config.cache ${target_configargs}"
e490616e 3403
b87487b6 3404FLAGS_FOR_TARGET=
bb654703 3405case " $target_configdirs " in
7965440a 3406 *" newlib "*)
3fedb745 3407 case " $target_configargs " in
7965440a 3408 *" --with-newlib "*)
b87487b6 3409 case "$target" in
5d571eaa 3410 *-cygwin*)
443e6238 3411 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
5d571eaa 3412 ;;
b87487b6
AO
3413 esac
3414
afd7db25 3415 # If we're not building GCC, don't discard standard headers.
ef40bc65 3416 if test -d ${srcdir}/gcc; then
d4eb109c 3417 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -nostdinc'
afd7db25
AO
3418
3419 if test "${build}" != "${host}"; then
3420 # On Canadian crosses, CC_FOR_TARGET will have already been set
3421 # by `configure', so we won't have an opportunity to add -Bgcc/
3422 # to it. This is right: we don't want to search that directory
3423 # for binaries, but we want the header files in there, so add
3424 # them explicitly.
0463992b 3425 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -isystem $$r/$(HOST_SUBDIR)/gcc/include -isystem $$r/$(HOST_SUBDIR)/gcc/include-fixed'
afd7db25
AO
3426
3427 # Someone might think of using the pre-installed headers on
3428 # Canadian crosses, in case the installed compiler is not fully
3429 # compatible with the compiler being built. In this case, it
3430 # would be better to flag an error than risking having
3431 # incompatible object files being constructed. We can't
3432 # guarantee that an error will be flagged, but let's hope the
3433 # compiler will do it, when presented with incompatible header
3434 # files.
3435 fi
d4eb109c
AO
3436 fi
3437
ab50d72b 3438 case "${target}-${is_cross_compiler}" in
f2a0e225 3439 i[[3456789]]86-*-linux*-no)
ab50d72b
DD
3440 # Here host == target, so we don't need to build gcc,
3441 # so we don't want to discard standard headers.
3442 FLAGS_FOR_TARGET=`echo " $FLAGS_FOR_TARGET " | sed -e 's/ -nostdinc / /'`
ab50d72b
DD
3443 ;;
3444 *)
3445 # If we're building newlib, use its generic headers last, but search
3446 # for any libc-related directories first (so make it the last -B
3447 # switch).
3448 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/newlib/ -isystem $$r/$(TARGET_SUBDIR)/newlib/targ-include -isystem $$s/newlib/libc/include'
c03353e2
RIL
3449
3450 # If we're building libgloss, find the startup file, simulator library
3451 # and linker script.
3452 case " $target_configdirs " in
3453 *" libgloss "*)
3454 # Look for startup file, simulator library and maybe linker script.
3455 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/libgloss/'"$libgloss_dir"
3456 # Look for libnosys.a in case the target needs it.
3457 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/libgloss/libnosys'
3458 # Most targets have the linker script in the source directory.
3459 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$s/libgloss/'"$libgloss_dir"
3460 ;;
3461 esac
ab50d72b
DD
3462 ;;
3463 esac
b87487b6 3464 ;;
7965440a
AO
3465 esac
3466 ;;
b87487b6 3467esac
5d571eaa 3468
b91f0a41 3469case "$target" in
5d571eaa
OS
3470 x86_64-*mingw* | *-w64-mingw*)
3471 # MinGW-w64 does not use newlib, nor does it use winsup. It may,
3472 # however, use a symlink named 'mingw' in ${prefix} .
3473 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L${prefix}/${target}/lib -L${prefix}/mingw/lib -isystem ${prefix}/${target}/include -isystem ${prefix}/mingw/include'
3474 ;;
3475 *-mingw*)
3476 # MinGW can't be handled as Cygwin above since it does not use newlib.
3477 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/mingw -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -isystem $$s/winsup/mingw/include -isystem $$s/winsup/w32api/include'
3478 ;;
b91f0a41 3479esac
d4eb109c 3480
6691a79e
ME
3481# Allow the user to override the flags for
3482# our build compiler if desired.
f019adc1
MF
3483if test x"${build}" = x"${host}" ; then
3484 CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
84401ce5 3485 CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
f019adc1
MF
3486 CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
3487 LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
3488fi
6691a79e 3489
d4eb109c
AO
3490# On Canadian crosses, we'll be searching the right directories for
3491# the previously-installed cross compiler, so don't bother to add
3492# flags for directories within the install tree of the compiler
3493# being built; programs in there won't even run.
ef40bc65 3494if test "${build}" = "${host}" && test -d ${srcdir}/gcc; then
b87487b6 3495 # Search for pre-installed headers if nothing else fits.
9124bc53 3496 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include'
b87487b6 3497fi
d4eb109c 3498
bb654703 3499if test "x${use_gnu_ld}" = x &&
55380b08 3500 echo " ${configdirs} " | grep " ld " > /dev/null ; then
b87487b6 3501 # Arrange for us to find uninstalled linker scripts.
215c351a 3502 FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(HOST_SUBDIR)/ld'
b87487b6
AO
3503fi
3504
e88a2c09
DD
3505# Search for other target-specific linker scripts and such.
3506case "${target}" in
3e19841a
PB
3507 mep*)
3508 FLAGS_FOR_TARGET="$FLAGS_FOR_TARGET -mlibrary"
3509 ;;
9b8ffbb8
OH
3510 # The VxWorks support for shared libraries is getting in
3511 # incrementally. Make sure it doesn't get activated implicitly:
3512 *vxworks*)
3513 if test "${enable_shared-unset}" = unset ; then
3514 enable_shared=no
3515 # So the build of libraries knows ...
3516 target_configargs="${target_configargs} --disable-shared"
3517 # So gcc knows ...
3518 host_configargs="${host_configargs} --disable-shared"
3519 fi
3520 ;;
e88a2c09
DD
3521esac
3522
671aa708 3523# Makefile fragments.
7b61653a
PE
3524for frag in host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag;
3525do
3526 eval fragval=\$$frag
3527 if test $fragval != /dev/null; then
3528 eval $frag=${srcdir}/$fragval
3529 fi
3530done
671aa708
NN
3531AC_SUBST_FILE(host_makefile_frag)
3532AC_SUBST_FILE(target_makefile_frag)
3533AC_SUBST_FILE(alphaieee_frag)
3534AC_SUBST_FILE(ospace_frag)
3535
3536# Miscellanea: directories, flags, etc.
671aa708 3537AC_SUBST(RPATH_ENVVAR)
d89f0ad6 3538AC_SUBST(GCC_SHLIB_SUBDIR)
671aa708
NN
3539AC_SUBST(tooldir)
3540AC_SUBST(build_tooldir)
ef9db8d5 3541AC_SUBST(CONFIGURE_GDB_TK)
671aa708 3542AC_SUBST(GDB_TK)
ef9db8d5 3543AC_SUBST(INSTALL_GDB_TK)
671aa708
NN
3544
3545# Build module lists & subconfigure args.
671aa708 3546AC_SUBST(build_configargs)
23f6b2f9 3547AC_SUBST(build_configdirs)
671aa708
NN
3548
3549# Host module lists & subconfigure args.
3550AC_SUBST(host_configargs)
3551AC_SUBST(configdirs)
aae29963 3552AC_SUBST(target_configdirs)
671aa708
NN
3553
3554# Target module lists & subconfigure args.
671aa708 3555AC_SUBST(target_configargs)
ee2312f3 3556
671aa708
NN
3557
3558# Build tools.
0999159b
PB
3559AC_SUBST(AR_FOR_BUILD)
3560AC_SUBST(AS_FOR_BUILD)
671aa708 3561AC_SUBST(CC_FOR_BUILD)
0999159b 3562AC_SUBST(CFLAGS_FOR_BUILD)
84401ce5
RP
3563AC_SUBST(CPP_FOR_BUILD)
3564AC_SUBST(CPPFLAGS_FOR_BUILD)
0999159b
PB
3565AC_SUBST(CXXFLAGS_FOR_BUILD)
3566AC_SUBST(CXX_FOR_BUILD)
3567AC_SUBST(DLLTOOL_FOR_BUILD)
3b5e8ee4 3568AC_SUBST(DSYMUTIL_FOR_BUILD)
0999159b 3569AC_SUBST(GFORTRAN_FOR_BUILD)
632e2a07 3570AC_SUBST(GOC_FOR_BUILD)
b4c522fa 3571AC_SUBST(GDC_FOR_BUILD)
0999159b
PB
3572AC_SUBST(LDFLAGS_FOR_BUILD)
3573AC_SUBST(LD_FOR_BUILD)
3574AC_SUBST(NM_FOR_BUILD)
3575AC_SUBST(RANLIB_FOR_BUILD)
3576AC_SUBST(WINDMC_FOR_BUILD)
3577AC_SUBST(WINDRES_FOR_BUILD)
671aa708 3578
2abefe3d
PB
3579# Generate default definitions for YACC, M4, LEX and other programs that run
3580# on the build machine. These are used if the Makefile can't locate these
3581# programs in objdir.
3582MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
3583
3584AC_CHECK_PROGS([YACC], ['bison -y' byacc yacc], [$MISSING bison -y])
3585case " $build_configdirs " in
3586 *" bison "*) YACC='$$r/$(BUILD_SUBDIR)/bison/tests/bison -y' ;;
2abefe3d
PB
3587esac
3588
3589AC_CHECK_PROGS([BISON], [bison], [$MISSING bison])
3590case " $build_configdirs " in
3591 *" bison "*) BISON='$$r/$(BUILD_SUBDIR)/bison/tests/bison' ;;
3592esac
3593
3594AC_CHECK_PROGS([M4], [gm4 gnum4 m4], [$MISSING m4])
3595case " $build_configdirs " in
3596 *" m4 "*) M4='$$r/$(BUILD_SUBDIR)/m4/m4' ;;
3597esac
3598
3599AC_CHECK_PROGS([LEX], [flex lex], [$MISSING flex])
3600case " $build_configdirs " in
3601 *" flex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
3602 *" lex "*) LEX='$$r/$(BUILD_SUBDIR)/lex/lex' ;;
3603esac
3604
3605AC_CHECK_PROGS([FLEX], [flex], [$MISSING flex])
3606case " $build_configdirs " in
3607 *" flex "*) FLEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
3608esac
3609
3610AC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
3611case " $build_configdirs " in
3612 *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
3613 *)
3614changequote(,)
d18ff35a 3615 # For an installed makeinfo, we require it to be from texinfo 4.7 or
2abefe3d
PB
3616 # higher, else we use the "missing" dummy.
3617 if ${MAKEINFO} --version \
d18ff35a 3618 | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
2abefe3d
PB
3619 :
3620 else
3621 MAKEINFO="$MISSING makeinfo"
3622 fi
3623 ;;
3624changequote([,])
3625esac
3626
3627# FIXME: expect and dejagnu may become build tools?
3628
3629AC_CHECK_PROGS(EXPECT, expect, expect)
3630case " $configdirs " in
3631 *" expect "*)
3632 test $host = $build && EXPECT='$$r/$(HOST_SUBDIR)/expect/expect'
3633 ;;
3634esac
3635
3636AC_CHECK_PROGS(RUNTEST, runtest, runtest)
3637case " $configdirs " in
3638 *" dejagnu "*)
c394e891 3639 test $host = $build && RUNTEST='$$s/$(HOST_SUBDIR)/dejagnu/runtest'
2abefe3d
PB
3640 ;;
3641esac
3642
4e3dcf20 3643
671aa708 3644# Host tools.
2693c0b0
PB
3645NCN_STRICT_CHECK_TOOLS(AR, ar)
3646NCN_STRICT_CHECK_TOOLS(AS, as)
3647NCN_STRICT_CHECK_TOOLS(DLLTOOL, dlltool)
3b5e8ee4 3648NCN_STRICT_CHECK_TOOLS(DSYMUTIL, dsymutil)
2693c0b0 3649NCN_STRICT_CHECK_TOOLS(LD, ld)
2abefe3d 3650NCN_STRICT_CHECK_TOOLS(LIPO, lipo)
2693c0b0 3651NCN_STRICT_CHECK_TOOLS(NM, nm)
8927b7c0
RO
3652NCN_STRICT_CHECK_TOOLS(RANLIB, ranlib, true)
3653NCN_STRICT_CHECK_TOOLS(STRIP, strip, true)
2693c0b0 3654NCN_STRICT_CHECK_TOOLS(WINDRES, windres)
901119ae 3655NCN_STRICT_CHECK_TOOLS(WINDMC, windmc)
2693c0b0
PB
3656NCN_STRICT_CHECK_TOOLS(OBJCOPY, objcopy)
3657NCN_STRICT_CHECK_TOOLS(OBJDUMP, objdump)
e4a9a572 3658NCN_STRICT_CHECK_TOOLS(OTOOL, otool)
e7a82751 3659NCN_STRICT_CHECK_TOOLS(READELF, readelf)
671aa708
NN
3660AC_SUBST(CC)
3661AC_SUBST(CXX)
3662AC_SUBST(CFLAGS)
3663AC_SUBST(CXXFLAGS)
5fee5ec3
IB
3664AC_SUBST(GDC)
3665AC_SUBST(GDCFLAGS)
1ed21e23 3666GDCFLAGS=${GDCFLAGS-${CFLAGS}}
671aa708 3667
126f707e
L
3668GCC_PLUGIN_OPTION(PLUGIN_OPTION)
3669AR_PLUGIN_OPTION=
3670RANLIB_PLUGIN_OPTION=
3671if test -n "$PLUGIN_OPTION"; then
3672 if $AR --help 2>&1 | grep -q "\--plugin"; then
3673 AR_PLUGIN_OPTION="$PLUGIN_OPTION"
3674 fi
3675 if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
3676 RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
3677 fi
3678fi
3679AC_SUBST(AR_PLUGIN_OPTION)
3680AC_SUBST(RANLIB_PLUGIN_OPTION)
3681
2abefe3d 3682# Target tools.
e8b05380 3683AC_ARG_WITH([build-time-tools],
33e39b66
AS
3684 [AS_HELP_STRING([--with-build-time-tools=PATH],
3685 [use given path to find target tools during the build])],
e8b05380
PB
3686 [case x"$withval" in
3687 x/*) ;;
3688 *)
3689 with_build_time_tools=
3690 AC_MSG_WARN([argument to --with-build-time-tools must be an absolute path])
3691 ;;
3692 esac],
3693 [with_build_time_tools=])
3694
2693c0b0
PB
3695NCN_STRICT_CHECK_TARGET_TOOLS(CC_FOR_TARGET, cc gcc)
3696NCN_STRICT_CHECK_TARGET_TOOLS(CXX_FOR_TARGET, c++ g++ cxx gxx)
2693c0b0 3697NCN_STRICT_CHECK_TARGET_TOOLS(GCC_FOR_TARGET, gcc, ${CC_FOR_TARGET})
2693c0b0 3698NCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran)
632e2a07 3699NCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo)
b4c522fa 3700NCN_STRICT_CHECK_TARGET_TOOLS(GDC_FOR_TARGET, gdc)
1eee94d3 3701NCN_STRICT_CHECK_TARGET_TOOLS(GM2_FOR_TARGET, gm2)
e8b05380
PB
3702
3703ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
3704ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
3705ACX_CHECK_INSTALLED_TARGET_TOOL(DLLTOOL_FOR_TARGET, dlltool)
3b5e8ee4 3706ACX_CHECK_INSTALLED_TARGET_TOOL(DSYMUTIL_FOR_TARGET, dsymutil)
e8b05380
PB
3707ACX_CHECK_INSTALLED_TARGET_TOOL(LD_FOR_TARGET, ld)
3708ACX_CHECK_INSTALLED_TARGET_TOOL(LIPO_FOR_TARGET, lipo)
3709ACX_CHECK_INSTALLED_TARGET_TOOL(NM_FOR_TARGET, nm)
9bccfdf5 3710ACX_CHECK_INSTALLED_TARGET_TOOL(OBJCOPY_FOR_TARGET, objcopy)
e8b05380 3711ACX_CHECK_INSTALLED_TARGET_TOOL(OBJDUMP_FOR_TARGET, objdump)
e4a9a572 3712ACX_CHECK_INSTALLED_TARGET_TOOL(OTOOL_FOR_TARGET, otool)
8927b7c0 3713ACX_CHECK_INSTALLED_TARGET_TOOL(RANLIB_FOR_TARGET, ranlib)
e7a82751 3714ACX_CHECK_INSTALLED_TARGET_TOOL(READELF_FOR_TARGET, readelf)
e8b05380
PB
3715ACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip)
3716ACX_CHECK_INSTALLED_TARGET_TOOL(WINDRES_FOR_TARGET, windres)
901119ae 3717ACX_CHECK_INSTALLED_TARGET_TOOL(WINDMC_FOR_TARGET, windmc)
4de997d1 3718
2abefe3d
PB
3719RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
3720
3721GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar])
3722GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new])
3723GCC_TARGET_TOOL(cc, CC_FOR_TARGET, CC, [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])
b3f122e0 3724dnl see comments for CXX_FOR_TARGET_FLAG_TO_PASS
2abefe3d 3725GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX,
2077db1b 3726 [gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags; then $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; else echo -funconfigured-libstdc++-v3 ; fi` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs],
2abefe3d
PB
3727 c++)
3728GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX,
2077db1b 3729 [gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs],
2abefe3d
PB
3730 c++)
3731GCC_TARGET_TOOL(dlltool, DLLTOOL_FOR_TARGET, DLLTOOL, [binutils/dlltool])
3b5e8ee4 3732GCC_TARGET_TOOL(dsymutil, DSYMUTIL_FOR_TARGET, DSYMUTIL)
2abefe3d 3733GCC_TARGET_TOOL(gcc, GCC_FOR_TARGET, , [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])
2abefe3d
PB
3734GCC_TARGET_TOOL(gfortran, GFORTRAN_FOR_TARGET, GFORTRAN,
3735 [gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/], fortran)
632e2a07
ILT
3736GCC_TARGET_TOOL(gccgo, GOC_FOR_TARGET, GOC,
3737 [gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go)
b4c522fa
IB
3738GCC_TARGET_TOOL(gdc, GDC_FOR_TARGET, GDC,
3739 [gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/], d)
1eee94d3
GM
3740GCC_TARGET_TOOL(gm2, GM2_FOR_TARGET, GM2,
3741 [gcc/gm2 -B$$r/$(HOST_SUBDIR)/gcc/], m2)
2abefe3d
PB
3742GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
3743GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
3744GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
ec8fd1c0 3745GCC_TARGET_TOOL(objcopy, OBJCOPY_FOR_TARGET, OBJCOPY, [binutils/objcopy])
2abefe3d 3746GCC_TARGET_TOOL(objdump, OBJDUMP_FOR_TARGET, OBJDUMP, [binutils/objdump])
e4a9a572 3747GCC_TARGET_TOOL(otool, OTOOL_FOR_TARGET, OTOOL)
2abefe3d 3748GCC_TARGET_TOOL(ranlib, RANLIB_FOR_TARGET, RANLIB, [binutils/ranlib])
e7a82751 3749GCC_TARGET_TOOL(readelf, READELF_FOR_TARGET, READELF, [binutils/readelf])
455c8f48 3750GCC_TARGET_TOOL(strip, STRIP_FOR_TARGET, STRIP, [binutils/strip-new])
2abefe3d 3751GCC_TARGET_TOOL(windres, WINDRES_FOR_TARGET, WINDRES, [binutils/windres])
901119ae 3752GCC_TARGET_TOOL(windmc, WINDMC_FOR_TARGET, WINDMC, [binutils/windmc])
4de997d1 3753
2abefe3d 3754AC_SUBST(FLAGS_FOR_TARGET)
4de997d1 3755AC_SUBST(RAW_CXX_FOR_TARGET)
be912515 3756
671aa708
NN
3757# Certain tools may need extra flags.
3758AR_FOR_TARGET=${AR_FOR_TARGET}${extra_arflags_for_target}
3759RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET}${extra_ranlibflags_for_target}
3760NM_FOR_TARGET=${NM_FOR_TARGET}${extra_nmflags_for_target}
6599da04 3761
2abefe3d
PB
3762# When building target libraries, except in a Canadian cross, we use
3763# the same toolchain as the compiler we just built.
3764COMPILER_AS_FOR_TARGET='$(AS_FOR_TARGET)'
3765COMPILER_LD_FOR_TARGET='$(LD_FOR_TARGET)'
3766COMPILER_NM_FOR_TARGET='$(NM_FOR_TARGET)'
3767if test $host = $build; then
3768 case " $configdirs " in
3769 *" gcc "*)
3770 COMPILER_AS_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/as'
3771 COMPILER_LD_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/collect-ld'
3772 COMPILER_NM_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/nm'${extra_nmflags_for_target}
3773 ;;
3774 esac
3775fi
3776
3777AC_SUBST(COMPILER_AS_FOR_TARGET)
3778AC_SUBST(COMPILER_LD_FOR_TARGET)
3779AC_SUBST(COMPILER_NM_FOR_TARGET)
3780
ee03dc5e
AO
3781AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
3782AC_ARG_ENABLE(maintainer-mode,
33e39b66
AS
3783[AS_HELP_STRING([--enable-maintainer-mode],
3784 [enable make rules and dependencies not useful
3785 (and sometimes confusing) to the casual installer])],
ee03dc5e
AO
3786 USE_MAINTAINER_MODE=$enableval,
3787 USE_MAINTAINER_MODE=no)
3788AC_MSG_RESULT($USE_MAINTAINER_MODE)
3789AC_SUBST(MAINTAINER_MODE_TRUE)
3790AC_SUBST(MAINTAINER_MODE_FALSE)
3791if test "$USE_MAINTAINER_MODE" = yes; then
3792 MAINTAINER_MODE_TRUE=
3793 MAINTAINER_MODE_FALSE='#'
3794else
3795 MAINTAINER_MODE_TRUE='#'
3796 MAINTAINER_MODE_FALSE=
3797fi
3798MAINT=$MAINTAINER_MODE_TRUE
3799AC_SUBST(MAINT)dnl
3800
2805b53a
NN
3801# ---------------------
3802# GCC bootstrap support
3803# ---------------------
3804
3805# Stage specific cflags for build.
3806stage1_cflags="-g"
3807case $build in
3808 vax-*-*)
3809 case ${GCC} in
3810 yes) stage1_cflags="-g -Wa,-J" ;;
3811 *) stage1_cflags="-g -J" ;;
3812 esac ;;
2805b53a 3813esac
0b50988a 3814
2805b53a
NN
3815AC_SUBST(stage1_cflags)
3816
8efea775
PB
3817# Enable --enable-checking in stage1 of the compiler.
3818AC_ARG_ENABLE(stage1-checking,
33e39b66
AS
3819[AS_HELP_STRING([[--enable-stage1-checking[=all]]],
3820 [choose additional checking for stage1 of the compiler])],
8efea775 3821[stage1_checking=--enable-checking=${enable_stage1_checking}],
e643dc23 3822[if test "x$enable_checking" = xno || test "x$enable_checking" = x; then
c10b5ea0
JJ
3823 # For --disable-checking or implicit --enable-checking=release, avoid
3824 # setting --enable-checking=gc in the default stage1 checking for LTO
3825 # bootstraps. See PR62077.
c10b5ea0
JJ
3826 case $BUILD_CONFIG in
3827 *lto*)
7db11a5a
JJ
3828 stage1_checking=--enable-checking=release,misc,gimple,rtlflag,tree,types;;
3829 *)
3830 stage1_checking=--enable-checking=yes,types;;
c10b5ea0 3831 esac
7db11a5a
JJ
3832 if test "x$enable_checking" = x && \
3833 test -d ${srcdir}/gcc && \
3834 test x"`cat ${srcdir}/gcc/DEV-PHASE`" = xexperimental; then
c100769b 3835 stage1_checking=--enable-checking=yes,types,extra
7db11a5a 3836 fi
8efea775 3837else
e643dc23 3838 stage1_checking=--enable-checking=$enable_checking,types
8efea775
PB
3839fi])
3840AC_SUBST(stage1_checking)
3841
2805b53a 3842# Enable -Werror in bootstrap stage2 and later.
2805b53a 3843AC_ARG_ENABLE(werror,
33e39b66 3844[AS_HELP_STRING([--enable-werror],
afd88efc
ML
3845 [enable -Werror in bootstrap stage2 and later])],
3846[
09a9c095
NN
3847case ${enable_werror} in
3848 yes) stage2_werror_flag="--enable-werror-always" ;;
3849 *) stage2_werror_flag="" ;;
2805b53a 3850esac
afd88efc
ML
3851],
3852[
01c712cb
ML
3853if test -d ${srcdir}/gcc && test x"`cat $srcdir/gcc/DEV-PHASE`" = xexperimental; then
3854 case $BUILD_CONFIG in
3855 bootstrap-debug)
3856 stage2_werror_flag="--enable-werror-always" ;;
3857 "")
3858 stage2_werror_flag="--enable-werror-always" ;;
3859 esac
3860fi
afd88efc 3861])
01c712cb 3862
09a9c095 3863AC_SUBST(stage2_werror_flag)
2805b53a 3864
f2689b09
SE
3865# Specify what files to not compare during bootstrap.
3866
3867compare_exclusions="gcc/cc*-checksum\$(objext) | gcc/ada/*tools/*"
1eee94d3
GM
3868compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/M2Version*"
3869compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/SYSTEM*"
3870compare_exclusions="$compare_exclusions | gcc/m2/gm2version*"
f2689b09
SE
3871case "$target" in
3872 hppa*64*-*-hpux*) ;;
4f943869 3873 powerpc*-ibm-aix*) compare_exclusions="$compare_exclusions | *libgomp*\$(objext)" ;;
f2689b09
SE
3874esac
3875AC_SUBST(compare_exclusions)
3876
3e54529c
RW
3877AC_CONFIG_FILES([Makefile],
3878 [sed "$extrasub_build" Makefile |
3879 sed "$extrasub_host" |
3880 sed "$extrasub_target" > mf$$
3881 mv -f mf$$ Makefile],
3882 [extrasub_build="$extrasub_build"
3883 extrasub_host="$extrasub_host"
3884 extrasub_target="$extrasub_target"])
3885AC_OUTPUT