OSDN Git Service

3e891d93646941ee8345947fc3ae505e5e384cc8
[pf3gnuchains/gcc-fork.git] / configure
1 #!/bin/sh
2
3 ### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
4
5 # Configuration script
6 # Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001,
7 # 2002 Free Software Foundation, Inc.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 # This file was originally written by K. Richard Pixley.
24
25 #
26 # Shell script to create proper links to machine-dependent files in
27 # preparation for compilation.
28 #
29 # If configure succeeds, it leaves its status in config.status.
30 # If configure fails after disturbing the status quo, 
31 #       config.status is removed.
32 #
33
34 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
35
36 remove=rm
37 hard_link=ln
38 symbolic_link='ln -s'
39
40 #for Test
41 #remove="echo rm"
42 #hard_link="echo ln"
43 #symbolic_link="echo ln -s"
44
45 # clear some things potentially inherited from environment.
46
47 Makefile=Makefile
48 Makefile_in=Makefile.in
49 arguments=
50 build_alias=
51 cache_file=config.cache
52 cache_file_option=
53 configdirs=
54 extraconfigdirs=
55 diroptions=
56 enable_threads=no
57 enable_shared=no
58 enable_libstdcxx_v3=yes
59 exec_prefix=
60 exec_prefixoption=
61 fatal=
62 floating_point=default
63 gas=default
64 gcc_version=
65 gcc_version_trigger=
66 host_alias=NOHOST
67 host_makefile_frag=
68 moveifchange=
69 norecursion=
70 other_options=
71 package_makefile_frag=
72 package_makefile_rules_frag=
73 prefix=/usr/local
74 progname=
75 program_prefix=
76 program_prefixoption=
77 program_suffix=
78 program_suffixoption=
79 program_transform_name=
80 program_transform_nameoption=
81 redirect=
82 removing=
83 site=
84 site_makefile_frag=
85 site_option=
86 srcdir=
87 srctrigger=
88 subdirs=
89 target_alias=NOTARGET
90 target_makefile_frag=
91 undefs=NOUNDEFS
92 version="$Revision: 1.43 $"
93 x11=default
94 bindir='${exec_prefix}/bin'
95 sbindir='${exec_prefix}/sbin'
96 libexecdir='${exec_prefix}/libexec'
97 datadir='${prefix}/share'
98 sysconfdir='${prefix}/etc'
99 sharedstatedir='${prefix}/com'
100 localstatedir='${prefix}/var'
101 libdir='${exec_prefix}/lib'
102 includedir='${prefix}/include'
103 oldincludedir='/usr/include'
104 infodir='${prefix}/info'
105 mandir='${prefix}/man'
106
107 ### we might need to use some other shell than /bin/sh for running subshells
108
109 ### If we are on Windows, search for the shell.  This will permit people
110 ### to not have /bin/sh, but to be able to see /SOME/PATH/sh configure
111 ### without also having to set CONFIG_SHELL.  This code will work when
112 ### using bash, which sets OSTYPE.
113 case "${OSTYPE}" in
114 *win32*)
115   if [ x${CONFIG_SHELL} = x ]; then
116     if [ ! -f /bin/sh ]; then
117       if [ x${SHELL} != x ] && [ -f ${SHELL} ]; then
118         CONFIG_SHELL=${SHELL}
119         export CONFIG_SHELL
120       else
121         for prog in sh sh.exe bash bash.exe; do
122           IFS="${IFS=   }"; save_ifs="$IFS"; IFS="${IFS}:"
123           for dir in $PATH; do
124             test -z "$dir" && dir=.
125             if test -f $dir/$prog; then
126               CONFIG_SHELL=$dir/$prog
127               export CONFIG_SHELL
128               break
129             fi
130           done
131           IFS="$save_ifs"
132           test -n "${CONFIG_SHELL}" && break
133         done
134       fi
135     fi
136   fi
137   ;;
138 esac
139
140 config_shell=${CONFIG_SHELL-/bin/sh}
141
142 NO_EDIT="This file was generated automatically by configure.  Do not edit."
143
144 ## this is a little touchy and won't always work, but...
145 ##
146 ## if the argv[0] starts with a slash then it is an absolute name that can (and
147 ## must) be used as is.
148 ##
149 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
150 ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
151 ##
152
153 progname=$0
154 # if PWD already has a value, it is probably wrong.
155 if [ -n "$PWD" ]; then PWD=`${PWDCMD-pwd}`; fi
156
157 case "${progname}" in
158 /* | [A-Za-z]:[\\/]* ) ;;
159 */*) ;;
160 *)
161         PATH=$PATH:${PWD=`${PWDCMD-pwd}`} ; export PATH
162         ;;
163 esac
164
165 # Export original configure arguments for use by sub-configures.
166 TOPLEVEL_CONFIGURE_ARGUMENTS="$progname $@"
167 export TOPLEVEL_CONFIGURE_ARGUMENTS
168
169 # Loop over all args
170
171 while :
172 do
173
174 # Break out if there are no more args
175         case $# in
176         0)
177                 break
178                 ;;
179         esac
180
181 # Get the first arg, and shuffle
182         option=$1
183         shift
184
185 # Make all options have two hyphens
186         orig_option=$option     # Save original for error messages
187         case $option in
188         --*) ;;
189         -*) option=-$option ;;
190         esac
191                 
192 # Split out the argument for options that take them
193         case $option in
194         --*=*)
195                 optarg=`echo $option | sed -e 's/^[^=]*=//'`
196                 arguments="$arguments $option"
197                 ;;
198 # These options have mandatory values.  Since we didn't find an = sign,
199 # the value must be in the next argument
200         --bu* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-* | --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
201                 optarg=$1
202                 shift
203                 arguments="$arguments $option=$optarg"
204                 ;;
205         --v)
206                 arguments="$arguments -v"
207                 ;;
208         --*)
209                 arguments="$arguments $option"
210                 ;;
211         esac
212
213 # Now, process the options
214         case $option in
215
216         --bi*)
217                 bindir=$optarg
218                 diroptions="$diroptions --bindir=$optarg"
219                 ;;
220         --build* | --bu*)
221                 case "$build_alias" in
222                 "") build_alias=$optarg ;;
223                 *) echo '***' Can only configure for one build machine at a time.  1>&2
224                    fatal=yes
225                    ;;
226                 esac
227                 ;;
228         --cache*)
229                 cache_file=$optarg
230                 ;;
231         --da*)
232                 datadir=$optarg
233                 diroptions="$diroptions --datadir=$optarg"
234                 ;;
235         --disable-*)
236                 enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
237                 eval $enableopt=no
238                 disableoptions="$disableoptions $option"
239                 ;;
240         --enable-*)
241                 case "$option" in
242                 *=*)    ;;
243                 *)      optarg=yes ;;
244                 esac
245
246                 enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
247                 eval "$enableopt=\$optarg"
248                 enableoptions="$enableoptions '$option'"
249                 ;;
250         --exec-prefix* | --ex*)
251                 exec_prefix=$optarg
252                 exec_prefixoption="--exec-prefix=$optarg"
253                 ;;
254         --gas | --g*)
255                 gas=yes
256                 ;;
257         --help | --he*)
258                 fatal=yes
259                 ;;
260         --host* | --ho*)
261                 case $host_alias in
262                 NOHOST) host_alias=$optarg ;;
263                 *) echo '***' Can only configure for one host at a time.  1>&2
264                    fatal=yes
265                    ;;
266                 esac
267                 ;;
268         --inc*)
269                 includedir=$optarg
270                 diroptions="$diroptions --includedir=$optarg"
271                 ;;
272         --inf*)
273                 infodir=$optarg
274                 diroptions="$diroptions --infodir=$optarg"
275                 ;;
276         --libd*)
277                 libdir=$optarg
278                 diroptions="$diroptions --libdir=$optarg"
279                 ;;
280         --libe*)
281                 libexecdir=$optarg
282                 diroptions="$diroptions --libexecdir=$optarg"
283                 ;;
284         --lo*)
285                 localstatedir=$optarg
286                 diroptions="$diroptions --localstatedir=$optarg"
287                 ;;
288         --ma*)
289                 mandir=$optarg
290                 diroptions="$diroptions --mandir=$optarg"
291                 ;;
292         --nfp | --nf*)
293                 floating_point=no
294                 floating_pointoption="--nfp"
295                 ;;
296         --norecursion | --no*)
297                 norecursion=yes
298                 ;;
299         --ol*)
300                 oldincludedir=$optarg
301                 diroptions="$diroptions --oldincludedir=$optarg"
302                 ;;
303         --prefix* | --pre*)
304                 prefix=$optarg
305                 prefixoption="--prefix=$optarg"
306                 ;;
307         --program-prefix* | --program-p*)
308                 program_prefix=$optarg
309                 program_prefixoption="--program-prefix=$optarg"
310                 ;;
311         --program-suffix* | --program-s*)
312                 program_suffix=$optarg
313                 program_suffixoption="--program-suffix=$optarg"
314                 ;;
315         --program-transform-name* | --program-t*)
316                 # Double any backslashes or dollar signs in the argument
317                 program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
318                 program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
319                 ;;
320         --rm)
321                 removing=--rm
322                 ;;
323         --sb*)
324                 sbindir=$optarg
325                 diroptions="$diroptions --sbindir=$optarg"
326                 ;;
327         --sh*)
328                 sharedstatedir=$optarg
329                 diroptions="$diroptions --sharedstatedir=$optarg"
330                 ;;
331         --silent | --sil* | --quiet | --q*)
332                 redirect=">/dev/null"
333                 verbose=--silent
334                 ;;
335         --site* | --sit*)
336                 site=$optarg
337                 site_option="--site=$optarg"
338                 ;;
339         --srcdir*/ | --sr*/)
340                 # Remove trailing slashes.  Otherwise, when the file name gets
341                 # bolted into an object file as debug info, it has two slashes
342                 # in it.  Ordinarily this is ok, but emacs takes double slash
343                 # to mean "forget the first part".
344                 srcdir=`echo $optarg | sed -e 's:/$::'`
345                 ;;
346         --srcdir* | --sr*)
347                 srcdir=$optarg
348                 ;;
349         --sy*)
350                 sysconfdir=$optarg
351                 diroptions="$diroptions --sysconfdir=$optarg"
352                 ;;
353         --target* | --ta*)
354                 case $target_alias in
355                 NOTARGET) target_alias=$optarg ;;
356                 *) echo '***' Can only configure for one target at a time.  1>&2
357                    fatal=yes
358                    ;;
359                 esac
360                 ;;
361         --tmpdir* | --tm*)
362                 TMPDIR=$optarg
363                 tmpdiroption="--tmpdir=$optarg"
364                 ;;
365         --verbose | --v | --verb*)
366                 redirect=
367                 verbose=--verbose
368                 ;;
369         --version | --V | --vers*)
370                 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
371                 exit 0
372                 ;;
373         --with-*)
374                 case "$option" in
375                 *=*)    ;;
376                 *)      optarg=yes ;;
377                 esac
378
379                 withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
380                 eval $withopt="\$optarg"
381                 withoptions="$withoptions $option"
382                 ;;
383         --without-*)
384                 withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
385                 eval $withopt=no
386                 withoutoptions="$withoutoptions $option"
387                 ;;
388         --x)    with_x=yes
389                 withoptions="$withoptions --with-x"
390                 ;;
391         --x-i* | --x-l*) other_options="$other_options $orig_option"
392                 ;;
393         --*)
394                 echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
395                 exit 1
396                 ;;
397         *)
398                 case $undefs in
399                 NOUNDEFS) undefs=$option ;;
400                 *) echo '***' Can only configure for one host and one target at a time.  1>&2
401                    fatal=yes
402                    ;;
403                 esac
404                 ;;
405         esac
406 done
407
408 # process host and target
409
410 # Do some error checking and defaulting for the host and target type.
411 # The inputs are:
412 #    configure --host=HOST --target=TARGET UNDEFS
413 #
414 # The rules are:
415 # 1. You aren't allowed to specify --host, --target, and undefs at the
416 #    same time.
417 # 2. Host defaults to undefs.
418 # 3. If undefs is not specified, then host defaults to the current host,
419 #    as determined by config.guess.
420 # 4. Target defaults to undefs.
421 # 5. If undefs is not specified, then target defaults to host.
422
423 case "${fatal}" in
424 "")
425         # Make sure that host, target & undefs aren't all specified at the
426         # same time.
427         case $host_alias---$target_alias---$undefs in
428         NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
429                 ;;
430         *) echo '***' Can only configure for one host and one target at a time.  1>&2
431            fatal=yes
432            break 2
433                 ;;
434         esac
435
436         # Now, do defaulting for host.
437         case $host_alias in
438         NOHOST)
439                 case $undefs in
440                 NOUNDEFS)
441                         # Neither --host option nor undefs were present.
442                         # Call config.guess.
443                         guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
444                         if host_alias=`${config_shell} ${guesssys}`
445                         then
446                                 # If the string we are going to use for
447                                 # the target is a prefix of the string
448                                 # we just guessed for the host, then
449                                 # assume we are running native, and force
450                                 # the same string for both target and host.
451                                 case $target_alias in
452                                 NOTARGET) ;;
453                                 *)
454                                         if expr $host_alias : $target_alias >/dev/null
455                                         then
456                                                 host_alias=$target_alias
457                                         fi
458                                         ;;
459                                 esac
460                                 echo "Configuring for a ${host_alias} host."
461                                 arguments="--host=$host_alias $arguments"
462                         else
463                                 echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
464                                 fatal=yes
465                         fi
466                         ;;
467                 *)
468                         host_alias=$undefs
469                         arguments="--host=$host_alias $arguments"
470                         undefs=NOUNDEFS
471                         ;;
472                 esac
473         esac
474
475         # Do defaulting for target.  If --target option isn't present, default
476         # to undefs.  If undefs isn't present, default to host.
477         case $target_alias in
478         NOTARGET)
479                 case $undefs in
480                 NOUNDEFS)
481                         target_alias=$host_alias
482                         ;;
483                 *)
484                         target_alias=$undefs
485                         arguments="--target=$target_alias $arguments"
486                         ;;
487                 esac
488         esac
489         ;;
490 *) ;;
491 esac
492
493 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
494         exec 1>&2
495         echo Usage: configure [OPTIONS] [HOST]
496         echo
497         echo Options: [defaults in brackets]
498         echo ' --prefix=MYDIR            install into MYDIR [/usr/local]'
499         echo ' --exec-prefix=MYDIR       install host-dependent files into MYDIR [/usr/local]'
500         echo ' --help                    print this message [normal config]'
501         echo ' --build=BUILD             configure for building on BUILD [BUILD=HOST]'
502         echo ' --host=HOST               configure for HOST [determined via config.guess]'
503         echo ' --norecursion             configure this directory only [recurse]'
504         echo ' --program-prefix=FOO      prepend FOO to installed program names [""]'
505         echo ' --program-suffix=FOO      append FOO to installed program names [""]'
506         echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
507         echo ' --site=SITE               configure with site-specific makefile for SITE'
508         echo ' --srcdir=DIR              find the sources in DIR [. or ..]'
509         echo ' --target=TARGET   configure for TARGET [TARGET=HOST]'
510         echo ' --tmpdir=TMPDIR   create temporary files in TMPDIR [/tmp]'
511         echo ' --nfp                     configure for software floating point [hard float]'
512         echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
513         echo ' --without-FOO             package FOO is NOT available'
514         echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
515         echo ' --disable-FOO             do not include feature FOO'
516         echo
517         echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
518         echo
519         if [ -r config.status ] ; then
520                 cat config.status
521         fi
522
523         exit 1
524 fi
525
526 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
527 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
528 ## the sed command below emulates the dirname command
529 topsrcdir=`cd \`echo ${progname} | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'\`; ${PWDCMD-pwd}`
530
531
532 # this is a hack.  sun4 must always be a valid host alias or this will fail.
533 if ${config_shell} ${configsub} sun4 >/dev/null 2>&1 ; then
534         true
535 else
536         echo '***' cannot find config.sub.  1>&2
537         exit 1
538 fi
539
540 touch config.junk
541 if ${config_shell} ${moveifchange} config.junk config.trash ; then
542         true
543 else
544         echo '***' cannot find move-if-change.  1>&2
545         exit 1
546 fi
547 rm -f config.junk config.trash
548
549 case "${srcdir}" in
550 "")
551         if [ -r configure.in ] ; then
552                 srcdir=.
553         else
554                 if [ -r ${progname}.in ] ; then
555                         srcdir=`echo ${progname} | sed 's:/configure$::'`
556                 else
557                         echo '***' "Can't find configure.in.  Try using --srcdir=some_dir"  1>&2
558                         exit 1
559                 fi
560         fi
561         ;;
562 *)
563         # Set srcdir to "." if that's what it is.
564         # This is important for multilib support.
565         if [ ! -d ${srcdir} ] ; then
566                 echo "Invalid source directory ${srcdir}" >&2
567                 exit 1
568         fi
569         pwd=`${PWDCMD-pwd}`
570         srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
571         if [ "${pwd}" = "${srcpwd}" ] ; then
572                 srcdir=.
573         fi
574 esac
575
576 # If it's an in-source build, make a directory and configure there instead.
577 # Name the build directory after the host for clarity's sake.  Remember that
578 # name for the redirecting makefile's use, since the makefile shouldn't have
579 # to duplicate the work of figuring out host_alias.
580 #
581 # Also remember if this is a native build or not.  Variations on "or not"
582 # are performed later in this script so we can't test them here.  In
583 # particular, build_alias will still be empty unless specified by the user,
584 # so do not try in-source builds when making a host-x-host compiler.
585 # For a cross compile, "make all" = "all".  Otherwise, "all" = "bootstrap".
586 if test "${srcdir}" = "." ; then
587         builddir=${host_alias}
588         if test ! -d ${builddir}; then
589                 mkdir ${builddir} || exit 1
590         fi
591         if test ${host_alias} != ${target_alias}; then
592                 t=all
593         else
594                 t=bootstrap
595         fi
596         # stamp-builddir is too long for #$&!*@ 8.3 filesystems
597         echo "builddir=${builddir}" > s-buildd
598         echo "defaulttarget=$t" >> s-buildd
599         cd ${builddir}
600 echo host $host_alias
601 echo target $target_alias
602 echo t $t
603 sleep 20
604         exec ${config_shell} ../configure $arguments
605 fi
606
607 ### warn about some conflicting configurations.
608
609 case "${srcdir}" in
610 ".") ;;
611 *)
612         if [ -f ${srcdir}/config.status ] ; then
613                 echo '***' Cannot configure here in \"${PWD=`${PWDCMD-pwd}`}\" when \"${srcdir}\" is currently configured. 1>&2
614                 exit 1
615         fi
616 esac
617
618 # default exec_prefix
619 case "${exec_prefixoption}" in
620 "") exec_prefix="\$(prefix)" ;;
621 *) ;;
622 esac
623
624 # Define the trigger file to make sure configure will re-run whenever
625 # the gcc version number changes.
626 if [ "${with_gcc_version_trigger+set}" = set ]; then
627     gcc_version_trigger="$with_gcc_version_trigger"
628     gcc_version=`grep version_string ${with_gcc_version_trigger} | sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/'`
629 else
630     # If gcc's sources are available, define the trigger file.
631     if [ -f ${topsrcdir}/gcc/version.c ] ; then
632         gcc_version_trigger=${topsrcdir}/gcc/version.c
633         gcc_version=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/'`
634         case "$arguments" in
635           *--with-gcc-version-trigger=$gcc_version_trigger* )
636             ;;
637           * )
638             # Make sure configure.in knows about this.
639             arguments="--with-gcc-version-trigger=$gcc_version_trigger $arguments"
640             ;;
641         esac
642         withoptions="--with-gcc-version-trigger=$gcc_version_trigger $withoptions"
643     fi
644 fi
645
646 ### break up ${srcdir}/configure.in.
647 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
648 "")
649         echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
650         # Check for a directory that's been converted to use autoconf since
651         # it was last configured.
652         if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
653           echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
654           if [ -r ${srcdir}/configure ] ; then
655             echo '***' Running the local configure script. 1>&2
656             case "${cache_file}" in
657             "") cache_file_option= ;;
658             *)  cache_file_option="--cache-file=${cache_file}" ;;
659             esac
660             srcdiroption="--srcdir=${srcdir}"
661             case "${build_alias}" in
662             "") buildopt= ;;
663             *)  buildopt="--build=${build_alias}" ;;
664             esac
665             eval exec ${config_shell} ${srcdir}/configure ${verbose} \
666                 ${buildopt} --host=${host_alias} --target=${target_alias} \
667                 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
668                 ${srcdiroption} ${diroptions} \
669                 ${program_prefixoption} ${program_suffixoption} \
670                 ${program_transform_nameoption} ${site_option} \
671                 ${withoptions} ${withoutoptions} \
672                 ${enableoptions} ${disableoptions} ${floating_pointoption} \
673                 ${cache_file_option} ${removing} ${other_options} ${redirect}
674           else
675             echo '***' There is no configure script present though. 1>&2
676           fi
677         fi
678         exit 1
679         ;;
680 *) ;;
681 esac
682
683 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
684 "")
685         echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
686         exit 1
687         ;;
688 *) ;;
689 esac
690
691 case "${TMPDIR}" in
692 "") TMPDIR=/tmp ; export TMPDIR ;;
693 *) ;;
694 esac
695
696 # keep this filename short for &%*%$*# 14 char file names and 8+3 file names
697 tmpdir=${TMPDIR}/cNf$$
698 mkdir ${tmpdir} || exit 1
699 tmpfile=${tmpdir}/cNf$$
700 # Note that under many versions of sh a trap handler for 0 will *override* any
701 # exit status you explicitly specify!  At this point, the only non-error exit
702 # is at the end of the script; these actions are duplicated there, minus
703 # the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
704 # trap handler, or you'll lose.
705 trap "rm -rf Makefile.tem ${tmpdir}; exit 1" 0 1 2 15
706
707 # split ${srcdir}/configure.in into common, per-host, per-target,
708 # and post-target parts.  Post-target is optional.
709 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
710 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
711 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
712   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
713   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
714 else
715   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
716   echo >${tmpfile}.pos
717 fi
718
719 ### do common part of configure.in
720
721 # If the language specific compiler does not exist, but the "gcc" directory does,
722 # we will skip this directory; in this case the sub-directory's common part
723 # of configure.in will create a small shell script "skip-this-dir" containing
724 # commands to completely clean up any temporary or created files.
725
726 . ${tmpfile}.com
727
728 if test -f skip-this-dir; then
729         # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
730         # and reset the trap handler.
731         trap 0
732         rm -rf Makefile* ${tmpdir}
733         # Execute the final clean-up actions
734         ${config_shell} skip-this-dir
735         # and stop configuring this directory.
736         exit 0
737 fi
738
739 # some sanity checks on configure.in
740 case "${srctrigger}" in
741 "")
742         echo '***' srctrigger not set in ${PWD=`${PWDCMD-pwd}`}/configure.in.  1>&2
743         exit 1
744         ;;
745 *) ;;
746 esac
747
748 case "${build_alias}" in
749 "")
750         if result=`${config_shell} ${configsub} ${host_alias}` ; then
751             build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
752             build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
753             build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
754             build=${build_cpu}-${build_vendor}-${build_os}
755             build_alias=${host_alias}
756         fi
757         ;;
758 *)
759         if result=`${config_shell} ${configsub} ${build_alias}` ; then
760             buildopt="--build=${build_alias}"
761             build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
762             build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
763             build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
764             build=${build_cpu}-${build_vendor}-${build_os}
765         else
766             echo "Unrecognized build system name ${build_alias}." 1>&2
767             exit 1
768         fi
769         ;;
770 esac
771
772 if result=`${config_shell} ${configsub} ${host_alias}` ; then
773     true
774 else
775     echo "Unrecognized host system name ${host_alias}." 1>&2
776     exit 1
777 fi
778 host_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
779 host_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
780 host_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
781 host=${host_cpu}-${host_vendor}-${host_os}
782
783 . ${tmpfile}.hst
784
785 if result=`${config_shell} ${configsub} ${target_alias}` ; then
786     true
787 else
788     echo "Unrecognized target system name ${target_alias}." 1>&2
789     exit 1
790 fi
791 target_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
792 target_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
793 target_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
794 target=${target_cpu}-${target_vendor}-${target_os}
795
796 . ${tmpfile}.tgt
797
798 # Find the source files, if location was not specified.
799 case "${srcdir}" in
800 "")
801         srcdirdefaulted=1
802         srcdir=.
803         if [ ! -r ${srctrigger} ] ; then
804                 srcdir=..
805         fi
806         ;;
807 *) ;;
808 esac
809
810 if [ ! -r ${srcdir}/${srctrigger} ] ; then
811         case "${srcdirdefaulted}" in
812         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`${PWDCMD-pwd}`}/${srcdir}" 1>&2 ;;
813         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`${PWDCMD-pwd}`}/. or ${PWD=`${PWDCMD-pwd}`}/.." 1>&2 ;;
814         esac
815
816         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
817         exit 1
818 fi
819
820 # Some systems (e.g., one of the i386-aix systems the gas testers are
821 # using) don't handle "\$" correctly, so don't use it here.
822 tooldir='$(exec_prefix)'/${target_alias}
823
824 if [ "${host_alias}" != "${target_alias}" ] ; then
825     if [ "${program_prefixoption}" = "" ] ; then
826         if [ "${program_suffixoption}" = "" ] ; then 
827             if [ "${program_transform_nameoption}" = "" ] ; then
828                 program_prefix=${target_alias}- ;
829             fi
830         fi
831     fi
832 fi
833
834 # Merge program_prefix and program_suffix onto program_transform_name.
835 # (program_suffix used to use $, but it's hard to preserve $ through both
836 # make and sh.)
837 if [ "${program_suffix}" != "" ] ; then
838     program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
839 fi
840
841 if [ "${program_prefix}" != "" ] ; then
842     program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
843 fi
844
845 # If CC and CXX are not set in the environment, and the Makefile
846 # exists, try to extract them from it.  This is to handle running
847 # ./config.status by hand.
848 if [ -z "${CC}" ] && [ -r Makefile ]; then
849   sed -n -e ':loop
850 /\\$/ N
851 s/\\\n//g
852 t loop
853 /^CC[   ]*=/ s/CC[      ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
854   CC=`tail -1 Makefile.cc`
855   rm -f Makefile.cc
856 fi
857
858 if [ -z "${CFLAGS}" ] && [ -r Makefile ]; then
859   sed -n -e ':loop
860 /\\$/ N
861 s/\\\n//g
862 t loop
863 /^CFLAGS[       ]*=/ s/CFLAGS[  ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
864   CFLAGS=`tail -1 Makefile.cc`
865   rm -f Makefile.cc
866 fi
867
868 if [ -z "${CXX}" ] && [ -r Makefile ]; then
869   sed -n -e ':loop
870 /\\$/ N
871 s/\\\n//g
872 t loop
873 /^CXX[  ]*=/ s/CXX[     ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
874   CXX=`tail -1 Makefile.cc`
875   rm -f Makefile.cc
876 fi
877
878 if [ -z "${CXXFLAGS}" ] && [ -r Makefile ]; then
879   sed -n -e ':loop
880 /\\$/ N
881 s/\\\n//g
882 t loop
883 /^CXXFLAGS[     ]*=/ s/CXXFLAGS[        ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
884   CXXFLAGS=`tail -1 Makefile.cc`
885   rm -f Makefile.cc
886 fi
887
888 # Generate a default definition for YACC.  This is used if the makefile can't
889 # locate bison or byacc in objdir.
890
891 for prog in 'bison -y' byacc yacc
892 do
893   set dummy $prog; tmp=$2
894   IFS="${IFS=   }"; save_ifs="$IFS"; IFS="${IFS}:"
895   for dir in $PATH; do
896     test -z "$dir" && dir=.
897     if test -f $dir/$tmp; then
898       DEFAULT_YACC="$prog"
899       break
900     fi
901   done
902   IFS="$save_ifs"
903
904   test -n "$DEFAULT_YACC" && break
905 done
906
907 # Generate a default definition for M4.  This is used if the makefile can't
908 # locate m4 in objdir.
909
910 for prog in gm4 gnum4 m4
911 do
912   set dummy $prog; tmp=$2
913   IFS="${IFS=   }"; save_ifs="$IFS"; IFS="${IFS}:"
914   for dir in $PATH; do
915     test -z "$dir" && dir=.
916     if test -f $dir/$tmp; then
917       DEFAULT_M4="$prog"
918       break
919     fi
920   done
921   IFS="$save_ifs"
922
923   test -n "$DEFAULT_M4" && break
924 done
925
926 # Generate a default definition for LEX.  This is used if the makefile can't
927 # locate flex in objdir.
928
929 for prog in flex lex
930 do
931   set dummy $prog; tmp=$2
932   IFS="${IFS=   }"; save_ifs="$IFS"; IFS="${IFS}:"
933   for dir in $PATH; do
934     test -z "$dir" && dir=.
935     if test -f $dir/$tmp; then
936       DEFAULT_LEX="$prog"
937       break
938     fi
939   done
940   IFS="$save_ifs"
941
942   test -n "$DEFAULT_LEX" && break
943 done
944
945 if [ "${build}" != "${host}" ]; then
946   # If we are doing a Canadian Cross, in which the host and build systems
947   # are not the same, we set reasonable default values for the tools.
948
949   tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
950   tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET GCJ_FOR_TARGET"
951   tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET GCC_FOR_TARGET BUILD_PREFIX"
952   tools="${tools} BUILD_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
953   tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
954   tools="${tools} WINDRES WINDRES_FOR_TARGET YACC"
955   tools="${tools} OBJCOPY OBJDUMP"
956
957   for var in ${tools}; do
958     if eval [ -z \"\$${var}\" ] && [ -r Makefile ]; then
959       sed -n -e ':loop
960 /\\$/ N
961 s/\\\n//g
962 t loop
963 /^'"${var}"'[   ]*=/ s/'"${var}"'[      ]*=[    ]*\(.*\)/\1/p' \
964         < Makefile > Makefile.v
965       t=`tail -1 Makefile.v`
966       if [ -n "${t}" ]; then
967         eval "${var}=\${t}"
968       fi
969       rm -f Makefile.v
970     fi
971   done
972
973   AR=${AR-${host_alias}-ar}
974   AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
975   AS=${AS-${host_alias}-as}
976   AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
977   BISON=${BISON-bison}
978   CC=${CC-${host_alias}-gcc}
979   CFLAGS=${CFLAGS-"-g -O2"}
980   CXX=${CXX-${host_alias}-c++}
981   CXXFLAGS=${CXXFLAGS-"-g -O2"}
982   CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
983   CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
984   CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++}
985   GCJ_FOR_TARGET=${GCJ_FOR_TARGET-${target_alias}-gcj}
986   DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
987   DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
988   GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}}
989   BUILD_PREFIX=${build_alias}-
990   BUILD_PREFIX_1=${build_alias}-
991   LD=${LD-${host_alias}-ld}
992   LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
993   MAKEINFO=${MAKEINFO-makeinfo}
994   NM=${NM-${host_alias}-nm}
995   NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
996   RANLIB=${RANLIB-${host_alias}-ranlib}
997   RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
998   WINDRES=${WINDRES-${host_alias}-windres}
999   WINDRES_FOR_TARGET=${WINDRES_FOR_TARGET-${target_alias}-windres}
1000   OBJCOPY=${OBJCOPY-${host_alias}-objcopy}
1001   OBJDUMP=${OBJDUMP-${host_alias}-objdump}
1002
1003   if [ -z "${YACC}" ]; then
1004     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
1005     for dir in $PATH; do
1006       test -z "$dir" && dir=.
1007       if test -f $dir/bison; then
1008         YACC="bison -y"
1009         break
1010       fi
1011       if test -f $dir/byacc; then
1012         YACC=byacc
1013         break
1014       fi
1015       if test -f $dir/yacc; then
1016         YACC=yacc
1017         break
1018       fi
1019     done
1020     IFS="$save_ifs"
1021     if [ -z "${YACC}" ]; then
1022       YACC="bison -y"
1023     fi
1024   fi
1025
1026   if [ -z "${LEX}" ]; then
1027     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
1028     for dir in $PATH; do
1029       test -z "$dir" && dir=.
1030       if test -f $dir/flex; then
1031         LEX=flex
1032         break
1033       fi
1034       if test -f $dir/lex; then
1035         LEX=lex
1036         break
1037       fi
1038     done
1039     IFS="$save_ifs"
1040     LEX=${LEX-flex}
1041   fi
1042
1043   # Export variables which autoconf might try to set.
1044   export AS
1045   export AR
1046   export CC_FOR_BUILD
1047   export DLLTOOL
1048   export LD
1049   export NM
1050   export RANLIB
1051   export WINDRES
1052   export OBJCOPY
1053   export OBJDUMP
1054 else
1055   # If CC is still not set, try to get gcc.
1056   if [ -z "${CC}" ]; then
1057     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
1058     for dir in $PATH; do
1059       test -z "$dir" && dir=.
1060       if test -f $dir/gcc; then
1061         CC="gcc"
1062         echo 'void f(){}' > conftest.c
1063         if test -z "`${CC} -g -c conftest.c 2>&1`"; then
1064           CFLAGS=${CFLAGS-"-g -O2"}
1065           CXXFLAGS=${CXXFLAGS-"-g -O2"}
1066         else
1067           CFLAGS=${CFLAGS-"-O2"}
1068           CXXFLAGS=${CXXFLAGS-"-O2"}
1069         fi
1070         rm -f conftest*
1071         break
1072       fi
1073     done
1074     IFS="$save_ifs"
1075     CC=${CC-cc}
1076   else
1077     if test -z "${CFLAGS}"; then
1078       # Here CC is set but CFLAGS is not.  Use a quick hack to use -O2 if CC
1079       # is set to a version of gcc.
1080       case "${CC}" in
1081       *gcc)
1082         echo 'void f(){}' > conftest.c
1083         if test -z "`${CC} -g -c conftest.c 2>&1`"; then
1084           CFLAGS=${CFLAGS-"-g -O2"}
1085           CXXFLAGS=${CXXFLAGS-"-g -O2"}
1086         else
1087           CFLAGS=${CFLAGS-"-O2"}
1088           CXXFLAGS=${CXXFLAGS-"-O2"}
1089         fi
1090         rm -f conftest*
1091         ;;
1092       esac
1093     fi
1094   fi
1095
1096   CXX=${CXX-"c++"}
1097   CFLAGS=${CFLAGS-"-g"}
1098   CXXFLAGS=${CXXFLAGS-"-g -O2"}
1099 fi
1100
1101 export CC
1102 export CXX
1103 export CFLAGS
1104 export CXXFLAGS
1105
1106 all_build_modules=
1107 if test x"${build_alias}" != x"${host_alias}"
1108 then
1109   all_build_modules='$(ALL_BUILD_MODULES_LIST)'
1110 fi
1111
1112 for subdir in . ${subdirs} ; do
1113
1114     # ${subdir} is relative path from . to the directory we're currently
1115     # configuring.
1116     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
1117     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
1118
1119     ### figure out what to do with srcdir
1120     case "${srcdir}" in
1121         ".")  # no -srcdir option.  We're building in place.
1122                 makesrcdir=. ;;
1123         /* | [A-Za-z]:[\\/]* ) # absolute path
1124                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
1125                 ;;
1126         *) # otherwise relative
1127                 case "${subdir}" in
1128                 .) makesrcdir=${srcdir} ;;
1129                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
1130                 esac
1131                 ;;
1132     esac
1133
1134     if [ "${subdir}/" != "./" ] ; then
1135         Makefile=${subdir}/Makefile
1136     fi
1137
1138     if [ ! -d ${subdir} ] ; then
1139         if mkdir ${subdir} ; then
1140                 true
1141         else
1142                 echo '***' "${progname}: could not make ${PWD=`${PWDCMD-pwd}`}/${subdir}" 1>&2
1143                 exit 1
1144         fi
1145     fi
1146
1147     case "${removing}" in
1148     "")
1149         case "${subdir}" in
1150         .) ;;
1151         *) eval echo Building in ${subdir} ${redirect} ;;
1152         esac
1153
1154         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
1155         # Set up the list of links to be made.
1156         # ${links} is the list of link names, and ${files} is the list of names to link to.
1157
1158         # Make the links.
1159         configlinks="${links}"
1160         if [ -r ${subdir}/config.status ] ; then
1161                 mv -f ${subdir}/config.status ${subdir}/config.back
1162         fi
1163         while [ -n "${files}" ] ; do
1164                 # set file to car of files, files to cdr of files
1165                 set ${files}; file=$1; shift; files=$*
1166                 set ${links}; link=$1; shift; links=$*
1167
1168                 if [ ! -r ${srcdir}/${file} ] ; then
1169                   if [ ! -r ${file} ] ; then
1170                     
1171                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
1172                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
1173                         exit 1
1174                   else
1175                         srcfile=${file}
1176                   fi
1177                 else
1178                         srcfile=${srcdir}/${file}
1179                 fi
1180
1181                 ${remove} -f ${link}
1182                 # Make a symlink if possible, otherwise try a hard link
1183                 if ${symbolic_link} ${srcfile} ${link} >/dev/null 2>&1 ; then
1184                         true
1185                 else
1186                         # We need to re-remove the file because Lynx leaves a 
1187                         # very strange directory there when it fails an NFS symlink.
1188                         ${remove} -r -f ${link}
1189                         ${hard_link} ${srcfile} ${link}
1190                 fi
1191                 if [ ! -r ${link} ] ; then
1192                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcfile}\"." 1>&2
1193                         exit 1
1194                 fi
1195
1196                 echo "Linked \"${link}\" to \"${srcfile}\"."
1197         done
1198
1199         # Create a .gdbinit file which runs the one in srcdir
1200         # and tells GDB to look there for source files.
1201
1202         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
1203                 case ${srcdir} in
1204                 .) ;;
1205                 *) cat > ${subdir}/.gdbinit <<EOF
1206 # ${NO_EDIT}
1207 dir ${makesrcdir}
1208 dir .
1209 source ${makesrcdir}/.gdbinit
1210 EOF
1211                         ;;
1212                 esac
1213         fi
1214
1215         # Install a makefile, and make it set VPATH
1216         # if necessary so that the sources are found.
1217         # Also change its value of srcdir.
1218         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
1219         # been somewhat optimized and is perhaps a bit twisty.
1220
1221         # code is order so as to try to sed the smallest input files we know.
1222         # so do these separately because I don't trust the order of sed -e expressions.
1223
1224         # the five makefile fragments MUST end up in the resulting Makefile in this order: 
1225         # package macros, target, host, site, and package rules.
1226
1227         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
1228
1229             # Conditionalize the makefile for this package from "Makefile.in" (or whatever it's called) into Makefile.tem.
1230             rm -f ${subdir}/${Makefile}.tem
1231             case "${package_makefile_rules_frag}" in
1232               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
1233               *)
1234                       if [ ! -f ${package_makefile_rules_frag} ] ; then
1235                               package_makefile_rules_frag=${srcdir}/${package_makefile_rules_frag}
1236                       fi
1237                       if [ -f ${package_makefile_rules_frag} ] ; then
1238                               sed -e "/^####/  r ${package_makefile_rules_frag}" ${srcdir}/${subdir}/${Makefile_in} > ${Makefile}.tem
1239                       else
1240                               echo '***' Expected package makefile rules fragment \"${package_makefile_rules_frag}\" 1>&2
1241                               echo '***' is missing in ${PWD=`${PWDCMD-pwd}`}. 1>&2
1242                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
1243                       fi
1244             esac
1245             # working copy now in ${Makefile}.tem
1246
1247             # Conditionalize for this site.
1248             rm -f ${Makefile}
1249               case "${site}" in
1250               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
1251               *)
1252                       site_makefile_frag=${srcdir}/config/ms-${site}
1253
1254                       if [ -f ${site_makefile_frag} ] ; then
1255                               sed -e "/^####/  r ${site_makefile_frag}" ${subdir}/Makefile.tem \
1256                                       > ${Makefile}
1257                       else
1258                               mv ${subdir}/Makefile.tem ${Makefile}
1259                               site_makefile_frag=
1260                       fi
1261                       ;;
1262             esac
1263             # working copy now in ${Makefile}
1264
1265             # Conditionalize the makefile for this host.
1266             rm -f ${subdir}/Makefile.tem
1267             case "${host_makefile_frag}" in
1268               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
1269               *)
1270                       if [ ! -f ${host_makefile_frag} ] ; then
1271                               host_makefile_frag=${srcdir}/${host_makefile_frag}
1272                       fi
1273                       if [ -f ${host_makefile_frag} ] ; then
1274                               sed -e "/^####/  r ${host_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
1275                       else
1276                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
1277                               echo '***' is missing in ${PWD=`${PWDCMD-pwd}`}. 1>&2
1278                               mv ${Makefile} ${subdir}/Makefile.tem
1279                       fi
1280             esac
1281             # working copy now in ${subdir)/Makefile.tem
1282
1283             # Conditionalize the makefile for this target.
1284             rm -f ${Makefile}
1285             case "${target_makefile_frag}" in
1286               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
1287               *)
1288                       if [ ! -f ${target_makefile_frag} ] ; then
1289                               target_makefile_frag=${srcdir}/${target_makefile_frag}
1290                       fi
1291                       if [ -f ${target_makefile_frag} ] ; then
1292                               sed -e "/^####/  r ${target_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
1293                       else
1294                               mv ${subdir}/Makefile.tem ${Makefile}
1295                               target_makefile_frag=
1296                       fi
1297                       ;;
1298             esac
1299             # working copy now in ${Makefile}
1300
1301             # Emit the default values of this package's macros.
1302             rm -f ${subdir}/Makefile.tem
1303             case "${package_makefile_frag}" in
1304               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
1305               *)
1306                       if [ ! -f ${package_makefile_frag} ] ; then
1307                               package_makefile_frag=${srcdir}/${package_makefile_frag}
1308                       fi
1309                       if [ -f ${package_makefile_frag} ] ; then
1310                               sed -e "/^####/  r ${package_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
1311                       else
1312                               echo '***' Expected package makefile fragment \"${package_makefile_rules_frag}\" 1>&2
1313                               echo '***' is missing in ${PWD=`${PWDCMD-pwd}`}. 1>&2
1314                               mv ${Makefile} ${subdir}/Makefile.tem
1315                       fi
1316             esac
1317             # real copy now in ${subdir}/Makefile.tem
1318
1319             # prepend warning about editing, and a bunch of variables.
1320             rm -f ${Makefile}
1321             cat > ${Makefile} <<EOF
1322 # ${NO_EDIT}
1323 VPATH = ${makesrcdir}
1324 links = ${configlinks}
1325 host_alias = ${host_alias}
1326 host_cpu = ${host_cpu}
1327 host_vendor = ${host_vendor}
1328 host_os = ${host_os}
1329 host_canonical = ${host_cpu}-${host_vendor}-${host_os}
1330 target_alias = ${target_alias}
1331 target_cpu = ${target_cpu}
1332 target_vendor = ${target_vendor}
1333 target_os = ${target_os}
1334 target_canonical = ${target_cpu}-${target_vendor}-${target_os}
1335 EOF
1336             case "${build}" in
1337               "") ;;
1338               *)  cat >> ${Makefile} << EOF
1339 build_alias = ${build_alias}
1340 build_cpu = ${build_cpu}
1341 build_vendor = ${build_vendor}
1342 build_os = ${build_os}
1343 build_canonical = ${build_cpu}-${build_vendor}-${build_os}
1344 EOF
1345             esac
1346
1347             case "${package_makefile_frag}" in
1348               "") ;;
1349               /* | [A-Za-z]:[\\/]* ) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
1350               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
1351             esac
1352
1353             case "${target_makefile_frag}" in
1354               "") ;;
1355               /* | [A-Za-z]:[\\/]* ) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
1356               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
1357             esac
1358
1359             case "${host_makefile_frag}" in
1360               "") ;;
1361               /* | [A-Za-z]:[\\/]* ) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
1362               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
1363             esac
1364
1365             if [ "${site_makefile_frag}" != "" ] ; then
1366                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
1367             fi 
1368
1369             echo enable_shared = ${enable_shared} >> ${Makefile}
1370             echo enable_threads = ${enable_threads} >> ${Makefile}
1371             # record if we want to rumtime library stuff installed in libsubdir.
1372             if test -z "${enable_version_specific_runtime_libs}"; then
1373                 echo enable_version_specific_runtime_libs = no >> ${Makefile}
1374             else
1375                 echo enable_version_specific_runtime_libs = ${enable_version_specific_runtime_libs} >> ${Makefile}
1376             fi
1377
1378             # Emit a macro which describes the file containing gcc's
1379             # version number.
1380             echo gcc_version_trigger = ${gcc_version_trigger} >> ${Makefile}
1381             # And emit a macro defining gcc's version number.
1382             echo gcc_version = ${gcc_version} >> ${Makefile}
1383
1384             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
1385             # remove any form feeds.
1386             if [ -z "${subdirs}" ]; then
1387                 rm -f ${subdir}/Makefile.tm2
1388                 sedtemp=sed.$$
1389                 cat >$sedtemp <<EOF
1390 s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:
1391 s:^NONSUBDIRS[  ]*=.*$:NONSUBDIRS = ${noconfigdirs}:
1392 EOF
1393                 sed -f $sedtemp \
1394                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tm2
1395                 rm -f $sedtemp
1396                 rm -f ${subdir}/Makefile.tem
1397                 mv ${subdir}/Makefile.tm2 ${subdir}/Makefile.tem
1398             fi
1399             sed     -e "s|^prefix[      ]*=.*$|prefix = ${prefix}|" \
1400                     -e "s|^exec_prefix[         ]*=.*$|exec_prefix = ${exec_prefix}|" \
1401                     -e "s|^bindir[      ]*=.*$|bindir = ${bindir}|" \
1402                     -e "s|^sbindir[     ]*=.*$|sbindir = ${sbindir}|" \
1403                     -e "s|^libexecdir[  ]*=.*$|libexecdir = ${libexecdir}|" \
1404                     -e "s|^datadir[     ]*=.*$|datadir = ${datadir}|" \
1405                     -e "s|^sysconfdir[  ]*=.*$|sysconfdir = ${sysconfdir}|" \
1406                     -e "s|^sharedstatedir[      ]*=.*$|sharedstatedir = ${sharedstatedir}|" \
1407                     -e "s|^localstatedir[       ]*=.*$|localstatedir = ${localstatedir}|" \
1408                     -e "s|^libdir[      ]*=.*$|libdir = ${libdir}|" \
1409                     -e "s|^includedir[  ]*=.*$|includedir = ${includedir}|" \
1410                     -e "s|^oldincludedir[       ]*=.*$|oldincludedir = ${oldincludedir}|" \
1411                     -e "s|^infodir[     ]*=.*$|infodir = ${infodir}|" \
1412                     -e "s|^mandir[      ]*=.*$|mandir = ${mandir}|" \
1413                     -e "s|^ALL_BUILD_MODULES =.*|ALL_BUILD_MODULES =${all_build_modules}|" \
1414                     -e "/^CC[   ]*=/{
1415                         :loop1
1416                         /\\\\$/ N
1417                         s/\\\\\\n//g
1418                         t loop1
1419                         s%^CC[  ]*=.*$%CC = ${CC}%
1420                         }" \
1421                     -e "/^CXX[  ]*=/{
1422                         :loop2
1423                         /\\\\$/ N
1424                         s/\\\\\\n//g
1425                         t loop2
1426                         s%^CXX[         ]*=.*$%CXX = ${CXX}%
1427                         }" \
1428                     -e "/^CFLAGS[       ]*=/{
1429                         :loop3
1430                         /\\\\$/ N
1431                         s/\\\\\\n//g
1432                         t loop3
1433                         s%^CFLAGS[      ]*=.*$%CFLAGS = ${CFLAGS}%
1434                         }" \
1435                     -e "/^CXXFLAGS[     ]*=/{
1436                         :loop4
1437                         /\\\\$/ N
1438                         s/\\\\\\n//g
1439                         t loop4
1440                         s%^CXXFLAGS[    ]*=.*$%CXXFLAGS = ${CXXFLAGS}%
1441                         }" \
1442                     -e "s|^SHELL[        ]*=.*$|SHELL = ${config_shell}|" \
1443                     -e "s|^srcdir[      ]*=.*$|srcdir = ${makesrcdir}|" \
1444                     -e "s/\f//" \
1445                     -e "s:^program_prefix[      ]*=.*$:program_prefix = ${program_prefix}:" \
1446                     -e "s:^program_suffix[      ]*=.*$:program_suffix = ${program_suffix}:" \
1447                     -e "s:^program_transform_name[      ]*=.*$:program_transform_name = ${program_transform_name}:" \
1448                     -e "s|^tooldir[     ]*=.*$|tooldir = ${tooldir}|" \
1449                     -e "s|^build_tooldir[       ]*=.*$|build_tooldir = ${tooldir}|" \
1450                     -e "s:^DEFAULT_YACC[         ]*=.*$:DEFAULT_YACC = ${DEFAULT_YACC}:" \
1451                     -e "s:^DEFAULT_LEX[  ]*=.*$:DEFAULT_LEX = ${DEFAULT_LEX}:" \
1452                     -e "s:^DEFAULT_M4[  ]*=.*$:DEFAULT_M4 = ${DEFAULT_M4}:" \
1453                     ${subdir}/Makefile.tem >> ${Makefile}
1454   
1455             sed -e "s:^GDB_TK[   ]*=.*$:GDB_TK = ${GDB_TK}:" ${Makefile} >${Makefile}.tem
1456             mv -f ${Makefile}.tem ${Makefile}
1457
1458             # If this is a Canadian Cross, preset the values of many more
1459             # tools.
1460             if [ "${build}" != "${host}" ]; then
1461                 for var in ${tools}; do
1462                     eval val=\$${var}
1463                     sed -e "/^${var}[   ]*=/{
1464                            :loop1
1465                            /\\\\$/ N
1466                            /\\\\$/ b loop1
1467                            s/\\\\\\n//g
1468                            s%^${var}[   ]*=.*$%${var} = ${val}%
1469                            }" ${Makefile} > ${Makefile}.tem
1470                     mv -f ${Makefile}.tem ${Makefile}
1471                 done
1472             fi
1473
1474             # final copy now in ${Makefile}
1475
1476         else
1477            echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
1478         fi
1479
1480         rm -f ${subdir}/Makefile.tem
1481
1482         case "${host_makefile_frag}" in
1483         "") using= ;;
1484         *) using="and \"${host_makefile_frag}\"" ;;
1485         esac
1486
1487         case "${target_makefile_frag}" in
1488         "") ;;
1489         *) using="${using} and \"${target_makefile_frag}\"" ;;
1490         esac
1491
1492         case "${site_makefile_frag}" in
1493         "") ;;
1494         *) using="${using} and \"${site_makefile_frag}\"" ;;
1495         esac
1496
1497         newusing=`echo "${using}" | sed 's/and/using/'`
1498         using=${newusing}
1499         echo "Created \"${Makefile}\" in" ${PWD=`${PWDCMD-pwd}`} ${using}
1500
1501         . ${tmpfile}.pos
1502
1503         # describe the chosen configuration in config.status.
1504         # Make that file a shellscript which will reestablish
1505         # the same configuration.  Used in Makefiles to rebuild
1506         # Makefiles.
1507
1508         case "${norecursion}" in
1509         "") arguments="${arguments} --norecursion" ;;
1510         *) ;;
1511         esac
1512
1513         if [ ${subdir} = . ] ; then
1514             echo "#!/bin/sh
1515 # ${NO_EDIT}
1516 # This directory was configured as follows:
1517 ${progname}" ${arguments}  "
1518 # ${using}" > ${subdir}/config.new
1519         else
1520             echo "#!/bin/sh
1521 # ${NO_EDIT}
1522 # This directory was configured as follows:
1523 cd ${invsubdir}
1524 ${progname}" ${arguments}  "
1525 # ${using}" > ${subdir}/config.new
1526         fi
1527         chmod a+x ${subdir}/config.new
1528         if [ -r ${subdir}/config.back ] ; then
1529                 mv -f ${subdir}/config.back ${subdir}/config.status
1530         fi
1531         ${config_shell} ${moveifchange} ${subdir}/config.new ${subdir}/config.status
1532         ;;
1533
1534     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
1535     esac
1536 done
1537
1538 # If there are subdirectories, then recur.
1539 if [ -z "${norecursion}" ] && [ -n "${configdirs}" ] ; then 
1540         for configdir in ${configdirs} ${extraconfigdirs} ; do
1541
1542                 # If configdir contains ',' it is
1543                 # srcdir,builddir,target_alias
1544                 # These come from extraconfigdirs.
1545                 case ${configdir} in
1546                 *,*)
1547                     eval `echo ${configdir} | sed -e 's/\([^,]*\),\([^,]*\),\(.*\)/cfg_dir=\1 bld_dir=\2 tgt_alias=\3/'`
1548                     ;;
1549                 *)
1550                     cfg_dir=${configdir}
1551                     bld_dir=${configdir}
1552                     tgt_alias=${target_alias}
1553                     ;;
1554                 esac
1555
1556                 if [ -d ${srcdir}/${cfg_dir} ] ; then
1557                         eval echo Configuring ${configdir}... ${redirect}
1558                         case "${srcdir}" in
1559                         ".") ;;
1560                         *)
1561                                 if [ ! -d ./${bld_dir} ] ; then
1562                                         if mkdir ./${bld_dir} ; then
1563                                                 true
1564                                         else
1565                                                 echo '***' "${progname}: could not make ${PWD=`${PWDCMD-pwd}`}/${bld_dir}" 1>&2
1566                                                 exit 1
1567                                         fi
1568                                 fi
1569                                 ;;
1570                         esac
1571
1572                         POPDIR=${PWD=`${PWDCMD-pwd}`}
1573                         cd ${bld_dir} 
1574
1575 ### figure out what to do with srcdir
1576                         case "${srcdir}" in
1577                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
1578                         /* | [A-Za-z]:[\\/]* ) # absolute path
1579                                 newsrcdir=${srcdir}/${cfg_dir}
1580                                 srcdiroption="--srcdir=${newsrcdir}"
1581                                 ;;
1582                         *) # otherwise relative
1583                                 newsrcdir=../${srcdir}/${cfg_dir}
1584                                 srcdiroption="--srcdir=${newsrcdir}"
1585                                 ;;
1586                         esac
1587
1588                         # Handle --cache-file=../XXX
1589                         case "${cache_file}" in
1590                         "") # empty
1591                                 ;;
1592                         /* | [A-Za-z]:[\\/]* ) # absolute path
1593                                 cache_file_option="--cache-file=${cache_file}"
1594                                 ;;
1595                         *) # relative path
1596                                 cache_file_option="--cache-file=../${cache_file}"
1597                                 ;;
1598                         esac
1599
1600 ### check for guested configure, otherwise fix possibly relative progname
1601                         if [ -f ${newsrcdir}/configure ] ; then
1602                                 recprog=${newsrcdir}/configure
1603                         elif [ -f ${newsrcdir}/configure.in ] ; then
1604                                 case "${progname}" in
1605                                 /* | [A-Za-z]:[\\/]* )  recprog=${progname} ;;
1606                                 *)                      recprog=../${progname} ;;
1607                                 esac
1608                         else
1609                                 eval echo No configuration information in ${cfg_dir} ${redirect}
1610                                 recprog=
1611                         fi
1612
1613 ### The recursion line is here.
1614                         if [ ! -z "${recprog}" ] ; then
1615                                 if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${tgt_alias} \
1616                                         ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
1617                                         ${srcdiroption} ${diroptions} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${floating_pointoption} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
1618                                         true
1619                                 else
1620                                         echo Configure in `${PWDCMD-pwd}` failed, exiting. 1>&2
1621                                         exit 1
1622                                 fi
1623                         fi
1624
1625                         cd ${POPDIR}
1626                 fi
1627         done
1628 fi
1629
1630 # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
1631 # and reset the trap handler.
1632 rm -rf ${tmpdir}
1633 trap 0
1634
1635 exit 0
1636
1637 #
1638 # Local Variables:
1639 # fill-column: 131
1640 # End:
1641 #
1642
1643 # end of configure