xref: /netbsd-src/external/gpl3/gdb/dist/configure.ac (revision 079139fb19b43ab2737358c774cc348c7601b6a4)
1597410b8Schristos#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2212397c6Schristos#   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
34b169a6bSchristos#   2014, 2015, 2016, 2019, 2022 Free Software Foundation, Inc.
4597410b8Schristos#
5597410b8Schristos# This file is free software; you can redistribute it and/or modify it
6597410b8Schristos# under the terms of the GNU General Public License as published by
7597410b8Schristos# the Free Software Foundation; either version 3 of the License, or
8597410b8Schristos# (at your option) any later version.
9597410b8Schristos#
10597410b8Schristos# This program is distributed in the hope that it will be useful, but
11597410b8Schristos# WITHOUT ANY WARRANTY; without even the implied warranty of
12597410b8Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13597410b8Schristos# General Public License for more details.
14597410b8Schristos#
15597410b8Schristos# You should have received a copy of the GNU General Public License
16597410b8Schristos# along with this program; see the file COPYING3.  If not see
17597410b8Schristos# <http://www.gnu.org/licenses/>.
18597410b8Schristos
19597410b8Schristos##############################################################################
20597410b8Schristos### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
21597410b8Schristos
22597410b8Schristosm4_include(config/acx.m4)
23597410b8Schristosm4_include(config/override.m4)
24597410b8Schristosm4_include(config/proginstall.m4)
25597410b8Schristosm4_include(config/elf.m4)
264b169a6bSchristosm4_include(config/ax_cxx_compile_stdcxx.m4)
27*079139fbSchristosm4_include(config/gcc-plugin.m4)
28597410b8Schristosm4_include([libtool.m4])
29597410b8Schristosm4_include([ltoptions.m4])
30597410b8Schristosm4_include([ltsugar.m4])
31597410b8Schristosm4_include([ltversion.m4])
32597410b8Schristosm4_include([lt~obsolete.m4])
3305598a80Schristosm4_include([config/isl.m4])
34597410b8Schristos
35597410b8SchristosAC_INIT(move-if-change)
36597410b8SchristosAC_DISABLE_OPTION_CHECKING
37597410b8Schristos
38597410b8Schristosprogname=$0
39597410b8Schristos# if PWD already has a value, it is probably wrong.
40597410b8Schristosif test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi
41597410b8Schristos
42597410b8Schristos# Export original configure arguments for use by sub-configures.
43597410b8Schristos# Quote arguments with shell meta charatcers.
44597410b8SchristosTOPLEVEL_CONFIGURE_ARGUMENTS=
45597410b8Schristosset -- "$progname" "$@"
46597410b8Schristosfor ac_arg
47597410b8Schristosdo
48597410b8Schristos  case "$ac_arg" in
49597410b8Schristos  *" "*|*"	"*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
50597410b8Schristos    ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
51597410b8Schristos    # if the argument is of the form -foo=baz, quote the baz part only
52597410b8Schristos    ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
53597410b8Schristos  *) ;;
54597410b8Schristos  esac
55597410b8Schristos  # Add the quoted argument to the list.
56597410b8Schristos  TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
57597410b8Schristosdone
58597410b8Schristosif test "$silent" = yes; then
59597410b8Schristos  TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
60597410b8Schristosfi
61597410b8Schristos# Remove the initial space we just introduced and, as these will be
62597410b8Schristos# expanded by make, quote '$'.
63597410b8SchristosTOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
64597410b8SchristosAC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
65597410b8Schristos
66597410b8Schristos# Find the build, host, and target systems.
67597410b8SchristosACX_NONCANONICAL_BUILD
68597410b8SchristosACX_NONCANONICAL_HOST
69597410b8SchristosACX_NONCANONICAL_TARGET
70597410b8Schristos
71597410b8Schristosdnl Autoconf 2.5x and later will set a default program prefix if
72597410b8Schristosdnl --target was used, even if it was the same as --host.  Disable
73597410b8Schristosdnl that behavior.  This must be done before AC_CANONICAL_SYSTEM
74597410b8Schristosdnl to take effect.
75597410b8Schristostest "$host_noncanonical" = "$target_noncanonical" &&
76597410b8Schristos  test "$program_prefix$program_suffix$program_transform_name" = \
77597410b8Schristos    NONENONEs,x,x, &&
78597410b8Schristos  program_transform_name=s,y,y,
79597410b8Schristos
80597410b8SchristosAC_CANONICAL_SYSTEM
81597410b8SchristosAC_ARG_PROGRAM
82597410b8Schristos
83597410b8Schristosm4_pattern_allow([^AS_FOR_TARGET$])dnl
84597410b8Schristosm4_pattern_allow([^AS_FOR_BUILD$])dnl
85597410b8Schristos
86597410b8Schristos# Get 'install' or 'install-sh' and its variants.
87597410b8SchristosAC_PROG_INSTALL
88597410b8SchristosACX_PROG_LN
89597410b8SchristosAC_PROG_LN_S
90597410b8SchristosAC_PROG_SED
91597410b8SchristosAC_PROG_AWK
92597410b8Schristos
93597410b8Schristossrcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
94597410b8Schristos
95597410b8Schristos# We pass INSTALL explicitly to sub-makes.  Make sure that it is not
96597410b8Schristos# a relative path.
97597410b8Schristosif test "$INSTALL" = "${srcdir}/install-sh -c"; then
98597410b8Schristos  INSTALL="${srcpwd}/install-sh -c"
99597410b8Schristosfi
100597410b8Schristos
101597410b8Schristos# Set srcdir to "." if that's what it is.
102597410b8Schristos# This is important for multilib support.
103597410b8Schristospwd=`${PWDCMD-pwd}`
104597410b8Schristosif test "${pwd}" = "${srcpwd}" ; then
105597410b8Schristos  srcdir=.
106597410b8Schristosfi
107597410b8Schristos
108597410b8Schristostopsrcdir=$srcpwd
109597410b8Schristos
110597410b8Schristosextra_host_args=
111597410b8Schristos
112597410b8Schristos### To add a new directory to the tree, first choose whether it is a target
113597410b8Schristos### or a host dependent tool.  Then put it into the appropriate list
114597410b8Schristos### (library or tools, host or target), doing a dependency sort.
115597410b8Schristos
116597410b8Schristos# Subdirs will be configured in the order listed in build_configdirs,
117597410b8Schristos# configdirs, or target_configdirs; see the serialization section below.
118597410b8Schristos
119597410b8Schristos# Dependency sorting is only needed when *configuration* must be done in
120597410b8Schristos# a particular order.  In all cases a dependency should be specified in
121597410b8Schristos# the Makefile, whether or not it's implicitly specified here.
122597410b8Schristos
123597410b8Schristos# Double entries in build_configdirs, configdirs, or target_configdirs may
124597410b8Schristos# cause circular dependencies and break everything horribly.
125597410b8Schristos
126597410b8Schristos# these library is used by various programs built for the build
127597410b8Schristos# environment
128597410b8Schristos#
129212397c6Schristosbuild_libs="build-libiberty build-libcpp"
130597410b8Schristos
131597410b8Schristos# these tools are built for the build environment
13205598a80Schristosbuild_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
133597410b8Schristos
134597410b8Schristos# these libraries are used by various programs built for the host environment
135212397c6Schristos#f
136*079139fbSchristoshost_libs="gettext libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libcody libdecnumber gmp mpfr mpc isl libiconv libctf libsframe libgrust "
137597410b8Schristos
138597410b8Schristos# these tools are built for the host environment
139597410b8Schristos# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
140597410b8Schristos# know that we are building the simulator.
141597410b8Schristos# binutils, gas and ld appear in that order because it makes sense to run
142597410b8Schristos# "make check" in that particular order.
143597410b8Schristos# If --enable-gold is used, "gold" may replace "ld".
144*079139fbSchristoshost_tools="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"
145597410b8Schristos
146597410b8Schristos# these libraries are built for the target environment, and are built after
147597410b8Schristos# the host libraries and the host tools (which may be a cross compiler)
14805598a80Schristos# Note that libiberty is not a target library.
149597410b8Schristostarget_libraries="target-libgcc \
15005598a80Schristos		target-libbacktrace \
151597410b8Schristos		target-libgloss \
152597410b8Schristos		target-newlib \
153597410b8Schristos		target-libgomp \
15405598a80Schristos		target-libatomic \
15505598a80Schristos		target-libitm \
156597410b8Schristos		target-libstdc++-v3 \
15705598a80Schristos		target-libsanitizer \
15803467a24Schristos		target-libvtv \
159597410b8Schristos		target-libssp \
160597410b8Schristos		target-libquadmath \
161597410b8Schristos		target-libgfortran \
162796c32c9Schristos		target-libffi \
163597410b8Schristos		target-libobjc \
164597410b8Schristos		target-libada \
165*079139fbSchristos		target-libgm2 \
1664b169a6bSchristos		target-libgo \
167*079139fbSchristos		target-libgrust \
1684b169a6bSchristos		target-libphobos \
1694b169a6bSchristos		target-zlib"
170597410b8Schristos
171597410b8Schristos# these tools are built using the target libraries, and are intended to
172597410b8Schristos# run only in the target environment
173597410b8Schristos#
174597410b8Schristos# note: any program that *uses* libraries that are in the "target_libraries"
175597410b8Schristos# list belongs in this list.
176597410b8Schristos#
17705598a80Schristostarget_tools="target-rda"
178597410b8Schristos
179597410b8Schristos################################################################################
180597410b8Schristos
181597410b8Schristos## All tools belong in one of the four categories, and are assigned above
182597410b8Schristos## We assign ${configdirs} this way to remove all embedded newlines.  This
183597410b8Schristos## is important because configure will choke if they ever get through.
184597410b8Schristos## ${configdirs} is directories we build using the host tools.
185597410b8Schristos## ${target_configdirs} is directories we build using the target tools.
186597410b8Schristosconfigdirs=`echo ${host_libs} ${host_tools}`
187597410b8Schristostarget_configdirs=`echo ${target_libraries} ${target_tools}`
188597410b8Schristosbuild_configdirs=`echo ${build_libs} ${build_tools}`
189597410b8Schristos
190597410b8Schristosm4_divert_text([PARSE_ARGS],
191597410b8Schristos[case $srcdir in
192597410b8Schristos  *" "*)
193597410b8Schristosm4_pushdef([AS_MESSAGE_LOG_FD], [])dnl
194597410b8Schristos    AC_MSG_ERROR([path to source, $srcdir, contains spaces])
195597410b8Schristosm4_popdef([AS_MESSAGE_LOG_FD])dnl
196597410b8Schristos    ;;
197597410b8Schristosesac
198597410b8Schristosac_subdirs_all=`cd $srcdir && echo */configure | sed 's,/configure,,g'`
199597410b8Schristos])
200597410b8Schristos
201597410b8Schristos################################################################################
202597410b8Schristos
203597410b8Schristossrcname="gnu development package"
204597410b8Schristos
205597410b8Schristos# This gets set non-empty for some net releases of packages.
206597410b8Schristosappdirs=""
207597410b8Schristos
208597410b8Schristos# Define is_cross_compiler to save on calls to 'test'.
209597410b8Schristosis_cross_compiler=
210597410b8Schristosif test x"${host}" = x"${target}" ; then
211597410b8Schristos  is_cross_compiler=no
212597410b8Schristoselse
213597410b8Schristos  is_cross_compiler=yes
214597410b8Schristosfi
215597410b8Schristos
216597410b8Schristos# Find the build and target subdir names.
217597410b8SchristosGCC_TOPLEV_SUBDIRS
218597410b8Schristos# Be sure to cover against remnants of an in-tree build.
219597410b8Schristosif test $srcdir != .  && test -d $srcdir/host-${host_noncanonical}; then
220597410b8Schristos  AC_MSG_ERROR([building out of tree but $srcdir contains host-${host_noncanonical}.
221597410b8SchristosUse a pristine source tree when building in a separate tree])
222597410b8Schristosfi
223597410b8Schristos
224597410b8Schristos# Skipdirs are removed silently.
225597410b8Schristosskipdirs=
226597410b8Schristos# Noconfigdirs are removed loudly.
227597410b8Schristosnoconfigdirs=""
228597410b8Schristos
229597410b8Schristosuse_gnu_ld=
230597410b8Schristos# Make sure we don't let GNU ld be added if we didn't want it.
231597410b8Schristosif test x$with_gnu_ld = xno ; then
232597410b8Schristos  use_gnu_ld=no
233597410b8Schristos  noconfigdirs="$noconfigdirs ld gold"
234597410b8Schristosfi
235597410b8Schristos
236597410b8Schristosuse_gnu_as=
237597410b8Schristos# Make sure we don't let GNU as be added if we didn't want it.
238597410b8Schristosif test x$with_gnu_as = xno ; then
239597410b8Schristos  use_gnu_as=no
240597410b8Schristos  noconfigdirs="$noconfigdirs gas"
241597410b8Schristosfi
242597410b8Schristos
243597410b8Schristosuse_included_zlib=
244212397c6SchristosAC_ARG_WITH(system-zlib,
245212397c6Schristos[AS_HELP_STRING([--with-system-zlib], [use installed libz])])
246597410b8Schristos# Make sure we don't let ZLIB be added if we didn't want it.
247597410b8Schristosif test x$with_system_zlib = xyes ; then
248597410b8Schristos  use_included_zlib=no
249597410b8Schristos  noconfigdirs="$noconfigdirs zlib"
250597410b8Schristosfi
251597410b8Schristos
2524559860eSchristos# Don't compile the bundled readline/libreadline.a if --with-system-readline
2534559860eSchristos# is provided.
2544559860eSchristosif test x$with_system_readline = xyes ; then
2554559860eSchristos  noconfigdirs="$noconfigdirs readline"
2564559860eSchristosfi
2574559860eSchristos
2584b169a6bSchristosAC_ARG_WITH(zstd,
2594b169a6bSchristos[AS_HELP_STRING([--with-zstd], [Support zstd compressed debug sections (default=auto)])])
2604b169a6bSchristos
261597410b8Schristos# some tools are so dependent upon X11 that if we're not building with X,
262597410b8Schristos# it's not even worth trying to configure, much less build, that tool.
263597410b8Schristos
264597410b8Schristoscase ${with_x} in
265597410b8Schristos  yes | "") ;; # the default value for this tree is that X11 is available
266597410b8Schristos  no)
267597410b8Schristos    skipdirs="${skipdirs} tk itcl libgui"
268597410b8Schristos    # We won't be able to build gdbtk without X.
269597410b8Schristos    enable_gdbtk=no
270597410b8Schristos    ;;
271597410b8Schristos  *)  echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2 ;;
272597410b8Schristosesac
273597410b8Schristos
274597410b8Schristos# Some are only suitable for cross toolchains.
275597410b8Schristos# Remove these if host=target.
276597410b8Schristoscross_only="target-libgloss target-newlib target-opcodes"
277597410b8Schristos
278597410b8Schristoscase $is_cross_compiler in
279597410b8Schristos  no) skipdirs="${skipdirs} ${cross_only}" ;;
280597410b8Schristosesac
281597410b8Schristos
282597410b8Schristos# If both --with-headers and --with-libs are specified, default to
283597410b8Schristos# --without-newlib.
284597410b8Schristosif test x"${with_headers}" != x && test x"${with_headers}" != xno \
285597410b8Schristos   && test x"${with_libs}" != x && test x"${with_libs}" != xno ; then
286597410b8Schristos  if test x"${with_newlib}" = x ; then
287597410b8Schristos    with_newlib=no
288597410b8Schristos  fi
289597410b8Schristosfi
290597410b8Schristos
291597410b8Schristos# Recognize --with-newlib/--without-newlib.
292597410b8Schristoscase ${with_newlib} in
293597410b8Schristos  no) skipdirs="${skipdirs} target-newlib" ;;
294597410b8Schristos  yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
295597410b8Schristosesac
296597410b8Schristos
297212397c6SchristosAC_ARG_ENABLE(as-accelerator-for,
298212397c6Schristos[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
299212397c6Schristos		[build as offload target compiler.
300212397c6Schristos		Specify offload host triple by ARG])])
301212397c6Schristos
302212397c6SchristosAC_ARG_ENABLE(offload-targets,
303212397c6Schristos[AS_HELP_STRING([--enable-offload-targets=LIST],
304212397c6Schristos		[enable offloading to devices from comma-separated LIST of
305212397c6Schristos		TARGET[=DIR]. Use optional path to find offload target compiler
306212397c6Schristos		during the build])],
307212397c6Schristos[
308212397c6Schristos  if test x"$enable_offload_targets" = x; then
309212397c6Schristos    AC_MSG_ERROR([no offload targets specified])
310212397c6Schristos  fi
311212397c6Schristos], [enable_offload_targets=])
312212397c6Schristos
3134b169a6bSchristosAC_ARG_ENABLE(offload-defaulted,
3144b169a6bSchristos[AS_HELP_STRING([--enable-offload-defaulted]
3154b169a6bSchristos		[If enabled, configured but not installed offload compilers and
3164b169a6bSchristos		libgomp plugins are silently ignored.  Useful for distribution
3174b169a6bSchristos		compilers where those are in separate optional packages.])],
3184b169a6bSchristos[enable_offload_defaulted=$enableval],
3194b169a6bSchristos[enable_offload_defaulted=])
3204b169a6bSchristos
321597410b8Schristos# Handle --enable-gold, --enable-ld.
322597410b8Schristos# --disable-gold [--enable-ld]
323597410b8Schristos#     Build only ld.  Default option.
324597410b8Schristos# --enable-gold [--enable-ld]
325597410b8Schristos#     Build both gold and ld.  Install gold as "ld.gold", install ld
326597410b8Schristos#     as "ld.bfd" and "ld".
327597410b8Schristos# --enable-gold=default [--enable-ld]
328597410b8Schristos#     Build both gold and ld.  Install gold as "ld.gold" and "ld",
329597410b8Schristos#     install ld as "ld.bfd".
330597410b8Schristos# --enable-gold[=default] --disable-ld
331597410b8Schristos#     Build only gold, which is then installed as both "ld.gold" and "ld".
332597410b8Schristos# --enable-gold --enable-ld=default
333597410b8Schristos#     Build both gold (installed as "ld.gold") and ld (installed as "ld"
334597410b8Schristos#     and ld.bfd).
335597410b8Schristos#     In other words, ld is default
336597410b8Schristos# --enable-gold=default --enable-ld=default
337597410b8Schristos#     Error.
338597410b8Schristos
339597410b8Schristosdefault_ld=
340597410b8SchristosAC_ARG_ENABLE(gold,
341597410b8Schristos[AS_HELP_STRING([[--enable-gold[=ARG]]],
342597410b8Schristos		[build gold @<:@ARG={default,yes,no}@:>@])],
343597410b8SchristosENABLE_GOLD=$enableval,
344597410b8SchristosENABLE_GOLD=no)
345597410b8Schristoscase "${ENABLE_GOLD}" in
346597410b8Schristos  yes|default)
347597410b8Schristos    # Check for ELF target.
348597410b8Schristos    is_elf=no
349597410b8Schristos    case "${target}" in
350597410b8Schristos      *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
35105598a80Schristos      | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
352597410b8Schristos      | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
353*079139fbSchristos      | *-*-solaris2* | *-*-nto* | *-*-nacl* | *-*-haiku*)
354597410b8Schristos        case "${target}" in
355597410b8Schristos          *-*-linux*aout* | *-*-linux*oldld*)
356597410b8Schristos            ;;
357597410b8Schristos          *)
358597410b8Schristos            is_elf=yes
359597410b8Schristos            ;;
360597410b8Schristos        esac
361597410b8Schristos    esac
362597410b8Schristos
363597410b8Schristos    if test "$is_elf" = "yes"; then
364597410b8Schristos      # Check for target supported by gold.
365597410b8Schristos      case "${target}" in
3669d210927Schristos        i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
3674b169a6bSchristos        | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | loongarch*-*-*)
368597410b8Schristos	  configdirs="$configdirs gold"
369597410b8Schristos	  if test x${ENABLE_GOLD} = xdefault; then
370597410b8Schristos	    default_ld=gold
371597410b8Schristos	  fi
372597410b8Schristos	  ENABLE_GOLD=yes
373597410b8Schristos          ;;
374597410b8Schristos      esac
375597410b8Schristos    fi
376597410b8Schristos    ;;
377597410b8Schristos  no)
378597410b8Schristos    ;;
379597410b8Schristos  *)
380597410b8Schristos    AC_MSG_ERROR([invalid --enable-gold argument])
381597410b8Schristos    ;;
382597410b8Schristosesac
383597410b8Schristos
384597410b8SchristosAC_ARG_ENABLE(ld,
385597410b8Schristos[AS_HELP_STRING([[--enable-ld[=ARG]]],
386597410b8Schristos		[build ld @<:@ARG={default,yes,no}@:>@])],
387597410b8SchristosENABLE_LD=$enableval,
388597410b8SchristosENABLE_LD=yes)
389597410b8Schristos
390597410b8Schristoscase "${ENABLE_LD}" in
391597410b8Schristos  default)
392597410b8Schristos    if test x${default_ld} != x; then
393597410b8Schristos      AC_MSG_ERROR([either gold or ld can be the default ld])
394597410b8Schristos    fi
395597410b8Schristos    ;;
396597410b8Schristos  yes)
397597410b8Schristos    ;;
398597410b8Schristos  no)
399597410b8Schristos    if test x${ENABLE_GOLD} != xyes; then
400597410b8Schristos      AC_MSG_WARN([neither ld nor gold are enabled])
401597410b8Schristos    fi
402597410b8Schristos    configdirs=`echo " ${configdirs} " | sed -e 's/ ld / /'`
403597410b8Schristos    ;;
404597410b8Schristos  *)
405597410b8Schristos    AC_MSG_ERROR([invalid --enable-ld argument])
406597410b8Schristos    ;;
407597410b8Schristosesac
408597410b8Schristos
4094b169a6bSchristosAC_ARG_ENABLE(gprofng,
4104b169a6bSchristos[AS_HELP_STRING([[--enable-gprofng[=ARG]]],
4114b169a6bSchristos		[build gprofng @<:@ARG={yes,no}@:>@])],
4124b169a6bSchristosenable_gprofng=$enableval,
4134b169a6bSchristosenable_gprofng=yes)
4144b169a6bSchristosif test "$enable_gprofng" = "yes"; then
4154b169a6bSchristos  case "${target}" in
4164b169a6bSchristos    x86_64-*-linux* | i?86-*-linux* | aarch64-*-linux*)
4174b169a6bSchristos    configdirs="$configdirs gprofng"
4184b169a6bSchristos    ;;
4194b169a6bSchristos  esac
4204b169a6bSchristosfi
4214b169a6bSchristos
4224b169a6bSchristos
423ba340e45Schristos# PR gas/19109
424ba340e45Schristos# Decide the default method for compressing debug sections.
425ba340e45Schristos# Provide a configure time option to override our default.
426ba340e45SchristosAC_ARG_ENABLE(compressed_debug_sections,
427ba340e45Schristos[AS_HELP_STRING([--enable-compressed-debug-sections={all,gas,gold,ld,none}],
428ba340e45Schristos		[Enable compressed debug sections for gas, gold or ld by
429ba340e45Schristos		 default])],
430ba340e45Schristos[
431ba340e45Schristos  if test x"$enable_compressed_debug_sections" = xyes; then
432ba340e45Schristos    AC_MSG_ERROR([no program with compressed debug sections specified])
433ba340e45Schristos  fi
434ba340e45Schristos], [enable_compressed_debug_sections=])
435ba340e45Schristos
4364b169a6bSchristos# Select default compression algorithm.
4374b169a6bSchristosAC_ARG_ENABLE(default_compressed_debug_sections_algorithm,
4384b169a6bSchristos[AS_HELP_STRING([--enable-default-compressed-debug-sections-algorithm={zlib,zstd}],
4394b169a6bSchristos		[Default compression algorithm for --enable-compressed-debug-sections.])],
4404b169a6bSchristos[], [default_compressed_debug_sections_algorithm=])
4414b169a6bSchristos
442597410b8Schristos# Configure extra directories which are host specific
443597410b8Schristos
444597410b8Schristoscase "${host}" in
445597410b8Schristos  *-cygwin*)
446597410b8Schristos    configdirs="$configdirs libtermcap" ;;
447597410b8Schristosesac
448597410b8Schristos
449597410b8Schristos# A target can indicate whether a language isn't supported for some reason.
450597410b8Schristos# Only spaces may be used in this macro; not newlines or tabs.
451597410b8Schristosunsupported_languages=
452597410b8Schristos
453597410b8Schristos# Remove more programs from consideration, based on the host or
454597410b8Schristos# target this usually means that a port of the program doesn't
455597410b8Schristos# exist yet.
456597410b8Schristos
457597410b8Schristoscase "${host}" in
458597410b8Schristos  i[[3456789]]86-*-msdosdjgpp*)
459597410b8Schristos    noconfigdirs="$noconfigdirs tcl tk itcl"
460597410b8Schristos    ;;
461597410b8Schristosesac
462597410b8Schristos
4634b169a6bSchristos# Default to --disable-year2038 until we can handle differences between
4644b169a6bSchristos# projects that use gnulib (which understands year 2038) and projects that
4654b169a6bSchristos# do not (like BFD).
4664b169a6bSchristosAC_ARG_ENABLE(year2038,
4674b169a6bSchristosAS_HELP_STRING([--enable-year2038],
4684b169a6bSchristos  [enable support for timestamps past the year 2038]),
4694b169a6bSchristosENABLE_YEAR2038=$enableval,
4704b169a6bSchristosENABLE_YEAR2038=no)
4714b169a6bSchristosenable_year2038=
4724b169a6bSchristosif test "${ENABLE_YEAR2038}" = "no" ; then
4734b169a6bSchristos  enable_year2038=no
4744b169a6bSchristosfi
475597410b8Schristos
476597410b8SchristosAC_ARG_ENABLE(libquadmath,
477597410b8SchristosAS_HELP_STRING([--disable-libquadmath],
478597410b8Schristos  [do not build libquadmath directory]),
479597410b8SchristosENABLE_LIBQUADMATH=$enableval,
480597410b8SchristosENABLE_LIBQUADMATH=yes)
481597410b8Schristosif test "${ENABLE_LIBQUADMATH}" = "no" ; then
482597410b8Schristos  noconfigdirs="$noconfigdirs target-libquadmath"
483597410b8Schristosfi
484597410b8Schristos
485597410b8Schristos
486597410b8SchristosAC_ARG_ENABLE(libquadmath-support,
487597410b8SchristosAS_HELP_STRING([--disable-libquadmath-support],
488597410b8Schristos  [disable libquadmath support for Fortran]),
489597410b8SchristosENABLE_LIBQUADMATH_SUPPORT=$enableval,
490597410b8SchristosENABLE_LIBQUADMATH_SUPPORT=yes)
491597410b8Schristosenable_libquadmath_support=
492597410b8Schristosif test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
493597410b8Schristos  enable_libquadmath_support=no
494597410b8Schristosfi
495597410b8Schristos
496597410b8Schristos
497597410b8SchristosAC_ARG_ENABLE(libada,
498597410b8Schristos[AS_HELP_STRING([--enable-libada], [build libada directory])],
499597410b8SchristosENABLE_LIBADA=$enableval,
500597410b8SchristosENABLE_LIBADA=yes)
501597410b8Schristosif test "${ENABLE_LIBADA}" != "yes" ; then
502597410b8Schristos  noconfigdirs="$noconfigdirs gnattools"
503597410b8Schristosfi
504597410b8Schristos
505*079139fbSchristosAC_ARG_ENABLE(libgm2,
506*079139fbSchristos[AS_HELP_STRING([--enable-libgm2], [build libgm2 directory])],
507*079139fbSchristosENABLE_LIBGM2=$enableval,
508*079139fbSchristosENABLE_LIBGM2=no)
509*079139fbSchristosif test "${ENABLE_LIBGM2}" != "yes" ; then
510*079139fbSchristos  noconfigdirs="$noconfigdirs gm2tools"
511*079139fbSchristosfi
512*079139fbSchristos
513597410b8SchristosAC_ARG_ENABLE(libssp,
514597410b8Schristos[AS_HELP_STRING([--enable-libssp], [build libssp directory])],
515597410b8SchristosENABLE_LIBSSP=$enableval,
516597410b8SchristosENABLE_LIBSSP=yes)
517597410b8Schristos
51805598a80SchristosAC_ARG_ENABLE(libstdcxx,
51905598a80SchristosAS_HELP_STRING([--disable-libstdcxx],
52005598a80Schristos  [do not build libstdc++-v3 directory]),
52105598a80SchristosENABLE_LIBSTDCXX=$enableval,
52205598a80SchristosENABLE_LIBSTDCXX=default)
52305598a80Schristos[if test "${ENABLE_LIBSTDCXX}" = "no" ; then
524212397c6Schristos  noconfigdirs="$noconfigdirs target-libstdc++-v3"
52505598a80Schristosfi]
52605598a80Schristos
527ba340e45Schristos# Enable libgomp by default on hosted POSIX systems, and a few others.
528597410b8Schristosif test x$enable_libgomp = x ; then
529597410b8Schristos    case "${target}" in
530597410b8Schristos    *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
531597410b8Schristos	;;
532597410b8Schristos    *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly*)
533597410b8Schristos	;;
53405598a80Schristos    *-*-solaris2* | *-*-hpux11*)
535597410b8Schristos	;;
536597410b8Schristos    *-*-darwin* | *-*-aix*)
537597410b8Schristos	;;
5384b169a6bSchristos    nvptx*-*-* | amdgcn*-*-*)
539ba340e45Schristos	;;
540597410b8Schristos    *)
541597410b8Schristos	noconfigdirs="$noconfigdirs target-libgomp"
542597410b8Schristos	;;
543597410b8Schristos    esac
544597410b8Schristosfi
545597410b8Schristos
54605598a80Schristos# Disable libatomic on unsupported systems.
54705598a80Schristosif test -d ${srcdir}/libatomic; then
54805598a80Schristos    if test x$enable_libatomic = x; then
54905598a80Schristos	AC_MSG_CHECKING([for libatomic support])
55005598a80Schristos	if (srcdir=${srcdir}/libatomic; \
55105598a80Schristos		. ${srcdir}/configure.tgt; \
55205598a80Schristos		test -n "$UNSUPPORTED")
55305598a80Schristos	then
55405598a80Schristos	    AC_MSG_RESULT([no])
55505598a80Schristos	    noconfigdirs="$noconfigdirs target-libatomic"
55605598a80Schristos	else
55705598a80Schristos	    AC_MSG_RESULT([yes])
55805598a80Schristos	fi
55905598a80Schristos    fi
56005598a80Schristosfi
56105598a80Schristos
56205598a80Schristos# Disable libitm on unsupported systems.
56305598a80Schristosif test -d ${srcdir}/libitm; then
56405598a80Schristos    if test x$enable_libitm = x; then
56505598a80Schristos	AC_MSG_CHECKING([for libitm support])
56605598a80Schristos	if (srcdir=${srcdir}/libitm; \
56705598a80Schristos		. ${srcdir}/configure.tgt; \
56805598a80Schristos		test -n "$UNSUPPORTED")
56905598a80Schristos	then
57005598a80Schristos	    AC_MSG_RESULT([no])
57105598a80Schristos	    noconfigdirs="$noconfigdirs target-libitm"
57205598a80Schristos	else
57305598a80Schristos	    AC_MSG_RESULT([yes])
57405598a80Schristos	fi
57505598a80Schristos    fi
57605598a80Schristosfi
57705598a80Schristos
57805598a80Schristos# Disable libsanitizer on unsupported systems.
57905598a80Schristosif test -d ${srcdir}/libsanitizer; then
58005598a80Schristos    if test x$enable_libsanitizer = x; then
58105598a80Schristos	AC_MSG_CHECKING([for libsanitizer support])
58205598a80Schristos	if (srcdir=${srcdir}/libsanitizer; \
58305598a80Schristos		. ${srcdir}/configure.tgt; \
58405598a80Schristos		test -n "$UNSUPPORTED")
58505598a80Schristos	then
58605598a80Schristos	    AC_MSG_RESULT([no])
58705598a80Schristos	    noconfigdirs="$noconfigdirs target-libsanitizer"
58805598a80Schristos	else
58905598a80Schristos	    AC_MSG_RESULT([yes])
59005598a80Schristos	fi
59105598a80Schristos    fi
59205598a80Schristosfi
59305598a80Schristos
59403467a24Schristos# Disable libvtv on unsupported systems.
59503467a24Schristosif test -d ${srcdir}/libvtv; then
59603467a24Schristos    if test x$enable_libvtv = x; then
59703467a24Schristos	AC_MSG_CHECKING([for libvtv support])
59803467a24Schristos	if (srcdir=${srcdir}/libvtv; \
59903467a24Schristos		. ${srcdir}/configure.tgt; \
60003467a24Schristos		test "$VTV_SUPPORTED" != "yes")
60103467a24Schristos	then
60203467a24Schristos	    AC_MSG_RESULT([no])
60303467a24Schristos	    noconfigdirs="$noconfigdirs target-libvtv"
60403467a24Schristos	else
60503467a24Schristos	    AC_MSG_RESULT([yes])
60603467a24Schristos	fi
60703467a24Schristos    fi
60803467a24Schristosfi
60903467a24Schristos
61005598a80Schristos# Disable libquadmath for some systems.
61105598a80Schristoscase "${target}" in
61205598a80Schristos  avr-*-*)
61305598a80Schristos    noconfigdirs="$noconfigdirs target-libquadmath"
61405598a80Schristos    ;;
61505598a80Schristos  # libquadmath is unused on AIX and libquadmath build process use of
61605598a80Schristos  # LD_LIBRARY_PATH can break AIX bootstrap.
61705598a80Schristos  powerpc-*-aix* | rs6000-*-aix*)
61805598a80Schristos    noconfigdirs="$noconfigdirs target-libquadmath"
61905598a80Schristos    ;;
62005598a80Schristosesac
62105598a80Schristos
622597410b8Schristos# Disable libssp for some systems.
623597410b8Schristoscase "${target}" in
624597410b8Schristos  avr-*-*)
625597410b8Schristos    # No hosted I/O support.
626597410b8Schristos    noconfigdirs="$noconfigdirs target-libssp"
627597410b8Schristos    ;;
6284b169a6bSchristos  bpf-*-*)
6294b169a6bSchristos    noconfigdirs="$noconfigdirs target-libssp"
6304b169a6bSchristos    ;;
631597410b8Schristos  powerpc-*-aix* | rs6000-*-aix*)
632597410b8Schristos    noconfigdirs="$noconfigdirs target-libssp"
633597410b8Schristos    ;;
6344b169a6bSchristos  pru-*-*)
6354b169a6bSchristos    # No hosted I/O support.
6364b169a6bSchristos    noconfigdirs="$noconfigdirs target-libssp"
6374b169a6bSchristos    ;;
63805598a80Schristos  rl78-*-*)
63905598a80Schristos    # libssp uses a misaligned load to trigger a fault, but the RL78
64005598a80Schristos    # doesn't fault for those - instead, it gives a build-time error
64105598a80Schristos    # for explicit misaligned loads.
64205598a80Schristos    noconfigdirs="$noconfigdirs target-libssp"
643597410b8Schristos    ;;
644212397c6Schristos  visium-*-*)
645212397c6Schristos    # No hosted I/O support.
646212397c6Schristos    noconfigdirs="$noconfigdirs target-libssp"
647212397c6Schristos    ;;
648597410b8Schristosesac
649597410b8Schristos
650597410b8Schristos# Disable libstdc++-v3 for some systems.
6514b169a6bSchristos# Allow user to override this if they pass --enable-libstdcxx
65205598a80Schristosif test "${ENABLE_LIBSTDCXX}" = "default" ; then
653597410b8Schristos  case "${target}" in
654597410b8Schristos    *-*-vxworks*)
655597410b8Schristos      # VxWorks uses the Dinkumware C++ library.
656597410b8Schristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
657597410b8Schristos      ;;
6584b169a6bSchristos    amdgcn*-*-*)
6594b169a6bSchristos      # Not ported/fails to build when using newlib.
6604b169a6bSchristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
6614b169a6bSchristos      ;;
662597410b8Schristos    arm*-wince-pe*)
663597410b8Schristos      # the C++ libraries don't build on top of CE's C libraries
664597410b8Schristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
665597410b8Schristos      ;;
666597410b8Schristos    avr-*-*)
667597410b8Schristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
668597410b8Schristos      ;;
6694b169a6bSchristos    bpf-*-*)
6704b169a6bSchristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
6714b169a6bSchristos      ;;
672ba340e45Schristos    ft32-*-*)
673ba340e45Schristos      noconfigdirs="$noconfigdirs target-libstdc++-v3"
674ba340e45Schristos      ;;
675597410b8Schristos  esac
67605598a80Schristosfi
677597410b8Schristos
6784b169a6bSchristos# Disable C++ on systems where it is known to not work.
6794b169a6bSchristos# For testing, you can override this with --enable-languages=c++.
6804b169a6bSchristoscase ,${enable_languages}, in
6814b169a6bSchristos  *,c++,*)
6824b169a6bSchristos    ;;
6834b169a6bSchristos  *)
6844b169a6bSchristos      case "${target}" in
6854b169a6bSchristos        bpf-*-*)
6864b169a6bSchristos          unsupported_languages="$unsupported_languages c++"
6874b169a6bSchristos          ;;
6884b169a6bSchristos      esac
6894b169a6bSchristos      ;;
6904b169a6bSchristosesac
6914b169a6bSchristos
6924b169a6bSchristos# Disable Objc on systems where it is known to not work.
6934b169a6bSchristos# For testing, you can override this with --enable-languages=objc.
6944b169a6bSchristoscase ,${enable_languages}, in
6954b169a6bSchristos  *,objc,*)
6964b169a6bSchristos    ;;
6974b169a6bSchristos  *)
6984b169a6bSchristos      case "${target}" in
6994b169a6bSchristos        bpf-*-*)
7004b169a6bSchristos          unsupported_languages="$unsupported_languages objc"
7014b169a6bSchristos          ;;
7024b169a6bSchristos      esac
7034b169a6bSchristos      ;;
7044b169a6bSchristosesac
7054b169a6bSchristos
7064b169a6bSchristos# Disable D on systems where it is known to not work.
7074b169a6bSchristos# For testing, you can override this with --enable-languages=d.
7084b169a6bSchristoscase ,${enable_languages}, in
7094b169a6bSchristos  *,d,*)
7104b169a6bSchristos    ;;
7114b169a6bSchristos  *)
7124b169a6bSchristos    case "${target}" in
7134b169a6bSchristos      bpf-*-*)
7144b169a6bSchristos	unsupported_languages="$unsupported_languages d"
7154b169a6bSchristos	;;
7164b169a6bSchristos    esac
7174b169a6bSchristos    ;;
7184b169a6bSchristosesac
7194b169a6bSchristos
7204b169a6bSchristos# Disable libphobos on unsupported systems.
7214b169a6bSchristos# For testing, you can override this with --enable-libphobos.
7224b169a6bSchristosif test -d ${srcdir}/libphobos; then
7234b169a6bSchristos    if test x$enable_libphobos = x; then
7244b169a6bSchristos	AC_MSG_CHECKING([for libphobos support])
7254b169a6bSchristos	if (srcdir=${srcdir}/libphobos; \
7264b169a6bSchristos		. ${srcdir}/configure.tgt; \
7274b169a6bSchristos		test "$LIBPHOBOS_SUPPORTED" != "yes")
7284b169a6bSchristos	then
7294b169a6bSchristos	    AC_MSG_RESULT([no])
7304b169a6bSchristos	    noconfigdirs="$noconfigdirs target-libphobos"
7314b169a6bSchristos	else
7324b169a6bSchristos	    AC_MSG_RESULT([yes])
7334b169a6bSchristos	fi
7344b169a6bSchristos    fi
7354b169a6bSchristosfi
7364b169a6bSchristos
737597410b8Schristos# Disable Fortran for some systems.
738597410b8Schristoscase "${target}" in
739597410b8Schristos  mmix-*-*)
740597410b8Schristos    # See <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00572.html>.
741597410b8Schristos    unsupported_languages="$unsupported_languages fortran"
742597410b8Schristos    ;;
7434b169a6bSchristos  bpf-*-*)
7444b169a6bSchristos    unsupported_languages="$unsupported_languages fortran"
7454b169a6bSchristos    ;;
746597410b8Schristosesac
747597410b8Schristos
748796c32c9Schristos# Disable libffi for some systems.
74905598a80Schristoscase "${target}" in
75005598a80Schristos  powerpc-*-darwin*)
75105598a80Schristos    ;;
75205598a80Schristos  i[[3456789]]86-*-darwin*)
75305598a80Schristos    ;;
75405598a80Schristos  x86_64-*-darwin[[912]]*)
75505598a80Schristos    ;;
75605598a80Schristos  *-*-darwin*)
757796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
75805598a80Schristos    ;;
75905598a80Schristos  *-*-netware*)
760796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
761796c32c9Schristos    ;;
762796c32c9Schristos  *-*-phoenix*)
763796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
76405598a80Schristos    ;;
76505598a80Schristos  *-*-rtems*)
766796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
76705598a80Schristos    ;;
76805598a80Schristos  *-*-tpf*)
769796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
77005598a80Schristos    ;;
77105598a80Schristos  *-*-uclinux*)
772796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
77305598a80Schristos    ;;
77405598a80Schristos  *-*-vxworks*)
775796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
776796c32c9Schristos    ;;
777796c32c9Schristos  aarch64*-*-freebsd*)
778796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
77905598a80Schristos    ;;
78005598a80Schristos  alpha*-*-*vms*)
781796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
78205598a80Schristos    ;;
783212397c6Schristos  arm*-*-freebsd*)
784796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
785212397c6Schristos    ;;
78605598a80Schristos  arm-wince-pe)
787796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
78805598a80Schristos    ;;
78905598a80Schristos  arm*-*-symbianelf*)
790796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
79105598a80Schristos    ;;
7924b169a6bSchristos  bpf-*-*)
7934b169a6bSchristos    noconfigdirs="$noconfigdirs target-libffi"
7944b169a6bSchristos    ;;
79505598a80Schristos  cris-*-* | crisv32-*-*)
79605598a80Schristos    case "${target}" in
79705598a80Schristos      *-*-linux*)
79805598a80Schristos	;;
79905598a80Schristos      *) # See PR46792 regarding target-libffi.
800796c32c9Schristos	noconfigdirs="$noconfigdirs target-libffi";;
80105598a80Schristos    esac
80205598a80Schristos    ;;
80305598a80Schristos  hppa*64*-*-hpux*)
804796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
80505598a80Schristos    ;;
80605598a80Schristos  hppa*-hp-hpux11*)
80705598a80Schristos    ;;
80805598a80Schristos  hppa*-*-hpux*)
809796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
81005598a80Schristos    ;;
81105598a80Schristos  ia64*-*-*vms*)
812796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
81305598a80Schristos    ;;
81405598a80Schristos  i[[3456789]]86-w64-mingw*)
815796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
81605598a80Schristos    ;;
81705598a80Schristos  i[[3456789]]86-*-mingw*)
818796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
81905598a80Schristos    ;;
82005598a80Schristos  x86_64-*-mingw*)
821796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
82205598a80Schristos    ;;
82305598a80Schristos  mmix-*-*)
824796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
82505598a80Schristos    ;;
82605598a80Schristos  powerpc-*-aix*)
82705598a80Schristos    ;;
82805598a80Schristos  rs6000-*-aix*)
82905598a80Schristos    ;;
830212397c6Schristos  ft32-*-*)
831796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
832212397c6Schristos    ;;
83305598a80Schristos  *-*-lynxos*)
834796c32c9Schristos    noconfigdirs="$noconfigdirs target-libffi"
83505598a80Schristos    ;;
83605598a80Schristosesac
83705598a80Schristos
838212397c6Schristos# Disable the go frontend on systems where it is known to not work. Please keep
839212397c6Schristos# this in sync with contrib/config-list.mk.
840212397c6Schristoscase "${target}" in
8414b169a6bSchristos*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* )
842212397c6Schristos    unsupported_languages="$unsupported_languages go"
843212397c6Schristos    ;;
844212397c6Schristosesac
845212397c6Schristos
8468dffb485Schristos# Only allow gdbserver on some systems.
8478dffb485Schristosif test -d ${srcdir}/gdbserver; then
8488dffb485Schristos    if test x$enable_gdbserver = x; then
8498dffb485Schristos	AC_MSG_CHECKING([for gdbserver support])
8508dffb485Schristos	if (srcdir=${srcdir}/gdbserver; \
8518dffb485Schristos		. ${srcdir}/configure.srv; \
8528dffb485Schristos		test -n "$UNSUPPORTED")
8538dffb485Schristos	then
8548dffb485Schristos	    AC_MSG_RESULT([no])
8558dffb485Schristos	    noconfigdirs="$noconfigdirs gdbserver"
8568dffb485Schristos	else
8578dffb485Schristos	    AC_MSG_RESULT([yes])
8588dffb485Schristos	fi
8598dffb485Schristos    fi
8608dffb485Schristosfi
8618dffb485Schristos
86205598a80Schristos# Disable libgo for some systems where it is known to not work.
86305598a80Schristos# For testing, you can easily override this with --enable-libgo.
86405598a80Schristosif test x$enable_libgo = x; then
86505598a80Schristos    case "${target}" in
86605598a80Schristos    *-*-darwin*)
86705598a80Schristos	# PR 46986
86805598a80Schristos	noconfigdirs="$noconfigdirs target-libgo"
86905598a80Schristos	;;
87005598a80Schristos    *-*-cygwin* | *-*-mingw*)
87105598a80Schristos	noconfigdirs="$noconfigdirs target-libgo"
87205598a80Schristos	;;
8734b169a6bSchristos    bpf-*-*)
8744b169a6bSchristos        noconfigdirs="$noconfigdirs target-libgo"
8754b169a6bSchristos        ;;
87605598a80Schristos    esac
87705598a80Schristosfi
87805598a80Schristos
879597410b8Schristos# Default libgloss CPU subdirectory.
880597410b8Schristoslibgloss_dir="$target_cpu"
881597410b8Schristos
882597410b8Schristoscase "${target}" in
88305598a80Schristos  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
88405598a80Schristos    libgloss_dir=wince
88505598a80Schristos    ;;
88605598a80Schristos  aarch64*-*-* )
88705598a80Schristos    libgloss_dir=aarch64
88805598a80Schristos    ;;
88905598a80Schristos  arm*-*-*)
89005598a80Schristos    libgloss_dir=arm
89105598a80Schristos    ;;
89205598a80Schristos  cris-*-* | crisv32-*-*)
89305598a80Schristos    libgloss_dir=cris
89405598a80Schristos    ;;
895*079139fbSchristos  kvx-*-elf)
896*079139fbSchristos    libgloss_dir=kvx-elf
897*079139fbSchristos    ;;
898*079139fbSchristos  kvx-*-mbr)
899*079139fbSchristos    libgloss_dir=kvx-mbr
900*079139fbSchristos    ;;
901*079139fbSchristos  kvx-*-cos)
902*079139fbSchristos    libgloss_dir=kvx-cos
903*079139fbSchristos    ;;
90405598a80Schristos  hppa*-*-*)
90505598a80Schristos    libgloss_dir=pa
90605598a80Schristos    ;;
90705598a80Schristos  i[[3456789]]86-*-*)
90805598a80Schristos    libgloss_dir=i386
90905598a80Schristos    ;;
9104b169a6bSchristos  loongarch*-*-*)
9114b169a6bSchristos    libgloss_dir=loongarch
9124b169a6bSchristos    ;;
91305598a80Schristos  m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
91405598a80Schristos    libgloss_dir=m68hc11
91505598a80Schristos    ;;
91605598a80Schristos  m68*-*-* | fido-*-*)
91705598a80Schristos    libgloss_dir=m68k
91805598a80Schristos    ;;
91905598a80Schristos  mips*-*-*)
92005598a80Schristos    libgloss_dir=mips
92105598a80Schristos    ;;
92205598a80Schristos  powerpc*-*-*)
92305598a80Schristos    libgloss_dir=rs6000
92405598a80Schristos    ;;
9254b169a6bSchristos  pru-*-*)
9264b169a6bSchristos    libgloss_dir=pru
9274b169a6bSchristos    ;;
92805598a80Schristos  sparc*-*-*)
92905598a80Schristos    libgloss_dir=sparc
93005598a80Schristos    ;;
93105598a80Schristosesac
93205598a80Schristos
93305598a80Schristos# Disable newlib and libgloss for various target OSes.
93405598a80Schristoscase "${target}" in
93505598a80Schristos  alpha*-dec-osf*)
93605598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
93705598a80Schristos    ;;
93805598a80Schristos  i[[3456789]]86-*-linux*)
93905598a80Schristos    # This section makes it possible to build newlib natively on linux.
94005598a80Schristos    # If we are using a cross compiler then don't configure newlib.
94105598a80Schristos    if test x${is_cross_compiler} != xno ; then
94205598a80Schristos      noconfigdirs="$noconfigdirs target-newlib"
94305598a80Schristos    fi
94405598a80Schristos    noconfigdirs="$noconfigdirs target-libgloss"
94505598a80Schristos    # If we are not using a cross compiler, do configure newlib.
94605598a80Schristos    # Note however, that newlib will only be configured in this situation
94705598a80Schristos    # if the --with-newlib option has been given, because otherwise
94805598a80Schristos    # 'target-newlib' will appear in skipdirs.
94905598a80Schristos    ;;
95005598a80Schristos  i[[3456789]]86-*-rdos*)
95105598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
95205598a80Schristos    ;;
95305598a80Schristos  sh*-*-pe|mips*-*-pe|arm-wince-pe)
95405598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
95505598a80Schristos    ;;
95605598a80Schristos  sparc-*-sunos4*)
95705598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
95805598a80Schristos    ;;
9594b169a6bSchristos  bpf-*-*)
9604b169a6bSchristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
9614b169a6bSchristos    ;;
96205598a80Schristos  *-*-aix*)
96305598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
96405598a80Schristos    ;;
96505598a80Schristos  *-*-beos*)
96605598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
96705598a80Schristos    ;;
968597410b8Schristos  *-*-chorusos)
969597410b8Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
970597410b8Schristos    ;;
97105598a80Schristos  *-*-dragonfly*)
97205598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
97305598a80Schristos    ;;
97405598a80Schristos  *-*-freebsd*)
97505598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
97605598a80Schristos    ;;
97705598a80Schristos  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
97805598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
97905598a80Schristos    ;;
98005598a80Schristos  *-*-lynxos*)
98105598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
98205598a80Schristos    ;;
98305598a80Schristos  *-*-mingw*)
98405598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
98505598a80Schristos    ;;
98605598a80Schristos  *-*-netbsd*)
98705598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
98805598a80Schristos    ;;
98905598a80Schristos  *-*-netware*)
99005598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
99105598a80Schristos    ;;
99205598a80Schristos  *-*-tpf*)
99305598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
99405598a80Schristos    ;;
99505598a80Schristos  *-*-uclinux*)
99605598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
99705598a80Schristos    ;;
99805598a80Schristos  *-*-vxworks*)
99905598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
100005598a80Schristos    ;;
100105598a80Schristosesac
100205598a80Schristos
100305598a80Schristoscase "${target}" in
100405598a80Schristos  *-*-chorusos)
100505598a80Schristos    ;;
1006ba340e45Schristos  aarch64-*-darwin*)
1007ba340e45Schristos    noconfigdirs="$noconfigdirs ld gas gdb gprof"
1008ba340e45Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1009ba340e45Schristos    ;;
10104b169a6bSchristos  amdgcn*-*-*)
10114b169a6bSchristos    ;;
1012ba340e45Schristos  arm-*-darwin*)
1013ba340e45Schristos    noconfigdirs="$noconfigdirs ld gas gdb gprof"
1014ba340e45Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1015ba340e45Schristos    ;;
1016597410b8Schristos  powerpc-*-darwin*)
1017597410b8Schristos    noconfigdirs="$noconfigdirs ld gas gdb gprof"
1018597410b8Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1019597410b8Schristos    ;;
1020597410b8Schristos  i[[3456789]]86-*-darwin*)
1021597410b8Schristos    noconfigdirs="$noconfigdirs ld gprof"
1022597410b8Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1023597410b8Schristos    ;;
1024597410b8Schristos  x86_64-*-darwin[[912]]*)
1025597410b8Schristos    noconfigdirs="$noconfigdirs ld gas gprof"
1026597410b8Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1027597410b8Schristos    ;;
1028597410b8Schristos  *-*-darwin*)
1029597410b8Schristos    noconfigdirs="$noconfigdirs ld gas gdb gprof"
1030597410b8Schristos    noconfigdirs="$noconfigdirs sim target-rda"
1031597410b8Schristos    ;;
1032597410b8Schristos  *-*-dragonfly*)
1033597410b8Schristos    ;;
1034597410b8Schristos  *-*-freebsd*)
10354b169a6bSchristos    if test "x$with_gmp" = x \
10364b169a6bSchristos	&& ! test -d ${srcdir}/gmp \
1037597410b8Schristos	&& test -f /usr/local/include/gmp.h; then
1038597410b8Schristos      with_gmp=/usr/local
1039597410b8Schristos    fi
1040597410b8Schristos    ;;
1041597410b8Schristos  *-*-kaos*)
1042597410b8Schristos    # Remove unsupported stuff on all kaOS configurations.
1043597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1044597410b8Schristos    ;;
1045597410b8Schristos  *-*-netbsd*)
1046597410b8Schristos    ;;
1047597410b8Schristos  *-*-netware*)
1048597410b8Schristos    ;;
1049796c32c9Schristos  *-*-phoenix*)
1050796c32c9Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1051796c32c9Schristos    ;;
1052597410b8Schristos  *-*-rtems*)
105305598a80Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1054597410b8Schristos    ;;
1055597410b8Schristos    # The tpf target doesn't support gdb yet.
1056597410b8Schristos  *-*-tpf*)
105705598a80Schristos    noconfigdirs="$noconfigdirs gdb tcl tk libgui itcl"
1058597410b8Schristos    ;;
1059597410b8Schristos  *-*-uclinux*)
106005598a80Schristos    noconfigdirs="$noconfigdirs target-rda"
1061597410b8Schristos    ;;
1062597410b8Schristos  *-*-vxworks*)
1063597410b8Schristos    ;;
1064597410b8Schristos  alpha*-dec-osf*)
1065597410b8Schristos    # ld works, but does not support shared libraries.
1066597410b8Schristos    # gas doesn't generate exception information.
106705598a80Schristos    noconfigdirs="$noconfigdirs gas ld"
1068597410b8Schristos    ;;
1069597410b8Schristos  alpha*-*-*vms*)
107005598a80Schristos    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
1071597410b8Schristos    ;;
1072597410b8Schristos  alpha*-*-*)
1073597410b8Schristos    # newlib is not 64 bit ready
107405598a80Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
1075597410b8Schristos    ;;
10764b169a6bSchristos  bpf-*-*)
10774b169a6bSchristos    noconfigdirs="$noconfigdirs target-libobjc target-libbacktrace"
10784b169a6bSchristos    ;;
1079597410b8Schristos  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
1080597410b8Schristos    noconfigdirs="$noconfigdirs tcl tk itcl libgui sim"
1081597410b8Schristos    ;;
1082796c32c9Schristos  arc*-*-*)
1083796c32c9Schristos    noconfigdirs="$noconfigdirs sim"
1084597410b8Schristos    ;;
1085597410b8Schristos  arm-*-pe*)
108605598a80Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1087597410b8Schristos    ;;
1088597410b8Schristos  arm-*-riscix*)
1089597410b8Schristos    noconfigdirs="$noconfigdirs ld target-libgloss"
1090597410b8Schristos    ;;
109105598a80Schristos  avr-*-*)
109205598a80Schristos    if test x${with_avrlibc} != xno; then
109305598a80Schristos      noconfigdirs="$noconfigdirs target-newlib target-libgloss"
109405598a80Schristos    fi
1095597410b8Schristos    ;;
1096597410b8Schristos  c4x-*-* | tic4x-*-*)
1097597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1098597410b8Schristos    ;;
1099597410b8Schristos  tic54x-*-*)
1100597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss gdb"
1101597410b8Schristos    ;;
1102597410b8Schristos  d10v-*-*)
1103597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1104597410b8Schristos    ;;
1105597410b8Schristos  d30v-*-*)
1106597410b8Schristos    noconfigdirs="$noconfigdirs gdb"
1107597410b8Schristos    ;;
1108597410b8Schristos  fr30-*-elf*)
110905598a80Schristos    noconfigdirs="$noconfigdirs gdb"
1110597410b8Schristos    ;;
1111212397c6Schristos  ft32-*-*)
1112212397c6Schristos    noconfigdirs="$noconfigdirs target-rda gprof"
1113212397c6Schristos    ;;
1114597410b8Schristos  moxie-*-*)
1115212397c6Schristos    noconfigdirs="$noconfigdirs"
1116597410b8Schristos    ;;
1117597410b8Schristos  h8300*-*-*)
111805598a80Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1119597410b8Schristos    ;;
1120597410b8Schristos  h8500-*-*)
1121597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1122597410b8Schristos    ;;
1123597410b8Schristos  hppa1.1-*-osf* | hppa1.1-*-bsd* )
1124597410b8Schristos    ;;
1125212397c6Schristos  hppa*64*-*-hpux*)
1126212397c6Schristos    noconfigdirs="$noconfigdirs gdb"
1127212397c6Schristos    ;;
1128212397c6Schristos  hppa*-*-hpux11*)
1129212397c6Schristos    noconfigdirs="$noconfigdirs gdb ld"
1130212397c6Schristos    ;;
1131597410b8Schristos  hppa*64*-*-linux*)
1132597410b8Schristos    ;;
1133597410b8Schristos  hppa*-*-linux*)
1134597410b8Schristos    ;;
1135597410b8Schristos  hppa*-*-*elf* | \
1136597410b8Schristos  hppa*-*-lites* | \
1137597410b8Schristos  hppa*-*-openbsd* | \
1138597410b8Schristos  hppa*64*-*-*)
1139597410b8Schristos    ;;
1140597410b8Schristos  hppa*-*-pro*)
1141597410b8Schristos    ;;
1142597410b8Schristos  hppa*-*-*)
114305598a80Schristos    noconfigdirs="$noconfigdirs ld"
1144597410b8Schristos    ;;
1145597410b8Schristos  i960-*-*)
1146597410b8Schristos    noconfigdirs="$noconfigdirs gdb"
1147597410b8Schristos    ;;
1148597410b8Schristos  ia64*-*-elf*)
1149597410b8Schristos    # No gdb support yet.
1150597410b8Schristos    noconfigdirs="$noconfigdirs readline libgui itcl gdb"
1151597410b8Schristos    ;;
1152597410b8Schristos  ia64*-**-hpux*)
1153597410b8Schristos    # No ld support yet.
1154212397c6Schristos    noconfigdirs="$noconfigdirs gdb libgui itcl ld"
1155597410b8Schristos    ;;
1156597410b8Schristos  ia64*-*-*vms*)
115705598a80Schristos    # No ld support yet.
115805598a80Schristos    noconfigdirs="$noconfigdirs libgui itcl ld"
1159597410b8Schristos    ;;
1160597410b8Schristos  i[[3456789]]86-w64-mingw*)
1161597410b8Schristos    ;;
1162597410b8Schristos  i[[3456789]]86-*-mingw*)
1163597410b8Schristos    target_configdirs="$target_configdirs target-winsup"
1164597410b8Schristos    ;;
1165597410b8Schristos  *-*-cygwin*)
1166597410b8Schristos    target_configdirs="$target_configdirs target-libtermcap target-winsup"
1167597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1168597410b8Schristos    # always build newlib if winsup directory is present.
1169597410b8Schristos    if test -d "$srcdir/winsup/cygwin"; then
1170597410b8Schristos      skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
1171597410b8Schristos    elif test -d "$srcdir/newlib"; then
1172597410b8Schristos      echo "Warning: winsup/cygwin is missing so newlib can't be built."
1173597410b8Schristos    fi
1174597410b8Schristos    ;;
1175597410b8Schristos  i[[3456789]]86-*-pe)
1176597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1177597410b8Schristos    ;;
1178597410b8Schristos  i[[3456789]]86-*-sco3.2v5*)
1179597410b8Schristos    # The linker does not yet know about weak symbols in COFF,
1180597410b8Schristos    # and is not configured to handle mixed ELF and COFF.
1181597410b8Schristos    noconfigdirs="$noconfigdirs ld target-libgloss"
1182597410b8Schristos    ;;
1183597410b8Schristos  i[[3456789]]86-*-sco*)
1184597410b8Schristos    noconfigdirs="$noconfigdirs gprof target-libgloss"
1185597410b8Schristos    ;;
118605598a80Schristos  i[[3456789]]86-*-solaris2* | x86_64-*-solaris2.1[[0-9]]*)
1187597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1188597410b8Schristos    ;;
1189597410b8Schristos  i[[3456789]]86-*-sysv4*)
1190597410b8Schristos    noconfigdirs="$noconfigdirs target-libgloss"
1191597410b8Schristos    ;;
1192597410b8Schristos  i[[3456789]]86-*-beos*)
119305598a80Schristos    noconfigdirs="$noconfigdirs gdb"
1194597410b8Schristos    ;;
1195597410b8Schristos  i[[3456789]]86-*-rdos*)
119605598a80Schristos    noconfigdirs="$noconfigdirs gdb"
1197597410b8Schristos    ;;
1198*079139fbSchristos  kvx-*-*)
1199*079139fbSchristos    noconfigdirs="$noconfigdirs gdb gdbserver sim"
1200*079139fbSchristos    ;;
1201597410b8Schristos  mmix-*-*)
120205598a80Schristos    noconfigdirs="$noconfigdirs gdb"
1203597410b8Schristos    ;;
1204597410b8Schristos  mt-*-*)
1205597410b8Schristos    noconfigdirs="$noconfigdirs sim"
1206597410b8Schristos    ;;
12074559860eSchristos  nfp-*-*)
12084559860eSchristos    noconfigdirs="$noconfigdirs ld gas gdb gprof sim"
12094559860eSchristos    noconfigdirs="$noconfigdirs $target_libraries"
12104559860eSchristos    ;;
12118dffb485Schristos  pdp11-*-*)
12128dffb485Schristos    noconfigdirs="$noconfigdirs gdb gprof"
12138dffb485Schristos    ;;
1214597410b8Schristos  powerpc-*-aix*)
1215597410b8Schristos    # copied from rs6000-*-* entry
121605598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1217597410b8Schristos    ;;
1218597410b8Schristos  powerpc*-*-winnt* | powerpc*-*-pe*)
1219597410b8Schristos    target_configdirs="$target_configdirs target-winsup"
1220597410b8Schristos    noconfigdirs="$noconfigdirs gdb tcl tk target-libgloss itcl"
1221597410b8Schristos    # always build newlib.
1222597410b8Schristos    skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
1223597410b8Schristos    ;;
1224597410b8Schristos    # This is temporary until we can link against shared libraries
1225597410b8Schristos  powerpcle-*-solaris*)
1226597410b8Schristos    noconfigdirs="$noconfigdirs gdb sim tcl tk itcl"
1227597410b8Schristos    ;;
1228597410b8Schristos  powerpc-*-beos*)
122905598a80Schristos    noconfigdirs="$noconfigdirs gdb"
1230597410b8Schristos    ;;
1231597410b8Schristos  rs6000-*-lynxos*)
123205598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1233597410b8Schristos    ;;
1234597410b8Schristos  rs6000-*-aix*)
123505598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1236597410b8Schristos    ;;
1237597410b8Schristos  rs6000-*-*)
123805598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1239597410b8Schristos    ;;
1240597410b8Schristos  m68k-apollo-*)
1241597410b8Schristos    noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss"
1242597410b8Schristos    ;;
1243597410b8Schristos  microblaze*)
124405598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1245597410b8Schristos    ;;
12469d210927Schristos  mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
1247597410b8Schristos    if test x$with_newlib = xyes; then
1248597410b8Schristos      noconfigdirs="$noconfigdirs gprof"
1249597410b8Schristos    fi
1250597410b8Schristos    ;;
1251597410b8Schristos  mips*-*-irix5*)
1252597410b8Schristos    noconfigdirs="$noconfigdirs gprof target-libgloss"
1253597410b8Schristos    ;;
1254597410b8Schristos  mips*-*-irix6*)
125505598a80Schristos    noconfigdirs="$noconfigdirs gprof target-libgloss"
1256597410b8Schristos    ;;
1257597410b8Schristos  mips*-*-bsd*)
125803467a24Schristos    noconfigdirs="$noconfigdirs ld gas gprof target-libgloss"
1259597410b8Schristos    ;;
1260597410b8Schristos  mips*-*-linux*)
1261597410b8Schristos    ;;
126203467a24Schristos  mips*-*-ultrix* | mips*-*-osf* | mips*-*-ecoff* | mips*-*-pe* \
126303467a24Schristos  | mips*-*-irix* | mips*-*-lnews* | mips*-*-riscos*)
126403467a24Schristos    noconfigdirs="$noconfigdirs ld gas gprof"
126503467a24Schristos    ;;
1266597410b8Schristos  mips*-*-*)
126705598a80Schristos    noconfigdirs="$noconfigdirs gprof"
1268597410b8Schristos    ;;
1269212397c6Schristos  nvptx*-*-*)
1270212397c6Schristos    noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
1271212397c6Schristos    ;;
1272796c32c9Schristos  sh-*-*)
1273597410b8Schristos    case "${target}" in
1274597410b8Schristos      sh*-*-elf)
127505598a80Schristos         ;;
1276597410b8Schristos      *)
127705598a80Schristos         noconfigdirs="$noconfigdirs target-libgloss" ;;
1278597410b8Schristos    esac
1279597410b8Schristos    ;;
1280597410b8Schristos  sparc-*-sunos4*)
128105598a80Schristos    if test x${is_cross_compiler} = xno ; then
1282597410b8Schristos           use_gnu_ld=no
1283597410b8Schristos    fi
1284597410b8Schristos    ;;
1285597410b8Schristos  tic6x-*-*)
128605598a80Schristos    noconfigdirs="$noconfigdirs sim"
128705598a80Schristos    ;;
1288796c32c9Schristos  tilepro*-*-* | tilegx*-*-*)
128905598a80Schristos    noconfigdirs="$noconfigdirs sim"
1290597410b8Schristos    ;;
1291597410b8Schristos  v810-*-*)
1292597410b8Schristos    noconfigdirs="$noconfigdirs bfd binutils gas gdb ld opcodes target-libgloss"
1293597410b8Schristos    ;;
1294597410b8Schristos  vax-*-*)
1295597410b8Schristos    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
1296597410b8Schristos    ;;
12974559860eSchristos  wasm32-*-*)
12984559860eSchristos    noconfigdirs="$noconfigdirs ld"
12994559860eSchristos    ;;
13004b169a6bSchristos  loongarch*-*-linux*)
13014b169a6bSchristos    ;;
13024b169a6bSchristos  loongarch*-*-*)
13034b169a6bSchristos    noconfigdirs="$noconfigdirs gprof"
13044b169a6bSchristos    ;;
1305597410b8Schristosesac
1306597410b8Schristos
1307597410b8Schristos# If we aren't building newlib, then don't build libgloss, since libgloss
1308597410b8Schristos# depends upon some newlib header files.
1309597410b8Schristoscase "${noconfigdirs}" in
1310597410b8Schristos  *target-libgloss*) ;;
1311597410b8Schristos  *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;;
1312597410b8Schristosesac
1313597410b8Schristos
1314597410b8Schristos# Work in distributions that contain no compiler tools, like Autoconf.
1315597410b8Schristoshost_makefile_frag=/dev/null
1316597410b8Schristosif test -d ${srcdir}/config ; then
1317597410b8Schristoscase "${host}" in
1318597410b8Schristos  i[[3456789]]86-*-msdosdjgpp*)
1319597410b8Schristos    host_makefile_frag="config/mh-djgpp"
1320597410b8Schristos    ;;
1321597410b8Schristos  *-cygwin*)
1322597410b8Schristos    ACX_CHECK_CYGWIN_CAT_WORKS
1323597410b8Schristos    host_makefile_frag="config/mh-cygwin"
1324597410b8Schristos    ;;
1325597410b8Schristos  *-mingw*)
1326597410b8Schristos    host_makefile_frag="config/mh-mingw"
1327597410b8Schristos    ;;
1328ba340e45Schristos  alpha*-linux*)
1329ba340e45Schristos    host_makefile_frag="config/mh-alpha-linux"
1330ba340e45Schristos    ;;
1331597410b8Schristos  hppa*-hp-hpux*)
1332597410b8Schristos    host_makefile_frag="config/mh-pa"
1333597410b8Schristos    ;;
1334597410b8Schristos  hppa*-*)
1335597410b8Schristos    host_makefile_frag="config/mh-pa"
1336597410b8Schristos    ;;
13374b169a6bSchristos  i?86-*-darwin[[89]]* | i?86-*-darwin1[[0-7]]* | powerpc*-*-darwin*)
1338597410b8Schristos    host_makefile_frag="config/mh-darwin"
1339597410b8Schristos    ;;
1340597410b8Schristos  powerpc-*-aix*)
1341597410b8Schristos    host_makefile_frag="config/mh-ppc-aix"
1342597410b8Schristos    ;;
1343597410b8Schristos  rs6000-*-aix*)
1344597410b8Schristos    host_makefile_frag="config/mh-ppc-aix"
1345597410b8Schristos    ;;
1346597410b8Schristosesac
1347597410b8Schristosfi
1348597410b8Schristos
1349597410b8Schristosif test "${build}" != "${host}" ; then
1350597410b8Schristos  AR_FOR_BUILD=${AR_FOR_BUILD-ar}
1351597410b8Schristos  AS_FOR_BUILD=${AS_FOR_BUILD-as}
1352597410b8Schristos  CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
13534b169a6bSchristos  CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CC_FOR_BUILD) -E}"
1354597410b8Schristos  CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
13554b169a6bSchristos  DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
1356597410b8Schristos  GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
1357597410b8Schristos  GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo}
13584b169a6bSchristos  GDC_FOR_BUILD=${GDC_FOR_BUILD-gdc}
1359597410b8Schristos  DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool}
1360597410b8Schristos  LD_FOR_BUILD=${LD_FOR_BUILD-ld}
1361597410b8Schristos  NM_FOR_BUILD=${NM_FOR_BUILD-nm}
1362597410b8Schristos  RANLIB_FOR_BUILD=${RANLIB_FOR_BUILD-ranlib}
1363597410b8Schristos  WINDRES_FOR_BUILD=${WINDRES_FOR_BUILD-windres}
1364597410b8Schristos  WINDMC_FOR_BUILD=${WINDMC_FOR_BUILD-windmc}
1365597410b8Schristoselse
1366597410b8Schristos  AR_FOR_BUILD="\$(AR)"
1367597410b8Schristos  AS_FOR_BUILD="\$(AS)"
1368597410b8Schristos  CC_FOR_BUILD="\$(CC)"
1369597410b8Schristos  CXX_FOR_BUILD="\$(CXX)"
13704b169a6bSchristos  DSYMUTIL_FOR_BUILD="\$(DSYMUTIL)"
1371597410b8Schristos  GFORTRAN_FOR_BUILD="\$(GFORTRAN)"
1372597410b8Schristos  GOC_FOR_BUILD="\$(GOC)"
13734b169a6bSchristos  GDC_FOR_BUILD="\$(GDC)"
1374597410b8Schristos  DLLTOOL_FOR_BUILD="\$(DLLTOOL)"
1375597410b8Schristos  LD_FOR_BUILD="\$(LD)"
1376597410b8Schristos  NM_FOR_BUILD="\$(NM)"
1377597410b8Schristos  RANLIB_FOR_BUILD="\$(RANLIB)"
1378597410b8Schristos  WINDRES_FOR_BUILD="\$(WINDRES)"
1379597410b8Schristos  WINDMC_FOR_BUILD="\$(WINDMC)"
1380597410b8Schristosfi
1381597410b8Schristos
13824b169a6bSchristosAC_PROG_CC_C99
1383597410b8SchristosAC_PROG_CXX
1384597410b8Schristos
1385597410b8Schristos# We must set the default linker to the linker used by gcc for the correct
1386597410b8Schristos# operation of libtool.  If LD is not defined and we are using gcc, try to
1387597410b8Schristos# set the LD default to the ld used by gcc.
1388597410b8Schristosif test -z "$LD"; then
1389597410b8Schristos  if test "$GCC" = yes; then
1390597410b8Schristos    case $build in
1391597410b8Schristos    *-*-mingw*)
1392597410b8Schristos      gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
1393597410b8Schristos    *)
1394597410b8Schristos      gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
1395597410b8Schristos    esac
1396597410b8Schristos    case $gcc_prog_ld in
1397597410b8Schristos    # Accept absolute paths.
1398597410b8Schristos    [[\\/]* | [A-Za-z]:[\\/]*)]
1399597410b8Schristos      LD="$gcc_prog_ld" ;;
1400597410b8Schristos    esac
1401597410b8Schristos  fi
1402597410b8Schristosfi
1403597410b8Schristos
140405598a80Schristos# Check whether -static-libstdc++ -static-libgcc is supported.
140505598a80Schristoshave_static_libs=no
140605598a80Schristosif test "$GCC" = yes; then
140705598a80Schristos  saved_LDFLAGS="$LDFLAGS"
140805598a80Schristos
140905598a80Schristos  LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
141005598a80Schristos  AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
141105598a80Schristos  AC_LANG_PUSH(C++)
14124559860eSchristos  AC_LINK_IFELSE([AC_LANG_SOURCE([
141305598a80Schristos#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
141405598a80Schristos#error -static-libstdc++ not implemented
141505598a80Schristos#endif
14164559860eSchristosint main() {}])],
141705598a80Schristos    [AC_MSG_RESULT([yes]); have_static_libs=yes],
141805598a80Schristos    [AC_MSG_RESULT([no])])
141905598a80Schristos  AC_LANG_POP(C++)
142005598a80Schristos
142105598a80Schristos  LDFLAGS="$saved_LDFLAGS"
142205598a80Schristosfi
142305598a80Schristos
1424597410b8SchristosACX_PROG_GNAT
14254b169a6bSchristosACX_PROG_GDC
1426597410b8SchristosACX_PROG_CMP_IGNORE_INITIAL
1427597410b8Schristos
142805598a80SchristosAC_ARG_ENABLE([bootstrap],
142905598a80Schristos[AS_HELP_STRING([--enable-bootstrap],
143005598a80Schristos		[enable bootstrapping @<:@yes if native build@:>@])],,
143105598a80Schristosenable_bootstrap=default)
143205598a80Schristos
143305598a80Schristos# Issue errors and warnings for invalid/strange bootstrap combinations.
143405598a80Schristosif test -r $srcdir/gcc/configure; then
143505598a80Schristos  have_compiler=yes
143605598a80Schristoselse
143705598a80Schristos  have_compiler=no
143805598a80Schristosfi
143905598a80Schristos
144005598a80Schristoscase "$have_compiler:$host:$target:$enable_bootstrap" in
144105598a80Schristos  *:*:*:no) ;;
144205598a80Schristos
144305598a80Schristos  # Default behavior.  Enable bootstrap if we have a compiler
144405598a80Schristos  # and we are in a native configuration.
144505598a80Schristos  yes:$build:$build:default)
144605598a80Schristos    enable_bootstrap=yes ;;
144705598a80Schristos
144805598a80Schristos  *:*:*:default)
144905598a80Schristos    enable_bootstrap=no ;;
145005598a80Schristos
145105598a80Schristos  # We have a compiler and we are in a native configuration, bootstrap is ok
145205598a80Schristos  yes:$build:$build:yes)
145305598a80Schristos    ;;
145405598a80Schristos
145505598a80Schristos  # Other configurations, but we have a compiler.  Assume the user knows
145605598a80Schristos  # what he's doing.
145705598a80Schristos  yes:*:*:yes)
145805598a80Schristos    AC_MSG_WARN([trying to bootstrap a cross compiler])
145905598a80Schristos    ;;
146005598a80Schristos
146105598a80Schristos  # No compiler: if they passed --enable-bootstrap explicitly, fail
146205598a80Schristos  no:*:*:yes)
146305598a80Schristos    AC_MSG_ERROR([cannot bootstrap without a compiler]) ;;
146405598a80Schristos
146505598a80Schristos  # Fail if wrong command line
146605598a80Schristos  *)
146705598a80Schristos    AC_MSG_ERROR([invalid option for --enable-bootstrap])
146805598a80Schristos    ;;
146905598a80Schristosesac
1470597410b8Schristos
14714b169a6bSchristos# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a
14724b169a6bSchristos# C++11 compiler can still start the bootstrap.  Otherwise, if building GCC,
14734b169a6bSchristos# require C++11 (or higher).
1474ba340e45Schristosif test "$enable_bootstrap:$GXX" = "yes:yes"; then
14754b169a6bSchristos  CXX="$CXX -std=c++11"
14764b169a6bSchristoselif test "$have_compiler" = yes; then
14774b169a6bSchristos  AX_CXX_COMPILE_STDCXX(11)
14784b169a6bSchristos
14794b169a6bSchristos  if test "${build}" != "${host}"; then
14804b169a6bSchristos    AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD])
1481ba340e45Schristos  fi
14824b169a6bSchristosfi
14834b169a6bSchristos
14844b169a6bSchristosAC_ARG_ENABLE([pgo-build],
14854b169a6bSchristos[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
14864b169a6bSchristos		[enable the PGO build])],
14874b169a6bSchristos[enable_pgo_build=$enableval],
14884b169a6bSchristos[enable_pgo_build=no])
14894b169a6bSchristos
14904b169a6bSchristos# Issue errors and warnings for invalid/strange PGO build combinations.
14914b169a6bSchristoscase "$have_compiler:$host:$target:$enable_pgo_build" in
14924b169a6bSchristos  *:*:*:no) ;;
14934b169a6bSchristos
14944b169a6bSchristos  # Allow the PGO build only if we aren't building a compiler and
14954b169a6bSchristos  # we are in a native configuration.
14964b169a6bSchristos  no:$build:$build:yes | no:$build:$build:lto) ;;
14974b169a6bSchristos
14984b169a6bSchristos  # Disallow the PGO bootstrap if we are building a compiler.
14994b169a6bSchristos  yes:*:*:yes | yes:*:*:lto)
15004b169a6bSchristos    AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;
15014b169a6bSchristos
15024b169a6bSchristos  *)
15034b169a6bSchristos    AC_MSG_ERROR([invalid option for --enable-pgo-build])
15044b169a6bSchristos    ;;
15054b169a6bSchristosesac
15064b169a6bSchristos
15074b169a6bSchristosif test "$enable_pgo_build" != "no"; then
15084b169a6bSchristos  AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
15094b169a6bSchristos  old_CFLAGS="$CFLAGS"
15104b169a6bSchristos  PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
15114b169a6bSchristos  CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
15124b169a6bSchristos  AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
15134b169a6bSchristos		    [PGO_BUILD_GEN_CFLAGS=])
15144b169a6bSchristos  CFLAGS="$old_CFLAGS"
15154b169a6bSchristos  if test -n "$PGO_BUILD_GEN_CFLAGS"; then
15164b169a6bSchristos    AC_MSG_RESULT([yes])
15174b169a6bSchristos    PGO_BUILD_USE_CFLAGS="-fprofile-use"
15184b169a6bSchristos  else
15194b169a6bSchristos    AC_MSG_RESULT([no])
15204b169a6bSchristos    AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
15214b169a6bSchristos  fi
15224b169a6bSchristos
15234b169a6bSchristos  if test "$enable_pgo_build" = "lto"; then
15244b169a6bSchristos    AC_MSG_CHECKING([whether the compiler supports -flto=jobserver -ffat-lto-objects])
15254b169a6bSchristos    old_CFLAGS="$CFLAGS"
15264b169a6bSchristos    PGO_BUILD_LTO_CFLAGS="-flto=jobserver -ffat-lto-objects"
15274b169a6bSchristos    CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
15284b169a6bSchristos    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
15294b169a6bSchristos		      [PGO_BUILD_LTO_CFLAGS=])
15304b169a6bSchristos    CFLAGS="$old_CFLAGS"
15314b169a6bSchristos    if test -n "$PGO_BUILD_LTO_CFLAGS"; then
15324b169a6bSchristos      AC_MSG_RESULT([yes])
15334b169a6bSchristos    else
15344b169a6bSchristos      AC_MSG_RESULT([no])
15354b169a6bSchristos      AC_MSG_WARN([LTO is disabled for the PGO build])
15364b169a6bSchristos    fi
15374b169a6bSchristos  fi
15384b169a6bSchristosfi
15394b169a6bSchristosAC_SUBST(PGO_BUILD_GEN_CFLAGS)
15404b169a6bSchristosAC_SUBST(PGO_BUILD_USE_CFLAGS)
15414b169a6bSchristosAC_SUBST(PGO_BUILD_LTO_CFLAGS)
1542ba340e45Schristos
1543597410b8Schristos# Used for setting $lt_cv_objdir
1544597410b8Schristos_LT_CHECK_OBJDIR
1545597410b8Schristos
1546597410b8Schristos# Check for GMP, MPFR and MPC
1547*079139fbSchristosrequire_gmp=no
1548*079139fbSchristosrequire_mpc=no
1549*079139fbSchristosif test -d ${srcdir}/gcc ; then
1550*079139fbSchristos  require_gmp=yes
1551*079139fbSchristos  require_mpc=yes
1552*079139fbSchristosfi
1553*079139fbSchristosif test -d ${srcdir}/gdb ; then
1554*079139fbSchristos  if test "x$enable_gdb" != xno; then
1555*079139fbSchristos   require_gmp=yes
1556*079139fbSchristos  fi
1557*079139fbSchristosfi
1558*079139fbSchristos
1559*079139fbSchristosgmplibs="-lmpfr -lgmp"
1560*079139fbSchristosif test x"$require_mpc" = "xyes" ; then
1561*079139fbSchristos  gmplibs="-lmpc $gmplibs"
1562*079139fbSchristosfi
1563597410b8Schristosgmpinc=
1564597410b8Schristoshave_gmp=no
1565597410b8Schristos
1566597410b8Schristos# Specify a location for mpc
1567597410b8Schristos# check for this first so it ends up on the link line before mpfr.
1568597410b8SchristosAC_ARG_WITH(mpc,
1569597410b8Schristos[AS_HELP_STRING([--with-mpc=PATH],
1570597410b8Schristos		[specify prefix directory for installed MPC package.
1571597410b8Schristos		 Equivalent to --with-mpc-include=PATH/include
1572597410b8Schristos		 plus --with-mpc-lib=PATH/lib])])
1573597410b8SchristosAC_ARG_WITH(mpc-include,
1574597410b8Schristos[AS_HELP_STRING([--with-mpc-include=PATH],
1575597410b8Schristos		[specify directory for installed MPC include files])])
1576597410b8SchristosAC_ARG_WITH(mpc-lib,
1577597410b8Schristos[AS_HELP_STRING([--with-mpc-lib=PATH],
1578597410b8Schristos		[specify directory for the installed MPC library])])
1579597410b8Schristos
1580597410b8Schristosif test "x$with_mpc" != x; then
1581597410b8Schristos  gmplibs="-L$with_mpc/lib $gmplibs"
1582597410b8Schristos  gmpinc="-I$with_mpc/include $gmpinc"
1583597410b8Schristosfi
1584597410b8Schristosif test "x$with_mpc_include" != x; then
1585597410b8Schristos  gmpinc="-I$with_mpc_include $gmpinc"
1586597410b8Schristosfi
1587597410b8Schristosif test "x$with_mpc_lib" != x; then
1588597410b8Schristos  gmplibs="-L$with_mpc_lib $gmplibs"
1589597410b8Schristosfi
1590597410b8Schristosif test "x$with_mpc$with_mpc_include$with_mpc_lib" = x && test -d ${srcdir}/mpc; then
1591597410b8Schristos  gmplibs='-L$$r/$(HOST_SUBDIR)/mpc/src/'"$lt_cv_objdir $gmplibs"
1592597410b8Schristos  gmpinc='-I$$s/mpc/src '"$gmpinc"
1593597410b8Schristos  # Do not test the mpc version.  Assume that it is sufficient, since
1594597410b8Schristos  # it is in the source tree, and the library has not been built yet
1595597410b8Schristos  # but it would be included on the link line in the version check below
1596597410b8Schristos  # hence making the test fail.
1597597410b8Schristos  have_gmp=yes
1598597410b8Schristosfi
1599597410b8Schristos
1600597410b8Schristos# Specify a location for mpfr
1601597410b8Schristos# check for this first so it ends up on the link line before gmp.
1602597410b8SchristosAC_ARG_WITH(mpfr,
1603597410b8Schristos[AS_HELP_STRING([--with-mpfr=PATH],
1604597410b8Schristos		[specify prefix directory for installed MPFR package.
1605597410b8Schristos		 Equivalent to --with-mpfr-include=PATH/include
1606597410b8Schristos		 plus --with-mpfr-lib=PATH/lib])])
1607597410b8SchristosAC_ARG_WITH(mpfr-include,
1608597410b8Schristos[AS_HELP_STRING([--with-mpfr-include=PATH],
1609597410b8Schristos		[specify directory for installed MPFR include files])])
1610597410b8SchristosAC_ARG_WITH(mpfr-lib,
1611597410b8Schristos[AS_HELP_STRING([--with-mpfr-lib=PATH],
1612597410b8Schristos		[specify directory for the installed MPFR library])])
1613597410b8Schristos
1614597410b8Schristosif test "x$with_mpfr" != x; then
1615597410b8Schristos  gmplibs="-L$with_mpfr/lib $gmplibs"
1616597410b8Schristos  gmpinc="-I$with_mpfr/include $gmpinc"
1617597410b8Schristosfi
1618597410b8Schristosif test "x$with_mpfr_include" != x; then
1619597410b8Schristos  gmpinc="-I$with_mpfr_include $gmpinc"
1620597410b8Schristosfi
1621597410b8Schristosif test "x$with_mpfr_lib" != x; then
1622597410b8Schristos  gmplibs="-L$with_mpfr_lib $gmplibs"
1623597410b8Schristosfi
1624597410b8Schristosif test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
162505598a80Schristos  # MPFR v3.1.0 moved the sources into a src sub-directory.
1626796c32c9Schristos  if ! test -d ${srcdir}/mpfr/src; then
1627796c32c9Schristos    AC_MSG_ERROR([dnl
1628796c32c9SchristosBuilding GCC with MPFR in the source tree is only handled for MPFR 3.1.0+.])
1629796c32c9Schristos  fi
163005598a80Schristos  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs"
163105598a80Schristos  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc"
163205598a80Schristos  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir"
1633597410b8Schristos  # Do not test the mpfr version.  Assume that it is sufficient, since
1634597410b8Schristos  # it is in the source tree, and the library has not been built yet
1635597410b8Schristos  # but it would be included on the link line in the version check below
1636597410b8Schristos  # hence making the test fail.
1637597410b8Schristos  have_gmp=yes
1638597410b8Schristosfi
1639597410b8Schristos
1640597410b8Schristos# Specify a location for gmp
1641597410b8SchristosAC_ARG_WITH(gmp,
1642597410b8Schristos[AS_HELP_STRING([--with-gmp=PATH],
1643597410b8Schristos		[specify prefix directory for the installed GMP package.
1644597410b8Schristos		 Equivalent to --with-gmp-include=PATH/include
1645597410b8Schristos		 plus --with-gmp-lib=PATH/lib])])
1646597410b8SchristosAC_ARG_WITH(gmp-include,
1647597410b8Schristos[AS_HELP_STRING([--with-gmp-include=PATH],
1648597410b8Schristos		[specify directory for installed GMP include files])])
1649597410b8SchristosAC_ARG_WITH(gmp-lib,
1650597410b8Schristos[AS_HELP_STRING([--with-gmp-lib=PATH],
1651597410b8Schristos		[specify directory for the installed GMP library])])
1652597410b8Schristos
1653597410b8Schristos
1654597410b8Schristosif test "x$with_gmp" != x; then
1655597410b8Schristos  gmplibs="-L$with_gmp/lib $gmplibs"
1656597410b8Schristos  gmpinc="-I$with_gmp/include $gmpinc"
1657597410b8Schristosfi
1658597410b8Schristosif test "x$with_gmp_include" != x; then
1659597410b8Schristos  gmpinc="-I$with_gmp_include $gmpinc"
1660597410b8Schristosfi
1661597410b8Schristosif test "x$with_gmp_lib" != x; then
1662597410b8Schristos  gmplibs="-L$with_gmp_lib $gmplibs"
1663597410b8Schristosfi
1664597410b8Schristosif test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
1665597410b8Schristos  gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir $gmplibs"
1666597410b8Schristos  gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
1667597410b8Schristos  extra_mpfr_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
1668597410b8Schristos  extra_mpc_gmp_configure_flags='--with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-gmp-lib=$$r/$(HOST_SUBDIR)/gmp/'"$lt_cv_objdir"
166905598a80Schristos  extra_isl_gmp_configure_flags='--with-gmp-builddir=$$r/$(HOST_SUBDIR)/gmp'
1670597410b8Schristos  # Do not test the gmp version.  Assume that it is sufficient, since
1671597410b8Schristos  # it is in the source tree, and the library has not been built yet
1672597410b8Schristos  # but it would be included on the link line in the version check below
1673597410b8Schristos  # hence making the test fail.
1674597410b8Schristos  have_gmp=yes
1675597410b8Schristosfi
1676597410b8Schristos
1677*079139fbSchristosif test "x$require_gmp" = xyes && test "x$have_gmp" = xno; then
1678597410b8Schristos  have_gmp=yes
1679597410b8Schristos  saved_CFLAGS="$CFLAGS"
1680597410b8Schristos  CFLAGS="$CFLAGS $gmpinc"
1681597410b8Schristos  # Check for the recommended and required versions of GMP.
1682597410b8Schristos  AC_MSG_CHECKING([for the correct version of gmp.h])
1683597410b8Schristos  AC_TRY_COMPILE([#include "gmp.h"],[
1684597410b8Schristos  #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1685597410b8Schristos  #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
168605598a80Schristos  #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,2,3)
1687597410b8Schristos  choke me
1688597410b8Schristos  #endif
1689597410b8Schristos  ], [AC_TRY_COMPILE([#include <gmp.h>],[
1690597410b8Schristos  #define GCC_GMP_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1691597410b8Schristos  #define GCC_GMP_VERSION GCC_GMP_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL)
1692597410b8Schristos  #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
1693597410b8Schristos  choke me
1694597410b8Schristos  #endif
1695597410b8Schristos  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
1696597410b8Schristos   [AC_MSG_RESULT([no]); have_gmp=no])
1697597410b8Schristos
1698597410b8Schristos  # If we have GMP, check the MPFR version.
1699597410b8Schristos  if test x"$have_gmp" = xyes; then
1700597410b8Schristos    # Check for the recommended and required versions of MPFR.
1701597410b8Schristos    AC_MSG_CHECKING([for the correct version of mpfr.h])
1702597410b8Schristos    AC_TRY_COMPILE([#include <gmp.h>
1703597410b8Schristos    #include <mpfr.h>],[
17044b169a6bSchristos    #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,0)
1705597410b8Schristos    choke me
1706597410b8Schristos    #endif
1707597410b8Schristos    ], [AC_TRY_COMPILE([#include <gmp.h>
1708597410b8Schristos    #include <mpfr.h>],[
17094b169a6bSchristos    #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,6)
1710597410b8Schristos    choke me
1711597410b8Schristos    #endif
1712597410b8Schristos    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
1713597410b8Schristos     [AC_MSG_RESULT([no]); have_gmp=no])
1714597410b8Schristos  fi
1715597410b8Schristos
1716597410b8Schristos  # Check for the MPC header version.
1717*079139fbSchristos  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes ; then
1718597410b8Schristos    # Check for the recommended and required versions of MPC.
1719597410b8Schristos    AC_MSG_CHECKING([for the correct version of mpc.h])
1720597410b8Schristos    AC_TRY_COMPILE([#include <mpc.h>],[
1721597410b8Schristos    #if MPC_VERSION < MPC_VERSION_NUM(0,8,0)
1722597410b8Schristos    choke me
1723597410b8Schristos    #endif
1724597410b8Schristos    ], [AC_TRY_COMPILE([#include <mpc.h>],[
1725597410b8Schristos    #if MPC_VERSION < MPC_VERSION_NUM(0,8,1)
1726597410b8Schristos    choke me
1727597410b8Schristos    #endif
1728597410b8Schristos    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
1729597410b8Schristos     [AC_MSG_RESULT([no]); have_gmp=no])
1730597410b8Schristos  fi
1731597410b8Schristos
1732597410b8Schristos  # Now check the MPFR library.
1733597410b8Schristos  if test x"$have_gmp" = xyes; then
1734597410b8Schristos    saved_LIBS="$LIBS"
1735597410b8Schristos    LIBS="$LIBS $gmplibs"
1736*079139fbSchristos    AC_MSG_CHECKING([for the correct version of the gmp/mpfr libraries])
1737*079139fbSchristos    AC_TRY_LINK([#include <mpfr.h>],[
1738597410b8Schristos    mpfr_t n;
1739597410b8Schristos    mpfr_t x;
1740597410b8Schristos    int t;
1741597410b8Schristos    mpfr_init (n);
1742597410b8Schristos    mpfr_init (x);
17434b169a6bSchristos    mpfr_atan2 (n, n, x, MPFR_RNDN);
17444b169a6bSchristos    mpfr_erfc (n, x, MPFR_RNDN);
17454b169a6bSchristos    mpfr_subnormalize (x, t, MPFR_RNDN);
1746597410b8Schristos    mpfr_clear(n);
1747597410b8Schristos    mpfr_clear(x);
1748*079139fbSchristos    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
1749*079139fbSchristos    LIBS="$saved_LIBS"
1750*079139fbSchristos  fi
1751*079139fbSchristos
1752*079139fbSchristos  # Now check the MPC library
1753*079139fbSchristos  if test "x$require_mpc" = xyes && test x"$have_gmp" = xyes; then
1754*079139fbSchristos    saved_LIBS="$LIBS"
1755*079139fbSchristos    LIBS="$LIBS $gmplibs"
1756*079139fbSchristos    AC_MSG_CHECKING([for the correct version of the mpc libraries])
1757*079139fbSchristos    AC_TRY_LINK([#include <mpc.h>],[
1758*079139fbSchristos    mpc_t c;
1759597410b8Schristos    mpc_init2 (c, 53);
1760597410b8Schristos    mpc_set_ui_ui (c, 1, 1, MPC_RNDNN);
1761597410b8Schristos    mpc_cosh (c, c, MPC_RNDNN);
1762597410b8Schristos    mpc_pow (c, c, c, MPC_RNDNN);
1763597410b8Schristos    mpc_acosh (c, c, MPC_RNDNN);
1764597410b8Schristos    mpc_clear (c);
1765597410b8Schristos    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
1766597410b8Schristos    LIBS="$saved_LIBS"
1767597410b8Schristos  fi
1768597410b8Schristos
1769597410b8Schristos  CFLAGS="$saved_CFLAGS"
1770597410b8Schristos
1771597410b8Schristos# The library versions listed in the error message below should match
1772597410b8Schristos# the HARD-minimums enforced above.
1773597410b8Schristos  if test x$have_gmp != xyes; then
1774*079139fbSchristos    if test -d ${srcdir}/gcc ; then
17754b169a6bSchristos      AC_MSG_ERROR([Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
1776597410b8SchristosTry the --with-gmp, --with-mpfr and/or --with-mpc options to specify
1777597410b8Schristostheir locations.  Source code for these libraries can be found at
1778597410b8Schristostheir respective hosting sites as well as at
17794b169a6bSchristoshttps://gcc.gnu.org/pub/gcc/infrastructure/.  See also
1780597410b8Schristoshttp://gcc.gnu.org/install/prerequisites.html for additional info.  If
1781597410b8Schristosyou obtained GMP, MPFR and/or MPC from a vendor distribution package,
1782597410b8Schristosmake sure that you have installed both the libraries and the header
1783597410b8Schristosfiles.  They may be located in separate packages.])
1784*079139fbSchristos    else
1785*079139fbSchristos      AC_MSG_ERROR([Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
1786*079139fbSchristosTry the --with-gmp and/or --with-mpfr options to specify
1787*079139fbSchristostheir locations.  If you obtained GMP and/or MPFR from a vendor
1788*079139fbSchristosdistribution package, make sure that you have installed both the libraries
1789*079139fbSchristosand the header files.  They may be located in separate packages.])
1790*079139fbSchristos    fi
1791597410b8Schristos  fi
1792597410b8Schristosfi
1793597410b8Schristos
1794597410b8Schristos# Flags needed for both GMP, MPFR and/or MPC.
1795597410b8SchristosAC_SUBST(gmplibs)
1796597410b8SchristosAC_SUBST(gmpinc)
1797597410b8SchristosAC_SUBST(extra_mpfr_configure_flags)
1798597410b8SchristosAC_SUBST(extra_mpc_gmp_configure_flags)
1799597410b8SchristosAC_SUBST(extra_mpc_mpfr_configure_flags)
180005598a80SchristosAC_SUBST(extra_isl_gmp_configure_flags)
1801597410b8Schristos
1802597410b8Schristos# Libraries to use for stage1 or when not bootstrapping.
1803597410b8SchristosAC_ARG_WITH(stage1-libs,
1804597410b8Schristos[AS_HELP_STRING([--with-stage1-libs=LIBS], [libraries for stage1])],
1805597410b8Schristos[if test "$withval" = "no" -o "$withval" = "yes"; then
1806597410b8Schristos   stage1_libs=
1807597410b8Schristos else
1808597410b8Schristos   stage1_libs=$withval
1809597410b8Schristos fi],
1810ba340e45Schristos[stage1_libs=])
1811597410b8SchristosAC_SUBST(stage1_libs)
1812597410b8Schristos
18138dffb485Schristos# Whether or not to use -static-libstdc++ and -static-libgcc.  The
18148dffb485Schristos# default is yes if gcc is being built; no otherwise.  The reason for
18158dffb485Schristos# this default is that gdb is sometimes linked against GNU Source
18168dffb485Schristos# Highlight, which is a shared library that uses C++ exceptions.  In
18178dffb485Schristos# this case, -static-libstdc++ will cause crashes.
18188dffb485SchristosAC_ARG_WITH(static-standard-libraries,
18198dffb485Schristos[AS_HELP_STRING([--with-static-standard-libraries],
18208dffb485Schristos                [use -static-libstdc++ and -static-libgcc (default=auto)])],
18218dffb485Schristos[], [with_static_standard_libraries=auto])
18228dffb485Schristosif test "$with_static_standard_libraries" = auto; then
18238dffb485Schristos  with_static_standard_libraries=$have_compiler
18248dffb485Schristosfi
18258dffb485Schristos
182605598a80Schristos# Linker flags to use for stage1 or when not bootstrapping.
182705598a80SchristosAC_ARG_WITH(stage1-ldflags,
182805598a80Schristos[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
182905598a80Schristos[if test "$withval" = "no" -o "$withval" = "yes"; then
183005598a80Schristos   stage1_ldflags=
183105598a80Schristos else
183205598a80Schristos   stage1_ldflags=$withval
183305598a80Schristos fi],
183405598a80Schristos[stage1_ldflags=
183505598a80Schristos # In stage 1, default to linking libstdc++ and libgcc statically with GCC
183605598a80Schristos # if supported.  But if the user explicitly specified the libraries to use,
183705598a80Schristos # trust that they are doing what they want.
18388dffb485Schristos if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
18398dffb485Schristos     -a "$have_static_libs" = yes; then
184005598a80Schristos   stage1_ldflags="-static-libstdc++ -static-libgcc"
184105598a80Schristos fi])
184205598a80SchristosAC_SUBST(stage1_ldflags)
184305598a80Schristos
1844ba340e45Schristos# Libraries to use for stage2 and later builds.
1845597410b8SchristosAC_ARG_WITH(boot-libs,
1846597410b8Schristos[AS_HELP_STRING([--with-boot-libs=LIBS], [libraries for stage2 and later])],
1847597410b8Schristos[if test "$withval" = "no" -o "$withval" = "yes"; then
1848597410b8Schristos   poststage1_libs=
1849597410b8Schristos else
1850597410b8Schristos   poststage1_libs=$withval
1851597410b8Schristos fi],
1852ba340e45Schristos[poststage1_libs=])
1853597410b8SchristosAC_SUBST(poststage1_libs)
1854597410b8Schristos
1855597410b8Schristos# Linker flags to use for stage2 and later builds.
1856597410b8SchristosAC_ARG_WITH(boot-ldflags,
1857597410b8Schristos[AS_HELP_STRING([--with-boot-ldflags=FLAGS],
1858597410b8Schristos		[linker flags for stage2 and later])],
1859597410b8Schristos[if test "$withval" = "no" -o "$withval" = "yes"; then
1860597410b8Schristos   poststage1_ldflags=
1861597410b8Schristos else
1862597410b8Schristos   poststage1_ldflags=$withval
1863597410b8Schristos fi],
1864597410b8Schristos[poststage1_ldflags=
1865597410b8Schristos # In stages 2 and 3, default to linking libstdc++ and libgcc
1866597410b8Schristos # statically.  But if the user explicitly specified the libraries to
1867597410b8Schristos # use, trust that they are doing what they want.
1868597410b8Schristos if test "$poststage1_libs" = ""; then
1869597410b8Schristos   poststage1_ldflags="-static-libstdc++ -static-libgcc"
1870597410b8Schristos fi])
1871*079139fbSchristoscase $target in
1872*079139fbSchristos  *-darwin2* | *-darwin1[[56789]]*)
1873*079139fbSchristos    # For these versions, we default to using embedded rpaths.
1874*079139fbSchristos    if test "x$enable_darwin_at_rpath" != "xno"; then
1875*079139fbSchristos      poststage1_ldflags="$poststage1_ldflags -nodefaultrpaths"
1876*079139fbSchristos    fi
1877*079139fbSchristos  ;;
1878*079139fbSchristos  *-darwin*)
1879*079139fbSchristos    # For these versions, we only use embedded rpaths on demand.
1880*079139fbSchristos    if test "x$enable_darwin_at_rpath" = "xyes"; then
1881*079139fbSchristos      poststage1_ldflags="$poststage1_ldflags -nodefaultrpaths"
1882*079139fbSchristos    fi
1883*079139fbSchristos  ;;
1884*079139fbSchristosesac
1885597410b8SchristosAC_SUBST(poststage1_ldflags)
1886597410b8Schristos
1887ba340e45Schristos# GCC GRAPHITE dependency isl.
1888212397c6Schristos# Basic setup is inlined here, actual checks are in config/isl.m4
1889597410b8Schristos
189005598a80SchristosAC_ARG_WITH(isl,
189105598a80Schristos  [AS_HELP_STRING(
189205598a80Schristos   [--with-isl=PATH],
1893ba340e45Schristos   [Specify prefix directory for the installed isl package.
189405598a80Schristos    Equivalent to --with-isl-include=PATH/include
189505598a80Schristos    plus --with-isl-lib=PATH/lib])])
1896597410b8Schristos
1897212397c6Schristos# Treat --without-isl as a request to disable
189805598a80Schristos# GRAPHITE support and skip all following checks.
1899212397c6Schristosif test "x$with_isl" != "xno"; then
1900ba340e45Schristos  # Check for isl
190105598a80Schristos  dnl Provide configure switches and initialize islinc & isllibs
190205598a80Schristos  dnl with user input.
190305598a80Schristos  ISL_INIT_FLAGS
1904ba340e45Schristos  dnl The versions of isl that work for Graphite
1905212397c6Schristos  ISL_CHECK_VERSION()
1906ba340e45Schristos  dnl Only execute fail-action, if isl has been requested.
190705598a80Schristos  ISL_IF_FAILED([
1908ba340e45Schristos    AC_MSG_ERROR([Unable to find a usable isl.  See config.log for details.])])
1909597410b8Schristosfi
1910597410b8Schristos
1911ba340e45Schristos# If the isl check failed, disable builds of in-tree variant of isl
191205598a80Schristosif test "x$with_isl" = xno ||
191305598a80Schristos   test "x$gcc_cv_isl" = xno; then
1914212397c6Schristos  noconfigdirs="$noconfigdirs isl"
191505598a80Schristos  islinc=
191605598a80Schristosfi
191705598a80Schristos
1918212397c6SchristosAC_SUBST(isllibs)
191905598a80SchristosAC_SUBST(islinc)
1920597410b8Schristos
1921597410b8Schristos# Check for LTO support.
1922597410b8SchristosAC_ARG_ENABLE(lto,
1923597410b8Schristos[AS_HELP_STRING([--enable-lto], [enable link time optimization support])],
1924597410b8Schristosenable_lto=$enableval,
1925597410b8Schristosenable_lto=yes; default_enable_lto=yes)
1926597410b8Schristos
1927597410b8SchristosACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
1928597410b8Schristos  build_lto_plugin=yes
1929597410b8Schristos],[if test x"$default_enable_lto" = x"yes" ; then
1930597410b8Schristos    case $target in
19314559860eSchristos      *-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;;
1932597410b8Schristos      # On other non-ELF platforms, LTO has yet to be validated.
1933597410b8Schristos      *) enable_lto=no ;;
1934597410b8Schristos    esac
1935597410b8Schristos  else
1936597410b8Schristos  # Apart from ELF platforms, only Windows and Darwin support LTO so far.
1937597410b8Schristos  # It would also be nice to check the binutils support, but we don't
1938597410b8Schristos  # have gcc_GAS_CHECK_FEATURE available here.  For now, we'll just
1939597410b8Schristos  # warn during gcc/ subconfigure; unless you're bootstrapping with
1940597410b8Schristos  # -flto it won't be needed until after installation anyway.
1941597410b8Schristos    case $target in
1942ba340e45Schristos      *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
1943597410b8Schristos      *) if test x"$enable_lto" = x"yes"; then
1944597410b8Schristos	AC_MSG_ERROR([LTO support is not enabled for this target.])
1945597410b8Schristos        fi
1946597410b8Schristos      ;;
1947597410b8Schristos    esac
1948597410b8Schristos  fi
1949597410b8Schristos  # Among non-ELF, only Windows platforms support the lto-plugin so far.
1950597410b8Schristos  # Build it unless LTO was explicitly disabled.
1951597410b8Schristos  case $target in
1952597410b8Schristos    *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;;
1953597410b8Schristos    *) ;;
1954597410b8Schristos  esac
1955597410b8Schristos])
1956597410b8Schristos
1957212397c6SchristosAC_ARG_ENABLE(linker-plugin-configure-flags,
1958212397c6Schristos  [AS_HELP_STRING([[--enable-linker-plugin-configure-flags=FLAGS]],
1959212397c6Schristos    [additional flags for configuring linker plugins @<:@none@:>@])],
1960212397c6Schristos  extra_linker_plugin_configure_flags=$enableval,
1961212397c6Schristos  extra_linker_plugin_configure_flags=)
1962212397c6SchristosAC_SUBST(extra_linker_plugin_configure_flags)
1963212397c6SchristosAC_ARG_ENABLE(linker-plugin-flags,
1964212397c6Schristos  [AS_HELP_STRING([[--enable-linker-plugin-flags=FLAGS]],
1965212397c6Schristos    [additional flags for configuring and building linker plugins @<:@none@:>@])],
1966212397c6Schristos  extra_linker_plugin_flags=$enableval,
1967212397c6Schristos  extra_linker_plugin_flags=)
1968212397c6SchristosAC_SUBST(extra_linker_plugin_flags)
1969212397c6Schristos
1970*079139fbSchristos# Handle --enable-host-pie
1971*079139fbSchristos# If host PIE executables are the default (or must be forced on) for some host,
1972*079139fbSchristos# we must pass that configuration to the gcc directory.
1973*079139fbSchristosgcc_host_pie=
1974*079139fbSchristosAC_ARG_ENABLE(host-pie,
1975*079139fbSchristos[AS_HELP_STRING([--enable-host-pie],
1976*079139fbSchristos		[build position independent host executables])],
1977*079139fbSchristos[host_pie=$enableval
1978*079139fbSchristos case $host in
1979*079139fbSchristos   *-*-darwin2*)
1980*079139fbSchristos     if test x$host_pie != xyes ; then
1981*079139fbSchristos       # for Darwin20+ this is required.
1982*079139fbSchristos       AC_MSG_WARN([PIE executables are required for the configured host, host-pie setting ignored.])
1983*079139fbSchristos       host_pie=yes
1984*079139fbSchristos       gcc_host_pie=--enable-host-pie
1985*079139fbSchristos     fi ;;
1986*079139fbSchristos  *) ;;
1987*079139fbSchristos esac],
1988*079139fbSchristos[case $host in
1989*079139fbSchristos  *-*-darwin2*)
1990*079139fbSchristos    # Default to PIE (mandatory for aarch64).
1991*079139fbSchristos    host_pie=yes
1992*079139fbSchristos    gcc_host_pie=--enable-host-pie
1993*079139fbSchristos    ;;
1994*079139fbSchristos  *) host_pie=no ;;
1995*079139fbSchristos esac])
1996*079139fbSchristos
1997*079139fbSchristosAC_SUBST(host_pie)
1998*079139fbSchristosAC_SUBST(gcc_host_pie)
1999*079139fbSchristos
20004559860eSchristos# Enable --enable-host-shared.
20014559860eSchristos# Checked early to determine whether jit is an 'all' language
20024559860eSchristosAC_ARG_ENABLE(host-shared,
20034559860eSchristos[AS_HELP_STRING([--enable-host-shared],
20044559860eSchristos		[build host code as shared libraries])],
20054b169a6bSchristos[host_shared=$enableval
20064b169a6bSchristos case $host in
20074b169a6bSchristos   x86_64-*-darwin* | aarch64-*-darwin*)
20084b169a6bSchristos     if test x$host_shared != xyes ; then
20094b169a6bSchristos       # PIC is the default, and actually cannot be switched off.
2010*079139fbSchristos       AC_MSG_WARN([PIC code is required for the configured host; host-shared setting ignored.])
2011*079139fbSchristos       host_shared=yes
2012*079139fbSchristos     fi ;;
2013*079139fbSchristos   *-*-darwin*)
2014*079139fbSchristos     if test x$host_pie = xyes -a x$host_shared != xyes ; then
2015*079139fbSchristos       AC_MSG_WARN([PIC code is required for PIE host executables host-shared setting ignored.])
20164b169a6bSchristos       host_shared=yes
20174b169a6bSchristos     fi ;;
20184b169a6bSchristos  *) ;;
20194b169a6bSchristos esac],
20204b169a6bSchristos[case $host in
2021*079139fbSchristos  # 64B x86_64 and Aarch64 Darwin default to PIC.
20224b169a6bSchristos  x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
2023*079139fbSchristos  # 32B and powerpc64 Darwin must use PIC to link PIE exes.
2024*079139fbSchristos  *-*-darwin*) host_shared=$host_pie ;;
20254b169a6bSchristos  *) host_shared=no;;
20264b169a6bSchristos esac])
2027*079139fbSchristos
20284559860eSchristosAC_SUBST(host_shared)
2029597410b8Schristos
2030*079139fbSchristosif test x$host_shared = xyes; then
2031*079139fbSchristos  case $host in
2032*079139fbSchristos    *-*-darwin*)
2033*079139fbSchristos      # Since host shared is the default for 64b Darwin, and also enabled for
2034*079139fbSchristos      # host_pie, ensure that we present the PIE flag when host_pie is active.
2035*079139fbSchristos      if test x$host_pie = xyes; then
2036*079139fbSchristos        PICFLAG=-fPIE
2037*079139fbSchristos      fi
2038*079139fbSchristos      ;;
2039*079139fbSchristos    *)
2040*079139fbSchristos      PICFLAG=-fPIC
2041*079139fbSchristos      ;;
2042*079139fbSchristos  esac
2043*079139fbSchristoselif test x$host_pie = xyes; then
2044*079139fbSchristos  PICFLAG=-fPIE
2045*079139fbSchristoselse
2046*079139fbSchristos  PICFLAG=
2047*079139fbSchristosfi
2048*079139fbSchristos
2049*079139fbSchristosAC_SUBST(PICFLAG)
2050*079139fbSchristos
2051*079139fbSchristos# If we are building PIC/PIE host executables, and we are building dependent
2052*079139fbSchristos# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
2053*079139fbSchristos# code.
2054*079139fbSchristoshost_libs_picflag=
2055*079139fbSchristosif test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
2056*079139fbSchristoshost_libs_picflag='--with-pic'
2057*079139fbSchristosfi
2058*079139fbSchristosAC_SUBST(host_libs_picflag)
2059*079139fbSchristos
206005598a80Schristos# By default, C and C++ are the only stage 1 languages.
2061597410b8Schristosstage1_languages=,c,
2062597410b8Schristos
2063597410b8Schristos# Target libraries that we bootstrap.
2064597410b8Schristosbootstrap_target_libs=,target-libgcc,
2065597410b8Schristos
2066597410b8Schristos# Figure out what language subdirectories are present.
2067597410b8Schristos# Look if the user specified --enable-languages="..."; if not, use
2068597410b8Schristos# the environment variable $LANGUAGES if defined. $LANGUAGES might
2069597410b8Schristos# go away some day.
2070597410b8Schristos# NB:  embedded tabs in this IF block -- do not untabify
2071597410b8Schristosif test -d ${srcdir}/gcc; then
2072597410b8Schristos  if test x"${enable_languages+set}" != xset; then
2073597410b8Schristos    if test x"${LANGUAGES+set}" = xset; then
2074597410b8Schristos      enable_languages="${LANGUAGES}"
2075ba340e45Schristos        echo configure.ac: warning: setting LANGUAGES is deprecated, use --enable-languages instead 1>&2
2076597410b8Schristos    else
20774559860eSchristos      enable_languages=default
2078597410b8Schristos    fi
2079597410b8Schristos  else
2080597410b8Schristos    if test x"${enable_languages}" = x ||
2081597410b8Schristos       test x"${enable_languages}" = xyes;
2082597410b8Schristos       then
2083ba340e45Schristos      echo configure.ac: --enable-languages needs at least one language argument 1>&2
2084597410b8Schristos      exit 1
2085597410b8Schristos    fi
2086597410b8Schristos  fi
2087597410b8Schristos  enable_languages=`echo "${enable_languages}" | sed -e 's/[[ 	,]][[ 	,]]*/,/g' -e 's/,$//'`
2088597410b8Schristos
2089597410b8Schristos  # 'f95' is the old name for the 'fortran' language. We issue a warning
2090597410b8Schristos  # and make the substitution.
2091597410b8Schristos  case ,${enable_languages}, in
2092597410b8Schristos    *,f95,*)
2093ba340e45Schristos      echo configure.ac: warning: 'f95' as language name is deprecated, use 'fortran' instead 1>&2
2094597410b8Schristos      enable_languages=`echo "${enable_languages}" | sed -e 's/f95/fortran/g'`
2095597410b8Schristos      ;;
2096597410b8Schristos  esac
2097597410b8Schristos
209805598a80Schristos  # If bootstrapping, C++ must be enabled.
209905598a80Schristos  case ",$enable_languages,:$enable_bootstrap" in
210005598a80Schristos    *,c++,*:*) ;;
210105598a80Schristos    *:yes)
210205598a80Schristos      if test -f ${srcdir}/gcc/cp/config-lang.in; then
210305598a80Schristos        enable_languages="${enable_languages},c++"
210405598a80Schristos      else
210505598a80Schristos        AC_MSG_ERROR([bootstrapping requires c++ sources])
210605598a80Schristos      fi
210705598a80Schristos      ;;
210805598a80Schristos  esac
210905598a80Schristos
2110597410b8Schristos  # First scan to see if an enabled language requires some other language.
2111597410b8Schristos  # We assume that a given config-lang.in will list all the language
2112597410b8Schristos  # front ends it requires, even if some are required indirectly.
2113597410b8Schristos  for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
2114597410b8Schristos    case ${lang_frag} in
2115597410b8Schristos      ..) ;;
2116597410b8Schristos      # The odd quoting in the next line works around
2117597410b8Schristos      # an apparent bug in bash 1.12 on linux.
2118597410b8Schristos      ${srcdir}/gcc/[[*]]/config-lang.in) ;;
2119597410b8Schristos      *)
2120597410b8Schristos        # From the config-lang.in, get $language, $lang_requires, and
2121597410b8Schristos        # $lang_requires_boot_languages.
2122597410b8Schristos        language=
2123597410b8Schristos        lang_requires=
2124597410b8Schristos        lang_requires_boot_languages=
21254559860eSchristos        # set srcdir during sourcing lang_frag to the gcc dir.
21264559860eSchristos        # Sadly overriding srcdir on the . line doesn't work in plain sh as it
21274559860eSchristos        # polutes this shell
21284559860eSchristos        saved_srcdir=${srcdir}
21294559860eSchristos        srcdir=${srcdir}/gcc . ${lang_frag}
21304559860eSchristos        srcdir=${saved_srcdir}
2131597410b8Schristos        for other in ${lang_requires} ${lang_requires_boot_languages}; do
2132597410b8Schristos          case ,${enable_languages}, in
2133597410b8Schristos	    *,$other,*) ;;
21344559860eSchristos	    *,default,*) ;;
2135597410b8Schristos	    *,all,*) ;;
2136597410b8Schristos	    *,$language,*)
2137597410b8Schristos	      echo " \`$other' language required by \`$language'; enabling" 1>&2
2138597410b8Schristos	      enable_languages="${enable_languages},${other}"
2139597410b8Schristos	      ;;
2140597410b8Schristos	  esac
2141597410b8Schristos        done
2142597410b8Schristos	for other in ${lang_requires_boot_languages} ; do
2143597410b8Schristos	  if test "$other" != "c"; then
2144597410b8Schristos	    case ,${enable_stage1_languages}, in
2145597410b8Schristos	      *,$other,*) ;;
21464559860eSchristos	      *,default,*) ;;
2147597410b8Schristos	      *,all,*) ;;
2148597410b8Schristos	      *)
2149597410b8Schristos		case ,${enable_languages}, in
2150597410b8Schristos		  *,$language,*)
2151597410b8Schristos		    echo " '$other' language required by '$language' in stage 1; enabling" 1>&2
2152597410b8Schristos		    enable_stage1_languages="$enable_stage1_languages,${other}"
2153597410b8Schristos		    ;;
2154597410b8Schristos		esac
2155597410b8Schristos		;;
2156597410b8Schristos	    esac
2157597410b8Schristos          fi
2158597410b8Schristos        done
2159597410b8Schristos        ;;
2160597410b8Schristos    esac
2161597410b8Schristos  done
2162597410b8Schristos
2163597410b8Schristos  new_enable_languages=,c,
2164597410b8Schristos
2165597410b8Schristos  # If LTO is enabled, add the LTO front end.
2166597410b8Schristos  if test "$enable_lto" = "yes" ; then
2167597410b8Schristos    case ,${enable_languages}, in
2168597410b8Schristos      *,lto,*) ;;
2169597410b8Schristos      *) enable_languages="${enable_languages},lto" ;;
2170597410b8Schristos    esac
2171597410b8Schristos    if test "${build_lto_plugin}" = "yes" ; then
2172597410b8Schristos      configdirs="$configdirs lto-plugin"
2173597410b8Schristos    fi
2174597410b8Schristos  fi
2175212397c6Schristos
2176212397c6Schristos  # If we're building an offloading compiler, add the LTO front end.
2177212397c6Schristos  if test x"$enable_as_accelerator_for" != x ; then
2178212397c6Schristos    case ,${enable_languages}, in
2179212397c6Schristos      *,lto,*) ;;
2180212397c6Schristos      *) enable_languages="${enable_languages},lto" ;;
2181212397c6Schristos    esac
2182212397c6Schristos  fi
2183597410b8Schristos
21844559860eSchristos  missing_languages=`echo ",$enable_languages," | sed -e s/,default,/,/ -e s/,all,/,/ -e s/,c,/,/ `
2185597410b8Schristos  potential_languages=,c,
2186597410b8Schristos
2187597410b8Schristos  enabled_target_libs=
2188597410b8Schristos  disabled_target_libs=
2189597410b8Schristos
2190597410b8Schristos  for lang_frag in ${srcdir}/gcc/*/config-lang.in .. ; do
2191597410b8Schristos    case ${lang_frag} in
2192597410b8Schristos      ..) ;;
2193597410b8Schristos      # The odd quoting in the next line works around
2194597410b8Schristos      # an apparent bug in bash 1.12 on linux.
2195597410b8Schristos      ${srcdir}/gcc/[[*]]/config-lang.in) ;;
2196597410b8Schristos      *)
2197597410b8Schristos        # From the config-lang.in, get $language, $target_libs,
2198597410b8Schristos        # $lang_dirs, $boot_language, and $build_by_default
2199597410b8Schristos        language=
2200597410b8Schristos        target_libs=
2201597410b8Schristos        lang_dirs=
2202597410b8Schristos        subdir_requires=
2203597410b8Schristos        boot_language=no
2204597410b8Schristos        build_by_default=yes
22054559860eSchristos        # set srcdir during sourcing.  See above about save & restore
22064559860eSchristos        saved_srcdir=${srcdir}
22074559860eSchristos        srcdir=${srcdir}/gcc . ${lang_frag}
22084559860eSchristos        srcdir=${saved_srcdir}
2209597410b8Schristos        if test x${language} = x; then
2210597410b8Schristos          echo "${lang_frag} doesn't set \$language." 1>&2
2211597410b8Schristos          exit 1
2212597410b8Schristos        fi
2213597410b8Schristos
221405598a80Schristos	if test "$language" = "c++"; then
2215597410b8Schristos	  boot_language=yes
2216597410b8Schristos	fi
2217597410b8Schristos
221805598a80Schristos        add_this_lang=no
22194559860eSchristos        # C is always enabled, so no need to add it again
22204559860eSchristos        if test "$language" != "c"; then
2221597410b8Schristos          case ,${enable_languages}, in
2222597410b8Schristos            *,${language},*)
222305598a80Schristos              # Language was explicitly selected; include it
2224597410b8Schristos	      add_this_lang=yes
2225597410b8Schristos              ;;
2226597410b8Schristos	    *,all,*)
22274559860eSchristos	      # All languages are enabled
22284559860eSchristos	      add_this_lang=all
22294559860eSchristos              ;;
22304559860eSchristos            *,default,*)
22314559860eSchristos              # 'default' was selected, select it if it is a default language
2232597410b8Schristos	      add_this_lang=${build_by_default}
2233597410b8Schristos              ;;
2234597410b8Schristos          esac
22354559860eSchristos        fi
2236597410b8Schristos
2237597410b8Schristos        # Disable languages that need other directories if these aren't available.
2238597410b8Schristos	for i in $subdir_requires; do
2239597410b8Schristos	  test -f "$srcdir/gcc/$i/config-lang.in" && continue
22404559860eSchristos	  case ${add_this_lang} in
22414559860eSchristos	    yes)
2242597410b8Schristos              # Specifically requested language; tell them.
2243597410b8Schristos              AC_MSG_ERROR([The gcc/$i directory contains parts of $language but is missing])
2244597410b8Schristos              ;;
22454559860eSchristos            all)
22464559860eSchristos              AC_MSG_WARN([The gcc/$i directory contains parts of $language but is missing])
22474559860eSchristos              add_this_lang=unsupported
22484559860eSchristos              ;;
2249597410b8Schristos            *)
2250597410b8Schristos              # Silently disable.
2251597410b8Schristos              add_this_lang=unsupported
2252597410b8Schristos              ;;
2253597410b8Schristos          esac
2254597410b8Schristos	done
2255597410b8Schristos
2256597410b8Schristos        # Disable Ada if no preexisting GNAT is available.
22574559860eSchristos        case ${add_this_lang}:${language}:${have_gnat} in
22584559860eSchristos          yes:ada:no)
2259597410b8Schristos            # Specifically requested language; tell them.
2260597410b8Schristos            AC_MSG_ERROR([GNAT is required to build $language])
2261597410b8Schristos            ;;
22624559860eSchristos          all:ada:no)
22634559860eSchristos            AC_MSG_WARN([GNAT is required to build $language])
22644559860eSchristos            add_this_lang=unsupported
22654559860eSchristos            ;;
2266597410b8Schristos          *:ada:no)
2267597410b8Schristos            # Silently disable.
2268597410b8Schristos            add_this_lang=unsupported
2269597410b8Schristos            ;;
2270597410b8Schristos        esac
2271597410b8Schristos
22724b169a6bSchristos        # Disable D if no preexisting GDC is available.
22734b169a6bSchristos        case ${add_this_lang}:${language}:${have_gdc} in
22744b169a6bSchristos          yes:d:no)
22754b169a6bSchristos            # Specifically requested language; tell them.
22764b169a6bSchristos            AC_MSG_ERROR([GDC is required to build $language])
22774b169a6bSchristos           ;;
22784b169a6bSchristos          all:d:no)
22794b169a6bSchristos            AC_MSG_WARN([GDC is required to build $language])
22804b169a6bSchristos            add_this_lang=unsupported
22814b169a6bSchristos            ;;
22824b169a6bSchristos          *:d:no)
22834b169a6bSchristos            # Silently disable.
22844b169a6bSchristos            add_this_lang=unsupported
22854b169a6bSchristos            ;;
22864b169a6bSchristos        esac
22874b169a6bSchristos
22884559860eSchristos        # Disable jit if -enable-host-shared not specified
22894b169a6bSchristos        # but not if building for Mingw. All code in Windows
22904b169a6bSchristos        # is position independent code (PIC).
22914b169a6bSchristos        case $target in
22924b169a6bSchristos          *mingw*) ;;
22934b169a6bSchristos          *)
22944559860eSchristos          case ${add_this_lang}:${language}:${host_shared} in
22954559860eSchristos            yes:jit:no)
22964559860eSchristos	           # PR jit/64780: explicitly specify --enable-host-shared
22974559860eSchristos	    AC_MSG_ERROR([
22984559860eSchristosEnabling language "jit" requires --enable-host-shared.
22994559860eSchristos
23004559860eSchristos--enable-host-shared typically slows the rest of the compiler down by
23014559860eSchristosa few %, so you must explicitly enable it.
23024559860eSchristos
23034559860eSchristosIf you want to build both the jit and the regular compiler, it is often
23044559860eSchristosbest to do this via two separate configure/builds, in separate
23054559860eSchristosdirectories, to avoid imposing the performance cost of
23064559860eSchristos--enable-host-shared on the regular compiler.])
23074559860eSchristos	            ;;
23084559860eSchristos            all:jit:no)
23094559860eSchristos	      AC_MSG_WARN([--enable-host-shared required to build $language])
23104559860eSchristos              add_this_lang=unsupported
23114559860eSchristos              ;;
23124559860eSchristos            *:jit:no)
23134559860eSchristos              # Silently disable.
23144559860eSchristos              add_this_lang=unsupported
23154559860eSchristos              ;;
23164559860eSchristos	        esac
23174b169a6bSchristos          ;;
23184b169a6bSchristos        esac
23194559860eSchristos
2320597410b8Schristos        # Disable a language that is unsupported by the target.
23214559860eSchristos	case "${add_this_lang}: $unsupported_languages " in
23224559860eSchristos	  no:*) ;;
23234559860eSchristos	  unsupported:*) ;;
23244559860eSchristos	  *:*" $language "*)
23254559860eSchristos	    AC_MSG_WARN([${language} not supported for this target])
2326597410b8Schristos	    add_this_lang=unsupported
2327597410b8Schristos	    ;;
2328597410b8Schristos	esac
2329597410b8Schristos
2330597410b8Schristos	case $add_this_lang in
2331597410b8Schristos	  unsupported)
2332597410b8Schristos            # Remove language-dependent dirs.
2333597410b8Schristos	    disabled_target_libs="$disabled_target_libs $target_libs"
2334597410b8Schristos	    noconfigdirs="$noconfigdirs $lang_dirs"
2335597410b8Schristos	    ;;
2336597410b8Schristos	  no)
2337597410b8Schristos            # Remove language-dependent dirs; still show language as supported.
2338597410b8Schristos	    disabled_target_libs="$disabled_target_libs $target_libs"
2339597410b8Schristos	    noconfigdirs="$noconfigdirs $lang_dirs"
2340597410b8Schristos            potential_languages="${potential_languages}${language},"
2341597410b8Schristos	    ;;
23424559860eSchristos          all|yes)
2343597410b8Schristos	    new_enable_languages="${new_enable_languages}${language},"
2344597410b8Schristos            potential_languages="${potential_languages}${language},"
2345597410b8Schristos	    missing_languages=`echo "$missing_languages" | sed "s/,$language,/,/"`
2346597410b8Schristos	    enabled_target_libs="$enabled_target_libs $target_libs"
2347597410b8Schristos	    case "${boot_language}:,$enable_stage1_languages," in
2348597410b8Schristos	      yes:* | *:*,$language,* | *:*,yes, | *:*,all,)
2349597410b8Schristos		# Add to (comma-separated) list of stage 1 languages.
2350597410b8Schristos		case ",$stage1_languages," in
2351597410b8Schristos		  *,$language,* | ,yes, | ,all,) ;;
2352597410b8Schristos		  *) stage1_languages="${stage1_languages}${language}," ;;
2353597410b8Schristos		esac
2354597410b8Schristos		# We need to bootstrap any supporting libraries.
23554b169a6bSchristos		bootstrap_target_libs=`echo "${bootstrap_target_libs}${target_libs}," | sed "s/ /,/g"`
2356597410b8Schristos		;;
2357597410b8Schristos	    esac
2358597410b8Schristos	    ;;
2359597410b8Schristos        esac
2360597410b8Schristos        ;;
2361597410b8Schristos    esac
2362597410b8Schristos  done
2363597410b8Schristos
2364597410b8Schristos  # Add target libraries which are only needed for disabled languages
2365597410b8Schristos  # to noconfigdirs.
2366597410b8Schristos  if test -n "$disabled_target_libs"; then
2367597410b8Schristos    for dir in $disabled_target_libs; do
2368597410b8Schristos      case " $enabled_target_libs " in
2369597410b8Schristos      *" ${dir} "*) ;;
2370597410b8Schristos      *) noconfigdirs="$noconfigdirs $dir" ;;
2371597410b8Schristos      esac
2372597410b8Schristos    done
2373597410b8Schristos  fi
2374597410b8Schristos
2375597410b8Schristos  AC_ARG_ENABLE(stage1-languages,
2376597410b8Schristos  [AS_HELP_STRING([[--enable-stage1-languages[=all]]],
2377597410b8Schristos		  [choose additional languages to build during
2378597410b8Schristos		  stage1.  Mostly useful for compiler development])],
2379597410b8Schristos  [case ,${enable_stage1_languages}, in
2380597410b8Schristos    ,no,|,,)
2381597410b8Schristos      # Set it to something that will have no effect in the loop below
2382597410b8Schristos      enable_stage1_languages=c ;;
2383597410b8Schristos    ,yes,)
2384597410b8Schristos      enable_stage1_languages=`echo $new_enable_languages | \
2385597410b8Schristos	sed -e "s/^,//" -e "s/,$//" ` ;;
2386597410b8Schristos    *,all,*)
2387597410b8Schristos      enable_stage1_languages=`echo ,$enable_stage1_languages, | \
2388597410b8Schristos	sed -e "s/,all,/$new_enable_languages/" -e "s/^,//" -e "s/,$//" ` ;;
2389597410b8Schristos  esac
2390597410b8Schristos
2391597410b8Schristos  # Add "good" languages from enable_stage1_languages to stage1_languages,
2392597410b8Schristos  # while "bad" languages go in missing_languages.  Leave no duplicates.
2393597410b8Schristos  for i in `echo $enable_stage1_languages | sed 's/,/ /g' `; do
2394597410b8Schristos    case $potential_languages in
2395597410b8Schristos      *,$i,*)
2396597410b8Schristos        case $stage1_languages in
2397597410b8Schristos          *,$i,*) ;;
2398597410b8Schristos          *) stage1_languages="$stage1_languages$i," ;;
2399597410b8Schristos        esac ;;
2400597410b8Schristos      *)
2401597410b8Schristos        case $missing_languages in
2402597410b8Schristos          *,$i,*) ;;
2403597410b8Schristos          *) missing_languages="$missing_languages$i," ;;
2404597410b8Schristos        esac ;;
2405597410b8Schristos     esac
2406597410b8Schristos  done])
2407597410b8Schristos
2408597410b8Schristos  # Remove leading/trailing commas that were added for simplicity
2409597410b8Schristos  potential_languages=`echo "$potential_languages" | sed -e "s/^,//" -e "s/,$//"`
2410597410b8Schristos  missing_languages=`echo "$missing_languages" | sed -e "s/^,//" -e "s/,$//"`
2411597410b8Schristos  stage1_languages=`echo "$stage1_languages" | sed -e "s/^,//" -e "s/,$//"`
2412597410b8Schristos  new_enable_languages=`echo "$new_enable_languages" | sed -e "s/^,//" -e "s/,$//"`
2413597410b8Schristos
2414597410b8Schristos  if test "x$missing_languages" != x; then
2415597410b8Schristos    AC_MSG_ERROR([
2416597410b8SchristosThe following requested languages could not be built: ${missing_languages}
2417597410b8SchristosSupported languages are: ${potential_languages}])
2418597410b8Schristos  fi
2419597410b8Schristos  if test "x$new_enable_languages" != "x$enable_languages"; then
2420597410b8Schristos    echo The following languages will be built: ${new_enable_languages}
2421597410b8Schristos    enable_languages="$new_enable_languages"
2422597410b8Schristos  fi
2423597410b8Schristos
2424597410b8Schristos  AC_SUBST(stage1_languages)
2425597410b8Schristos  ac_configure_args=`echo " $ac_configure_args" | sed -e "s/ '--enable-languages=[[^ ]]*'//g" -e "s/$/ '--enable-languages="$enable_languages"'/" `
2426597410b8Schristosfi
2427597410b8Schristos
2428597410b8Schristos# Handle --disable-<component> generically.
2429597410b8Schristosfor dir in $configdirs $build_configdirs $target_configdirs ; do
2430597410b8Schristos  dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g`
2431597410b8Schristos  varname=`echo $dirname | sed -e s/+/_/g`
2432597410b8Schristos  if eval test x\${enable_${varname}} "=" xno ; then
2433597410b8Schristos    noconfigdirs="$noconfigdirs $dir"
2434597410b8Schristos  fi
2435597410b8Schristosdone
2436597410b8Schristos
2437597410b8Schristos# Check for Boehm's garbage collector
2438597410b8SchristosAC_ARG_ENABLE(objc-gc,
2439597410b8Schristos[AS_HELP_STRING([--enable-objc-gc],
2440597410b8Schristos		[enable use of Boehm's garbage collector with the
2441796c32c9Schristos		 GNU Objective-C runtime])])
2442796c32c9SchristosAC_ARG_WITH([target-bdw-gc],
2443796c32c9Schristos[AS_HELP_STRING([--with-target-bdw-gc=PATHLIST],
2444796c32c9Schristos		[specify prefix directory for installed bdw-gc package.
2445796c32c9Schristos		 Equivalent to --with-target-bdw-gc-include=PATH/include
2446796c32c9Schristos		 plus --with-target-bdw-gc-lib=PATH/lib])])
2447796c32c9SchristosAC_ARG_WITH([target-bdw-gc-include],
2448796c32c9Schristos[AS_HELP_STRING([--with-target-bdw-gc-include=PATHLIST],
2449796c32c9Schristos		[specify directories for installed bdw-gc include files])])
2450796c32c9SchristosAC_ARG_WITH([target-bdw-gc-lib],
2451796c32c9Schristos[AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
2452796c32c9Schristos		[specify directories for installed bdw-gc library])])
2453597410b8Schristos
2454796c32c9Schristoscase ,${enable_languages},:${enable_objc_gc} in *,objc,*:yes|*,objc,*:auto)
2455796c32c9Schristos  AC_MSG_CHECKING([for bdw garbage collector])
2456796c32c9Schristos  if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
2457796c32c9Schristos    dnl no bdw-gw options, assume default locations
2458796c32c9Schristos    AC_MSG_RESULT([using bdw-gc in default locations])
2459796c32c9Schristos  else
2460796c32c9Schristos    dnl bdw-gw options, first error checking, complete checking in libobjc
2461796c32c9Schristos    if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
2462796c32c9Schristos      AC_MSG_ERROR([found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing])
2463796c32c9Schristos    elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
2464796c32c9Schristos      AC_MSG_ERROR([found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing])
2465796c32c9Schristos    else
2466796c32c9Schristos      AC_MSG_RESULT([using paths configured with --with-target-bdw-gc options])
2467597410b8Schristos    fi
2468796c32c9Schristos  fi
2469597410b8Schristosesac
2470597410b8Schristos
2471*079139fbSchristos# Disable libitm, libsanitizer, libvtv if we're not building C++
247205598a80Schristoscase ,${enable_languages}, in
2473212397c6Schristos  *,c++,*)
24744559860eSchristos    # Disable libitm, libsanitizer if we're not building libstdc++
2475212397c6Schristos    case "${noconfigdirs}" in
2476212397c6Schristos      *target-libstdc++-v3*)
24774559860eSchristos        noconfigdirs="$noconfigdirs target-libitm target-libsanitizer"
2478212397c6Schristos        ;;
2479212397c6Schristos      *) ;;
2480212397c6Schristos    esac
2481212397c6Schristos    ;;
248205598a80Schristos  *)
2483*079139fbSchristos    noconfigdirs="$noconfigdirs target-libitm target-libsanitizer target-libvtv"
2484*079139fbSchristos    ;;
2485*079139fbSchristosesac
2486*079139fbSchristos
2487*079139fbSchristoscase ,${enable_languages}, in
2488*079139fbSchristos  *,rust,*)
2489*079139fbSchristos    case " ${noconfigdirs} " in
2490*079139fbSchristos      *\ target-libstdc++-v3\ *)
2491*079139fbSchristos        # Disable target libgrust if we're not building target libstdc++.
2492*079139fbSchristos        noconfigdirs="$noconfigdirs target-libgrust"
2493*079139fbSchristos        ;;
2494*079139fbSchristos    esac
249505598a80Schristos    ;;
249605598a80Schristosesac
249705598a80Schristos
24984b169a6bSchristos# If gcc/ is not in the source tree then we'll not be building a
24994b169a6bSchristos# target compiler, assume in that case we don't want to build any
25004b169a6bSchristos# target libraries or tools.
25014b169a6bSchristos#
25024b169a6bSchristos# This was added primarily for the benefit for binutils-gdb who reuse
25034b169a6bSchristos# this configure script, but don't always have target tools available.
25044b169a6bSchristosif test ! -d ${srcdir}/gcc; then
25054b169a6bSchristos   skipdirs="${skipdirs} ${target_configdirs}"
25064b169a6bSchristosfi
25074b169a6bSchristos
2508597410b8Schristos# Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
2509597410b8Schristos# $build_configdirs and $target_configdirs.
2510597410b8Schristos# If we have the source for $noconfigdirs entries, add them to $notsupp.
2511597410b8Schristos
2512597410b8Schristosnotsupp=""
2513597410b8Schristosfor dir in . $skipdirs $noconfigdirs ; do
2514597410b8Schristos  dirname=`echo $dir | sed -e s/target-//g -e s/build-//g`
2515597410b8Schristos  if test $dir != .  && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2516597410b8Schristos    configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
2517597410b8Schristos    if test -r $srcdir/$dirname/configure ; then
2518597410b8Schristos      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2519597410b8Schristos	true
2520597410b8Schristos      else
2521597410b8Schristos	notsupp="$notsupp $dir"
2522597410b8Schristos      fi
2523597410b8Schristos    fi
2524597410b8Schristos  fi
2525597410b8Schristos  if test $dir != .  && echo " ${build_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2526597410b8Schristos    build_configdirs=`echo " ${build_configdirs} " | sed -e "s/ ${dir} / /"`
2527597410b8Schristos    if test -r $srcdir/$dirname/configure ; then
2528597410b8Schristos      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2529597410b8Schristos	true
2530597410b8Schristos      else
2531597410b8Schristos	notsupp="$notsupp $dir"
2532597410b8Schristos      fi
2533597410b8Schristos    fi
2534597410b8Schristos  fi
2535597410b8Schristos  if test $dir != . && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2536597410b8Schristos    target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
2537597410b8Schristos    if test -r $srcdir/$dirname/configure ; then
2538597410b8Schristos      if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2539597410b8Schristos	true
2540597410b8Schristos      else
2541597410b8Schristos	notsupp="$notsupp $dir"
2542597410b8Schristos      fi
2543597410b8Schristos    fi
2544597410b8Schristos  fi
2545597410b8Schristosdone
2546597410b8Schristos
2547597410b8Schristos# Quietly strip out all directories which aren't configurable in this tree.
2548597410b8Schristos# This relies on all configurable subdirectories being autoconfiscated, which
2549597410b8Schristos# is now the case.
2550597410b8Schristosbuild_configdirs_all="$build_configdirs"
2551597410b8Schristosbuild_configdirs=
2552597410b8Schristosfor i in ${build_configdirs_all} ; do
2553597410b8Schristos  j=`echo $i | sed -e s/build-//g`
2554597410b8Schristos  if test -f ${srcdir}/$j/configure ; then
2555597410b8Schristos    build_configdirs="${build_configdirs} $i"
2556597410b8Schristos  fi
2557597410b8Schristosdone
2558597410b8Schristos
2559597410b8Schristosconfigdirs_all="$configdirs"
2560597410b8Schristosconfigdirs=
2561597410b8Schristosfor i in ${configdirs_all} ; do
2562597410b8Schristos  if test -f ${srcdir}/$i/configure ; then
2563597410b8Schristos    configdirs="${configdirs} $i"
2564597410b8Schristos  fi
2565597410b8Schristosdone
2566597410b8Schristos
2567597410b8Schristostarget_configdirs_all="$target_configdirs"
2568597410b8Schristostarget_configdirs=
2569597410b8Schristosfor i in ${target_configdirs_all} ; do
2570597410b8Schristos  j=`echo $i | sed -e s/target-//g`
2571597410b8Schristos  if test -f ${srcdir}/$j/configure ; then
2572597410b8Schristos    target_configdirs="${target_configdirs} $i"
2573597410b8Schristos  fi
2574597410b8Schristosdone
2575597410b8Schristos
2576212397c6Schristos# libiberty-linker-plugin is special: it doesn't have its own source directory,
2577212397c6Schristos# so we have to add it after the preceding checks.
2578212397c6Schristosif test x"$extra_linker_plugin_flags$extra_linker_plugin_configure_flags" != x
2579212397c6Schristosthen
2580212397c6Schristos  case " $configdirs " in
2581212397c6Schristos    *" libiberty "*)
2582212397c6Schristos      # If we can build libiberty, we can also build libiberty-linker-plugin.
2583212397c6Schristos      configdirs="$configdirs libiberty-linker-plugin"
2584212397c6Schristos      extra_linker_plugin_configure_flags="$extra_linker_plugin_configure_flags \
2585212397c6Schristos        --with-libiberty=../libiberty-linker-plugin";;
2586212397c6Schristos    *)
2587212397c6Schristos      AC_MSG_ERROR([libiberty missing]);;
2588212397c6Schristos  esac
2589212397c6Schristosfi
2590212397c6Schristos
2591212397c6Schristos# Sometimes we have special requirements for the host libiberty.
2592212397c6Schristosextra_host_libiberty_configure_flags=
2593212397c6Schristoscase " $configdirs " in
25944b169a6bSchristos  *" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
2595212397c6Schristos    # When these are to be built as shared libraries, the same applies to
2596212397c6Schristos    # libiberty.
2597212397c6Schristos    extra_host_libiberty_configure_flags=--enable-shared
2598212397c6Schristos    ;;
25994b169a6bSchristosesac
26004b169a6bSchristosAC_SUBST(extra_host_libiberty_configure_flags)
26014b169a6bSchristos
26024b169a6bSchristos# Sometimes we have special requirements for the host zlib.
26034b169a6bSchristosextra_host_zlib_configure_flags=
26044b169a6bSchristoscase " $configdirs " in
2605212397c6Schristos  *" bfd "*)
2606212397c6Schristos    # When bfd is to be built as a shared library, the same applies to
2607212397c6Schristos    # zlib.
2608212397c6Schristos    if test "$enable_shared" = "yes"; then
2609212397c6Schristos      extra_host_zlib_configure_flags=--enable-host-shared
2610212397c6Schristos    fi
2611212397c6Schristos    ;;
2612212397c6Schristosesac
2613212397c6SchristosAC_SUBST(extra_host_zlib_configure_flags)
2614212397c6Schristos
2615597410b8Schristos# Produce a warning message for the subdirs we can't configure.
2616597410b8Schristos# This isn't especially interesting in the Cygnus tree, but in the individual
2617597410b8Schristos# FSF releases, it's important to let people know when their machine isn't
2618597410b8Schristos# supported by the one or two programs in a package.
2619597410b8Schristos
2620597410b8Schristosif test -n "${notsupp}" && test -z "${norecursion}" ; then
2621597410b8Schristos  # If $appdirs is non-empty, at least one of those directories must still
2622597410b8Schristos  # be configured, or we error out.  (E.g., if the gas release supports a
2623597410b8Schristos  # specified target in some subdirs but not the gas subdir, we shouldn't
2624597410b8Schristos  # pretend that all is well.)
2625597410b8Schristos  if test -n "$appdirs" ; then
2626597410b8Schristos    for dir in $appdirs ; do
2627597410b8Schristos      if test -r $dir/Makefile.in ; then
2628597410b8Schristos	if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
2629597410b8Schristos	  appdirs=""
2630597410b8Schristos	  break
2631597410b8Schristos	fi
2632597410b8Schristos	if echo " ${target_configdirs} " | grep " target-${dir} " >/dev/null 2>&1; then
2633597410b8Schristos	  appdirs=""
2634597410b8Schristos	  break
2635597410b8Schristos	fi
2636597410b8Schristos      fi
2637597410b8Schristos    done
2638597410b8Schristos    if test -n "$appdirs" ; then
2639597410b8Schristos      echo "*** This configuration is not supported by this package." 1>&2
2640597410b8Schristos      exit 1
2641597410b8Schristos    fi
2642597410b8Schristos  fi
2643597410b8Schristos  # Okay, some application will build, or we don't care to check.  Still
2644597410b8Schristos  # notify of subdirs not getting built.
2645597410b8Schristos  echo "*** This configuration is not supported in the following subdirectories:" 1>&2
2646597410b8Schristos  echo "    ${notsupp}" 1>&2
2647597410b8Schristos  echo "    (Any other directories should still work fine.)" 1>&2
2648597410b8Schristosfi
2649597410b8Schristos
2650597410b8Schristoscase "$host" in
2651597410b8Schristos  *msdosdjgpp*)
2652597410b8Schristos    enable_gdbtk=no ;;
2653597410b8Schristosesac
2654597410b8Schristos
2655597410b8Schristos# To find our prefix, in gcc_cv_tool_prefix.
2656597410b8SchristosACX_TOOL_DIRS
2657597410b8Schristos
2658597410b8Schristoscopy_dirs=
2659597410b8Schristos
2660597410b8SchristosAC_ARG_WITH([build-sysroot],
2661597410b8Schristos  [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
2662597410b8Schristos		  [use sysroot as the system root during the build])],
2663597410b8Schristos  [if test x"$withval" != x ; then
2664597410b8Schristos     SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
2665597410b8Schristos   fi],
2666597410b8Schristos  [SYSROOT_CFLAGS_FOR_TARGET=])
2667597410b8SchristosAC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
2668597410b8Schristos
2669597410b8SchristosAC_ARG_WITH([debug-prefix-map],
2670597410b8Schristos  [AS_HELP_STRING([--with-debug-prefix-map='A=B C=D ...'],
2671597410b8Schristos		  [map A to B, C to D ... in debug information])],
2672597410b8Schristos  [if test x"$withval" != x; then
2673597410b8Schristos     DEBUG_PREFIX_CFLAGS_FOR_TARGET=
2674597410b8Schristos     for debug_map in $withval; do
2675597410b8Schristos       DEBUG_PREFIX_CFLAGS_FOR_TARGET="$DEBUG_PREFIX_CFLAGS_FOR_TARGET -fdebug-prefix-map=$debug_map"
2676597410b8Schristos     done
2677597410b8Schristos   fi],
2678597410b8Schristos  [DEBUG_PREFIX_CFLAGS_FOR_TARGET=])
2679597410b8SchristosAC_SUBST(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
2680597410b8Schristos
2681597410b8Schristos# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
2682597410b8Schristos# might be empty or "-g".  We don't require a C++ compiler, so CXXFLAGS
2683597410b8Schristos# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
2684597410b8Schristos# We want to ensure that TARGET libraries (which we know are built with
2685597410b8Schristos# gcc) are built with "-O2 -g", so include those options when setting
2686597410b8Schristos# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
2687597410b8Schristosif test "x$CFLAGS_FOR_TARGET" = x; then
2688212397c6Schristos  if test "x${is_cross_compiler}" = xyes; then
2689212397c6Schristos    CFLAGS_FOR_TARGET="-g -O2"
2690212397c6Schristos  else
2691597410b8Schristos    CFLAGS_FOR_TARGET=$CFLAGS
2692597410b8Schristos    case " $CFLAGS " in
2693597410b8Schristos      *" -O2 "*) ;;
269405598a80Schristos      *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
2695597410b8Schristos    esac
2696597410b8Schristos    case " $CFLAGS " in
2697597410b8Schristos      *" -g "* | *" -g3 "*) ;;
269805598a80Schristos      *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
2699597410b8Schristos    esac
2700597410b8Schristos  fi
2701212397c6Schristosfi
2702597410b8SchristosAC_SUBST(CFLAGS_FOR_TARGET)
2703597410b8Schristos
2704597410b8Schristosif test "x$CXXFLAGS_FOR_TARGET" = x; then
2705212397c6Schristos  if test "x${is_cross_compiler}" = xyes; then
2706212397c6Schristos    CXXFLAGS_FOR_TARGET="-g -O2"
2707212397c6Schristos  else
2708597410b8Schristos    CXXFLAGS_FOR_TARGET=$CXXFLAGS
2709597410b8Schristos    case " $CXXFLAGS " in
2710597410b8Schristos      *" -O2 "*) ;;
271105598a80Schristos      *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
2712597410b8Schristos    esac
2713597410b8Schristos    case " $CXXFLAGS " in
2714597410b8Schristos      *" -g "* | *" -g3 "*) ;;
271505598a80Schristos      *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
2716597410b8Schristos    esac
2717597410b8Schristos  fi
2718212397c6Schristosfi
2719597410b8SchristosAC_SUBST(CXXFLAGS_FOR_TARGET)
2720597410b8Schristos
272105598a80SchristosAC_SUBST(LDFLAGS_FOR_TARGET)
272205598a80Schristos
2723597410b8Schristos# Handle --with-headers=XXX.  If the value is not "yes", the contents of
2724597410b8Schristos# the named directory are copied to $(tooldir)/sys-include.
2725597410b8Schristosif test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
2726597410b8Schristos  if test x${is_cross_compiler} = xno ; then
2727597410b8Schristos    echo 1>&2 '***' --with-headers is only supported when cross compiling
2728597410b8Schristos    exit 1
2729597410b8Schristos  fi
2730597410b8Schristos  if test x"${with_headers}" != xyes ; then
2731597410b8Schristos    x=${gcc_cv_tool_prefix}
2732597410b8Schristos    copy_dirs="${copy_dirs} ${with_headers} $x/${target_noncanonical}/sys-include"
2733597410b8Schristos  fi
2734597410b8Schristosfi
2735597410b8Schristos
2736597410b8Schristos# Handle --with-libs=XXX.  If the value is not "yes", the contents of
2737597410b8Schristos# the name directories are copied to $(tooldir)/lib.  Multiple directories
2738597410b8Schristos# are permitted.
2739597410b8Schristosif test x"${with_libs}" != x && test x"${with_libs}" != xno ; then
2740597410b8Schristos  if test x${is_cross_compiler} = xno ; then
2741597410b8Schristos    echo 1>&2 '***' --with-libs is only supported when cross compiling
2742597410b8Schristos    exit 1
2743597410b8Schristos  fi
2744597410b8Schristos  if test x"${with_libs}" != xyes ; then
2745597410b8Schristos    # Copy the libraries in reverse order, so that files in the first named
2746597410b8Schristos    # library override files in subsequent libraries.
2747597410b8Schristos    x=${gcc_cv_tool_prefix}
2748597410b8Schristos    for l in ${with_libs}; do
2749597410b8Schristos      copy_dirs="$l $x/${target_noncanonical}/lib ${copy_dirs}"
2750597410b8Schristos    done
2751597410b8Schristos  fi
2752597410b8Schristosfi
2753597410b8Schristos
2754597410b8Schristos# Set with_gnu_as, with_gnu_ld, and with_system_zlib as appropriate.
2755597410b8Schristos#
2756597410b8Schristos# This is done by determining whether or not the appropriate directory
2757597410b8Schristos# is available, and by checking whether or not specific configurations
2758597410b8Schristos# have requested that this magic not happen.
2759597410b8Schristos#
2760597410b8Schristos# The command line options always override the explicit settings in
2761ba340e45Schristos# configure.ac, and the settings in configure.ac override this magic.
2762597410b8Schristos#
2763597410b8Schristos# If the default for a toolchain is to use GNU as and ld, and you don't
2764597410b8Schristos# want to do that, then you should use the --without-gnu-as and
2765597410b8Schristos# --without-gnu-ld options for the configure script.  Similarly, if
2766597410b8Schristos# the default is to use the included zlib and you don't want to do that,
2767597410b8Schristos# you should use the --with-system-zlib option for the configure script.
2768597410b8Schristos
2769597410b8Schristosif test x${use_gnu_as} = x &&
2770597410b8Schristos   echo " ${configdirs} " | grep " gas " > /dev/null 2>&1 ; then
2771597410b8Schristos  with_gnu_as=yes
2772597410b8Schristos  extra_host_args="$extra_host_args --with-gnu-as"
2773597410b8Schristosfi
2774597410b8Schristos
2775597410b8Schristosif test x${use_gnu_ld} = x &&
2776597410b8Schristos   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
2777597410b8Schristos  with_gnu_ld=yes
2778597410b8Schristos  extra_host_args="$extra_host_args --with-gnu-ld"
2779597410b8Schristosfi
2780597410b8Schristos
2781597410b8Schristosif test x${use_included_zlib} = x &&
2782597410b8Schristos   echo " ${configdirs} " | grep " zlib " > /dev/null 2>&1 ; then
2783597410b8Schristos  :
2784597410b8Schristoselse
2785597410b8Schristos  with_system_zlib=yes
2786597410b8Schristos  extra_host_args="$extra_host_args --with-system-zlib"
2787597410b8Schristosfi
2788597410b8Schristos
2789597410b8Schristos# If using newlib, add --with-newlib to the extra_host_args so that gcc/configure
2790597410b8Schristos# can detect this case.
2791597410b8Schristos
2792597410b8Schristosif test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 ; then
2793597410b8Schristos  with_newlib=yes
2794597410b8Schristos  extra_host_args="$extra_host_args --with-newlib"
2795597410b8Schristosfi
2796597410b8Schristos
2797597410b8Schristos# Handle ${copy_dirs}
2798597410b8Schristosset fnord ${copy_dirs}
2799597410b8Schristosshift
2800597410b8Schristoswhile test $# != 0 ; do
2801597410b8Schristos  if test -f $2/COPIED && test x"`cat $2/COPIED`" = x"$1" ; then
2802597410b8Schristos    :
2803597410b8Schristos  else
2804597410b8Schristos    echo Copying $1 to $2
2805597410b8Schristos
2806597410b8Schristos    # Use the install script to create the directory and all required
2807597410b8Schristos    # parent directories.
2808597410b8Schristos    if test -d $2 ; then
2809597410b8Schristos      :
2810597410b8Schristos    else
2811597410b8Schristos      echo >config.temp
2812597410b8Schristos      ${srcdir}/install-sh -c -m 644 config.temp $2/COPIED
2813597410b8Schristos    fi
2814597410b8Schristos
2815597410b8Schristos    # Copy the directory, assuming we have tar.
2816597410b8Schristos    # FIXME: Should we use B in the second tar?  Not all systems support it.
2817597410b8Schristos    (cd $1; tar -cf - .) | (cd $2; tar -xpf -)
2818597410b8Schristos
2819597410b8Schristos    # It is the responsibility of the user to correctly adjust all
2820597410b8Schristos    # symlinks.  If somebody can figure out how to handle them correctly
2821597410b8Schristos    # here, feel free to add the code.
2822597410b8Schristos
2823597410b8Schristos    echo $1 > $2/COPIED
2824597410b8Schristos  fi
2825597410b8Schristos  shift; shift
2826597410b8Schristosdone
2827597410b8Schristos
2828597410b8Schristos# Determine a target-dependent exec_prefix that the installed
2829597410b8Schristos# gcc will search in.  Keep this list sorted by triplet, with
2830597410b8Schristos# the *-*-osname triplets last.
2831597410b8Schristosmd_exec_prefix=
2832597410b8Schristoscase "${target}" in
2833597410b8Schristos  i[[34567]]86-pc-msdosdjgpp*)
2834597410b8Schristos    md_exec_prefix=/dev/env/DJDIR/bin
2835597410b8Schristos    ;;
2836597410b8Schristos  *-*-hpux* | \
2837597410b8Schristos  *-*-nto-qnx* | \
2838597410b8Schristos  *-*-solaris2*)
2839597410b8Schristos    md_exec_prefix=/usr/ccs/bin
2840597410b8Schristos    ;;
2841597410b8Schristosesac
2842597410b8Schristos
2843597410b8Schristosextra_arflags_for_target=
2844597410b8Schristosextra_nmflags_for_target=
2845597410b8Schristosextra_ranlibflags_for_target=
2846597410b8Schristostarget_makefile_frag=/dev/null
2847597410b8Schristoscase "${target}" in
2848597410b8Schristos  spu-*-*)
2849597410b8Schristos    target_makefile_frag="config/mt-spu"
2850597410b8Schristos    ;;
2851*079139fbSchristos  loongarch*-*linux* | loongarch*-*gnu*)
2852*079139fbSchristos    target_makefile_frag="config/mt-loongarch-gnu"
2853*079139fbSchristos    ;;
2854*079139fbSchristos  loongarch*-*elf*)
2855*079139fbSchristos    target_makefile_frag="config/mt-loongarch-elf"
2856*079139fbSchristos    ;;
28579d210927Schristos  mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
2858597410b8Schristos    target_makefile_frag="config/mt-sde"
2859597410b8Schristos    ;;
2860597410b8Schristos  mipsisa*-*-elfoabi*)
2861597410b8Schristos    target_makefile_frag="config/mt-mips-elfoabi"
2862597410b8Schristos    ;;
2863597410b8Schristos  mips*-*-*linux* | mips*-*-gnu*)
2864597410b8Schristos    target_makefile_frag="config/mt-mips-gnu"
2865597410b8Schristos    ;;
28669d210927Schristos  nios2-*-elf*)
28679d210927Schristos    target_makefile_frag="config/mt-nios2-elf"
28689d210927Schristos    ;;
28694559860eSchristos  *-*-linux-android*)
28704559860eSchristos    target_makefile_frag="config/mt-android"
28714559860eSchristos    ;;
2872597410b8Schristos  *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
2873597410b8Schristos    target_makefile_frag="config/mt-gnu"
2874597410b8Schristos    ;;
2875597410b8Schristos  *-*-aix4.[[3456789]]* | *-*-aix[[56789]].*)
2876597410b8Schristos    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm
2877597410b8Schristos    # commands to handle both 32-bit and 64-bit objects.  These flags are
2878597410b8Schristos    # harmless if we're using GNU nm or ar.
2879597410b8Schristos    extra_arflags_for_target=" -X32_64"
2880597410b8Schristos    extra_nmflags_for_target=" -B -X32_64"
2881597410b8Schristos    ;;
2882597410b8Schristosesac
2883597410b8Schristos
2884597410b8Schristosalphaieee_frag=/dev/null
2885597410b8Schristoscase $target in
2886597410b8Schristos  alpha*-*-*)
2887597410b8Schristos    # This just makes sure to use the -mieee option to build target libs.
2888597410b8Schristos    # This should probably be set individually by each library.
2889597410b8Schristos    alphaieee_frag="config/mt-alphaieee"
2890597410b8Schristos    ;;
2891597410b8Schristosesac
2892597410b8Schristos
2893597410b8Schristos# If --enable-target-optspace always use -Os instead of -O2 to build
2894597410b8Schristos# the target libraries, similarly if it is not specified, use -Os
2895597410b8Schristos# on selected platforms.
2896597410b8Schristosospace_frag=/dev/null
2897597410b8Schristoscase "${enable_target_optspace}:${target}" in
2898597410b8Schristos  yes:*)
2899597410b8Schristos    ospace_frag="config/mt-ospace"
2900597410b8Schristos    ;;
2901597410b8Schristos  :d30v-*)
2902597410b8Schristos    ospace_frag="config/mt-d30v"
2903597410b8Schristos    ;;
2904212397c6Schristos  :m32r-* | :d10v-* | :fr30-* | :i?86*-*-elfiamcu)
2905597410b8Schristos    ospace_frag="config/mt-ospace"
2906597410b8Schristos    ;;
2907597410b8Schristos  no:* | :*)
2908597410b8Schristos    ;;
2909597410b8Schristos  *)
2910597410b8Schristos    echo "*** bad value \"${enable_target_optspace}\" for --enable-target-optspace flag; ignored" 1>&2
2911597410b8Schristos    ;;
2912597410b8Schristosesac
2913597410b8Schristos
2914597410b8Schristos# Some systems (e.g., one of the i386-aix systems the gas testers are
2915597410b8Schristos# using) don't handle "\$" correctly, so don't use it here.
2916597410b8Schristostooldir='${exec_prefix}'/${target_noncanonical}
2917597410b8Schristosbuild_tooldir=${tooldir}
2918597410b8Schristos
2919597410b8Schristos# Create a .gdbinit file which runs the one in srcdir
2920597410b8Schristos# and tells GDB to look there for source files.
2921597410b8Schristos
2922597410b8Schristosif test -r ${srcdir}/.gdbinit ; then
2923597410b8Schristos  case ${srcdir} in
2924597410b8Schristos    .) ;;
2925597410b8Schristos    *) cat > ./.gdbinit <<EOF
2926597410b8Schristos# ${NO_EDIT}
2927597410b8Schristosdir ${srcdir}
2928597410b8Schristosdir .
2929597410b8Schristossource ${srcdir}/.gdbinit
2930597410b8SchristosEOF
2931597410b8Schristos    ;;
2932597410b8Schristos  esac
2933597410b8Schristosfi
2934597410b8Schristos
2935597410b8Schristos# Make sure that the compiler is able to generate an executable.  If it
2936597410b8Schristos# can't, we are probably in trouble.  We don't care whether we can run the
2937597410b8Schristos# executable--we might be using a cross compiler--we only care whether it
2938597410b8Schristos# can be created.  At this point the main configure script has set CC.
2939597410b8Schristoswe_are_ok=no
2940597410b8Schristosecho "int main () { return 0; }" > conftest.c
2941597410b8Schristos${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
2942597410b8Schristosif test $? = 0 ; then
2943597410b8Schristos  if test -s conftest || test -s conftest.exe ; then
2944597410b8Schristos    we_are_ok=yes
2945597410b8Schristos  fi
2946597410b8Schristosfi
2947597410b8Schristoscase $we_are_ok in
2948597410b8Schristos  no)
2949597410b8Schristos    echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
2950597410b8Schristos    echo 1>&2 "*** You must set the environment variable CC to a working compiler."
2951597410b8Schristos    rm -f conftest*
2952597410b8Schristos    exit 1
2953597410b8Schristos    ;;
2954597410b8Schristosesac
2955597410b8Schristosrm -f conftest*
2956597410b8Schristos
2957597410b8Schristos# Decide which environment variable is used to find dynamic libraries.
2958597410b8Schristoscase "${host}" in
2959597410b8Schristos  *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
2960597410b8Schristos  *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
2961597410b8Schristos  *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
2962597410b8Schristos  *) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
2963597410b8Schristosesac
2964597410b8Schristos
2965597410b8Schristos# On systems where the dynamic library environment variable is PATH,
2966597410b8Schristos# gcc/ will put dynamic libraries into a subdirectory to avoid adding
2967597410b8Schristos# built executables to PATH.
2968597410b8Schristosif test "$RPATH_ENVVAR" = PATH; then
2969597410b8Schristos  GCC_SHLIB_SUBDIR=/shlib
2970597410b8Schristoselse
2971597410b8Schristos  GCC_SHLIB_SUBDIR=
2972597410b8Schristosfi
2973597410b8Schristos
29749d210927Schristos# Adjust the toplevel makefile according to whether bootstrap was selected.
29759d210927Schristoscase $enable_bootstrap in
29769d210927Schristos  yes)
29779d210927Schristos    bootstrap_suffix=bootstrap
29789d210927Schristos    BUILD_CONFIG=bootstrap-debug
29799d210927Schristos    ;;
29809d210927Schristos  no)
29819d210927Schristos    bootstrap_suffix=no-bootstrap
29829d210927Schristos    BUILD_CONFIG=
29839d210927Schristos    ;;
29849d210927Schristosesac
29859d210927Schristos
29869d210927SchristosAC_MSG_CHECKING(for default BUILD_CONFIG)
29879d210927Schristos
29889d210927SchristosAC_ARG_WITH([build-config],
29899d210927Schristos  [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
29909d210927Schristos		  [use config/NAME.mk build configuration])],
29919d210927Schristos  [case $with_build_config in
29929d210927Schristos   yes) with_build_config= ;;
29939d210927Schristos   no) with_build_config= BUILD_CONFIG= ;;
29949d210927Schristos   esac])
29959d210927Schristos
29969d210927Schristosif test "x${with_build_config}" != x; then
29979d210927Schristos  BUILD_CONFIG=$with_build_config
29989d210927Schristoselse
29999d210927Schristos  case $BUILD_CONFIG in
30009d210927Schristos  bootstrap-debug)
30019d210927Schristos    if echo "int f (void) { return 0; }" > conftest.c &&
30029d210927Schristos       ${CC} -c conftest.c &&
30039d210927Schristos       mv conftest.o conftest.o.g0 &&
30049d210927Schristos       ${CC} -c -g conftest.c &&
30059d210927Schristos       mv conftest.o conftest.o.g &&
30069d210927Schristos       ${srcdir}/contrib/compare-debug conftest.o.g0 conftest.o.g > /dev/null 2>&1; then
30079d210927Schristos      :
30089d210927Schristos    else
30099d210927Schristos      BUILD_CONFIG=
30109d210927Schristos    fi
30119d210927Schristos    rm -f conftest.c conftest.o conftest.o.g0 conftest.o.g
30129d210927Schristos    ;;
30139d210927Schristos  esac
30149d210927Schristosfi
30159d210927SchristosAC_MSG_RESULT($BUILD_CONFIG)
30169d210927SchristosAC_SUBST(BUILD_CONFIG)
30179d210927Schristos
30189d210927Schristos# Use same top-level configure hooks in libgcc/libstdc++/libvtv.
30199d210927SchristosAC_MSG_CHECKING([for --enable-vtable-verify])
30209d210927SchristosAC_ARG_ENABLE(vtable-verify,
3021ba340e45Schristos[AS_HELP_STRING([--enable-vtable-verify],
3022ba340e45Schristos		[Enable vtable verification feature])],
30239d210927Schristos[case "$enableval" in
30249d210927Schristos yes) enable_vtable_verify=yes ;;
30259d210927Schristos no)  enable_vtable_verify=no ;;
30269d210927Schristos *)   enable_vtable_verify=no;;
30279d210927Schristos esac],
30289d210927Schristos[enable_vtable_verify=no])
30299d210927SchristosAC_MSG_RESULT($enable_vtable_verify)
30309d210927Schristos
3031597410b8Schristos# Record target_configdirs and the configure arguments for target and
3032597410b8Schristos# build configuration in Makefile.
3033597410b8Schristostarget_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
3034597410b8Schristosbuild_configdirs=`echo "${build_configdirs}" | sed -e 's/build-//g'`
30359d210927Schristosbootstrap_fixincludes=no
3036597410b8Schristos
3037597410b8Schristos# If we are building libgomp, bootstrap it.
3038597410b8Schristosif echo " ${target_configdirs} " | grep " libgomp " > /dev/null 2>&1 ; then
3039597410b8Schristos  bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
3040597410b8Schristosfi
3041597410b8Schristos
30429d210927Schristos# If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
30439d210927Schristos# or bootstrap-ubsan, bootstrap it.
304405598a80Schristosif echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
30459d210927Schristos  case "$BUILD_CONFIG" in
30464b169a6bSchristos    *bootstrap-hwasan* | *bootstrap-asan* | *bootstrap-ubsan* )
304705598a80Schristos      bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
30489d210927Schristos      bootstrap_fixincludes=yes
30499d210927Schristos      ;;
30509d210927Schristos  esac
305105598a80Schristosfi
305205598a80Schristos
30539d210927Schristos# If we are building libvtv and --enable-vtable-verify, bootstrap it.
30549d210927Schristosif echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 &&
30559d210927Schristos   test "$enable_vtable_verify" != no; then
305603467a24Schristos  bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
305703467a24Schristosfi
305803467a24Schristos
30594b169a6bSchristos# If we are building libatomic and the list of enabled languages includes the
30604b169a6bSchristos# D frontend, bootstrap it.
30614b169a6bSchristosif echo " ${target_configdirs} " | grep " libatomic " > /dev/null 2>&1; then
30624b169a6bSchristos  case ,${enable_languages}, in
30634b169a6bSchristos    *,d,*)
30644b169a6bSchristos      bootstrap_target_libs=${bootstrap_target_libs}target-libatomic,
30654b169a6bSchristos      ;;
30664b169a6bSchristos  esac
30674b169a6bSchristosfi
30684b169a6bSchristos
3069597410b8Schristos# Determine whether gdb needs tk/tcl or not.
3070597410b8Schristos# Use 'maybe' since enable_gdbtk might be true even if tk isn't available
3071597410b8Schristos# and in that case we want gdb to be built without tk.  Ugh!
3072597410b8Schristos# In fact I believe gdb is the *only* package directly dependent on tk,
3073597410b8Schristos# so we should be able to put the 'maybe's in unconditionally and
3074597410b8Schristos# leave out the maybe dependencies when enable_gdbtk is false.  I'm not
3075597410b8Schristos# 100% sure that that's safe though.
3076597410b8Schristos
3077597410b8Schristosgdb_tk="maybe-all-tcl maybe-all-tk maybe-all-itcl maybe-all-libgui"
3078597410b8Schristoscase "$enable_gdbtk" in
3079597410b8Schristos  no)
3080597410b8Schristos    GDB_TK="" ;;
3081597410b8Schristos  yes)
3082597410b8Schristos    GDB_TK="${gdb_tk}" ;;
3083597410b8Schristos  *)
3084597410b8Schristos    # Only add the dependency on gdbtk when GDBtk is part of the gdb
3085597410b8Schristos    # distro.  Eventually someone will fix this and move Insight, nee
3086597410b8Schristos    # gdbtk to a separate directory.
3087597410b8Schristos    if test -d ${srcdir}/gdb/gdbtk ; then
3088597410b8Schristos      GDB_TK="${gdb_tk}"
3089597410b8Schristos    else
3090597410b8Schristos      GDB_TK=""
3091597410b8Schristos    fi
3092597410b8Schristos    ;;
3093597410b8Schristosesac
3094597410b8SchristosCONFIGURE_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-configure-/g`
3095597410b8SchristosINSTALL_GDB_TK=`echo ${GDB_TK} | sed s/-all-/-install-/g`
3096597410b8Schristos
30978dffb485Schristos# gdb and gdbserver depend on gnulib and gdbsupport, but as nothing
30988dffb485Schristos# else does, only include them if one of these is built.  The Makefile
30998dffb485Schristos# provides the ordering, so it's enough here to add to the list.
31008dffb485Schristoscase " ${configdirs} " in
31018dffb485Schristos  *\ gdb\ *)
31028dffb485Schristos    configdirs="${configdirs} gnulib gdbsupport"
31038dffb485Schristos    ;;
31048dffb485Schristos  *\ gdbserver\ *)
31058dffb485Schristos    configdirs="${configdirs} gnulib gdbsupport"
31068dffb485Schristos    ;;
31074b169a6bSchristos  *\ sim\ *)
31084b169a6bSchristos    configdirs="${configdirs} gnulib"
31094b169a6bSchristos    ;;
31108dffb485Schristosesac
31118dffb485Schristos
3112597410b8Schristos# Strip out unwanted targets.
3113597410b8Schristos
3114597410b8Schristos# While at that, we remove Makefiles if we were started for recursive
3115597410b8Schristos# configuration, so that the top-level Makefile reconfigures them,
3116597410b8Schristos# like we used to do when configure itself was recursive.
3117597410b8Schristos
3118597410b8Schristos# Loop over modules.  We used to use the "$extrasub" feature from Autoconf
3119597410b8Schristos# but now we're fixing up the Makefile ourselves with the additional
3120597410b8Schristos# commands passed to AC_CONFIG_FILES.  Use separate variables
3121597410b8Schristos# extrasub-{build,host,target} not because there is any reason to split
3122597410b8Schristos# the substitutions up that way, but only to remain below the limit of
3123597410b8Schristos# 99 commands in a script, for HP-UX sed.
31244559860eSchristos
31254559860eSchristos# Do not nest @if/@endif or @unless/@endunless pairs, because
31264559860eSchristos# configure will not warn you at all.
3127597410b8Schristos
3128597410b8Schristoscase "$enable_bootstrap:$ENABLE_GOLD: $configdirs :,$stage1_languages," in
3129597410b8Schristos  yes:yes:*\ gold\ *:*,c++,*) ;;
3130597410b8Schristos  yes:yes:*\ gold\ *:*)
3131597410b8Schristos    AC_MSG_ERROR([in a combined tree, bootstrapping with --enable-gold requires c++ in stage1_languages])
3132597410b8Schristos    ;;
3133597410b8Schristosesac
3134597410b8Schristos
3135597410b8Schristosextrasub_build=
3136597410b8Schristosfor module in ${build_configdirs} ; do
3137597410b8Schristos  if test -z "${no_recursion}" \
3138597410b8Schristos     && test -f ${build_subdir}/${module}/Makefile; then
3139597410b8Schristos    echo 1>&2 "*** removing ${build_subdir}/${module}/Makefile to force reconfigure"
3140597410b8Schristos    rm -f ${build_subdir}/${module}/Makefile
3141597410b8Schristos  fi
3142597410b8Schristos  extrasub_build="$extrasub_build
3143597410b8Schristos/^@if build-$module\$/d
3144597410b8Schristos/^@endif build-$module\$/d
31454559860eSchristos/^@unless build-$module\$/,/^@endunless build-$module\$/d
3146597410b8Schristos/^@if build-$module-$bootstrap_suffix\$/d
31474559860eSchristos/^@endif build-$module-$bootstrap_suffix\$/d
31484559860eSchristos/^@unless build-$module-$bootstrap_suffix\$/,/^@endunless build-$module-$bootstrap_suffix\$/d"
3149597410b8Schristosdone
3150597410b8Schristosextrasub_host=
3151597410b8Schristosfor module in ${configdirs} ; do
3152597410b8Schristos  if test -z "${no_recursion}"; then
3153597410b8Schristos    for file in stage*-${module}/Makefile prev-${module}/Makefile ${module}/Makefile; do
3154597410b8Schristos      if test -f ${file}; then
3155597410b8Schristos	echo 1>&2 "*** removing ${file} to force reconfigure"
3156597410b8Schristos	rm -f ${file}
3157597410b8Schristos      fi
3158597410b8Schristos    done
3159597410b8Schristos  fi
31609d210927Schristos  case ${module},${bootstrap_fixincludes} in
31619d210927Schristos    fixincludes,no) host_bootstrap_suffix=no-bootstrap ;;
31629d210927Schristos    *) host_bootstrap_suffix=$bootstrap_suffix ;;
31639d210927Schristos  esac
3164597410b8Schristos  extrasub_host="$extrasub_host
3165597410b8Schristos/^@if $module\$/d
3166597410b8Schristos/^@endif $module\$/d
31674559860eSchristos/^@unless $module\$/,/^@endunless $module\$/d
31689d210927Schristos/^@if $module-$host_bootstrap_suffix\$/d
31694559860eSchristos/^@endif $module-$host_bootstrap_suffix\$/d
31704559860eSchristos/^@unless $module-$host_bootstrap_suffix\$/,/^@endunless $module-$host_bootstrap_suffix\$/d"
3171597410b8Schristosdone
3172597410b8Schristosextrasub_target=
3173597410b8Schristosfor module in ${target_configdirs} ; do
3174597410b8Schristos  if test -z "${no_recursion}" \
3175597410b8Schristos     && test -f ${target_subdir}/${module}/Makefile; then
3176597410b8Schristos    echo 1>&2 "*** removing ${target_subdir}/${module}/Makefile to force reconfigure"
3177597410b8Schristos    rm -f ${target_subdir}/${module}/Makefile
3178597410b8Schristos  fi
3179597410b8Schristos
3180597410b8Schristos  # We only bootstrap target libraries listed in bootstrap_target_libs.
3181597410b8Schristos  case $bootstrap_target_libs in
3182597410b8Schristos    *,target-$module,*) target_bootstrap_suffix=$bootstrap_suffix ;;
3183597410b8Schristos    *) target_bootstrap_suffix=no-bootstrap ;;
3184597410b8Schristos  esac
3185597410b8Schristos
3186597410b8Schristos  extrasub_target="$extrasub_target
3187597410b8Schristos/^@if target-$module\$/d
3188597410b8Schristos/^@endif target-$module\$/d
31894559860eSchristos/^@unless target-$module\$/,/^@endunless target-$module\$/d
3190597410b8Schristos/^@if target-$module-$target_bootstrap_suffix\$/d
31914559860eSchristos/^@endif target-$module-$target_bootstrap_suffix\$/d
31924559860eSchristos/^@unless target-$module-$target_bootstrap_suffix\$/,/^@endunless target-$module-$target_bootstrap_suffix\$/d"
3193597410b8Schristosdone
3194597410b8Schristos
3195597410b8Schristos# Do the final fixup along with target modules.
3196597410b8Schristosextrasub_target="$extrasub_target
31974559860eSchristos/^@if /,/^@endif /d
31984559860eSchristos/^@unless /d
31994559860eSchristos/^@endunless /d"
3200597410b8Schristos
32014b169a6bSchristosif test "$enable_pgo_build" != "no"; then
32024b169a6bSchristos  extrasub_build="$extrasub_build
32034b169a6bSchristos/^@if pgo-build\$/d
32044b169a6bSchristos/^@endif pgo-build\$/d"
32054b169a6bSchristosfi
32064b169a6bSchristos
3207597410b8Schristos# Create the serialization dependencies.  This uses a temporary file.
3208597410b8Schristos
3209597410b8SchristosAC_ARG_ENABLE([serial-configure],
3210597410b8Schristos[AS_HELP_STRING([[--enable-serial-[{host,target,build}-]configure]],
3211597410b8Schristos		[force sequential configuration of
3212597410b8Schristos		 sub-packages for the host, target or build
3213597410b8Schristos		 machine, or all sub-packages])])
3214597410b8Schristos
3215597410b8Schristoscase ${enable_serial_configure} in
3216597410b8Schristos  yes)
3217597410b8Schristos    enable_serial_build_configure=yes
3218597410b8Schristos    enable_serial_host_configure=yes
3219597410b8Schristos    enable_serial_target_configure=yes
3220597410b8Schristos    ;;
3221597410b8Schristosesac
3222597410b8Schristos
3223597410b8Schristos# These force 'configure's to be done one at a time, to avoid problems
3224597410b8Schristos# with contention over a shared config.cache.
3225597410b8Schristosrm -f serdep.tmp
3226*079139fbSchristosif test "x${enable_serial_build_configure}" = xyes || test "x${enable_serial_host_configure}" = xyes || test "x${enable_serial_target_configure}" = xyes; then
3227597410b8Schristosecho '# serdep.tmp' > serdep.tmp
3228*079139fbSchristosfi
3229597410b8Schristosolditem=
3230597410b8Schristostest "x${enable_serial_build_configure}" = xyes &&
3231597410b8Schristosfor item in ${build_configdirs} ; do
3232597410b8Schristos  case ${olditem} in
3233597410b8Schristos    "") ;;
3234597410b8Schristos    *) echo "configure-build-${item}: configure-build-${olditem}" >> serdep.tmp ;;
3235597410b8Schristos  esac
3236597410b8Schristos  olditem=${item}
3237597410b8Schristosdone
3238597410b8Schristosolditem=
3239597410b8Schristostest "x${enable_serial_host_configure}" = xyes &&
3240597410b8Schristosfor item in ${configdirs} ; do
3241597410b8Schristos  case ${olditem} in
3242597410b8Schristos    "") ;;
3243597410b8Schristos    *) echo "configure-${item}: configure-${olditem}" >> serdep.tmp ;;
3244597410b8Schristos  esac
3245597410b8Schristos  olditem=${item}
3246597410b8Schristosdone
3247597410b8Schristosolditem=
3248597410b8Schristostest "x${enable_serial_target_configure}" = xyes &&
3249597410b8Schristosfor item in ${target_configdirs} ; do
3250597410b8Schristos  case ${olditem} in
3251597410b8Schristos    "") ;;
3252597410b8Schristos    *) echo "configure-target-${item}: configure-target-${olditem}" >> serdep.tmp ;;
3253597410b8Schristos  esac
3254597410b8Schristos  olditem=${item}
3255597410b8Schristosdone
3256597410b8Schristosserialization_dependencies=serdep.tmp
3257597410b8SchristosAC_SUBST_FILE(serialization_dependencies)
3258597410b8Schristos
3259597410b8Schristos# Base args.  Strip norecursion, cache-file, srcdir, host, build,
3260597410b8Schristos# target, nonopt, and variable assignments.  These are the ones we
3261597410b8Schristos# might not want to pass down to subconfigures.  The exception being
3262597410b8Schristos# --cache-file=/dev/null, which is used to turn off the use of cache
3263597410b8Schristos# files altogether, and which should be passed on to subconfigures.
3264597410b8Schristos# Also strip program-prefix, program-suffix, and program-transform-name,
3265597410b8Schristos# so that we can pass down a consistent program-transform-name.
3266*079139fbSchristoshbaseargs=
3267*079139fbSchristosbbaseargs=
3268597410b8Schristostbaseargs=
3269597410b8Schristoskeep_next=no
3270597410b8Schristosskip_next=no
3271597410b8Schristoseval "set -- $ac_configure_args"
3272597410b8Schristosfor ac_arg
3273597410b8Schristosdo
3274597410b8Schristos  if test X"$skip_next" = X"yes"; then
3275597410b8Schristos    skip_next=no
3276597410b8Schristos    continue
3277597410b8Schristos  fi
3278597410b8Schristos  if test X"$keep_next" = X"yes"; then
3279597410b8Schristos    case $ac_arg in
3280597410b8Schristos      *\'*)
3281597410b8Schristos	ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
3282597410b8Schristos    esac
3283*079139fbSchristos    hbaseargs="$hbaseargs '$ac_arg'"
3284*079139fbSchristos    bbaseargs="$bbaseargs '$ac_arg'"
3285597410b8Schristos    tbaseargs="$tbaseargs '$ac_arg'"
3286597410b8Schristos    keep_next=no
3287597410b8Schristos    continue
3288597410b8Schristos  fi
3289597410b8Schristos
3290597410b8Schristos  # Handle separated arguments.  Based on the logic generated by
3291597410b8Schristos  # autoconf 2.59.
3292597410b8Schristos  case $ac_arg in
3293597410b8Schristos    *=* | --config-cache | -C | -disable-* | --disable-* \
3294597410b8Schristos      | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
3295597410b8Schristos      | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
3296597410b8Schristos      | -with-* | --with-* | -without-* | --without-* | --x)
3297597410b8Schristos      separate_arg=no
3298597410b8Schristos      ;;
3299597410b8Schristos    -*)
3300597410b8Schristos      separate_arg=yes
3301597410b8Schristos      ;;
3302597410b8Schristos    *)
3303597410b8Schristos      separate_arg=no
3304597410b8Schristos      ;;
3305597410b8Schristos  esac
3306597410b8Schristos
3307597410b8Schristos  skip_targ=no
3308*079139fbSchristos  skip_barg=no
3309597410b8Schristos  case $ac_arg in
3310597410b8Schristoschangequote(,)
3311597410b8Schristos  --with-* | --without-*)
3312597410b8Schristos    libopt=`echo "$ac_arg" | sed -e 's,^--[^-_]*[-_],,' -e 's,=.*$,,'`
3313597410b8Schristos
3314597410b8Schristos    case $libopt in
3315597410b8Schristos    *[-_]include)
3316597410b8Schristos      lib=`echo "$libopt" | sed 's,[-_]include$,,'`
3317597410b8Schristos      ;;
3318597410b8Schristos    *[-_]lib)
3319597410b8Schristos      lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
3320597410b8Schristos      ;;
3321*079139fbSchristos    *[-_]prefix)
3322*079139fbSchristos      lib=`echo "$libopt" | sed 's,[-_]prefix$,,'`
3323*079139fbSchristos      ;;
3324*079139fbSchristos    *[-_]type)
3325*079139fbSchristos      lib=`echo "$libopt" | sed 's,[-_]type$,,'`
3326*079139fbSchristos      ;;
3327597410b8Schristos    *)
3328597410b8Schristos      lib=$libopt
3329597410b8Schristos      ;;
3330597410b8Schristos    esac
3331597410b8Schristoschangequote([,])
3332597410b8Schristos
3333597410b8Schristos    case $lib in
3334212397c6Schristos    mpc | mpfr | gmp | isl)
3335597410b8Schristos      # If we're processing --with-$lib, --with-$lib-include or
3336597410b8Schristos      # --with-$lib-lib, for one of the libs above, and target is
3337597410b8Schristos      # different from host, don't pass the current argument to any
3338597410b8Schristos      # target library's configure.
3339597410b8Schristos      if test x$is_cross_compiler = xyes; then
3340597410b8Schristos        skip_targ=yes
3341597410b8Schristos      fi
3342597410b8Schristos      ;;
3343*079139fbSchristos    libintl | libiconv)
3344*079139fbSchristos      # We don't want libintl (and co.) in anything but the host arguments.
3345*079139fbSchristos      skip_targ=yes
3346*079139fbSchristos      skip_barg=yes
3347*079139fbSchristos      ;;
3348597410b8Schristos    esac
3349597410b8Schristos    ;;
3350597410b8Schristos  esac
3351597410b8Schristos
3352597410b8Schristos  case "$ac_arg" in
3353597410b8Schristos    --cache-file=/dev/null | \
3354597410b8Schristos    -cache-file=/dev/null )
3355597410b8Schristos      # Handled here to avoid the test to skip args below.
3356*079139fbSchristos      hbaseargs="$hbaseargs '$ac_arg'"
3357*079139fbSchristos      bbaseargs="$bbaseargs '$ac_arg'"
3358597410b8Schristos      tbaseargs="$tbaseargs '$ac_arg'"
3359597410b8Schristos      # Assert: $separate_arg should always be no.
3360597410b8Schristos      keep_next=$separate_arg
3361597410b8Schristos      ;;
3362597410b8Schristos    --no*)
3363597410b8Schristos      continue
3364597410b8Schristos      ;;
3365597410b8Schristos    --c* | \
3366597410b8Schristos    --sr* | \
3367597410b8Schristos    --ho* | \
3368597410b8Schristos    --bu* | \
3369597410b8Schristos    --t* | \
3370597410b8Schristos    --program-* | \
3371597410b8Schristos    -cache_file* | \
3372597410b8Schristos    -srcdir* | \
3373597410b8Schristos    -host* | \
3374597410b8Schristos    -build* | \
3375597410b8Schristos    -target* | \
3376597410b8Schristos    -program-prefix* | \
3377597410b8Schristos    -program-suffix* | \
3378597410b8Schristos    -program-transform-name* )
3379597410b8Schristos      skip_next=$separate_arg
3380597410b8Schristos      continue
3381597410b8Schristos      ;;
3382597410b8Schristos    -*)
3383597410b8Schristos      # An option.  Add it.
3384597410b8Schristos      case $ac_arg in
3385597410b8Schristos	*\'*)
3386597410b8Schristos	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
3387597410b8Schristos      esac
3388*079139fbSchristos      hbaseargs="$hbaseargs '$ac_arg'"
3389*079139fbSchristos      if test X"$skip_barg" = Xno; then
3390*079139fbSchristos	bbaseargs="$bbaseargs '$ac_arg'"
3391*079139fbSchristos      fi
3392597410b8Schristos      if test X"$skip_targ" = Xno; then
3393597410b8Schristos        tbaseargs="$tbaseargs '$ac_arg'"
3394597410b8Schristos      fi
3395597410b8Schristos      keep_next=$separate_arg
3396597410b8Schristos      ;;
3397597410b8Schristos    *)
3398597410b8Schristos      # Either a variable assignment, or a nonopt (triplet).  Don't
3399597410b8Schristos      # pass it down; let the Makefile handle this.
3400597410b8Schristos      continue
3401597410b8Schristos      ;;
3402597410b8Schristos  esac
3403597410b8Schristosdone
3404597410b8Schristos# Remove the initial space we just introduced and, as these will be
3405597410b8Schristos# expanded by make, quote '$'.
3406*079139fbSchristoshbaseargs=`echo "x$hbaseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
3407*079139fbSchristosbbaseargs=`echo "x$bbaseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
3408597410b8Schristos
3409597410b8Schristos# Add in --program-transform-name, after --program-prefix and
3410597410b8Schristos# --program-suffix have been applied to it.  Autoconf has already
3411597410b8Schristos# doubled dollar signs and backslashes in program_transform_name; we want
3412597410b8Schristos# the backslashes un-doubled, and then the entire thing wrapped in single
3413597410b8Schristos# quotes, because this will be expanded first by make and then by the shell.
3414597410b8Schristos# Also, because we want to override the logic in subdir configure scripts to
3415597410b8Schristos# choose program_transform_name, replace any s,x,x, with s,y,y,.
3416597410b8Schristossed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
3417597410b8Schristos${program_transform_name}
3418597410b8SchristosEOF_SED
3419597410b8Schristosgcc_transform_name=`cat conftestsed.out`
3420597410b8Schristosrm -f conftestsed.out
3421*079139fbSchristoshbaseargs="$hbaseargs --program-transform-name='${gcc_transform_name}'"
3422*079139fbSchristosbbaseargs="$bbaseargs --program-transform-name='${gcc_transform_name}'"
3423597410b8Schristostbaseargs="$tbaseargs --program-transform-name='${gcc_transform_name}'"
3424597410b8Schristosif test "$silent" = yes; then
3425*079139fbSchristos  bbaseargs="$bbaseargs --silent"
3426*079139fbSchristos  hbaseargs="$hbaseargs --silent"
3427597410b8Schristos  tbaseargs="$tbaseargs --silent"
3428597410b8Schristosfi
34294b169a6bSchristos
3430*079139fbSchristosbbaseargs="$bbaseargs --disable-option-checking"
3431*079139fbSchristoshbaseargs="$hbaseargs --disable-option-checking"
3432597410b8Schristostbaseargs="$tbaseargs --disable-option-checking"
3433597410b8Schristos
34344b169a6bSchristosif test "$enable_year2038" = no; then
3435*079139fbSchristos  bbaseargs="$bbaseargs --disable-year2038"
3436*079139fbSchristos  hbaseargs="$hbaseargs --disable-year2038"
34374b169a6bSchristos  tbaseargs="$tbaseargs --disable-year2038"
34384b169a6bSchristosfi
34394b169a6bSchristos
3440597410b8Schristos# Record and document user additions to sub configure arguments.
3441597410b8SchristosAC_ARG_VAR([build_configargs],
3442597410b8Schristos	   [additional configure arguments for build directories])
3443597410b8SchristosAC_ARG_VAR([host_configargs],
3444597410b8Schristos	   [additional configure arguments for host directories])
3445597410b8SchristosAC_ARG_VAR([target_configargs],
3446597410b8Schristos	   [additional configure arguments for target directories])
3447597410b8Schristos
3448597410b8Schristos# For the build-side libraries, we just need to pretend we're native,
3449597410b8Schristos# and not use the same cache file.  Multilibs are neither needed nor
3450212397c6Schristos# desired.  We can't even use the same cache file for all build-side
3451212397c6Schristos# libraries, as they're compiled differently; some with C, some with
3452212397c6Schristos# C++ or with different feature-enabling options.
3453*079139fbSchristosbuild_configargs="$build_configargs --cache-file=./config.cache ${bbaseargs}"
3454597410b8Schristos
3455597410b8Schristos# For host modules, accept cache file option, or specification as blank.
3456597410b8Schristoscase "${cache_file}" in
3457597410b8Schristos"") # empty
3458597410b8Schristos  cache_file_option="" ;;
3459597410b8Schristos/* | [[A-Za-z]]:[[\\/]]* ) # absolute path
3460597410b8Schristos  cache_file_option="--cache-file=${cache_file}" ;;
3461597410b8Schristos*) # relative path
3462597410b8Schristos  cache_file_option="--cache-file=../${cache_file}" ;;
3463597410b8Schristosesac
3464597410b8Schristos
3465597410b8Schristos# Host dirs don't like to share a cache file either, horribly enough.
3466597410b8Schristos# This seems to be due to autoconf 2.5x stupidity.
3467*079139fbSchristoshost_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${hbaseargs}"
3468597410b8Schristos
3469597410b8Schristostarget_configargs="$target_configargs ${tbaseargs}"
3470597410b8Schristos
3471597410b8Schristos# Passing a --with-cross-host argument lets the target libraries know
3472597410b8Schristos# whether they are being built with a cross-compiler or being built
3473597410b8Schristos# native.  However, it would be better to use other mechanisms to make the
3474597410b8Schristos# sorts of decisions they want to make on this basis.  Please consider
3475597410b8Schristos# this option to be deprecated.  FIXME.
3476597410b8Schristosif test x${is_cross_compiler} = xyes ; then
3477597410b8Schristos  target_configargs="--with-cross-host=${host_noncanonical} ${target_configargs}"
3478597410b8Schristosfi
3479597410b8Schristos
348003467a24Schristos# Special user-friendly check for native x86_64-linux build, if
348103467a24Schristos# multilib is not explicitly enabled.
348203467a24Schristoscase "$target:$have_compiler:$host:$target:$enable_multilib" in
348303467a24Schristos  x86_64-*linux*:yes:$build:$build:)
3484ba340e45Schristos    # Make sure we have a development environment that handles 32-bit
348503467a24Schristos    dev64=no
348603467a24Schristos    echo "int main () { return 0; }" > conftest.c
348703467a24Schristos    ${CC} -m32 -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
348803467a24Schristos    if test $? = 0 ; then
348903467a24Schristos      if test -s conftest || test -s conftest.exe ; then
349003467a24Schristos	dev64=yes
349103467a24Schristos      fi
349203467a24Schristos    fi
349303467a24Schristos    rm -f conftest*
349403467a24Schristos    if test x${dev64} != xyes ; then
3495ba340e45Schristos      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.])
349603467a24Schristos    fi
349703467a24Schristos    ;;
349803467a24Schristosesac
349903467a24Schristos
3500597410b8Schristos# Default to --enable-multilib.
3501597410b8Schristosif test x${enable_multilib} = x ; then
3502597410b8Schristos  target_configargs="--enable-multilib ${target_configargs}"
3503597410b8Schristosfi
3504597410b8Schristos
3505597410b8Schristos# Pass --with-newlib if appropriate.  Note that target_configdirs has
3506597410b8Schristos# changed from the earlier setting of with_newlib.
3507597410b8Schristosif test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then
3508597410b8Schristos  target_configargs="--with-newlib ${target_configargs}"
3509597410b8Schristosfi
3510597410b8Schristos
3511597410b8Schristos# Different target subdirs use different values of certain variables
3512597410b8Schristos# (notably CXX).  Worse, multilibs use *lots* of different values.
3513597410b8Schristos# Worse yet, autoconf 2.5x makes some of these 'precious', meaning that
3514597410b8Schristos# it doesn't automatically accept command-line overrides of them.
3515597410b8Schristos# This means it's not safe for target subdirs to share a cache file,
3516597410b8Schristos# which is disgusting, but there you have it.  Hopefully this can be
3517597410b8Schristos# fixed in future.  It's still worthwhile to use a cache file for each
3518597410b8Schristos# directory.  I think.
3519597410b8Schristos
3520597410b8Schristos# Pass the appropriate --build, --host, --target and --cache-file arguments.
3521597410b8Schristos# We need to pass --target, as newer autoconf's requires consistency
3522597410b8Schristos# for target_alias and gcc doesn't manage it consistently.
3523597410b8Schristostarget_configargs="--cache-file=./config.cache ${target_configargs}"
3524597410b8Schristos
3525597410b8SchristosFLAGS_FOR_TARGET=
3526597410b8Schristoscase " $target_configdirs " in
3527597410b8Schristos *" newlib "*)
3528597410b8Schristos  case " $target_configargs " in
3529597410b8Schristos  *" --with-newlib "*)
3530597410b8Schristos   case "$target" in
3531597410b8Schristos    *-cygwin*)
353205598a80Schristos      FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
3533597410b8Schristos      ;;
3534597410b8Schristos   esac
3535597410b8Schristos
3536597410b8Schristos   # If we're not building GCC, don't discard standard headers.
3537597410b8Schristos   if test -d ${srcdir}/gcc; then
3538597410b8Schristos     FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -nostdinc'
3539597410b8Schristos
3540597410b8Schristos     if test "${build}" != "${host}"; then
3541597410b8Schristos       # On Canadian crosses, CC_FOR_TARGET will have already been set
3542597410b8Schristos       # by `configure', so we won't have an opportunity to add -Bgcc/
3543597410b8Schristos       # to it.  This is right: we don't want to search that directory
3544597410b8Schristos       # for binaries, but we want the header files in there, so add
3545597410b8Schristos       # them explicitly.
3546597410b8Schristos       FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -isystem $$r/$(HOST_SUBDIR)/gcc/include -isystem $$r/$(HOST_SUBDIR)/gcc/include-fixed'
3547597410b8Schristos
3548597410b8Schristos       # Someone might think of using the pre-installed headers on
3549597410b8Schristos       # Canadian crosses, in case the installed compiler is not fully
3550597410b8Schristos       # compatible with the compiler being built.  In this case, it
3551597410b8Schristos       # would be better to flag an error than risking having
3552597410b8Schristos       # incompatible object files being constructed.  We can't
3553597410b8Schristos       # guarantee that an error will be flagged, but let's hope the
3554597410b8Schristos       # compiler will do it, when presented with incompatible header
3555597410b8Schristos       # files.
3556597410b8Schristos     fi
3557597410b8Schristos   fi
3558597410b8Schristos
3559597410b8Schristos   case "${target}-${is_cross_compiler}" in
3560597410b8Schristos   i[[3456789]]86-*-linux*-no)
3561597410b8Schristos      # Here host == target, so we don't need to build gcc,
3562597410b8Schristos      # so we don't want to discard standard headers.
3563597410b8Schristos      FLAGS_FOR_TARGET=`echo " $FLAGS_FOR_TARGET " | sed -e 's/ -nostdinc / /'`
3564597410b8Schristos      ;;
3565597410b8Schristos   *)
3566597410b8Schristos      # If we're building newlib, use its generic headers last, but search
3567597410b8Schristos      # for any libc-related directories first (so make it the last -B
3568597410b8Schristos      # switch).
3569597410b8Schristos      FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/newlib/ -isystem $$r/$(TARGET_SUBDIR)/newlib/targ-include -isystem $$s/newlib/libc/include'
3570597410b8Schristos
3571597410b8Schristos      # If we're building libgloss, find the startup file, simulator library
3572597410b8Schristos      # and linker script.
3573597410b8Schristos      case " $target_configdirs " in
3574597410b8Schristos	*" libgloss "*)
3575597410b8Schristos	# Look for startup file, simulator library and maybe linker script.
3576597410b8Schristos	FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/libgloss/'"$libgloss_dir"
3577597410b8Schristos	# Look for libnosys.a in case the target needs it.
3578597410b8Schristos	FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/libgloss/libnosys'
3579597410b8Schristos	# Most targets have the linker script in the source directory.
3580597410b8Schristos	FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$s/libgloss/'"$libgloss_dir"
3581597410b8Schristos	;;
3582597410b8Schristos      esac
3583597410b8Schristos      ;;
3584597410b8Schristos   esac
3585597410b8Schristos   ;;
3586597410b8Schristos  esac
3587597410b8Schristos  ;;
3588597410b8Schristosesac
3589597410b8Schristos
3590597410b8Schristoscase "$target" in
3591597410b8Schristos  x86_64-*mingw* | *-w64-mingw*)
3592597410b8Schristos  # MinGW-w64 does not use newlib, nor does it use winsup. It may,
3593597410b8Schristos  # however, use a symlink named 'mingw' in ${prefix} .
3594597410b8Schristos    FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L${prefix}/${target}/lib -L${prefix}/mingw/lib -isystem ${prefix}/${target}/include -isystem ${prefix}/mingw/include'
3595597410b8Schristos    ;;
3596597410b8Schristos  *-mingw*)
3597597410b8Schristos  # MinGW can't be handled as Cygwin above since it does not use newlib.
3598597410b8Schristos    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'
3599597410b8Schristos    ;;
3600597410b8Schristosesac
3601597410b8Schristos
3602597410b8Schristos# Allow the user to override the flags for
3603597410b8Schristos# our build compiler if desired.
3604597410b8Schristosif test x"${build}" = x"${host}" ; then
3605597410b8Schristos  CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
36064b169a6bSchristos  CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
3607597410b8Schristos  CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
3608597410b8Schristos  LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
3609597410b8Schristosfi
3610597410b8Schristos
3611597410b8Schristos# On Canadian crosses, we'll be searching the right directories for
3612597410b8Schristos# the previously-installed cross compiler, so don't bother to add
3613597410b8Schristos# flags for directories within the install tree of the compiler
3614597410b8Schristos# being built; programs in there won't even run.
3615597410b8Schristosif test "${build}" = "${host}" && test -d ${srcdir}/gcc; then
3616597410b8Schristos  # Search for pre-installed headers if nothing else fits.
3617597410b8Schristos  FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include'
3618597410b8Schristosfi
3619597410b8Schristos
3620597410b8Schristosif test "x${use_gnu_ld}" = x &&
3621597410b8Schristos   echo " ${configdirs} " | grep " ld " > /dev/null ; then
3622597410b8Schristos  # Arrange for us to find uninstalled linker scripts.
3623597410b8Schristos  FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(HOST_SUBDIR)/ld'
3624597410b8Schristosfi
3625597410b8Schristos
3626597410b8Schristos# Search for other target-specific linker scripts and such.
3627597410b8Schristoscase "${target}" in
3628597410b8Schristos  mep*)
3629597410b8Schristos    FLAGS_FOR_TARGET="$FLAGS_FOR_TARGET -mlibrary"
3630597410b8Schristos    ;;
36314b169a6bSchristos  # The VxWorks support for shared libraries is getting in
36324b169a6bSchristos  # incrementally.  Make sure it doesn't get activated implicitly:
36334b169a6bSchristos  *vxworks*)
36344b169a6bSchristos    if test "${enable_shared-unset}" = unset ; then
36354b169a6bSchristos      enable_shared=no
36364b169a6bSchristos      # So the build of libraries knows ...
36374b169a6bSchristos      target_configargs="${target_configargs} --disable-shared"
36384b169a6bSchristos      # So gcc knows ...
36394b169a6bSchristos      host_configargs="${host_configargs} --disable-shared"
36404b169a6bSchristos    fi
36414b169a6bSchristos    ;;
3642597410b8Schristosesac
3643597410b8Schristos
3644597410b8Schristos# Makefile fragments.
3645597410b8Schristosfor frag in host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag;
3646597410b8Schristosdo
3647597410b8Schristos  eval fragval=\$$frag
3648597410b8Schristos  if test $fragval != /dev/null; then
3649597410b8Schristos    eval $frag=${srcdir}/$fragval
3650597410b8Schristos  fi
3651597410b8Schristosdone
3652597410b8SchristosAC_SUBST_FILE(host_makefile_frag)
3653597410b8SchristosAC_SUBST_FILE(target_makefile_frag)
3654597410b8SchristosAC_SUBST_FILE(alphaieee_frag)
3655597410b8SchristosAC_SUBST_FILE(ospace_frag)
3656597410b8Schristos
3657597410b8Schristos# Miscellanea: directories, flags, etc.
3658597410b8SchristosAC_SUBST(RPATH_ENVVAR)
3659597410b8SchristosAC_SUBST(GCC_SHLIB_SUBDIR)
3660597410b8SchristosAC_SUBST(tooldir)
3661597410b8SchristosAC_SUBST(build_tooldir)
3662597410b8SchristosAC_SUBST(CONFIGURE_GDB_TK)
3663597410b8SchristosAC_SUBST(GDB_TK)
3664597410b8SchristosAC_SUBST(INSTALL_GDB_TK)
3665597410b8Schristos
3666597410b8Schristos# Build module lists & subconfigure args.
3667597410b8SchristosAC_SUBST(build_configargs)
3668597410b8SchristosAC_SUBST(build_configdirs)
3669597410b8Schristos
3670597410b8Schristos# Host module lists & subconfigure args.
3671597410b8SchristosAC_SUBST(host_configargs)
3672597410b8SchristosAC_SUBST(configdirs)
3673597410b8SchristosAC_SUBST(target_configdirs)
3674597410b8Schristos
3675597410b8Schristos# Target module lists & subconfigure args.
3676597410b8SchristosAC_SUBST(target_configargs)
3677597410b8Schristos
3678597410b8Schristos
3679597410b8Schristos# Build tools.
3680597410b8SchristosAC_SUBST(AR_FOR_BUILD)
3681597410b8SchristosAC_SUBST(AS_FOR_BUILD)
3682597410b8SchristosAC_SUBST(CC_FOR_BUILD)
3683597410b8SchristosAC_SUBST(CFLAGS_FOR_BUILD)
36844b169a6bSchristosAC_SUBST(CPP_FOR_BUILD)
36854b169a6bSchristosAC_SUBST(CPPFLAGS_FOR_BUILD)
3686597410b8SchristosAC_SUBST(CXXFLAGS_FOR_BUILD)
3687597410b8SchristosAC_SUBST(CXX_FOR_BUILD)
3688597410b8SchristosAC_SUBST(DLLTOOL_FOR_BUILD)
36894b169a6bSchristosAC_SUBST(DSYMUTIL_FOR_BUILD)
3690597410b8SchristosAC_SUBST(GFORTRAN_FOR_BUILD)
3691597410b8SchristosAC_SUBST(GOC_FOR_BUILD)
36924b169a6bSchristosAC_SUBST(GDC_FOR_BUILD)
3693597410b8SchristosAC_SUBST(LDFLAGS_FOR_BUILD)
3694597410b8SchristosAC_SUBST(LD_FOR_BUILD)
3695597410b8SchristosAC_SUBST(NM_FOR_BUILD)
3696597410b8SchristosAC_SUBST(RANLIB_FOR_BUILD)
3697597410b8SchristosAC_SUBST(WINDMC_FOR_BUILD)
3698597410b8SchristosAC_SUBST(WINDRES_FOR_BUILD)
3699597410b8Schristos
3700597410b8Schristos# Generate default definitions for YACC, M4, LEX and other programs that run
3701597410b8Schristos# on the build machine.  These are used if the Makefile can't locate these
3702597410b8Schristos# programs in objdir.
3703597410b8SchristosMISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
3704597410b8Schristos
3705597410b8SchristosAC_CHECK_PROGS([YACC], ['bison -y' byacc yacc], [$MISSING bison -y])
3706597410b8Schristoscase " $build_configdirs " in
3707597410b8Schristos  *" bison "*) YACC='$$r/$(BUILD_SUBDIR)/bison/tests/bison -y' ;;
3708597410b8Schristosesac
3709597410b8Schristos
3710597410b8SchristosAC_CHECK_PROGS([BISON], [bison], [$MISSING bison])
3711597410b8Schristoscase " $build_configdirs " in
3712597410b8Schristos  *" bison "*) BISON='$$r/$(BUILD_SUBDIR)/bison/tests/bison' ;;
3713597410b8Schristosesac
3714597410b8Schristos
3715597410b8SchristosAC_CHECK_PROGS([M4], [gm4 gnum4 m4], [$MISSING m4])
3716597410b8Schristoscase " $build_configdirs " in
3717597410b8Schristos  *" m4 "*) M4='$$r/$(BUILD_SUBDIR)/m4/m4' ;;
3718597410b8Schristosesac
3719597410b8Schristos
3720597410b8SchristosAC_CHECK_PROGS([LEX], [flex lex], [$MISSING flex])
3721597410b8Schristoscase " $build_configdirs " in
3722597410b8Schristos  *" flex "*) LEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
3723597410b8Schristos  *" lex "*) LEX='$$r/$(BUILD_SUBDIR)/lex/lex' ;;
3724597410b8Schristosesac
3725597410b8Schristos
3726597410b8SchristosAC_CHECK_PROGS([FLEX], [flex], [$MISSING flex])
3727597410b8Schristoscase " $build_configdirs " in
3728597410b8Schristos  *" flex "*) FLEX='$$r/$(BUILD_SUBDIR)/flex/flex' ;;
3729597410b8Schristosesac
3730597410b8Schristos
3731597410b8SchristosAC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
3732597410b8Schristoscase " $build_configdirs " in
3733597410b8Schristos  *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
3734597410b8Schristos  *)
3735597410b8Schristoschangequote(,)
3736597410b8Schristos    # For an installed makeinfo, we require it to be from texinfo 4.7 or
3737597410b8Schristos    # higher, else we use the "missing" dummy.
3738597410b8Schristos    if ${MAKEINFO} --version \
3739597410b8Schristos       | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
3740597410b8Schristos      :
3741597410b8Schristos    else
3742597410b8Schristos      MAKEINFO="$MISSING makeinfo"
3743597410b8Schristos    fi
3744597410b8Schristos    ;;
3745597410b8Schristoschangequote([,])
3746597410b8Schristosesac
3747597410b8Schristos
3748597410b8Schristos# FIXME: expect and dejagnu may become build tools?
3749597410b8Schristos
3750597410b8SchristosAC_CHECK_PROGS(EXPECT, expect, expect)
3751597410b8Schristoscase " $configdirs " in
3752597410b8Schristos  *" expect "*)
3753597410b8Schristos    test $host = $build && EXPECT='$$r/$(HOST_SUBDIR)/expect/expect'
3754597410b8Schristos    ;;
3755597410b8Schristosesac
3756597410b8Schristos
3757597410b8SchristosAC_CHECK_PROGS(RUNTEST, runtest, runtest)
3758597410b8Schristoscase " $configdirs " in
3759597410b8Schristos  *" dejagnu "*)
3760597410b8Schristos    test $host = $build && RUNTEST='$$s/$(HOST_SUBDIR)/dejagnu/runtest'
3761597410b8Schristos    ;;
3762597410b8Schristosesac
3763597410b8Schristos
3764597410b8Schristos
3765597410b8Schristos# Host tools.
3766597410b8SchristosNCN_STRICT_CHECK_TOOLS(AR, ar)
3767597410b8SchristosNCN_STRICT_CHECK_TOOLS(AS, as)
3768597410b8SchristosNCN_STRICT_CHECK_TOOLS(DLLTOOL, dlltool)
37694b169a6bSchristosNCN_STRICT_CHECK_TOOLS(DSYMUTIL, dsymutil)
3770597410b8SchristosNCN_STRICT_CHECK_TOOLS(LD, ld)
3771597410b8SchristosNCN_STRICT_CHECK_TOOLS(LIPO, lipo)
3772597410b8SchristosNCN_STRICT_CHECK_TOOLS(NM, nm)
3773597410b8SchristosNCN_STRICT_CHECK_TOOLS(RANLIB, ranlib, true)
3774597410b8SchristosNCN_STRICT_CHECK_TOOLS(STRIP, strip, true)
3775597410b8SchristosNCN_STRICT_CHECK_TOOLS(WINDRES, windres)
3776597410b8SchristosNCN_STRICT_CHECK_TOOLS(WINDMC, windmc)
3777597410b8SchristosNCN_STRICT_CHECK_TOOLS(OBJCOPY, objcopy)
3778597410b8SchristosNCN_STRICT_CHECK_TOOLS(OBJDUMP, objdump)
37794b169a6bSchristosNCN_STRICT_CHECK_TOOLS(OTOOL, otool)
378005598a80SchristosNCN_STRICT_CHECK_TOOLS(READELF, readelf)
3781597410b8SchristosAC_SUBST(CC)
3782597410b8SchristosAC_SUBST(CXX)
3783597410b8SchristosAC_SUBST(CFLAGS)
3784597410b8SchristosAC_SUBST(CXXFLAGS)
37854b169a6bSchristosAC_SUBST(GDC)
37864b169a6bSchristosAC_SUBST(GDCFLAGS)
3787*079139fbSchristosGDCFLAGS=${GDCFLAGS-${CFLAGS}}
37884b169a6bSchristosAC_SUBST(PKG_CONFIG_PATH)
37894b169a6bSchristos
37904b169a6bSchristosGCC_PLUGIN_OPTION(PLUGIN_OPTION)
37914b169a6bSchristosAR_PLUGIN_OPTION=
37924b169a6bSchristosRANLIB_PLUGIN_OPTION=
37934b169a6bSchristosif test -n "$PLUGIN_OPTION"; then
37944b169a6bSchristos  if $AR --help 2>&1 | grep -q "\--plugin"; then
37954b169a6bSchristos    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
37964b169a6bSchristos  fi
37974b169a6bSchristos  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
37984b169a6bSchristos    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
37994b169a6bSchristos  fi
38004b169a6bSchristosfi
38014b169a6bSchristosAC_SUBST(AR_PLUGIN_OPTION)
38024b169a6bSchristosAC_SUBST(RANLIB_PLUGIN_OPTION)
3803597410b8Schristos
3804597410b8Schristos# Target tools.
3805597410b8SchristosAC_ARG_WITH([build-time-tools],
3806597410b8Schristos  [AS_HELP_STRING([--with-build-time-tools=PATH],
3807597410b8Schristos		  [use given path to find target tools during the build])],
3808597410b8Schristos  [case x"$withval" in
3809597410b8Schristos     x/*) ;;
3810597410b8Schristos     *)
3811597410b8Schristos       with_build_time_tools=
3812597410b8Schristos       AC_MSG_WARN([argument to --with-build-time-tools must be an absolute path])
3813597410b8Schristos       ;;
3814597410b8Schristos   esac],
3815597410b8Schristos  [with_build_time_tools=])
3816597410b8Schristos
3817597410b8SchristosNCN_STRICT_CHECK_TARGET_TOOLS(CC_FOR_TARGET, cc gcc)
3818597410b8SchristosNCN_STRICT_CHECK_TARGET_TOOLS(CXX_FOR_TARGET, c++ g++ cxx gxx)
3819597410b8SchristosNCN_STRICT_CHECK_TARGET_TOOLS(GCC_FOR_TARGET, gcc, ${CC_FOR_TARGET})
3820597410b8SchristosNCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran)
3821597410b8SchristosNCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo)
38224b169a6bSchristosNCN_STRICT_CHECK_TARGET_TOOLS(GDC_FOR_TARGET, gdc)
3823*079139fbSchristosNCN_STRICT_CHECK_TARGET_TOOLS(GM2_FOR_TARGET, gm2)
3824597410b8Schristos
3825597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar)
3826597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as)
3827597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(DLLTOOL_FOR_TARGET, dlltool)
38284b169a6bSchristosACX_CHECK_INSTALLED_TARGET_TOOL(DSYMUTIL_FOR_TARGET, dsymutil)
3829597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(LD_FOR_TARGET, ld)
3830597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(LIPO_FOR_TARGET, lipo)
3831597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(NM_FOR_TARGET, nm)
38329d210927SchristosACX_CHECK_INSTALLED_TARGET_TOOL(OBJCOPY_FOR_TARGET, objcopy)
3833597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(OBJDUMP_FOR_TARGET, objdump)
38344b169a6bSchristosACX_CHECK_INSTALLED_TARGET_TOOL(OTOOL_FOR_TARGET, otool)
3835597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(RANLIB_FOR_TARGET, ranlib)
383605598a80SchristosACX_CHECK_INSTALLED_TARGET_TOOL(READELF_FOR_TARGET, readelf)
3837597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(STRIP_FOR_TARGET, strip)
3838597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(WINDRES_FOR_TARGET, windres)
3839597410b8SchristosACX_CHECK_INSTALLED_TARGET_TOOL(WINDMC_FOR_TARGET, windmc)
3840597410b8Schristos
3841597410b8SchristosRAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
3842597410b8Schristos
3843597410b8SchristosGCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar])
3844597410b8SchristosGCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new])
3845597410b8SchristosGCC_TARGET_TOOL(cc, CC_FOR_TARGET, CC, [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])
3846597410b8Schristosdnl see comments for CXX_FOR_TARGET_FLAG_TO_PASS
3847597410b8SchristosGCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX,
384803467a24Schristos		[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],
3849597410b8Schristos		c++)
3850597410b8SchristosGCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX,
385103467a24Schristos		[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],
3852597410b8Schristos		c++)
3853597410b8SchristosGCC_TARGET_TOOL(dlltool, DLLTOOL_FOR_TARGET, DLLTOOL, [binutils/dlltool])
38544b169a6bSchristosGCC_TARGET_TOOL(dsymutil, DSYMUTIL_FOR_TARGET, DSYMUTIL)
3855597410b8SchristosGCC_TARGET_TOOL(gcc, GCC_FOR_TARGET, , [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])
3856597410b8SchristosGCC_TARGET_TOOL(gfortran, GFORTRAN_FOR_TARGET, GFORTRAN,
3857597410b8Schristos		[gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/], fortran)
3858597410b8SchristosGCC_TARGET_TOOL(gccgo, GOC_FOR_TARGET, GOC,
3859597410b8Schristos		[gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go)
38604b169a6bSchristosGCC_TARGET_TOOL(gdc, GDC_FOR_TARGET, GDC,
38614b169a6bSchristos		[gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/], d)
3862*079139fbSchristosGCC_TARGET_TOOL(gm2, GM2_FOR_TARGET, GM2,
3863*079139fbSchristos		[gcc/gm2 -B$$r/$(HOST_SUBDIR)/gcc/], m2)
3864597410b8SchristosGCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
3865597410b8SchristosGCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
3866597410b8SchristosGCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
3867212397c6SchristosGCC_TARGET_TOOL(objcopy, OBJCOPY_FOR_TARGET, OBJCOPY, [binutils/objcopy])
3868597410b8SchristosGCC_TARGET_TOOL(objdump, OBJDUMP_FOR_TARGET, OBJDUMP, [binutils/objdump])
38694b169a6bSchristosGCC_TARGET_TOOL(otool, OTOOL_FOR_TARGET, OTOOL)
3870597410b8SchristosGCC_TARGET_TOOL(ranlib, RANLIB_FOR_TARGET, RANLIB, [binutils/ranlib])
387105598a80SchristosGCC_TARGET_TOOL(readelf, READELF_FOR_TARGET, READELF, [binutils/readelf])
3872597410b8SchristosGCC_TARGET_TOOL(strip, STRIP_FOR_TARGET, STRIP, [binutils/strip-new])
3873597410b8SchristosGCC_TARGET_TOOL(windres, WINDRES_FOR_TARGET, WINDRES, [binutils/windres])
3874597410b8SchristosGCC_TARGET_TOOL(windmc, WINDMC_FOR_TARGET, WINDMC, [binutils/windmc])
3875597410b8Schristos
3876597410b8SchristosAC_SUBST(FLAGS_FOR_TARGET)
3877597410b8SchristosAC_SUBST(RAW_CXX_FOR_TARGET)
3878597410b8Schristos
3879597410b8Schristos# Certain tools may need extra flags.
3880597410b8SchristosAR_FOR_TARGET=${AR_FOR_TARGET}${extra_arflags_for_target}
3881597410b8SchristosRANLIB_FOR_TARGET=${RANLIB_FOR_TARGET}${extra_ranlibflags_for_target}
3882597410b8SchristosNM_FOR_TARGET=${NM_FOR_TARGET}${extra_nmflags_for_target}
3883597410b8Schristos
3884597410b8Schristos# When building target libraries, except in a Canadian cross, we use
3885597410b8Schristos# the same toolchain as the compiler we just built.
3886597410b8SchristosCOMPILER_AS_FOR_TARGET='$(AS_FOR_TARGET)'
3887597410b8SchristosCOMPILER_LD_FOR_TARGET='$(LD_FOR_TARGET)'
3888597410b8SchristosCOMPILER_NM_FOR_TARGET='$(NM_FOR_TARGET)'
3889597410b8Schristosif test $host = $build; then
3890597410b8Schristos  case " $configdirs " in
3891597410b8Schristos    *" gcc "*)
3892597410b8Schristos      COMPILER_AS_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/as'
3893597410b8Schristos      COMPILER_LD_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/collect-ld'
3894597410b8Schristos      COMPILER_NM_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/nm'${extra_nmflags_for_target}
3895597410b8Schristos      ;;
3896597410b8Schristos  esac
3897597410b8Schristosfi
3898597410b8Schristos
3899597410b8SchristosAC_SUBST(COMPILER_AS_FOR_TARGET)
3900597410b8SchristosAC_SUBST(COMPILER_LD_FOR_TARGET)
3901597410b8SchristosAC_SUBST(COMPILER_NM_FOR_TARGET)
3902597410b8Schristos
3903597410b8SchristosAC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
3904597410b8SchristosAC_ARG_ENABLE(maintainer-mode,
3905597410b8Schristos[AS_HELP_STRING([--enable-maintainer-mode],
3906597410b8Schristos		[enable make rules and dependencies not useful
3907597410b8Schristos		 (and sometimes confusing) to the casual installer])],
3908597410b8Schristos      USE_MAINTAINER_MODE=$enableval,
3909597410b8Schristos      USE_MAINTAINER_MODE=no)
3910597410b8SchristosAC_MSG_RESULT($USE_MAINTAINER_MODE)
3911597410b8SchristosAC_SUBST(MAINTAINER_MODE_TRUE)
3912597410b8SchristosAC_SUBST(MAINTAINER_MODE_FALSE)
3913597410b8Schristosif test "$USE_MAINTAINER_MODE" = yes; then
3914597410b8Schristos  MAINTAINER_MODE_TRUE=
3915597410b8Schristos  MAINTAINER_MODE_FALSE='#'
3916597410b8Schristoselse
3917597410b8Schristos  MAINTAINER_MODE_TRUE='#'
3918597410b8Schristos  MAINTAINER_MODE_FALSE=
3919597410b8Schristosfi
3920597410b8SchristosMAINT=$MAINTAINER_MODE_TRUE
3921597410b8SchristosAC_SUBST(MAINT)dnl
3922597410b8Schristos
3923597410b8Schristos# ---------------------
3924597410b8Schristos# GCC bootstrap support
3925597410b8Schristos# ---------------------
3926597410b8Schristos
3927597410b8Schristos# Stage specific cflags for build.
3928597410b8Schristosstage1_cflags="-g"
3929597410b8Schristoscase $build in
3930597410b8Schristos  vax-*-*)
3931597410b8Schristos    case ${GCC} in
3932597410b8Schristos      yes) stage1_cflags="-g -Wa,-J" ;;
3933597410b8Schristos      *) stage1_cflags="-g -J" ;;
3934597410b8Schristos    esac ;;
3935597410b8Schristosesac
3936597410b8Schristos
3937597410b8SchristosAC_SUBST(stage1_cflags)
3938597410b8Schristos
3939597410b8Schristos# Enable --enable-checking in stage1 of the compiler.
3940597410b8SchristosAC_ARG_ENABLE(stage1-checking,
3941597410b8Schristos[AS_HELP_STRING([[--enable-stage1-checking[=all]]],
3942597410b8Schristos		[choose additional checking for stage1 of the compiler])],
3943597410b8Schristos[stage1_checking=--enable-checking=${enable_stage1_checking}],
3944597410b8Schristos[if test "x$enable_checking" = xno || test "x$enable_checking" = x; then
3945ba340e45Schristos  # For --disable-checking or implicit --enable-checking=release, avoid
3946ba340e45Schristos  # setting --enable-checking=gc in the default stage1 checking for LTO
3947ba340e45Schristos  # bootstraps.  See PR62077.
3948ba340e45Schristos  case $BUILD_CONFIG in
3949ba340e45Schristos    *lto*)
3950796c32c9Schristos      stage1_checking=--enable-checking=release,misc,gimple,rtlflag,tree,types;;
3951796c32c9Schristos    *)
3952796c32c9Schristos      stage1_checking=--enable-checking=yes,types;;
3953796c32c9Schristos  esac
3954ba340e45Schristos  if test "x$enable_checking" = x && \
3955ba340e45Schristos     test -d ${srcdir}/gcc && \
3956ba340e45Schristos     test x"`cat ${srcdir}/gcc/DEV-PHASE`" = xexperimental; then
3957796c32c9Schristos    stage1_checking=--enable-checking=yes,types,extra
3958796c32c9Schristos  fi
3959597410b8Schristoselse
3960597410b8Schristos  stage1_checking=--enable-checking=$enable_checking,types
3961597410b8Schristosfi])
3962597410b8SchristosAC_SUBST(stage1_checking)
3963597410b8Schristos
3964597410b8Schristos# Enable -Werror in bootstrap stage2 and later.
3965597410b8SchristosAC_ARG_ENABLE(werror,
3966597410b8Schristos[AS_HELP_STRING([--enable-werror],
39674559860eSchristos		[enable -Werror in bootstrap stage2 and later])],
39684559860eSchristos[
3969597410b8Schristoscase ${enable_werror} in
3970597410b8Schristos  yes) stage2_werror_flag="--enable-werror-always" ;;
3971597410b8Schristos  *) stage2_werror_flag="" ;;
3972597410b8Schristosesac
39734559860eSchristos],
39744559860eSchristos[
39754559860eSchristosif test -d ${srcdir}/gcc && test x"`cat $srcdir/gcc/DEV-PHASE`" = xexperimental; then
39764559860eSchristos  case $BUILD_CONFIG in
39774559860eSchristos  bootstrap-debug)
39784559860eSchristos      stage2_werror_flag="--enable-werror-always" ;;
39794559860eSchristos  "")
39804559860eSchristos      stage2_werror_flag="--enable-werror-always" ;;
3981212397c6Schristos  esac
3982212397c6Schristosfi
39834559860eSchristos])
39844559860eSchristos
39854559860eSchristosAC_SUBST(stage2_werror_flag)
3986212397c6Schristos
3987597410b8Schristos# Specify what files to not compare during bootstrap.
3988597410b8Schristos
3989597410b8Schristoscompare_exclusions="gcc/cc*-checksum\$(objext) | gcc/ada/*tools/*"
3990*079139fbSchristoscompare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/M2Version*"
3991*079139fbSchristoscompare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/SYSTEM*"
3992*079139fbSchristoscompare_exclusions="$compare_exclusions | gcc/m2/gm2version*"
3993597410b8Schristoscase "$target" in
3994597410b8Schristos  hppa*64*-*-hpux*) ;;
39954b169a6bSchristos  powerpc*-ibm-aix*) compare_exclusions="$compare_exclusions | *libgomp*\$(objext)" ;;
3996597410b8Schristosesac
3997597410b8SchristosAC_SUBST(compare_exclusions)
3998597410b8Schristos
3999597410b8SchristosAC_CONFIG_FILES([Makefile],
4000597410b8Schristos  [sed "$extrasub_build" Makefile |
4001597410b8Schristos   sed "$extrasub_host" |
4002597410b8Schristos   sed "$extrasub_target" > mf$$
4003597410b8Schristos   mv -f mf$$ Makefile],
4004597410b8Schristos  [extrasub_build="$extrasub_build"
4005597410b8Schristos   extrasub_host="$extrasub_host"
4006597410b8Schristos   extrasub_target="$extrasub_target"])
4007597410b8SchristosAC_OUTPUT
4008