Fix typo.
[external/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         --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
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* | --b*)
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         --*)
289                 echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
290                 exit 1
291                 ;;
292         *)
293                 case $undefs in
294                 NOUNDEFS) undefs=$option ;;
295                 *) echo '***' Can only configure for one host and one target at a time.  1>&2
296                    fatal=yes
297                    ;;
298                 esac
299                 ;;
300         esac
301 done
302
303 # process host and target
304
305 # Do some error checking and defaulting for the host and target type.
306 # The inputs are:
307 #    configure --host=HOST --target=TARGET UNDEFS
308 #
309 # The rules are:
310 # 1. You aren't allowed to specify --host, --target, and undefs at the
311 #    same time.
312 # 2. Host defaults to undefs.
313 # 3. If undefs is not specified, then host defaults to the current host,
314 #    as determined by config.guess.
315 # 4. Target defaults to undefs.
316 # 5. If undefs is not specified, then target defaults to host.
317
318 case "${fatal}" in
319 "")
320         # Make sure that host, target & undefs aren't all specified at the
321         # same time.
322         case $host_alias---$target_alias---$undefs in
323         NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
324                 ;;
325         *) echo '***' Can only configure for one host and one target at a time.  1>&2
326            fatal=yes
327            break 2
328                 ;;
329         esac
330
331         # Now, do defaulting for host.
332         case $host_alias in
333         NOHOST)
334                 case $undefs in
335                 NOUNDEFS)
336                         # Neither --host option nor undefs were present.
337                         # Call config.guess.
338                         guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
339                         if host_alias=`${guesssys}`
340                         then
341                                 # If the string we are going to use for
342                                 # the target is a prefix of the string
343                                 # we just guessed for the host, then
344                                 # assume we are running native, and force
345                                 # the same string for both target and host.
346                                 case $target_alias in
347                                 NOTARGET) ;;
348                                 *)
349                                         if expr $host_alias : $target_alias >/dev/null
350                                         then
351                                                 host_alias=$target_alias
352                                         fi
353                                         ;;
354                                 esac
355                                 echo "Configuring for a ${host_alias} host." 1>&2
356                                 arguments="--host=$host_alias $arguments"
357                         else
358                                 echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
359                                 fatal=yes
360                         fi
361                         ;;
362                 *)
363                         host_alias=$undefs
364                         arguments="--host=$host_alias $arguments"
365                         undefs=NOUNDEFS
366                         ;;
367                 esac
368         esac
369
370         # Do defaulting for target.  If --target option isn't present, default
371         # to undefs.  If undefs isn't present, default to host.
372         case $target_alias in
373         NOTARGET)
374                 case $undefs in
375                 NOUNDEFS)
376                         target_alias=$host_alias
377                         ;;
378                 *)
379                         target_alias=$undefs
380                         arguments="--target=$target_alias $arguments"
381                         ;;
382                 esac
383         esac
384         ;;
385 *) ;;
386 esac
387
388 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
389         exec 1>&2
390         echo Usage: configure [OPTIONS] [HOST]
391         echo
392         echo Options: [defaults in brackets]
393         echo ' --prefix=MYDIR            install into MYDIR [/usr/local]'
394         echo ' --exec-prefix=MYDIR       install host-dependent files into MYDIR [/usr/local]'
395         echo ' --help                    print this message [normal config]'
396         echo ' --build=BUILD             configure for building on BUILD [BUILD=HOST]'
397         echo ' --host=HOST               configure for HOST [determined via config.guess]'
398         echo ' --norecursion             configure this directory only [recurse]'
399         echo ' --program-prefix=FOO      prepend FOO to installed program names [""]'
400         echo ' --program-suffix=FOO      append FOO to installed program names [""]'
401         echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
402         echo ' --site=SITE               configure with site-specific makefile for SITE'
403         echo ' --srcdir=DIR              find the sources in DIR [. or ..]'
404         echo ' --target=TARGET   configure for TARGET [TARGET=HOST]'
405         echo ' --tmpdir=TMPDIR   create temporary files in TMPDIR [/tmp]'
406         echo ' --nfp                     configure for software floating point [hard float]'
407         echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
408         echo ' --without-FOO             package FOO is NOT available'
409         echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
410         echo ' --disable-FOO             do not include feature FOO'
411         echo
412         echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
413         echo
414         if [ -r config.status ] ; then
415                 cat config.status
416         fi
417
418         exit 1
419 fi
420
421 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
422 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
423
424 # this is a hack.  sun4 must always be a valid host alias or this will fail.
425 if ${configsub} sun4 >/dev/null 2>&1 ; then
426         true
427 else
428         echo '***' cannot find config.sub.  1>&2
429         exit 1
430 fi
431
432 touch config.junk
433 if ${moveifchange} config.junk config.trash ; then
434         true
435 else
436         echo '***' cannot find move-if-change.  1>&2
437         exit 1
438 fi
439 rm -f config.junk config.trash
440
441 case "${srcdir}" in
442 "")
443         if [ -r configure.in ] ; then
444                 srcdir=.
445         else
446                 if [ -r ${progname}.in ] ; then
447                         srcdir=`echo ${progname} | sed 's:/configure$::'`
448                 else
449                         echo '***' "Can't find configure.in.  Try using --srcdir=some_dir"  1>&2
450                         exit 1
451                 fi
452         fi
453         ;;
454 *)
455         # Set srcdir to "." if that's what it is.
456         # This is important for multilib support.
457         if [ ! -d ${srcdir} ] ; then
458                 echo "Invalid source directory ${srcdir}" >&2
459                 exit 1
460         fi
461         pwd=`pwd`
462         srcpwd=`cd ${srcdir} ; pwd`
463         if [ "${pwd}" = "${srcpwd}" ] ; then
464                 srcdir=.
465         fi
466 esac
467
468 ### warn about some conflicting configurations.
469
470 case "${srcdir}" in
471 ".") ;;
472 *)
473         if [ -f ${srcdir}/config.status ] ; then
474                 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
475                 exit 1
476         fi
477 esac
478
479 # default exec_prefix
480 case "${exec_prefixoption}" in
481 "") exec_prefix="\$(prefix)" ;;
482 *) ;;
483 esac
484
485 ### break up ${srcdir}/configure.in.
486 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
487 "")
488         echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
489         # Check for a directory that's been converted to use autoconf since
490         # it was last configured.
491         if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
492           echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
493           if [ -r ${srcdir}/configure ] ; then
494             echo '***' Running the local configure script. 1>&2
495             case "${cache_file}" in
496             "") cache_file_option= ;;
497             *)  cache_file_option="--cache-file=${cache_file}" ;;
498             esac
499             srcdiroption="--srcdir=${srcdir}"
500             case "${build_alias}" in
501             "") buildopt= ;;
502             *)  buildopt="--build=${build_alias}" ;;
503             esac
504             eval exec ${config_shell} ${srcdir}/configure ${verbose} \
505                 ${buildopt} --host=${host_alias} --target=${target_alias} \
506                 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
507                 ${srcdiroption} \
508                 ${program_prefixoption} ${program_suffixoption} \
509                 ${program_transform_nameoption} ${site_option} \
510                 ${withoptions} ${withoutoptions} \
511                 ${enableoptions} ${disableoptions} \
512                 ${cache_file_option} ${removing} ${other_options} ${redirect}
513           else
514             echo '***' There is no configure script present though. 1>&2
515           fi
516         fi
517         exit 1
518         ;;
519 *) ;;
520 esac
521
522 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
523 "")
524         echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
525         exit 1
526         ;;
527 *) ;;
528 esac
529
530 case "${TMPDIR}" in
531 "") TMPDIR=/tmp ; export TMPDIR ;;
532 *) ;;
533 esac
534
535 # keep this filename short for &%*%$*# 14 char file names
536 tmpfile=${TMPDIR}/cONf$$
537 # Note that under many versions of sh a trap handler for 0 will *override* any
538 # exit status you explicitly specify!  At this point, the only non-error exit
539 # is at the end of the script; these actions are duplicated there, minus
540 # the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
541 # trap handler, or you'll lose.
542 trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
543
544 # split ${srcdir}/configure.in into common, per-host, per-target,
545 # and post-target parts.  Post-target is optional.
546 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
547 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
548 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
549   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
550   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
551 else
552   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
553   echo >${tmpfile}.pos
554 fi
555
556 ### do common part of configure.in
557
558 . ${tmpfile}.com
559
560 # some sanity checks on configure.in
561 case "${srctrigger}" in
562 "")
563         echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
564         exit 1
565         ;;
566 *) ;;
567 esac
568
569 case "${build_alias}" in
570 "")
571         if result=`${config_shell} ${configsub} ${host_alias}` ; then
572             build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
573             build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
574             build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
575             build=${build_cpu}-${build_vendor}-${build_os}
576             build_alias=${host_alias}
577         fi
578         ;;
579 *)
580         if result=`${config_shell} ${configsub} ${build_alias}` ; then
581             buildopt="--build=${build_alias}"
582             build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
583             build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
584             build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
585             build=${build_cpu}-${build_vendor}-${build_os}
586         else
587             echo "Unrecognized build system name ${build_alias}." 1>&2
588             exit 1
589         fi
590         ;;
591 esac
592
593 if result=`${config_shell} ${configsub} ${host_alias}` ; then
594     true
595 else
596     echo "Unrecognized host system name ${host_alias}." 1>&2
597     exit 1
598 fi
599 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
600 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
601 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
602 host=${host_cpu}-${host_vendor}-${host_os}
603
604 . ${tmpfile}.hst
605
606 if result=`${config_shell} ${configsub} ${target_alias}` ; then
607     true
608 else
609     echo "Unrecognized target system name ${target_alias}." 1>&2
610     exit 1
611 fi
612 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
613 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
614 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
615 target=${target_cpu}-${target_vendor}-${target_os}
616
617 . ${tmpfile}.tgt
618
619 # Find the source files, if location was not specified.
620 case "${srcdir}" in
621 "")
622         srcdirdefaulted=1
623         srcdir=.
624         if [ ! -r ${srctrigger} ] ; then
625                 srcdir=..
626         fi
627         ;;
628 *) ;;
629 esac
630
631 if [ ! -r ${srcdir}/${srctrigger} ] ; then
632         case "${srcdirdefaulted}" in
633         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
634         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
635         esac
636
637         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
638         exit 1
639 fi
640
641 # Some systems (e.g., one of the i386-aix systems the gas testers are
642 # using) don't handle "\$" correctly, so don't use it here.
643 tooldir='$(exec_prefix)'/${target_alias}
644
645 if [ "${host_alias}" != "${target_alias}" ] ; then
646     if [ "${program_prefixoption}" = "" ] ; then
647         if [ "${program_suffixoption}" = "" ] ; then 
648             if [ "${program_transform_nameoption}" = "" ] ; then
649                 program_prefix=${target_alias}- ;
650             fi
651         fi
652     fi
653 fi
654
655 # Merge program_prefix and program_suffix onto program_transform_name.
656 # (program_suffix used to use $, but it's hard to preserve $ through both
657 # make and sh.)
658 if [ "${program_suffix}" != "" ] ; then
659     program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
660 fi
661
662 if [ "${program_prefix}" != "" ] ; then
663     program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
664 fi
665
666 # If CC and CXX are not set in the environment, and the Makefile
667 # exists, try to extract them from it.  This is to handle running
668 # ./config.status by hand.
669 if [ -z "${CC}" -a -r Makefile ]; then
670   sed -n -e ':loop
671 /\\$/ N
672 /\\$/ b loop
673 s/\\\n//g
674 /^CC[   ]*=/ s/CC[      ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
675   CC=`tail -1 Makefile.cc`
676   rm -f Makefile.cc
677 fi
678
679 if [ -z "${CXX}" -a -r Makefile ]; then
680   sed -n -e ':loop
681 /\\$/ N
682 /\\$/ b loop
683 s/\\\n//g
684 /^CXX[  ]*=/ s/CXX[     ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
685   CXX=`tail -1 Makefile.cc`
686   rm -f Makefile.cc
687 fi
688
689 if [ "${build}" != "${host}" ]; then
690   # If we are doing a Canadian Cross, in which the host and build systems
691   # are not the same, we set reasonable default values for the tools.
692
693   tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
694   tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET HOST_PREFIX"
695   tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
696   tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
697
698   for var in ${tools}; do
699     if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then
700       sed -n -e ':loop
701 /\\$/ N
702 /\\$/ b loop
703 s/\\\n//g
704 /^'"${var}"'[   ]*=/ s/'"${var}"'[      ]*=[    ]*\(.*\)/\1/p' \
705         < Makefile > Makefile.v
706       t=`tail -1 Makefile.v`
707       if [ -n "${t}" ]; then
708         eval "${var}='${t}'"
709       fi
710       rm -f Makefile.v
711     fi
712   done
713
714   AR=${AR-${host_alias}-ar}
715   AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
716   AS=${AS-${host_alias}-as}
717   AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
718   CC=${CC-${host_alias}-gcc}
719   CXX=${CXX-${host_alias}-gcc}
720   CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
721   CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
722   CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-gcc}
723   HOST_PREFIX=${build_alias}-
724   HOST_PREFIX_1=${build_alias}-
725   LD=${LD-${host_alias}-ld}
726   LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
727   MAKEINFO=${MAKEINFO-makeinfo}
728   NM=${NM-${host_alias}-nm}
729   NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
730   RANLIB=${RANLIB-${host_alias}-ranlib}
731   RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
732
733   if [ -z "${BISON}" ]; then
734     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
735     for dir in $PATH; do
736       test -z "$dir" && dir=.
737       if test -f $dir/byacc; then
738         BISON=byacc
739         break
740       fi
741       if test -f $dir/bison; then
742         BISON=bison
743         break
744       fi
745       if test -f $dir/yacc; then
746         BISON=yacc
747         break
748       fi
749     done
750     IFS="$save_ifs"
751     BISON=${BISON-bison}
752   fi
753
754   if [ -z "${LEX}" ]; then
755     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
756     for dir in $PATH; do
757       test -z "$dir" && dir=.
758       if test -f $dir/flex; then
759         LEX=flex
760         break
761       fi
762       if test -f $dir/lex; then
763         LEX=lex
764         break
765       fi
766     done
767     IFS="$save_ifs"
768     LEX=${LEX-flex}
769   fi
770
771   # Export variables which autoconf might try to set.
772   export AS
773   export AR
774   export CC_FOR_BUILD
775   export LD
776   export NM
777   export RANLIB
778 else
779   # If CC is still not set, try to get gcc.
780   if [ -z "${CC}" ]; then
781     IFS="${IFS=         }"; save_ifs="$IFS"; IFS="${IFS}:"
782     for dir in $PATH; do
783       test -z "$dir" && dir=.
784       if test -f $dir/gcc; then
785         CC="gcc -O2"
786         break
787       fi
788     done
789     IFS="$save_ifs"
790     CC=${CC-cc}
791   fi
792
793   CXX=${CXX-"gcc"}
794 fi
795
796 export CC
797 export CXX
798
799 for subdir in . ${subdirs} ; do
800
801     # ${subdir} is relative path from . to the directory we're currently
802     # configuring.
803     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
804     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
805
806     ### figure out what to do with srcdir
807     case "${srcdir}" in
808         ".")  # no -srcdir option.  We're building in place.
809                 makesrcdir=. ;;
810         /*) # absolute path
811                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
812                 ;;
813         *) # otherwise relative
814                 case "${subdir}" in
815                 .) makesrcdir=${srcdir} ;;
816                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
817                 esac
818                 ;;
819     esac
820
821     if [ "${subdir}/" != "./" ] ; then
822         Makefile=${subdir}/Makefile
823     fi
824
825     if [ ! -d ${subdir} ] ; then
826         if mkdir ${subdir} ; then
827                 true
828         else
829                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
830                 exit 1
831         fi
832     fi
833
834     case "${removing}" in
835     "")
836         case "${subdir}" in
837         .) ;;
838         *) eval echo Building in ${subdir} ${redirect} ;;
839         esac
840
841         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
842         # Set up the list of links to be made.
843         # ${links} is the list of link names, and ${files} is the list of names to link to.
844
845         # Make the links.
846         configlinks="${links}"
847         if [ -r ${subdir}/config.status ] ; then
848                 mv -f ${subdir}/config.status ${subdir}/config.back
849         fi
850         while [ -n "${files}" ] ; do
851                 # set file to car of files, files to cdr of files
852                 set ${files}; file=$1; shift; files=$*
853                 set ${links}; link=$1; shift; links=$*
854
855                 if [ ! -r ${srcdir}/${file} ] ; then
856                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
857                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
858                         exit 1
859                 fi
860
861                 ${remove} -f ${link}
862                 # Make a symlink if possible, otherwise try a hard link
863                 if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
864                         true
865                 else
866                         # We need to re-remove the file because Lynx leaves a 
867                         # very strange directory there when it fails an NFS symlink.
868                         ${remove} -r -f ${link}
869                         ${hard_link} ${srcdir}/${file} ${link}
870                 fi
871                 if [ ! -r ${link} ] ; then
872                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
873                         exit 1
874                 fi
875
876                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
877         done
878
879         # Create a .gdbinit file which runs the one in srcdir
880         # and tells GDB to look there for source files.
881
882         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
883                 case ${srcdir} in
884                 .) ;;
885                 *) cat > ${subdir}/.gdbinit <<EOF
886 # ${NO_EDIT}
887 dir ${makesrcdir}
888 dir .
889 source ${makesrcdir}/.gdbinit
890 EOF
891                         ;;
892                 esac
893         fi
894
895         # Install a makefile, and make it set VPATH
896         # if necessary so that the sources are found.
897         # Also change its value of srcdir.
898         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
899         # been somewhat optimized and is perhaps a bit twisty.
900
901         # code is order so as to try to sed the smallest input files we know.
902
903         # the four makefile fragments MUST end up in the resulting Makefile in this order: 
904         # package, target, host, and site.  so do these separately because I don't trust the
905         #  order of sed -e expressions.
906
907         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
908
909             # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
910             rm -f ${subdir}/Makefile.tem
911               case "${site}" in
912               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
913               *)
914                       site_makefile_frag=${srcdir}/config/ms-${site}
915
916                       if [ -f ${site_makefile_frag} ] ; then
917                               sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
918                                       > ${subdir}/Makefile.tem
919                       else
920                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
921                               site_makefile_frag=
922                       fi
923                       ;;
924             esac
925             # working copy now in ${subdir}/Makefile.tem
926
927             # Conditionalize the makefile for this host.
928             rm -f ${Makefile}
929             case "${host_makefile_frag}" in
930               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
931               *)
932                       if [ ! -f ${host_makefile_frag} ] ; then
933                               host_makefile_frag=${srcdir}/${host_makefile_frag}
934                       fi
935                       if [ -f ${host_makefile_frag} ] ; then
936                               sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
937                       else
938                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
939                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
940                               mv ${subdir}/Makefile.tem ${Makefile}
941                       fi
942             esac
943             # working copy now in ${Makefile}
944
945             # Conditionalize the makefile for this target.
946             rm -f ${subdir}/Makefile.tem
947             case "${target_makefile_frag}" in
948               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
949               *)
950                       if [ ! -f ${target_makefile_frag} ] ; then
951                               target_makefile_frag=${srcdir}/${target_makefile_frag}
952                       fi
953                       if [ -f ${target_makefile_frag} ] ; then
954                               sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
955                       else
956                               mv ${Makefile} ${subdir}/Makefile.tem
957                               target_makefile_frag=
958                       fi
959                       ;;
960             esac
961             # real copy now in ${subdir}/Makefile.tem
962
963             # Conditionalize the makefile for this package.
964             rm -f ${Makefile}
965             case "${package_makefile_frag}" in
966               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
967               *)
968                       if [ ! -f ${package_makefile_frag} ] ; then
969                               package_makefile_frag=${srcdir}/${package_makefile_frag}
970                       fi
971                       if [ -f ${package_makefile_frag} ] ; then
972                               sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
973                               rm -f ${subdir}/Makefile.tem
974                       else
975                               echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
976                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
977                               mv ${subdir}/Makefile.tem ${Makefile}
978                       fi
979             esac
980             # working copy now in ${Makefile}
981
982             mv ${Makefile} ${subdir}/Makefile.tem
983
984             # real copy now in ${subdir}/Makefile.tem
985
986             # prepend warning about editting, and a bunch of variables.
987             rm -f ${Makefile}
988             cat > ${Makefile} <<EOF
989 # ${NO_EDIT}
990 VPATH = ${makesrcdir}
991 links = ${configlinks}
992 host_alias = ${host_alias}
993 host_cpu = ${host_cpu}
994 host_vendor = ${host_vendor}
995 host_os = ${host_os}
996 host_canonical = ${host_cpu}-${host_vendor}-${host_os}
997 target_alias = ${target_alias}
998 target_cpu = ${target_cpu}
999 target_vendor = ${target_vendor}
1000 target_os = ${target_os}
1001 target_canonical = ${target_cpu}-${target_vendor}-${target_os}
1002 EOF
1003             case "${build}" in
1004               "") ;;
1005               *)  cat >> ${Makefile} << EOF
1006 build_alias = ${build_alias}
1007 build_cpu = ${build_cpu}
1008 build_vendor = ${build_vendor}
1009 build_os = ${build_os}
1010 build_canonical = ${build_cpu}-${build_vendor}-${build_os}
1011 EOF
1012             esac
1013
1014             case "${package_makefile_frag}" in
1015               "") ;;
1016               /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
1017               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
1018             esac
1019
1020             case "${target_makefile_frag}" in
1021               "") ;;
1022               /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
1023               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
1024             esac
1025
1026             case "${host_makefile_frag}" in
1027               "") ;;
1028               /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
1029               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
1030             esac
1031
1032             if [ "${site_makefile_frag}" != "" ] ; then
1033                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
1034             fi 
1035
1036             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
1037             # remove any form feeds.
1038             if [ -z "${subdirs}" ]; then
1039                 rm -f ${subdir}/Makefile.tem2
1040                 sed -e "s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:" \
1041                     -e "s:^NONSUBDIRS[  ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
1042                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
1043                 rm -f ${subdir}/Makefile.tem
1044                 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
1045             fi
1046             sed -e "s:^prefix[  ]*=.*$:prefix = ${prefix}:" \
1047                     -e "s:^exec_prefix[         ]*=.*$:exec_prefix = ${exec_prefix}:" \
1048                     -e "/^CC[   ]*=/{
1049                         :loop1
1050                         /\\\\$/ N
1051                         /\\\\$/ b loop1
1052                         s/\\\\\\n//g
1053                         s%^CC[  ]*=.*$%CC = ${CC}%
1054                         }" \
1055                     -e "/^CXX[  ]*=/{
1056                         :loop2
1057                         /\\\\$/ N
1058                         /\\\\$/ b loop2
1059                         s/\\\\\\n//g
1060                         s%^CXX[         ]*=.*$%CXX = ${CXX}%
1061                         }" \
1062                     -e "s:^SHELL[        ]*=.*$:SHELL = ${config_shell}:" \
1063                     -e "s:^srcdir[      ]*=.*$:srcdir = ${makesrcdir}:" \
1064                     -e "s/\f//" \
1065                     -e "s:^program_prefix[      ]*=.*$:program_prefix = ${program_prefix}:" \
1066                     -e "s:^program_suffix[      ]*=.*$:program_suffix = ${program_suffix}:" \
1067                     -e "s:^program_transform_name[      ]*=.*$:program_transform_name = ${program_transform_name}:" \
1068                     -e "s:^tooldir[     ]*=.*$:tooldir = ${tooldir}:" \
1069                     ${subdir}/Makefile.tem >> ${Makefile}
1070
1071             # If this is a Canadian Cross, preset the values of many more
1072             # tools.
1073             if [ "${build}" != "${host}" ]; then
1074                 for var in ${tools}; do
1075                     val=`eval 'echo $'"${var}"`
1076                     sed -e "/^${var}[   ]*=/{
1077                            :loop1
1078                            /\\\\$/ N
1079                            /\\\\$/ b loop1
1080                            s/\\\\\\n//g
1081                            s%^${var}[   ]*=.*$%${var} = ${val}%
1082                            }" ${Makefile} > ${Makefile}.tem
1083                     mv -f ${Makefile}.tem ${Makefile}
1084                 done
1085             fi
1086
1087             # final copy now in ${Makefile}
1088
1089         else
1090            echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
1091         fi
1092
1093         rm -f ${subdir}/Makefile.tem
1094
1095         case "${host_makefile_frag}" in
1096         "") using= ;;
1097         *) using="and \"${host_makefile_frag}\"" ;;
1098         esac
1099
1100         case "${target_makefile_frag}" in
1101         "") ;;
1102         *) using="${using} and \"${target_makefile_frag}\"" ;;
1103         esac
1104
1105         case "${site_makefile_frag}" in
1106         "") ;;
1107         *) using="${using} and \"${site_makefile_frag}\"" ;;
1108         esac
1109
1110         newusing=`echo "${using}" | sed 's/and/using/'`
1111         using=${newusing}
1112         echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
1113
1114         . ${tmpfile}.pos
1115
1116         # describe the chosen configuration in config.status.
1117         # Make that file a shellscript which will reestablish
1118         # the same configuration.  Used in Makefiles to rebuild
1119         # Makefiles.
1120
1121         case "${norecursion}" in
1122         "") arguments="${arguments} --norecursion" ;;
1123         *) ;;
1124         esac
1125
1126         if [ ${subdir} = . ] ; then
1127             echo "#!/bin/sh
1128 # ${NO_EDIT}
1129 # This directory was configured as follows:
1130 ${progname}" ${arguments}  "
1131 # ${using}" > ${subdir}/config.new
1132         else
1133             echo "#!/bin/sh
1134 # ${NO_EDIT}
1135 # This directory was configured as follows:
1136 cd ${invsubdir}
1137 ${progname}" ${arguments}  "
1138 # ${using}" > ${subdir}/config.new
1139         fi
1140         chmod a+x ${subdir}/config.new
1141         if [ -r ${subdir}/config.back ] ; then
1142                 mv -f ${subdir}/config.back ${subdir}/config.status
1143         fi
1144         ${moveifchange} ${subdir}/config.new ${subdir}/config.status
1145         ;;
1146
1147     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
1148     esac
1149 done
1150
1151 # If there are subdirectories, then recur. 
1152 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
1153         for configdir in ${configdirs} ; do
1154
1155                 if [ -d ${srcdir}/${configdir} ] ; then
1156                         eval echo Configuring ${configdir}... ${redirect}
1157                         case "${srcdir}" in
1158                         ".") ;;
1159                         *)
1160                                 if [ ! -d ./${configdir} ] ; then
1161                                         if mkdir ./${configdir} ; then
1162                                                 true
1163                                         else
1164                                                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
1165                                                 exit 1
1166                                         fi
1167                                 fi
1168                                 ;;
1169                         esac
1170
1171                         POPDIR=${PWD=`pwd`}
1172                         cd ${configdir} 
1173
1174 ### figure out what to do with srcdir
1175                         case "${srcdir}" in
1176                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
1177                         /*) # absolute path
1178                                 newsrcdir=${srcdir}/${configdir}
1179                                 srcdiroption="--srcdir=${newsrcdir}"
1180                                 ;;
1181                         *) # otherwise relative
1182                                 newsrcdir=../${srcdir}/${configdir}
1183                                 srcdiroption="--srcdir=${newsrcdir}"
1184                                 ;;
1185                         esac
1186
1187                         # Handle --cache-file=../XXX
1188                         case "${cache_file}" in
1189                         "") # empty
1190                                 ;;
1191                         /*) # absolute path
1192                                 cache_file_option="--cache-file=${cache_file}"
1193                                 ;;
1194                         *) # relative path
1195                                 cache_file_option="--cache-file=../${cache_file}"
1196                                 ;;
1197                         esac
1198
1199 ### check for guested configure, otherwise fix possibly relative progname
1200                         if [ -f ${newsrcdir}/configure ] ; then
1201                                 recprog=${newsrcdir}/configure
1202                         elif [ -f ${newsrcdir}/configure.in ] ; then
1203                                 case "${progname}" in
1204                                 /*)     recprog=${progname} ;;
1205                                 *)      recprog=../${progname} ;;
1206                                 esac
1207                         else
1208                                 eval echo No configuration information in ${configdir} ${redirect}
1209                                 recprog=
1210                         fi
1211
1212 ### The recursion line is here.
1213                         if [ ! -z "${recprog}" ] ; then
1214                                 if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
1215                                         ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
1216                                         ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
1217                                         true
1218                                 else
1219                                         echo Configure in `pwd` failed, exiting. 1>&2
1220                                         exit 1
1221                                 fi
1222                         fi
1223
1224                         cd ${POPDIR}
1225                 fi
1226         done
1227 fi
1228
1229 # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
1230 # and reset the trap handler.
1231 rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
1232 trap 0
1233
1234 exit 0
1235
1236 #
1237 # Local Variables:
1238 # fill-column: 131
1239 # End:
1240 #
1241
1242 # end of configure