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