OSDN Git Service

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