Passes down version_path for things which install themselves into
[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 export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
37
38 #set -e
39
40 remove=rm
41 hard_link=ln
42 symbolic_link='ln -s'
43
44 #for Test
45 #remove="echo rm"
46 #hard_link="echo ln"
47 #symbolic_link="echo ln -s"
48
49 # clear some things potentially inherited from environment.
50
51 Makefile=Makefile
52 Makefile_in=Makefile.in
53 ansi=
54 arguments=$*
55 commontargets=
56 configdirs=
57 ddestdir=
58 defaulttargets=
59 destdir=
60 fatal=
61 hostsubdir=
62 idestdir=
63 next_ddestdir=
64 next_destdir=
65 next_idestdir=
66 next_objdir=
67 next_site=
68 next_target=
69 next_tmpdir=
70 norecursion=
71 objdir=
72 objdiroption=
73 progname=
74 recurring=
75 removing=
76 srcdir=
77 srctrigger=
78 target=
79 targets=
80 targetsubdir=
81 verbose=
82 # or maybe grab from gcc/version.c
83 version_path="1.95.02"
84 for arg in $*;
85 do
86         # handle things that might have args following as separate words
87         if [ -n "${next_ddestdir}" ] ; then ddestdir=${arg} ; next_ddestdir=
88         elif [ -n "${next_destdir}" ] ; then destdir=${arg} ; next_destdir= ; ddestdir=${destdir} ; idestdir=${destdir}
89         elif [ -n "${next_idestdir}" ] ; then idestdir=${arg} ; next_idestdir=
90         elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; next_objdir=
91         elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
92         elif [ -n "${next_target}" ] ; then
93                 next_target=
94                 if [ -n "${targets}" ] ; then
95                         subdirs="+subdirs"
96                 fi
97
98                 newtargets="${targets} ${arg}"
99                 targets="${newtargets}"
100
101         elif [ -n "${next_tmpdir}" ] ; then
102                 next_tmpdir=
103                 tmpdiroption="+tmpdir=${arg}"
104                 TMPDIR=${arg}
105
106         else
107                 case ${arg} in
108                 -ansi | +a*)
109                         ansi=true
110                         clib=clib
111                         ;;
112                 -noversion | +noversion)
113                         version_path=""
114                         ;;
115                 -ddestdir=* | +ddestdir=* | +ddestdi=* | +ddestd=* | +ddest=* | +ddes=* | +dde=* | +dd=*)
116                         ddestdir=`echo ${arg} | sed 's/[+-]dd[a-z]*=//'`
117                         ;;
118                 -ddestdir | +ddestdir | +ddestdi | +ddestd | +ddest | +ddes | +dde | +dd)
119                         next_ddestdir=yes
120                         ;;
121                 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=*)
122                         destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
123                         ddestdir=${destdir}
124                         idestdir=${destdir}
125                         ;;
126                 -destdir | +destdir | +destdi | +destd | +dest | +des | +de)
127                         next_destdir=yes
128                         ;;
129                 -gas | +g*)
130                         gas=yes
131                         ;;
132                 -help | +h*)
133                         fatal=true
134                         ;;
135                 -idestdir=* | +idestdir=* | +idestdi=* | +idestd=* | +idest=* | +ides=* | +ide=* | +id=*)
136                         idestdir=`echo ${arg} | sed 's/[+-]id[a-z]*=//'`
137                         ;;
138                 -idestdir | +idestdir | +idestdi | +idestd | +idest | +ides | +ide | +id)
139                         next_idestdir=yes
140                         ;;
141                 -languages=* | +languages=* | +language=* | +languag=* \
142                         | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
143                         | +l=*)
144                         languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
145                         ;;
146                 -nfp | +nf*)
147                         nfp=yes
148                         ;;
149                 -norecursion | +no*)
150                         norecursion=true
151                         ;;
152                 -objdir=* | +objdir=* | +objdi=* | +objd=* | +obj=* | +ob=* | +o=*)
153                         objdiroption=${arg}
154                         objdir=`echo ${arg} | sed 's/[+-]o[a-z]*=//'`
155                         ;;
156                 -objdir | +objdir | +objdi | +objd | +obj | +ob | +o)
157                         next_objdir=yes
158                         ;;
159                 -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re)
160                         recurring=true
161                         arguments=`echo ${arguments} | sed "s:${arg}::"`
162                         ;;
163                 -rm | +rm)
164                         removing=${arg}
165                         ;;
166                 -site=* | +site=* | +sit=* | +si=*)
167                         site=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
168                         ;;
169                 -site | +site | +sit | +si)
170                         next_site=yes
171                         ;;
172         #       -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=*)
173         #               srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
174         #               ;;
175                 -subdirs | +su*)
176                         subdirs=${arg}
177                         ;;
178                 -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*)
179                         if [ -n "${targets}" ] ; then
180                                 subdirs="+subdirs"
181                         fi
182
183                         newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
184                         targets="${newtargets}"
185                         ;;
186                 -target | +target | +targe | +targ | +tar | +ta)
187                         next_target=yes
188                         ;;
189                 -tmpdir=* | +tmpdir=* | +tmpdi=* | +tmpd=* | +tmp=* | +tm=*)
190                         tmpdiroption=${arg}
191                         TMPDIR=`echo ${arg} | sed 's/[+-]t[a-z]*=//'`
192                         ;;
193                 -tmpdir | +tmpdir | +tmpdi | +tmpd | +tmp | +tm)
194                         next_tmpdir=yes
195                         ;;
196                 -v | -verbose | +v*)
197                         verbose=${arg}
198                         ;;
199                 -* | +*)
200                         (echo ;
201                         echo "Unrecognized option: \"${arg}\"". ;
202                         echo) 1>&2
203                         fatal=true
204                         ;;
205                 *)
206                         if [ -n "${hosts}" ] ; then
207                                 subdirs="+subdirs"
208                         fi
209
210                         newhosts="${hosts} ${arg}"
211                         hosts=${newhosts}
212                         ;;
213                 esac
214         fi
215 done
216
217 if [ -n "${verbose}" ] ; then
218         echo $0 $*
219 fi
220
221 ## this is a little touchy and won't always work, but...
222 ##
223 ## if the argv[0] starts with a slash then it is an absolute name that can be
224 ## used as is.
225 ##
226 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
227 ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
228 ##
229 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
230 ## path.
231 ##
232
233 if (echo $0 | grep '^/' > /dev/null) ; then
234         progname=$0
235 else
236         if (echo $0 | grep '/' > /dev/null) ; then
237                 progname=`pwd`/$0
238         else
239                 progname=$0
240                 PATH=$PATH:`pwd` ; export PATH
241         fi
242 fi
243
244 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
245
246 if ${configsub} none >/dev/null 2>&1 ; then
247         true
248 else
249         echo '***' cannot find config.sub.
250         echo 1
251 fi
252
253 # process host and target only if not removing.
254 if [ -z "${removing}" -a -z "${fatal}" ] ; then
255         # Complain if an arg is missing
256         if [ -z "${hosts}" ] ; then
257                 (echo ;
258                 echo "configure: No HOST specified." ;
259                 echo) 1>&2
260                 fatal=true
261         fi
262 fi
263
264 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
265         (echo "Usage: configure HOST" ;
266         echo ;
267         echo "Options: [defaults in brackets]" ;
268         echo " +ansi            configure w/ANSI library. [no ansi lib]" ;
269         echo " +ddestdir=MYDIR  configure for installation host dependent files" ;
270         echo "                  into MYDIR. [\"/usr/local\"]" ;
271         echo " +idestdir=MYDIR  configure for installation host independent files" ;
272         echo "                  into MYDIR. [\"/usr/local\"]" ;
273         echo " +destdir=MYDIR   configure for installation of both host dependent and" ;
274         echo "                  host independent files into MYDIR. [\"/usr/local\"]" ;
275         echo " +gas             configure the compilers for use with gas. [native as]" ;
276         echo " +help            print this message. [normal config]" ;
277         echo " +lang=LANG       configure to build LANG. [gcc]" ;
278         echo " +nfp             configure the compilers default to soft floating point. [hard float]" ;
279         echo " +norecursion     configure this directory only. [recurse]" ;
280         echo " +objdir=ODIR     configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
281         echo " +rm              remove this configuration. [build a configuration]" ;
282         echo " +site            configure with site specific makefile" ;
283 # This is correctly aligned in the output, even though it isn't here.
284         echo " +subdirs configure in subdirectories.  [in source directories]" ;
285         echo " +target=TARGET   configure for TARGET.  [TARGET = HOST]" ;
286         echo " +tmpdir=TMPDIR   create temporary files in TMPDIR.  [ TMPDIR = \"/tmp\" ]" ;
287         echo ;
288         echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
289         echo "Asking for more than one \"+target\" implies \"+subdirs\".  Any other" ;
290         echo "options given will apply to all targets.") 1>&2
291
292         if [ -r config.status ] ; then
293                 cat config.status
294         fi
295
296         exit 1
297 fi
298
299 ### break up configure.in.
300 if [ -r configure.in ] ; then
301         if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
302                 echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2
303                 exit 1
304         fi
305
306         if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
307                 echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2
308                 exit 1
309         fi
310
311         if [ -z "${TMPDIR}" ] ; then
312                 TMPDIR=/tmp ; export TMPDIR
313         fi
314
315         # keep this filename short for &%*%$*# 14 char file names
316         tmpfile=${TMPDIR}/cONf$$
317
318         # split configure.in into common, per-host, per-target,
319         # and post-target parts.  Post-target is optional.
320         sed -e '/^# per\-host:/,$d' configure.in > ${tmpfile}.com
321         sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > ${tmpfile}.hst
322         if grep '^# post-target:' configure.in >/dev/null ; then
323           sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > ${tmpfile}.tgt
324           sed -e '1,/^# post\-target:/d' configure.in > ${tmpfile}.pos
325         else
326           sed -e '1,/^# per\-target:/d' configure.in > ${tmpfile}.tgt
327           echo >${tmpfile}.pos
328         fi
329
330 else
331         echo '***' No configure.in in `pwd`
332         exit 1
333 fi
334
335 ### do common part of configure.in
336
337 . ${tmpfile}.com
338
339 # some sanity checks on configure.in
340 if [ -z "${srctrigger}" ] ; then
341         echo '***' srctrigger not set in `pwd`/configure.in.
342         exit 1
343 fi
344
345 for host in ${hosts} ; do
346         # Default other arg
347         if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
348                 targets=${host}
349                 defaulttargets=true
350         fi
351
352         host_alias=${host}
353
354         result=`${configsub} ${host}`
355         host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
356         host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
357         host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
358         host=${host_cpu}-${host_vendor}-${host_os}
359         host_makefile_frag=config/mh-${host}
360         if [ ! -f ${host_makefile_frag} ]
361         then
362                 host_makefile_frag=config/mh-${host_alias}
363         fi
364
365         . ${tmpfile}.hst
366
367         for target in ${targets} ; do
368
369                 target_alias=${target}
370                 result=`${configsub} ${target}`
371                 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
372                 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
373                 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
374                 target=${target_cpu}-${target_vendor}-${target_os}
375                 target_makefile_frag=config/mt-${target}
376                 if [ ! -f ${target_makefile_frag} ]
377                 then
378                         target_makefile_frag=config/mt-${target_alias}
379                 fi
380
381                 . ${tmpfile}.tgt
382
383                 hostsubdir=H-${host_alias}
384                 targetsubdir=T-${target_alias}
385
386                 if [ -n "${removing}" ] ; then
387                         if [ -n "${objdir}" ] ; then
388                                 echo '***' +rm not supported for +objdir.  Just \"rm -rf ${objdir}\" by hand.
389                                 exit 1
390                         fi
391
392                         if [ -n "${subdirs}" ] ; then
393                                 if [ -d "${hostsubdir}" ] ; then
394                                         rm -rf ${hostsubdir}/${targetsubdir}
395
396                                         if [ -z "`(ls ${hostsubdir}) 2>&1 | grep T- | grep -v T-independent`" ] ; then
397                                                 rm -rf ${hostsubdir}
398                                         fi
399                                 else
400                                         echo Warning: no `pwd`/${hostsubdir} to remove.
401                                 fi
402                         else
403                                 rm -f ${Makefile} config.status ${links}
404                         fi
405                 else
406                         if [ -n "${objdir}" ]; then
407                                 srcdir=`pwd`
408                                 cd ${objdir}
409                         fi
410
411                         if [ -n "${subdirs}" ] ; then
412                                 # check for existing status before allowing forced subdirs.
413                                 if [ -f ${Makefile} ] ; then
414                                         echo '***' "${Makefile} already exists in source directory.  `pwd` not configured." 1>&2
415                                         exit 1
416                                 fi
417
418                                 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
419                                 cd ${hostsubdir}
420
421                                 if [ ! -d ${targetsubdir} ] ; then
422                                         if [ -z "${commontargets}" ] ; then
423                                                 mkdir ${targetsubdir}
424                                         else
425                                                 if [ ! -d T-independent ] ; then
426                                                         mkdir T-independent
427                                                 fi
428
429                                                 ${symbolic_link} T-independent ${targetsubdir}
430                                         fi # if target independent
431                                 fi # if no target dir yet
432
433                                 cd ${targetsubdir}
434
435                                 if [ -z "${srcdir}" ] ; then
436                                         srcdir=../..
437                                 fi
438                         else
439                                 # if not subdir builds, then make sure none exist.
440                                 if [ -n "`(ls .) 2>&1 | (grep H- ; true)`" ] ; then
441                                         echo '***' "Configured subdirs exist.  `pwd` not configured." 1>&2
442                                         exit 1
443                                 else
444                                         true
445                                 fi
446                         fi
447
448                         # Find the source files, if location was not specified.
449                         if [ -z "${srcdir}" ] ; then
450                                 srcdirdefaulted=1
451                                 srcdir=.
452                                 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
453                                         srcdir=..
454                                 fi
455                         fi
456
457                         if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
458                                 if [ -z "${srcdirdefaulted}" ] ; then
459                                         echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
460                                 else
461                                         echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
462                                 fi
463
464                                 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
465                                 exit 1
466                         fi
467
468                         # Set up the list of links to be made.
469                         # ${links} is the list of link names, and ${files} is the list of names to link to.
470
471                         # Make the links.
472                         while [ -n "${files}" ] ; do
473                                 # set file to car of files, files to cdr of files
474                                 set ${files}; file=$1; shift; files=$*
475                                 set ${links}; link=$1; shift; links=$*
476
477                                 if [ ! -r ${srcdir}/${file} ] ; then
478                                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
479                                         echo '***' "since the file \"${file}\" does not exist." 1>&2
480                                         exit 1
481                                 fi
482
483                                 ${remove} -f ${link}
484                                 rm -f config.status
485                                 # Make a symlink if possible, otherwise try a hard link
486                                 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
487
488                                 if [ ! -r ${link} ] ; then
489                                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
490                                         exit 1
491                                 fi
492
493                                 if [ -n "${verbose}" ] ; then
494                                         echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
495                                 fi
496                         done
497
498                         # Create a .gdbinit file which runs the one in srcdir
499                         # and tells GDB to look there for source files.
500
501                         case ${srcdir} in
502                         .)
503                                 ;;
504                         *)
505                                 echo "dir ." > .gdbinit
506                                 echo "dir ${srcdir}" >> .gdbinit
507                                 echo "source ${srcdir}/.gdbinit" >> .gdbinit
508                                 ;;
509                         esac
510
511                         # Install a makefile, and make it set VPATH
512                         # if necessary so that the sources are found.
513                         # Also change its value of srcdir.
514
515                 # FIXME-someday: This business of always writing to .tem and mv back
516                 # is so that I don't screw things up while developing.  Once this
517                 # template is stable, these should be optimized. xoxorich.
518
519                         # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
520                         if [ "${host}" != "${target}" ] ; then
521                                 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
522                                 echo "ALL=start.encap" >> ${Makefile}
523                         else
524                                 echo "ALL=all.internal" > ${Makefile}
525                         fi
526
527                         # set target, host, VPATH
528                         echo "host_alias = ${host_alias}" >> ${Makefile}
529                         echo "host_cpu = ${host_cpu}" >> ${Makefile}
530                         echo "host_vendor = ${host_vendor}" >> ${Makefile}
531                         echo "host_os = ${host_os}" >> ${Makefile}
532                         echo "version_path = ${version_path}" >> ${Makefile}
533                         echo "target_alias = ${target_alias}" >> ${Makefile}
534                         echo "target_cpu = ${target_cpu}" >> ${Makefile}
535                         echo "target_vendor = ${target_vendor}" >> ${Makefile}
536                         echo "target_os = ${target_os}" >> ${Makefile}
537
538                         if [ -n "${subdirs}" ] ; then
539                                 (echo "subdir = /${hostsubdir}/${targetsubdir}" ;
540                                         echo "unsubdir = ../..") >> ${Makefile}
541                         else
542                                 (echo "subdir =" ;
543                                         echo "unsubdir = .") >> ${Makefile}
544                         fi
545
546                 #       echo "workdir = `pwd`" >> ${Makefile}
547                         echo "VPATH = ${srcdir}" >> ${Makefile}
548
549                         # add "Makefile.in" (or whatever it's called)
550                         cat ${srcdir}/${Makefile_in} >> ${Makefile}
551
552                         # Conditionalize the makefile for this site.
553                         if [ -n "${site}" ] ; then
554                                 site_makefile_frag=config/ms-${site}
555
556                                 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
557                                         (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ; 
558                                                 sed -e "/^####/  r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
559                                 else
560                                         (echo "site_makefile_frag =" ; 
561                                                 cat ${Makefile}) > Makefile.tem
562                                 fi
563                                 mv Makefile.tem ${Makefile}
564                         fi
565
566                         # Conditionalize the makefile for this host.
567                         if [ -f ${srcdir}/${host_makefile_frag} ] ; then
568                                 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
569                                         sed -e "/^####/  r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
570                         else
571                                 (echo "host_makefile_frag =" ;
572                                         cat ${Makefile}) > Makefile.tem
573                         fi
574                         mv Makefile.tem ${Makefile}
575
576                         # Conditionalize the makefile for this target.
577                         if [ -f ${srcdir}/${target_makefile_frag} ] ; then
578                                 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; 
579                                         sed -e "/^####/  r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
580                         else
581                                 (echo "target_makefile_frag =" ; 
582                                         cat ${Makefile}) > Makefile.tem
583                         fi
584                         mv Makefile.tem ${Makefile}
585
586                         # set srcdir
587                         sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
588                         mv Makefile.tem ${Makefile}
589
590                         # set ddestdir
591                         if [ -n "${ddestdir}" ] ; then
592                                 sed "s:^ddestdir =.*$:ddestdir = ${ddestdir}:" ${Makefile} > Makefile.tem
593                                 mv Makefile.tem ${Makefile}
594                         fi
595
596                         # set idestdir
597                         if [ -n "${idestdir}" ] ; then
598                                 sed "s:^idestdir =.*$:idestdir = ${idestdir}:" ${Makefile} > Makefile.tem
599                                 mv Makefile.tem ${Makefile}
600                         fi
601
602                         # reset SUBDIRS
603                         sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
604                         mv Makefile.tem ${Makefile}
605
606                         # reset NONSUBDIRS
607                         sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
608                         mv Makefile.tem ${Makefile}
609
610                         # remove any form feeds.
611                         sed -e "s/\f//" ${Makefile} > Makefile.tem
612                         mv Makefile.tem ${Makefile}
613
614                         using=
615                         if [ -f ${srcdir}/${host_makefile_frag} ] ; then
616                                 using="${using} and \"${host_makefile_frag}\""
617                         fi
618                         if [ -f ${srcdir}/${target_makefile_frag} ] ; then
619                                 using="${using} and \"${target_makefile_frag}\""
620                         fi
621                         if [ -n "${site}" -a \
622                              -f ${srcdir}/${site_makefile_frag} ] ; then
623                                 using="${using} and \"${site_makefile_frag}\""
624                         fi
625                         using=`echo "${using}" | sed 's/and/using/'`
626                         using="Created \"${Makefile}\" in `pwd`${using}."
627
628                         if [ -n "${verbose}" -o -z "${recurring}" ] ; then
629                                 echo ${using}
630                         fi
631
632                         . ${tmpfile}.pos
633
634                         # describe the chosen configuration in config.status.
635                         # Make that file a shellscript which will reestablish
636                         # the same configuration.  Used in Makefiles to rebuild
637                         # Makefiles.
638
639                         echo "#!/bin/sh
640 # `pwd` was configured as follows:
641 (cd ${srcdir} ; ${progname}" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` ")
642 # ${using}" > config.status
643                         chmod a+x config.status
644
645                         originaldir=`pwd`
646                         cd ${srcdir}
647                 fi
648
649                 # If there are subdirectories, then recurse. 
650                 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
651                         for configdir in ${configdirs} ; do
652                                 if [ -n "${verbose}" ] ; then
653                                         echo Configuring ${configdir}...
654                                 fi
655
656                                 if [ -d ${configdir} ] ; then
657                                         if [ -n "${objdir}" ] ; then
658                                                 if [ ! -d ${objdir}/${configdir} ] ; then
659                                                         mkdir ${objdir}/${configdir}
660                                                 fi
661                                         fi
662
663                                         POPDIR=`pwd`
664                                         cd ${configdir} 
665
666                                         if (${progname} +recurring ${host_alias} +target=${target_alias} \
667                                                 ${verbose} ${subdirs} ${removing} +ddestdir=${ddestdir} +idestdir=${idestdir} \
668                                                 `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \
669                                                 ${tmpdiroption}) ; then
670                                                 true
671                                         else
672                                                 exit 1
673                                         fi
674
675                                         cd ${POPDIR}
676
677 #                                       (cd ${configdir} ;
678 #                                               if (${progname} +recurring ${host_alias} +target=${target_alias} \
679 #                                                       ${verbose} ${subdirs} ${removing} +destdir=${destdir} \
680 #                                                       `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \
681 #                                                       ${tmpdiroption}) ; then true ; else exit 1 ; fi) \
682 #                                               | sed 's/^/     /'
683                                 else
684                                         if [ -n "${verbose}" ] ; then
685                                                 echo Warning: directory \"${configdir}\" is missing.
686                                         fi
687                                 fi
688                         done
689                 fi
690         done # for each target
691
692         # Now build a Makefile for this host.
693         if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
694                 push=`pwd`
695
696                 if [ -n "${objdir}" ] ; then
697                         cd ${objdir}
698                 fi
699
700                 cd ${hostsubdir}
701                 cat > GNUmakefile << 'E!O!F'
702 # Makefile generated by configure for host ${host_alias}.
703
704 ALL := $(shell ls -d T-*)
705
706 %:
707         $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
708
709 all:
710 E!O!F
711                 cd ${push}
712         fi
713 done # for each host
714
715 ### clean up.
716
717 rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
718
719 exit 0
720
721 #
722 #
723 # $Log$
724 # Revision 1.71  1991/11/13 20:56:11  sac
725 # Passes down version_path for things which install themselves into
726 # libsubdir.
727 #
728 # Revision 1.70  1991/11/13  19:49:17  sac
729 # The +noversion flag will make an installation happen to the machine/..
730 # directory rather than the machine/version/.. directory.
731 #
732 # Steve
733 #
734 # Revision 1.69  1991/11/12  04:41:21  rich
735 # allow +foo bar options.  stolen from texinfo configure
736 #
737 # Revision 1.68  1991/11/09  11:34:52  rich
738 # correct a comment
739 #
740 # Revision 1.67  1991/11/06  22:28:08  rich
741 # pass +idestdir and +ddestdir
742 #
743 # Revision 1.66  1991/11/05  04:02:14  rich
744 # don't allow +recurring to reach config.status
745 #
746 # Revision 1.65  1991/11/01  00:25:28  rich
747 # new install theme
748 #
749 # Revision 1.64  1991/10/30  06:55:25  rich
750 # suck in site makefile frags first
751 #
752 # Revision 1.63  1991/10/25  02:07:18  steve
753 # More name changing
754 #
755 # Revision 1.62  1991/10/24  11:59:03  rich
756 # add null definitions for makefile_frag_foo
757 #
758 # Revision 1.61  1991/10/24  00:23:59  hgs
759 # Allow for using tmake-sun4
760 #
761 # Revision 1.60  1991/10/23  21:48:28  rich
762 # Makefiles should include the makefile frag names even if the makefile
763 # frag doesn't exist in *this* directory.  Otherwise we inherit the
764 # variable setting from our parent Makefile.
765 #
766 # Revision 1.59  1991/10/16  19:53:31  gnu
767 # Update for SCO problems.
768 #
769 # * Fix "Larry Wall kludge" line so it works.  If this script is run by csh,
770 # it will complain, feed itself to sh, and complain some more.  But will work.
771 #
772 # * Use <14 char file names in /tmp.
773 #
774 # Revision 1.58  1991/10/16  06:12:52  rich
775 # Two small bugs.  First, single quoted sed line doesn't need to quote
776 # '$'.  Second, use quotes around the hereis document trigger in order
777 # to quote the entire contents of the hereis document.
778 #
779 # Revision 1.57  1991/10/11  05:31:05  gnu
780 # Simplify "Using" message code.  Put the message that configure prints
781 # (or suppresses) into the config.status file as a comment.
782 #
783 # Revision 1.56  1991/10/10  05:01:47  rich
784 # Remove the set -e but protect the recusion call.
785 #
786 # Revision 1.55  1991/10/10  04:57:23  rich
787 # * Die when sub-configure's do.
788 # * get the makefile building message line correct.
789 # * set -e
790 #
791 # Revision 1.54  1991/10/10  01:04:42  rich
792 # Backed out the "/bin/sh config.sub" change.  Fails when config.sub was
793 # on PATH.
794 #
795 # Revision 1.53  1991/10/10  00:38:08  rich
796 # Call config.sub as "/bin/sh config.sub" instead of directly.  This
797 # protects us from the case where config.sub isn't executable.
798 #
799 # Revision 1.52  1991/10/09  00:48:26  rich
800 # Another patch from jim.
801 #
802 # Revision 1.51  1991/10/08  06:07:58  wilson
803 # Fix bug in smake- file code.
804 #
805 # Revision 1.50  1991/10/04  23:49:37  rich
806 # Per's patch for my config.sub botch.
807 #
808 # Revision 1.49  1991/10/04  22:52:09  rich
809 # Use john's heuristic for finding ourselves.  kinda like hare krishna.
810 #
811 # Revision 1.48  1991/10/02  13:17:28  rich
812 # take out the set -e for now
813 #
814 # Revision 1.47  1991/10/02  10:02:23  rich
815 # * temporary files in TMPDIR
816 # * +objdir
817 #
818 # Revision 1.46  1991/10/02  06:29:53  rich
819 # Added +site=foo option for naming site specific Makefile fragments.
820 #
821 # Revision 1.45  1991/10/02  06:15:13  rich
822 # Removed +f option.  Used to stand for +forcesubdirs which is now
823 # called +subdirs.
824 #
825 # Revision 1.44  1991/10/02  06:02:35  rich
826 # Added rcs log line.
827 #
828 #
829 #
830
831 #
832 # Local Variables:
833 # fill-column: 131
834 # End:
835 #
836
837 # end of configure