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