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