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