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