* configure: Add support for 'subdirs' variable, which is
[external/binutils.git] / configure
1 #!/bin/sh
2
3 # Configuration script
4 #   Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 # Please email any bugs, comments, and/or additions to this file to:
21 # configure@cygnus.com
22
23 # This file was written by K. Richard Pixley.
24
25 #
26 # Shell script to create proper links to machine-dependent files in
27 # preparation for compilation.
28 #
29 # If configure succeeds, it leaves its status in config.status.
30 # If configure fails after disturbing the status quo, 
31 #       config.status is removed.
32 #
33
34 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
35
36 remove=rm
37 hard_link=ln
38 symbolic_link='ln -s'
39
40 #for Test
41 #remove="echo rm"
42 #hard_link="echo ln"
43 #symbolic_link="echo ln -s"
44
45 # clear some things potentially inherited from environment.
46
47 Makefile=Makefile
48 Makefile_in=Makefile.in
49 arguments=$*
50 configdirs=
51 exec_prefix=
52 exec_prefixoption=
53 fatal=
54 floating_point=default
55 gas=default
56 host_alias=
57 host_makefile_frag=
58 next_host=
59 next_prefix=
60 next_site=
61 next_srcdir=
62 next_target=
63 next_tmpdir=
64 norecursion=
65 removing=
66 prefix=/usr/local
67 progname=
68 program_prefix=
69 program_prefix_option=
70 silent=
71 site=
72 site_option=
73 site_makefile_frag=
74 srcdir=
75 srctrigger=
76 subdirs=
77 target_alias=
78 target_makefile_frag=
79 undefinedargs=
80 verbose=
81 version="$Revision$"
82 x11=default
83
84 NO_EDIT="This file was generated automatically by configure.  Do not edit."
85
86 ## this is a little touchy and won't always work, but...
87 ##
88 ## if the argv[0] starts with a slash then it is an absolute name that can (and
89 ## must) be used as is.
90 ##
91 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
92 ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
93 ##
94
95 PWD=`pwd`
96 progname=$0
97
98 case "${progname}" in
99 /*) ;;
100 */*) ;;
101 *)
102         PATH=$PATH:${PWD} ; export PATH
103         ;;
104 esac
105
106 for arg in $*;
107 do
108         # handle things that might have args following as separate words
109         if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
110         elif [ -n "${next_exec_prefix}" ] ; then
111                 exec_prefix=${arg}
112                 exec_prefixoption="-exec_prefix=${exec_prefix}"
113                 next_exec_prefix=
114         elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
115         # remove any possible trailing slash from srcdir.  See note below.
116         elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
117         elif [ -n "${next_program_prefix}" ] ; then
118                 program_prefix=${arg}
119                 program_prefixoption="-program_prefix=${program_prefix}"
120                 next_program_prefix=
121         elif [ -n "${next_target}" ] ; then
122                 next_target=
123                 case "${target_alias}" in
124                 "")
125                         target_alias="${arg}"
126                         ;;
127                 *)
128                         echo '***' Can only configure for one target at a time.  1>&2
129                         fatal=yes
130                         ;;
131                 esac
132         elif [ -n "${next_tmpdir}" ] ; then
133                 next_tmpdir=
134                 tmpdiroption="--tmpdir=${arg}"
135                 TMPDIR=${arg}
136
137         else
138                 case ${arg} in
139                 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
140                         exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
141                         exec_prefixoption=${arg}
142                         ;;
143                 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
144                         next_exec_prefix=yes
145                         ;;
146                 -gas | --g*)
147                         gas=yes
148                         ;;
149                 -help | --he*)
150                         fatal=true
151                         ;;
152                 -host=* | --host=* | --hos=* | --ho=*)
153                         case "${host_alias}" in
154                         "")
155                                 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
156                                 ;;
157                         *)
158                                 echo '***' Can only configure for one host at a time.  1>&2
159                                 fatal=yes
160                                 ;;
161                         esac
162                         ;;
163                 -nfp | --nf*)
164                         floating_point=no
165                         ;;
166                 -norecursion | --no*)
167                         norecursion=true
168                         ;;
169                 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
170                         prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
171                         prefixoption=${arg}
172                         ;;
173                 -prefix | --prefix | --prefi | --pref | --pre)
174                         next_prefix=yes
175                         ;;
176                 -rm | --rm) removing=${arg} ;;
177                 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | --program_=* | --program=* | --progra=* | --progr=* | --prog=* | --pro=*)
178                         program_prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
179                         program_prefixoption=${arg}
180                         ;;
181                 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | --program_ | --program | --progra | --progr | --prog | --pro)
182                         next_program_prefix=yes
183                         ;;
184                 -s | -silent | --silent | --silen | --sile | --sil)
185                         silent=true
186                         arguments=`echo ${arguments} | sed "s:${arg}::"`
187                         ;;
188                 -site=* | --site=* | --sit=* | --si=*)
189                         site_option=${arg}
190                         site=`echo ${arg} | sed 's/^[-a-z]*=//'`
191                         ;;
192                 -site | --site | --sit)
193                         next_site=yes
194                         ;;
195                 # remove trailing slashes.  Otherwise, when the file name gets
196                 # bolted into an object file as debug info, it has two slashes in
197                 # it.  Ordinarily this is ok, but emacs takes double slash to
198                 # mean "forget the first part".
199                 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
200                         srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
201                         ;;
202                 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
203                         next_srcdir=yes
204                         ;;
205                 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
206                         case "${target_alias}" in
207                         "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
208                         *)
209                                 echo '***' Can only configure for one target at a time.  1>&2
210                                 fatal=yes
211                                 ;;
212                         esac
213                         ;;
214                 -target | --target | --targe | --targ | --tar | --ta)
215                         next_target=yes
216                         ;;
217                 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
218                         tmpdiroption=${arg}
219                         TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
220                         ;;
221                 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
222                         next_tmpdir=yes
223                         ;;
224                 -v | -verbose | --v)
225                         verbose=${arg}
226                         ;;
227                 -version | -V | --version | --V)
228                         echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
229                         exit 0
230                         ;;
231                 -x | --x) ;;
232                 -* | --*)
233                         (echo ;
234                         echo "Unrecognized option: \"${arg}\"". ;
235                         echo) 1>&2
236                         fatal=true
237                         ;;
238                 *)
239                         case "${undefs}" in
240                         "")
241                                 undefs="${arg}"
242                                 ;;
243                         *)
244                                 echo '***' Can only configure for one host and one target at a time.  1>&2
245                                 fatal=yes
246                                 ;;
247                         esac
248                         ;;
249                 esac
250         fi
251 done
252
253 # process host and target
254 case "${fatal}" in
255 "")
256 #       # Complain if an arg is missing
257 #       if [ -z "${host_alias}" ] ; then
258 #               (echo ;
259 #               echo "configure: No HOST specified." ;
260 #               echo) 1>&2
261 #               fatal=true
262 #       fi
263
264 ### This is a bit twisted.
265 ### * if all three are specified, this is an error.
266 ### * if we have neither hosts, nor unadorned args, this is an error.
267 ### * if no hosts are specified, then the unadorned args are hosts, but if
268 ### there were none, this is an error.
269 ### * if no targets are specified, then the unadorned args are targets, but if
270 ### there were no unadorned args, then the hosts are also targets.
271
272         if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
273                 echo '***' Can only configure for one host and one target at a time.  1>&2
274                 fatal=yes
275         elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
276                 echo '***' You must tell me for which host you want to configure.  1>&2
277                 fatal=yes
278         else
279                 case "${host_alias}" in
280                 "") host_alias=${undefs} ;;
281                 *) ;;
282                 esac
283
284                 case "${target_alias}" in
285                 "")
286                         case "${undefs}" in
287                         "")     target_alias=${host_alias} ;;
288                         *)      target_alias=${undefs} ;;
289                         esac
290                         ;;
291                 *) ;;
292                 esac
293         fi
294         ;;
295 *) ;;
296 esac
297
298 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
299         (echo "Usage: configure HOST" ;
300         echo ;
301         echo "Options: [defaults in brackets]" ;
302         echo " -exec_prefix=MYDIR       configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
303         echo " -gas                     configure the compilers for use with gas. [native as]" ;
304         echo " -help                    print this message. [normal config]" ;
305         echo " -lang=LANG               configure to build LANG. [gcc]" ;
306         echo " -nfp                     configure the compilers default to soft floating point. [hard float]" ;
307         echo " -norecursion             configure this directory only. [recurse]" ;
308         echo " -prefix=MYDIR            configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
309         echo " -program_prefix=FOO      install programs with FOO prepended to their names. [ \"\" ]" ;
310         echo " -site=SITE               configure with site specific makefile for SITE" ;
311         echo " -srcdir=DIR              find the sources in DIR. [\".\" or \"..\"]" ;
312         echo " -target=TARGET           configure for TARGET.  [TARGET = HOST]" ;
313         echo " -tmpdir=TMPDIR           create temporary files in TMPDIR.  [ TMPDIR = \"/tmp\" ]" ;
314         echo ;
315         echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
316         ) 1>&2
317
318         if [ -r config.status ] ; then
319                 cat config.status
320         fi
321
322         exit 1
323 fi
324
325 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
326
327 if ${configsub} `echo ${host_alias} | sed -e 's/ .*//'` >/dev/null 2>&1 ; then
328         true
329 else
330         echo '***' cannot find config.sub.  1>&2
331         exit 1
332 fi
333
334 case "${srcdir}" in
335 "")
336         if [ -r configure.in ] ; then
337                 srcdir=.
338         else
339                 if [ -r ${progname}.in ] ; then
340                         srcdir=`echo ${progname} | sed 's:/configure$::'`
341                 else
342                         echo '***' "Can't find configure.in.  Try using -srcdir=some_dir"  1>&2
343                         exit 1
344                 fi
345         fi
346         ;;
347 *) ;;
348 esac
349
350 ### warn about some conflicting configurations.
351
352 case "${srcdir}" in
353 ".") ;;
354 *)
355         if [ -f ${srcdir}/config.status ] ; then
356                 echo '***' Cannot configure here in \"${PWD}\" when \"${srcdir}\" is currently configured. 1>&2
357                 exit 1
358         fi
359 esac
360
361 # default exec_prefix
362 case "${exec_prefix}" in
363 "") exec_prefix="\$(prefix)" ;;
364 *) ;;
365 esac
366
367 ### break up ${srcdir}/configure.in.
368 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
369 "")
370         echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
371         exit 1
372         ;;
373 *) ;;
374 esac
375
376 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
377 "")
378         echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
379         exit 1
380         ;;
381 *) ;;
382 esac
383
384 case "${TMPDIR}" in
385 "") TMPDIR=/tmp ; export TMPDIR ;;
386 *) ;;
387 esac
388
389 # keep this filename short for &%*%$*# 14 char file names
390 tmpfile=${TMPDIR}/cONf$$
391 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
392
393 # split ${srcdir}/configure.in into common, per-host, per-target,
394 # and post-target parts.  Post-target is optional.
395 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
396 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
397 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
398   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
399   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
400 else
401   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
402   echo >${tmpfile}.pos
403 fi
404
405 ### do common part of configure.in
406
407 . ${tmpfile}.com
408
409 # some sanity checks on configure.in
410 case "${srctrigger}" in
411 "")
412         echo '***' srctrigger not set in ${PWD}/configure.in.  1>&2
413         exit 1
414         ;;
415 *) ;;
416 esac
417
418 result=`${configsub} ${host_alias}`
419 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
420 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
421 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
422 host=${host_cpu}-${host_vendor}-${host_os}
423
424 . ${tmpfile}.hst
425
426 result=`${configsub} ${target_alias}`
427 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
428 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
429 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
430 target=${target_cpu}-${target_vendor}-${target_os}
431
432 . ${tmpfile}.tgt
433
434 # Find the source files, if location was not specified.
435 case "${srcdir}" in
436 "")
437         srcdirdefaulted=1
438         srcdir=.
439         if [ ! -r ${srctrigger} ] ; then
440                 srcdir=..
441         fi
442         ;;
443 *) ;;
444 esac
445
446 if [ ! -r ${srcdir}/${srctrigger} ] ; then
447         case "${srcdirdefaulted}" in
448         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 ;;
449         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 ;;
450         esac
451
452         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
453         exit 1
454 fi
455
456 for subdir in . ${subdirs} ; do
457
458     # ${subdir} is relative path from . to the directory we're currently
459     # configuring.
460     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
461     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
462
463     ### figure out what to do with srcdir
464     case "${srcdir}" in
465         ".")  # no -srcdir option.  We're building in place.
466                 makesrcdir=. ;;
467         /*) # absolute path
468                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
469                 ;;
470         *) # otherwise relative
471                 makesrcdir=../${srcdir}/${subdir}
472                 ;;
473     esac
474
475     if [ "${subdir}/" != "./" ] ; then
476         Makefile=${subdir}/Makefile
477     fi
478
479     case "${removing}" in
480     "")
481         if [ -n "${verbose}" -o -z "${silent}" ] ; then
482             echo Building in ${subdir}
483         fi
484         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
485         # Set up the list of links to be made.
486         # ${links} is the list of link names, and ${files} is the list of names to link to.
487
488         # Make the links.
489         configlinks="${links}"
490         while [ -n "${files}" ] ; do
491                 # set file to car of files, files to cdr of files
492                 set ${files}; file=$1; shift; files=$*
493                 set ${links}; link=$1; shift; links=$*
494
495                 if [ ! -r ${srcdir}/${file} ] ; then
496                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
497                         echo '***' "since the file \"${file}\" does not exist." 1>&2
498                         exit 1
499                 fi
500
501                 ${remove} -f ${link}
502                 rm -f config.status
503                 # Make a symlink if possible, otherwise try a hard link
504                 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
505
506                 if [ ! -r ${link} ] ; then
507                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
508                         exit 1
509                 fi
510
511                 case "${verbose}" in
512                 "") ;;
513                 *)  echo "Linked \"${link}\" to \"${srcdir}/${file}\"." ;;
514                 esac
515         done
516
517         # Create a .gdbinit file which runs the one in srcdir
518         # and tells GDB to look there for source files.
519
520         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
521                 case ${srcdir} in
522                 .)
523                         ;;
524                 *) cat > ${subdir}/.gdbinit <<EOF
525 # ${NO_EDIT}
526 dir .
527 dir ${makesrcdir}
528 source ${makesrcdir}/.gdbinit
529 EOF
530                         ;;
531                 esac
532         fi
533
534         # Install a makefile, and make it set VPATH
535         # if necessary so that the sources are found.
536         # Also change its value of srcdir.
537         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
538         # been somewhat optimized and is perhaps a bit twisty.
539
540         # code is order so as to try to sed the smallest input files we know.
541
542         # the three makefile fragments MUST end up in the resulting Makefile in this order: target, host, and site.
543         # so do these separately because I don't trust the order of sed -e expressions.
544
545         # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
546         case "${site}" in
547         "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
548         *)
549                 site_makefile_frag=${srcdir}/config/ms-${site}
550
551                 if [ -f ${site_makefile_frag} ] ; then
552                         sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
553                                 > ${subdir}/Makefile.tem
554                 else
555                         cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
556                         site_makefile_frag=
557                 fi
558                 ;;
559         esac
560         # working copy now in ${subdir}/Makefile.tem
561
562         # Conditionalize the makefile for this host.
563         case "${host_makefile_frag}" in
564         "") mv ${subdir}/Makefile.tem ${Makefile} ;;
565         *)
566                 if [ ! -f ${host_makefile_frag} ] ; then
567                         host_makefile_frag=${srcdir}/${host_makefile_frag}
568                 fi
569                 if [ -f ${host_makefile_frag} ] ; then
570                         sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
571                 else
572                         echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
573                         echo '***' is missing in ${PWD}. 1>&2
574                         mv ${subdir}/Makefile.tem ${Makefile}
575                 fi
576         esac
577         # working copy now in ${Makefile}
578
579         # Conditionalize the makefile for this target.
580         case "${target_makefile_frag}" in
581         "") mv ${Makefile} ${subdir}/Makefile.tem ;;
582         *)
583                 target_makefile_frag=${srcdir}/${target_makefile_frag}
584                 if [ -f ${target_makefile_frag} ] ; then
585                         sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
586                 else
587                         mv ${Makefile} ${subdir}/Makefile.tem
588                         target_makefile_frag=
589                 fi
590                 ;;
591         esac
592         # real copy now in ${subdir}/Makefile.tem
593
594         # prepend warning about editting, and a bunch of variables.
595         cat > ${Makefile} <<EOF
596 # ${NO_EDIT}
597 VPATH = ${makesrcdir}
598 links = ${configlinks}
599 host_alias = ${host_alias}
600 host_cpu = ${host_cpu}
601 host_vendor = ${host_vendor}
602 host_os = ${host_os}
603 target_alias = ${target_alias}
604 target_cpu = ${target_cpu}
605 target_vendor = ${target_vendor}
606 target_os = ${target_os}
607 EOF
608         if [ "${target_makefile_frag}" != "" ] ; then
609             echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile}
610         fi 
611         if [ "${host_makefile_frag}" != "" ] ; then
612             echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile}
613         fi 
614         if [ "${site_makefile_frag}" != "" ] ; then
615             echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
616         fi 
617
618         # fixme: this shouldn't be in configure.
619         # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
620         case "${host_alias}" in
621         "${target_alias}")
622                 tooldir="\$(libdir)"
623                 echo "ALL=all.internal" >> ${Makefile}
624                 ;;
625         *)
626                 echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
627                 echo "ALL=all.cross" >> ${Makefile}
628                 case "${program_prefix}" in
629                 "")     program_prefix=${target_alias}- ;;
630                 *)      ;;
631                 esac
632
633                 tooldir="\$(libdir)/${target_alias}"
634                 ;;
635         esac
636
637         # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
638         # remove any form feeds.
639         if [ -z "${subdirs}" ]; then
640             sed -e "s:^SUBDIRS[         ]*=.*$:SUBDIRS = ${configdirs}:" \
641                 -e "s:^NONSUBDIRS[      ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
642                 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
643             mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
644         fi
645         sed -e "s:^prefix[      ]*=.*$:prefix = ${prefix}:" \
646                 -e "s:^exec_prefix[     ]*=.*$:exec_prefix = ${exec_prefix}:" \
647                 -e "s:^srcdir[  ]*=.*$:srcdir = ${makesrcdir}:" \
648                 -e "s/\f//" \
649                 -e "s:^program_prefix[  ]*=.*$:program_prefix = ${program_prefix}:" \
650                 -e "s:^tooldir[         ]*=.*$:tooldir = ${tooldir}:" \
651                 ${subdir}/Makefile.tem >> ${Makefile}
652         # final copy now in ${Makefile}
653
654         rm ${subdir}/Makefile.tem
655
656         if [ -n "${verbose}" -o -z "${silent}" ] ; then
657                 case "${host_makefile_frag}" in
658                 "") using= ;;
659                 *) using="and \"${host_makefile_frag}\"" ;;
660                 esac
661
662                 case "${target_makefile_frag}" in
663                 "") ;;
664                 *) using="${using} and \"${target_makefile_frag}\"" ;;
665                 esac
666
667                 case "${site_makefile_frag}" in
668                 "") ;;
669                 *) using="${using} and \"${site_makefile_frag}\"" ;;
670                 esac
671
672                 echo "Created \"${Makefile}\" in" ${PWD} `echo "${using}" | sed 's/and/using/'`
673         fi
674
675         . ${tmpfile}.pos
676
677         # describe the chosen configuration in config.status.
678         # Make that file a shellscript which will reestablish
679         # the same configuration.  Used in Makefiles to rebuild
680         # Makefiles.
681
682         case "${norecursion}" in
683         "") arguments="${arguments} -norecursion" ;;
684         *) ;;
685         esac
686
687         if [ ${subdir} = . ] ; then
688             echo "#!/bin/sh
689 # ${NO_EDIT}
690 # ${PWD} was configured as follows:
691 ${progname}" ${arguments}  "
692 # ${using}" > ${subdir}/config.status
693         else
694             echo "#!/bin/sh
695 # ${NO_EDIT}
696 # ${PWD}/${subdir} was configured as follows:
697 cd ${invsubdir}
698 ${progname}" ${arguments}  "
699 # ${using}" > ${subdir}/config.status
700         fi
701         chmod a+x ${subdir}/config.status
702         ;;
703
704     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
705     esac
706 done
707
708 # If there are subdirectories, then recur. 
709 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
710         for configdir in ${configdirs} ; do
711                 case "${verbose}" in
712                 "") ;;
713                 *) echo Configuring ${configdir}... ;;
714                 esac
715
716                 if [ -d ${srcdir}/${configdir} ] ; then
717                         case "${srcdir}" in
718                         ".") ;;
719                         *)
720                                 if [ ! -d ./${configdir} ] ; then
721                                         mkdir ./${configdir}
722                                 fi
723                                 ;;
724                         esac
725
726                         POPDIR=${PWD}
727                         cd ${configdir} 
728
729 ### figure out what to do with srcdir
730                         case "${srcdir}" in
731                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
732                         /*) # absolute path
733                                 newsrcdir=${srcdir}/${configdir}
734                                 srcdiroption="-srcdir=${newsrcdir}"
735                                 ;;
736                         *) # otherwise relative
737                                 newsrcdir=../${srcdir}/${configdir}
738                                 srcdiroption="-srcdir=${newsrcdir}"
739                                 ;;
740                         esac
741
742 ### check for guested configure, otherwise fix possibly relative progname
743                         if [ -f ${newsrcdir}/configure ] ; then
744                                 recprog=${newsrcdir}/configure
745                         else
746                                 case "${progname}" in
747                                 /*)     recprog=${progname} ;;
748                                 *)      recprog=../${progname} ;;
749                                 esac
750                         fi
751
752 ### The recursion line is here.
753                         if ${recprog} -s ${host_alias} -target=${target_alias} \
754                                 ${verbose} ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
755                                 ${srcdiroption} ${program_prefixoption} ${site_option} ${removing} ; then
756                                 true
757                         else
758                                 exit 1
759                         fi
760
761                         cd ${POPDIR}
762                 else
763                         case "${verbose}" in
764                         "") ;;
765                         *) echo Warning: source directory \"${srcdir}/${configdir}\" is missing. ;;
766                         esac
767                 fi
768         done
769 fi
770
771 ### clean up.
772
773 # trap cmd above handles this now:
774 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
775
776 exit 0
777
778 #
779 # Local Variables:
780 # fill-column: 131
781 # End:
782 #
783
784 # end of configure