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