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