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