work around lynxos /bin/sh lossage
[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, 1990, 1991, 1992, 1993 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 email any bugs, comments, and/or additions to this file to:
23 # configure@cygnus.com
24
25 # This file was written by K. Richard Pixley.
26
27 #
28 # Shell script to create proper links to machine-dependent files in
29 # preparation for compilation.
30 #
31 # If configure succeeds, it leaves its status in config.status.
32 # If configure fails after disturbing the status quo, 
33 #       config.status is removed.
34 #
35
36 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
37
38 remove=rm
39 hard_link=ln
40 symbolic_link='ln -s'
41
42 #for Test
43 #remove="echo rm"
44 #hard_link="echo ln"
45 #symbolic_link="echo ln -s"
46
47 # clear some things potentially inherited from environment.
48
49 Makefile=Makefile
50 Makefile_in=Makefile.in
51 arguments=$*
52 configdirs=
53 exec_prefix=
54 exec_prefixoption=
55 fatal=
56 floating_point=default
57 gas=default
58 host_alias=
59 host_makefile_frag=
60 moveifchange=
61 next_host=
62 next_prefix=
63 next_site=
64 next_srcdir=
65 next_target=
66 next_tmpdir=
67 norecursion=
68 package_makefile_frag=
69 prefix=/usr/local
70 progname=
71 program_prefix=
72 program_prefixoption=
73 program_suffix=
74 program_suffixoption=
75 program_transform_name=
76 program_transform_nameoption=
77 redirect=">/dev/null"
78 removing=
79 site=
80 site_makefile_frag=
81 site_option=
82 srcdir=
83 srctrigger=
84 subdirs=
85 target_alias=
86 target_makefile_frag=
87 undefinedargs=
88 version="$Revision$"
89 x11=default
90
91 NO_EDIT="This file was generated automatically by configure.  Do not edit."
92
93 ## this is a little touchy and won't always work, but...
94 ##
95 ## if the argv[0] starts with a slash then it is an absolute name that can (and
96 ## must) be used as is.
97 ##
98 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
99 ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
100 ##
101
102 progname=$0
103 # if PWD already has a value, it is probably wrong.
104 if [ -n "$PWD" ]; then PWD=`pwd`; fi
105
106 case "${progname}" in
107 /*) ;;
108 */*) ;;
109 *)
110         PATH=$PATH:${PWD=`pwd`} ; export PATH
111         ;;
112 esac
113
114 for arg in $*
115 do
116         # handle things that might have args following as separate words
117         if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
118         elif [ -n "${next_exec_prefix}" ] ; then
119                 exec_prefix=${arg}
120                 exec_prefixoption="-exec-prefix=${exec_prefix}"
121                 next_exec_prefix=
122         elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
123         # remove any possible trailing slash from srcdir.  See note below.
124         elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
125         elif [ -n "${next_program_prefix}" ] ; then
126                 program_prefix=${arg}
127                 program_prefixoption="-program_prefix=${program_prefix}"
128                 next_program_prefix=
129         elif [ -n "${next_program_suffix}" ] ; then
130                 program_suffix=${arg}
131                 program_suffixoption="-program_suffix=${program_suffix}"
132                 next_program_suffix=
133         elif [ -n "${next_program_transform_name}" ] ; then
134                 # Double any backslashes or dollar signs in the argument
135                 if [ -n "${arg}" ] ; then
136                         program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
137                 fi
138                 program_transform_nameoption="${program_transform_nameoption} --program-transform-name='${arg}'"
139                 next_program_transform_name=
140         elif [ -n "${next_target}" ] ; then
141                 next_target=
142                 case "${target_alias}" in
143                 "")
144                         target_alias="${arg}"
145                         ;;
146                 *)
147                         echo '***' Can only configure for one target at a time.  1>&2
148                         fatal=yes
149                         ;;
150                 esac
151         elif [ -n "${next_tmpdir}" ] ; then
152                 next_tmpdir=
153                 tmpdiroption="--tmpdir=${arg}"
154                 TMPDIR=${arg}
155
156         else
157                 case ${arg} in
158                 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=* | -exec-prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* )
159                         exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
160                         exec_prefixoption=${arg}
161                         ;;
162                 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e | -exec-prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec-)
163                         next_exec_prefix=yes
164                         ;;
165                 -gas | --g*)
166                         gas=yes
167                         ;;
168                 -help | --he*)
169                         fatal=true
170                         ;;
171                 -host=* | --host=* | --hos=* | --ho=*)
172                         case "${host_alias}" in
173                         "")
174                                 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
175                                 ;;
176                         *)
177                                 echo '***' Can only configure for one host at a time.  1>&2
178                                 fatal=yes
179                                 ;;
180                         esac
181                         ;;
182                 -nfp | --nf*)
183                         floating_point=no
184                         ;;
185                 -norecursion | --no*)
186                         norecursion=true
187                         ;;
188                 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
189                         prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
190                         prefixoption=${arg}
191                         ;;
192                 -prefix | --prefix | --prefi | --pref | --pre)
193                         next_prefix=yes
194                         ;;
195                 -rm | --rm) removing=${arg} ;;
196                 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | -program-prefix=* | --program-prefix=* | --program-prefi=* | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
197                         program_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
198                         program_prefixoption=${arg}
199                         ;;
200                 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | -program-prefix | --program-prefix | --program-prefi | --program-pref | --program-pre | --program-pr | --program-p)
201                         next_program_prefix=yes
202                         ;;
203                 -program_suffix=* | --program_suffix=* | --program_suffi=* | --program_suff=* | --program_suf=* | --program_su=* | --program_s=* | -program-suffix=* | --program-suffix=* | --program-suffi=* | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
204                         program_suffix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
205                         program_suffixoption=${arg}
206                         ;;
207                 -program_suffix | --program_suffix | --program_suffi | --program_suff | --program_suf | --program_su | --program_s |-program-suffix | --program-suffix | --program-suffi | --program-suff | --program-suf | --program-su | --program-s)
208                         next_program_suffix=yes
209                         ;;
210                 -program_transform_name=* | --program_transform_name=* | --program_transform_nam=* | --program_transform_na=* | --program_transform_n=* | --program_transform_=* | --program_transform=* | --program_transfor=* | --program_transfo=* | --program_transf=* | --program_trans=* | --program_tran=* | --program_tra=* | --program_tr=* | --program_t=* | -program-transform-name=* | --program-transform-name=* | --program-transform-nam=* | --program-transform-na=* | --program-transform-n=* | --program-transform-=* | --program-transform=* | --program-transfor=* | --program-transfo=* | --program-transf=* | --program-trans=* | --program-tran=* | --program-tra=* | --program-tr=* | --program-t=*)
211                         arg=`echo ${arg} | sed -e 's/^[-a-z_]*=//'`
212                         # Double any \ or $ in the argument
213                         if [ -n "${arg}" ] ; then
214                                 program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
215                         fi
216                         program_transform_nameoption="${program_transform_nameoption} --program-transform-name='${arg}'"
217                         ;;
218                 -program_transform_name | --program_transform_name | --program_transform_nam | --program_transform_na | --program_transform_n | --program_transform_ | --program_transform | --program_transfor | --program_transfo | --program_transf | --program_trans | --program_tran | --program_tra | --program_tr | --program_t | -program-transform-name | --program-transform-name | --program-transform-nam | --program-transform-na | --program-transform-n | --program-transform- | --program-transform | --program-transfor | --program-transfo | --program-transf | --program-trans | --program-tran | --program-tra | --program-tr | --program-t)
219                         next_program_transform_name=yes
220                         ;;
221                 -site=* | --site=* | --sit=* | --si=*)
222                         site_option=${arg}
223                         site=`echo ${arg} | sed 's/^[-a-z]*=//'`
224                         ;;
225                 -site | --site | --sit)
226                         next_site=yes
227                         ;;
228                 # remove trailing slashes.  Otherwise, when the file name gets
229                 # bolted into an object file as debug info, it has two slashes in
230                 # it.  Ordinarily this is ok, but emacs takes double slash to
231                 # mean "forget the first part".
232                 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
233                         srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
234                         ;;
235                 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
236                         next_srcdir=yes
237                         ;;
238                 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
239                         case "${target_alias}" in
240                         "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
241                         *)
242                                 echo '***' Can only configure for one target at a time.  1>&2
243                                 fatal=yes
244                                 ;;
245                         esac
246                         ;;
247                 -target | --target | --targe | --targ | --tar | --ta)
248                         next_target=yes
249                         ;;
250                 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
251                         tmpdiroption=${arg}
252                         TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
253                         ;;
254                 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
255                         next_tmpdir=yes
256                         ;;
257                 -v | -verbose | --v)
258                         redirect=
259                         verbose=-v
260                         ;;
261                 -version | -V | --version | --V)
262                         echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
263                         exit 0
264                         ;;
265                 -with*=* | --with*=*)
266                         withopt=`echo ${arg} | sed 's:^-*\(with[^=]*\)=.*$:\1:;s/-/_/g'`
267                         withval=`echo ${arg} | sed 's:^-*with[^=]*=\(.*\)$:\1:'`
268                         eval $withopt="$withval"
269                         withoptions="$withoptions $arg"
270                         ;;
271                 -without* | --without*)
272                         withopt=`echo ${arg} | sed 's:^-*without:with:;s/-/_/g'`                
273                         eval $withopt=no
274                         withoutoptions="$withoutoptions $arg"
275                         ;;
276                 -with* | --with*)
277                         withopt=`echo ${arg} | sed 's:^-*with:with:;s/-/_/g'`
278                         eval $withopt=yes
279                         withoptions="$withoptions $arg"
280                         ;;
281                 -x | --x) ;;
282                 -* | --*)
283                         (echo ;
284                         echo "Unrecognized option: \"${arg}\"". ;
285                         echo) 1>&2
286                         fatal=true
287                         ;;
288                 *)
289                         case "${undefs}" in
290                         "")
291                                 undefs="${arg}"
292                                 ;;
293                         *)
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         fi
301 done
302
303 # process host and target
304 case "${fatal}" in
305 "")
306 #       # Complain if an arg is missing
307 #       if [ -z "${host_alias}" ] ; then
308 #               (echo ;
309 #               echo "configure: No HOST specified." ;
310 #               echo) 1>&2
311 #               fatal=true
312 #       fi
313
314 ### This is a bit twisted.
315 ### * if all three are specified, this is an error.
316 ### * if we have neither hosts, nor unadorned args, this is an error.
317 ### * if no hosts are specified, then the unadorned args are hosts, but if
318 ### there were none, this is an error.
319 ### * if no targets are specified, then the unadorned args are targets, but if
320 ### there were no unadorned args, then the hosts are also targets.
321
322         if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
323                 echo '***' Can only configure for one host and one target at a time.  1>&2
324                 fatal=yes
325         elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
326                 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
327                 if tmp_alias=`${guesssys}` ; then
328                         echo "Configuring for a ${tmp_alias} host." 1>&2
329                         host_alias=${tmp_alias}
330                         case "${target_alias}" in
331                         "") target_alias=${tmp_alias} ;;
332                         *) ;;
333                         esac
334                         arguments="--host=${host_alias} ${arguments}"
335                 else
336                         echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
337                         fatal=yes
338                 fi
339         else
340                 case "${host_alias}" in
341                 "") host_alias=${undefs} ;;
342                 *) ;;
343                 esac
344
345                 case "${target_alias}" in
346                 "")
347                         case "${undefs}" in
348                         "")     target_alias=${host_alias} ;;
349                         *)      target_alias=${undefs} ;;
350                         esac
351                         ;;
352                 *) ;;
353                 esac
354         fi
355         ;;
356 *) ;;
357 esac
358
359 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
360         (echo "Usage: configure HOST" ;
361         echo ;
362         echo "Options: [defaults in brackets]" ;
363         echo " --prefix=MYDIR            configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
364         echo " --exec-prefix=MYDIR       configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
365         echo " --help                    print this message. [normal config]" ;
366         echo " --norecursion             configure this directory only. [recurse]" ;
367         echo " --program-prefix=FOO      install programs with FOO prepended to their names. [ \"\" ]" ;
368         echo " --program-suffix=FOO      install programs with FOO appended to their names. [ \"\" ]" ;
369         echo " --program-transform-name=FOO      install programs with names transformed by sed pattern FOO. [ \"\" ]" ;
370         echo " --site=SITE               configure with site specific makefile for SITE" ;
371         echo " --srcdir=DIR              find the sources in DIR. [\".\" or \"..\"]" ;
372         echo " --target=TARGET           configure for TARGET.  [TARGET = HOST]" ;
373         echo " --tmpdir=TMPDIR           create temporary files in TMPDIR.  [ TMPDIR = \"/tmp\" ]" ;
374         echo " --nfp                     configure the compilers default to soft floating point. [hard float]" ;
375         echo " --with-FOO, --with-FOO=BAR specify that FOO is available"
376         echo " --without-FOO             specify that FOO is NOT available"
377         echo ;
378         echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
379         echo ;
380         ) 1>&2
381         if [ -r config.status ] ; then
382                 cat config.status
383         fi
384
385         exit 1
386 fi
387
388 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
389 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
390
391 # this is a hack.  sun4 must always be a valid host alias or this will fail.
392 if ${configsub} sun4 >/dev/null 2>&1 ; then
393         true
394 else
395         echo '***' cannot find config.sub.  1>&2
396         exit 1
397 fi
398
399 touch config.junk
400 if ${moveifchange} config.junk config.trash ; then
401         true
402 else
403         echo '***' cannot find move-if-change.  1>&2
404         exit 1
405 fi
406 rm -f config.junk config.trash
407
408 case "${srcdir}" in
409 "")
410         if [ -r configure.in ] ; then
411                 srcdir=.
412         else
413                 if [ -r ${progname}.in ] ; then
414                         srcdir=`echo ${progname} | sed 's:/configure$::'`
415                 else
416                         echo '***' "Can't find configure.in.  Try using -srcdir=some_dir"  1>&2
417                         exit 1
418                 fi
419         fi
420         ;;
421 *) ;;
422 esac
423
424 ### warn about some conflicting configurations.
425
426 case "${srcdir}" in
427 ".") ;;
428 *)
429         if [ -f ${srcdir}/config.status ] ; then
430                 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
431                 exit 1
432         fi
433 esac
434
435 # default exec_prefix
436 case "${exec_prefix}" in
437 "") exec_prefix="\$(prefix)" ;;
438 *) ;;
439 esac
440
441 ### break up ${srcdir}/configure.in.
442 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
443 "")
444         echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
445         exit 1
446         ;;
447 *) ;;
448 esac
449
450 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
451 "")
452         echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
453         exit 1
454         ;;
455 *) ;;
456 esac
457
458 case "${TMPDIR}" in
459 "") TMPDIR=/tmp ; export TMPDIR ;;
460 *) ;;
461 esac
462
463 # keep this filename short for &%*%$*# 14 char file names
464 tmpfile=${TMPDIR}/cONf$$
465 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
466
467 # split ${srcdir}/configure.in into common, per-host, per-target,
468 # and post-target parts.  Post-target is optional.
469 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
470 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
471 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
472   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
473   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
474 else
475   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
476   echo >${tmpfile}.pos
477 fi
478
479 ### do common part of configure.in
480
481 . ${tmpfile}.com
482
483 # some sanity checks on configure.in
484 case "${srctrigger}" in
485 "")
486         echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
487         exit 1
488         ;;
489 *) ;;
490 esac
491
492 result=`${configsub} ${host_alias}`
493 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
494 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
495 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
496 host=${host_cpu}-${host_vendor}-${host_os}
497
498 . ${tmpfile}.hst
499
500 result=`${configsub} ${target_alias}`
501 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
502 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
503 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
504 target=${target_cpu}-${target_vendor}-${target_os}
505
506 . ${tmpfile}.tgt
507
508 # Find the source files, if location was not specified.
509 case "${srcdir}" in
510 "")
511         srcdirdefaulted=1
512         srcdir=.
513         if [ ! -r ${srctrigger} ] ; then
514                 srcdir=..
515         fi
516         ;;
517 *) ;;
518 esac
519
520 if [ ! -r ${srcdir}/${srctrigger} ] ; then
521         case "${srcdirdefaulted}" in
522         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
523         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
524         esac
525
526         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
527         exit 1
528 fi
529
530 # Some systems (e.g., one of the i386-aix systems the gas testers are
531 # using) don't handle "\$" correctly, so don't use it here.
532 tooldir='$(exec_prefix)'/${target_alias}
533
534 if [ "${host_alias}" != "${target_alias}" ] ; then
535     if [ "${program_prefixoption}" = "" ] ; then
536         if [ "${program_suffixoption}" = "" ] ; then 
537             if [ "${program_transform_nameoption}" = "" ] ; then
538                 program_prefix=${target_alias}- ;
539             fi
540         fi
541     fi
542 fi
543
544 # Merge program_prefix and program_suffix onto program_transform_name
545 # Use a double $ so that make ignores it
546 if [ "${program_suffix}" != "" ] ; then
547     program_transform_name="-e s/\$\$/${program_suffix}/ ${program_transform_name}"
548 fi
549
550 if [ "${program_prefix}" != "" ] ; then
551     program_transform_name="-e s/^/${program_prefix}/ ${program_transform_name}"
552 fi
553
554 for subdir in . ${subdirs} ; do
555
556     # ${subdir} is relative path from . to the directory we're currently
557     # configuring.
558     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
559     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
560
561     ### figure out what to do with srcdir
562     case "${srcdir}" in
563         ".")  # no -srcdir option.  We're building in place.
564                 makesrcdir=. ;;
565         /*) # absolute path
566                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
567                 ;;
568         *) # otherwise relative
569                 case "${subdir}" in
570                 .) makesrcdir=${srcdir} ;;
571                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
572                 esac
573                 ;;
574     esac
575
576     if [ "${subdir}/" != "./" ] ; then
577         Makefile=${subdir}/Makefile
578     fi
579
580     if [ ! -d ${subdir} ] ; then
581         if mkdir ${subdir} ; then
582                 true
583         else
584                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
585                 exit 1
586         fi
587     fi
588
589     case "${removing}" in
590     "")
591         case "${subdir}" in
592         .) ;;
593         *) eval echo Building in ${subdir} ${redirect} ;;
594         esac
595
596         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
597         # Set up the list of links to be made.
598         # ${links} is the list of link names, and ${files} is the list of names to link to.
599
600         # Make the links.
601         configlinks="${links}"
602         if [ -r ${subdir}/config.status ] ; then
603                 mv -f ${subdir}/config.status ${subdir}/config.back
604         fi
605         while [ -n "${files}" ] ; do
606                 # set file to car of files, files to cdr of files
607                 set ${files}; file=$1; shift; files=$*
608                 set ${links}; link=$1; shift; links=$*
609
610                 if [ ! -r ${srcdir}/${file} ] ; then
611                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
612                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
613                         exit 1
614                 fi
615
616                 ${remove} -f ${link}
617                 # Make a symlink if possible, otherwise try a hard link
618                 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
619
620                 if [ ! -r ${link} ] ; then
621                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
622                         exit 1
623                 fi
624
625                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
626         done
627
628         # Create a .gdbinit file which runs the one in srcdir
629         # and tells GDB to look there for source files.
630
631         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
632                 case ${srcdir} in
633                 .) ;;
634                 *) cat > ${subdir}/.gdbinit <<EOF
635 # ${NO_EDIT}
636 dir .
637 dir ${makesrcdir}
638 source ${makesrcdir}/.gdbinit
639 EOF
640                         ;;
641                 esac
642         fi
643
644         # Install a makefile, and make it set VPATH
645         # if necessary so that the sources are found.
646         # Also change its value of srcdir.
647         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
648         # been somewhat optimized and is perhaps a bit twisty.
649
650         # code is order so as to try to sed the smallest input files we know.
651
652         # the four makefile fragments MUST end up in the resulting Makefile in this order: 
653         # package, target, host, and site.  so do these separately because I don't trust the
654         #  order of sed -e expressions.
655
656         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
657
658             # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
659             rm -f ${subdir}/Makefile.tem
660               case "${site}" in
661               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
662               *)
663                       site_makefile_frag=${srcdir}/config/ms-${site}
664
665                       if [ -f ${site_makefile_frag} ] ; then
666                               sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
667                                       > ${subdir}/Makefile.tem
668                       else
669                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
670                               site_makefile_frag=
671                       fi
672                       ;;
673             esac
674             # working copy now in ${subdir}/Makefile.tem
675
676             # Conditionalize the makefile for this host.
677             rm -f ${Makefile}
678             case "${host_makefile_frag}" in
679               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
680               *)
681                       if [ ! -f ${host_makefile_frag} ] ; then
682                               host_makefile_frag=${srcdir}/${host_makefile_frag}
683                       fi
684                       if [ -f ${host_makefile_frag} ] ; then
685                               sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
686                       else
687                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
688                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
689                               mv ${subdir}/Makefile.tem ${Makefile}
690                       fi
691             esac
692             # working copy now in ${Makefile}
693
694             # Conditionalize the makefile for this target.
695             rm -f ${subdir}/Makefile.tem
696             case "${target_makefile_frag}" in
697               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
698               *)
699                       if [ ! -f ${target_makefile_frag} ] ; then
700                               target_makefile_frag=${srcdir}/${target_makefile_frag}
701                       fi
702                       if [ -f ${target_makefile_frag} ] ; then
703                               sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
704                       else
705                               mv ${Makefile} ${subdir}/Makefile.tem
706                               target_makefile_frag=
707                       fi
708                       ;;
709             esac
710             # real copy now in ${subdir}/Makefile.tem
711
712             # Conditionalize the makefile for this package.
713             rm -f ${Makefile}
714             case "${package_makefile_frag}" in
715               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
716               *)
717                       if [ ! -f ${package_makefile_frag} ] ; then
718                               package_makefile_frag=${srcdir}/${package_makefile_frag}
719                       fi
720                       if [ -f ${package_makefile_frag} ] ; then
721                               sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
722                       else
723                               echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
724                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
725                               mv ${subdir}/Makefile.tem ${Makefile}
726                       fi
727             esac
728             # working copy now in ${Makefile}
729
730             mv ${Makefile} ${subdir}/Makefile.tem
731
732             # real copy now in ${subdir}/Makefile.tem
733
734             # prepend warning about editting, and a bunch of variables.
735             rm -f ${Makefile}
736             cat > ${Makefile} <<EOF
737 # ${NO_EDIT}
738 VPATH = ${makesrcdir}
739 links = ${configlinks}
740 host_alias = ${host_alias}
741 host_cpu = ${host_cpu}
742 host_vendor = ${host_vendor}
743 host_os = ${host_os}
744 host_canonical = ${host_cpu}-${host_vendor}-${host_os}
745 target_alias = ${target_alias}
746 target_cpu = ${target_cpu}
747 target_vendor = ${target_vendor}
748 target_os = ${target_os}
749 target_canonical = ${target_cpu}-${target_vendor}-${target_os}
750 EOF
751             case "${package_makefile_frag}" in
752               "") ;;
753               /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
754               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
755             esac
756
757             case "${target_makefile_frag}" in
758               "") ;;
759               /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
760               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
761             esac
762
763             case "${host_makefile_frag}" in
764               "") ;;
765               /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
766               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
767             esac
768
769             if [ "${site_makefile_frag}" != "" ] ; then
770                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
771             fi 
772
773             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
774             # remove any form feeds.
775             if [ -z "${subdirs}" ]; then
776                 rm -f ${subdir}/Makefile.tem2
777                 sed -e "s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:" \
778                     -e "s:^NONSUBDIRS[  ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
779                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
780                 rm -f ${subdir}/Makefile.tem
781                 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
782             fi
783             sed -e "s:^prefix[  ]*=.*$:prefix = ${prefix}:" \
784                     -e "s:^exec_prefix[         ]*=.*$:exec_prefix = ${exec_prefix}:" \
785                     -e "s:^srcdir[      ]*=.*$:srcdir = ${makesrcdir}:" \
786                     -e "s/\f//" \
787                     -e "s:^program_prefix[      ]*=.*$:program_prefix = ${program_prefix}:" \
788                     -e "s:^program_suffix[      ]*=.*$:program_suffix = ${program_suffix}:" \
789                     -e "s:^program_transform_name[      ]*=.*$:program_transform_name = ${program_transform_name}:" \
790                     -e "s:^tooldir[     ]*=.*$:tooldir = ${tooldir}:" \
791                     ${subdir}/Makefile.tem >> ${Makefile}
792             # final copy now in ${Makefile}
793
794         else
795            echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
796         fi
797
798         rm -f ${subdir}/Makefile.tem
799
800         case "${host_makefile_frag}" in
801         "") using= ;;
802         *) using="and \"${host_makefile_frag}\"" ;;
803         esac
804
805         case "${target_makefile_frag}" in
806         "") ;;
807         *) using="${using} and \"${target_makefile_frag}\"" ;;
808         esac
809
810         case "${site_makefile_frag}" in
811         "") ;;
812         *) using="${using} and \"${site_makefile_frag}\"" ;;
813         esac
814
815         newusing=`echo "${using}" | sed 's/and/using/'`
816         using=${newusing}
817         echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
818
819         . ${tmpfile}.pos
820
821         # describe the chosen configuration in config.status.
822         # Make that file a shellscript which will reestablish
823         # the same configuration.  Used in Makefiles to rebuild
824         # Makefiles.
825
826         case "${norecursion}" in
827         "") arguments="${arguments} -norecursion" ;;
828         *) ;;
829         esac
830
831         if [ ${subdir} = . ] ; then
832             echo "#!/bin/sh
833 # ${NO_EDIT}
834 # This directory was configured as follows:
835 ${progname}" ${arguments}  "
836 # ${using}" > ${subdir}/config.new
837         else
838             echo "#!/bin/sh
839 # ${NO_EDIT}
840 # This directory was configured as follows:
841 cd ${invsubdir}
842 ${progname}" ${arguments}  "
843 # ${using}" > ${subdir}/config.new
844         fi
845         chmod a+x ${subdir}/config.new
846         if [ -r ${subdir}/config.back ] ; then
847                 mv -f ${subdir}/config.back ${subdir}/config.status
848         fi
849         ${moveifchange} ${subdir}/config.new ${subdir}/config.status
850         ;;
851
852     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
853     esac
854 done
855
856 # If there are subdirectories, then recur. 
857 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
858         for configdir in ${configdirs} ; do
859
860                 if [ -d ${srcdir}/${configdir} ] ; then
861                         eval echo Configuring ${configdir}... ${redirect}
862                         case "${srcdir}" in
863                         ".") ;;
864                         *)
865                                 if [ ! -d ./${configdir} ] ; then
866                                         if mkdir ./${configdir} ; then
867                                                 true
868                                         else
869                                                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
870                                                 exit 1
871                                         fi
872                                 fi
873                                 ;;
874                         esac
875
876                         POPDIR=${PWD=`pwd`}
877                         cd ${configdir} 
878
879 ### figure out what to do with srcdir
880                         case "${srcdir}" in
881                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
882                         /*) # absolute path
883                                 newsrcdir=${srcdir}/${configdir}
884                                 srcdiroption="-srcdir=${newsrcdir}"
885                                 ;;
886                         *) # otherwise relative
887                                 newsrcdir=../${srcdir}/${configdir}
888                                 srcdiroption="-srcdir=${newsrcdir}"
889                                 ;;
890                         esac
891
892 ### check for guested configure, otherwise fix possibly relative progname
893                         if [ -f ${newsrcdir}/configure ] ; then
894                                 recprog=${newsrcdir}/configure
895                         else
896                                 case "${progname}" in
897                                 /*)     recprog=${progname} ;;
898                                 *)      recprog=../${progname} ;;
899                                 esac
900                         fi
901
902 ### The recursion line is here.
903                         if eval ${recprog} ${verbose} --host=${host_alias} --target=${target_alias} \
904                                 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
905                                 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${removing} ${redirect} ; then
906                                 true
907                         else
908                                 exit 1
909                         fi
910
911                         cd ${POPDIR}
912                 fi
913         done
914 fi
915
916 exit 0
917
918 #
919 # Local Variables:
920 # fill-column: 131
921 # End:
922 #
923
924 # end of configure