OSDN Git Service

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