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