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