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