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