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