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