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