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