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