fixed a bug in multiple targets
[binutils-gdb.git] / readline / configure
1 #!/bin/sh
2 # Please do not edit this file. It is generated automatically from
3 # configure.in and a configure template.
4 configdirs=
5
6 # the debugger.
7 #set -x
8
9 #!/bin/sh
10
11 # Configuration script template
12 # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
13
14 #This file is part of GNU.
15
16 #GNU CC is free software; you can redistribute it and/or modify
17 #it under the terms of the GNU General Public License as published by
18 #the Free Software Foundation; either version 1, or (at your option)
19 #any later version.
20
21 #GNU CC is distributed in the hope that it will be useful,
22 #but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 #GNU General Public License for more details.
25
26 #You should have received a copy of the GNU General Public License
27 #along with GNU CC; see the file COPYING. If not, write to
28 #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29
30 # $Id$
31
32 #
33 # Shell script to create proper links to machine-dependent files in
34 # preparation for compilation.
35 #
36 # If configure succeeds, it leaves its status in config.status.
37 # If configure fails after disturbing the status quo,
38 # config.status is removed.
39 #
40
41 remove=rm
42 hard_link=ln
43 symbolic_link='ln -s'
44
45 #for Test
46 #remove="echo rm"
47 #hard_link="echo ln"
48 #symbolic_link="echo ln -s"
49
50 progname=$0
51
52 # clear some things potentially inherited from environment.
53 ansi=
54 defaulttargets=
55 destdir=
56 fatal=
57 hostsubdir=
58 norecurse=
59 removing=
60 srcdir=
61 srctrigger=
62 target=
63 targets=
64 targetsubdir=
65 template=
66 verbose=
67
68 for arg in $*;
69 do
70 case ${arg} in
71 -ansi | +ansi)
72 ansi=true
73 ;;
74 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
75 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
76 ;;
77 -forcesubdirs | +forcesubdirs | +forcesubdir | +forcesubdi | +forcesubd \
78 | +forcesub | +forcesu | +forces | +force | +forc | +for | +fo | +f)
79 forcesubdirs=${arg}
80 ;;
81 -languages=* | +languages=* | +language=* | +languag=* \
82 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
83 | +l=*)
84 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
85 ;;
86 -gas | +gas | +ga | +g)
87 gas=yes
88 ;;
89 -help | +h | +help)
90 fatal=true
91 ;;
92 -nfp | +nfp | +nf | +n)
93 nfp=yes
94 ;;
95 -norecurse | +norecurse)
96 norecurse=true
97 ;;
98 -rm | +rm)
99 removing=${arg}
100 ;;
101 # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
102 # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
103 # ;;
104 -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=* | +t=*)
105 if [ -n "${targets}" ] ; then
106 forcesubdirs="+forcesubdirs"
107 fi
108
109 newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
110 targets="${newtargets}"
111 ;;
112 -template=* | +template=*)
113 template=`echo ${arg} | sed 's/[+-]template=//'`
114 ;;
115 +verbose | +verbos | +verbo | +verb | +ver | +ve | +v)
116 verbose=${arg}
117 ;;
118 -* | +*)
119 (echo ;
120 echo "Unrecognized option: \"${arg}\"". ;
121 echo) 1>&2
122 fatal=true
123 ;;
124 *)
125 if [ -n "${hosts}" ] ; then
126 forcesubdirs="+forcesubdirs"
127 fi
128
129 newhosts="${hosts} ${arg}"
130 hosts=${newhosts}
131 ;;
132 esac
133 done
134
135 if [ -n "${verbose}" ] ; then
136 echo `pwd`/configure $*
137 echo targets=\"${targets}\"
138 fi
139
140 # process host and target only if not rebuilding configure itself or removing.
141 if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
142 # Complain if an arg is missing
143 if [ -z "${hosts}" ] ; then
144 (echo ;
145 echo "configure: No HOST specified." ;
146 echo) 2>&1
147 fatal=true
148 fi
149 fi
150
151 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
152 (echo "Usage: configure HOST" ;
153 echo ;
154 echo "Options: [defaults in brackets]" ;
155 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
156 echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ;
157 echo " +forcesubdirs configure in subdirectories. [in source directories]" ;
158 echo " +lang=LANG configure to build LANG. [gcc]" ;
159 echo " +help print this message. [normal config]" ;
160 echo " +gas configure the compilers for use with gas. [native as]" ;
161 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
162 echo " +norecurse configure this directory only. [recurse]" ;
163 echo " +rm remove this configuration. [build a configuration]" ;
164 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
165 echo " +template=TEM rebuild configure using TEM. [normal config]" ;
166 echo ;
167 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
168 echo "Asking for more than one \"+target\" implies \"+forcesubdirs\". Any other" ;
169 echo "options given will apply to all targets.") 1>&2
170
171 if [ -r config.status ] ; then
172 cat config.status
173 fi
174
175 exit 1
176 fi
177
178 #### configure.in common parts come in here.
179 # This file is a shell script fragment that supplies the information
180 # necessary to tailor a template configure script into the configure
181 # script appropriate for this directory. For more information, check
182 # any existing configure script.
183
184 configdirs=
185 srctrigger=readline.c
186 srcname="the readline library"
187
188 ## end of common part.
189
190 # are we rebuilding config itself?
191 if [ -n "${template}" ] ; then
192 if [ ! -r ${template} ] ; then
193 echo "Can't find template ${template}."
194 exit 1
195 fi
196
197 # prep the template
198 sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\
199 #### configure.in common parts come in here.\
200 ## end of common part.' \
201 -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\
202 #### configure.in per-host parts come in here.\
203 ## end of per-host part.' \
204 -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\
205 #### configure.in per-target parts come in here.\
206 ## end of per-target part.' \
207 < ${template} > template.new
208
209 if [ -r configure.in ] ; then
210 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
211 echo `pwd`/configure.in has no "per-host:" line.
212 exit 1
213 fi
214
215 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
216 echo `pwd`/configure.in has no "per-target:" line.
217 exit 1
218 fi
219
220 # split configure.in into common, per-host, and per-target parts
221 sed -e '/^# per\-host:/,$d' configure.in > configure.com
222 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
223 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
224
225 # and insert them
226 sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \
227 -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \
228 -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \
229 template.new > configure.new
230
231 rm -f configure.com configure.tgt configure.hst
232 else
233 echo Warning: no configure.in in `pwd`
234 cat ${template} >> configure
235 fi
236
237 chmod a+x configure.new
238 rm template.new
239 # mv configure configure.old
240 mv configure.new configure
241 echo Rebuilt configure in `pwd`
242
243 if [ -z "${norecurse}" ] ; then
244 while [ -n "${configdirs}" ] ; do
245 # set configdir to car of configdirs, configdirs to cdr of configdirs
246 set ${configdirs}; configdir=$1; shift; configdirs=$*
247
248 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
249 targetspecificdirs=${configdir}.*
250 else
251 targetspecificdirs=
252 fi
253
254 for i in ${configdir} ${targetspecificdirs} ; do
255 if [ -d $i ] ; then
256 if [ -r $i/configure ] ; then
257 (cd $i ;
258 ./configure +template=${template} ${verbose})
259 else
260 echo No configure script in `pwd`/$i
261 fi
262 else
263 echo Warning: directory $i is missing.
264 fi
265 done
266 done
267 fi
268
269 exit 0
270 fi
271
272 # some sanity checks on configure.in
273 if [ -z "${srctrigger}" ] ; then
274 echo srctrigger not set in configure.in. `pwd` not configured.
275 exit 1
276 fi
277
278 for host in ${hosts} ; do
279 # Default other arg
280 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
281 targets=${host}
282 defaulttargets=true
283 fi
284
285 host_makefile_frag=config/hmake-${host}
286
287 #### configure.in per-host parts come in here.
288
289 ## end of per-host part.
290
291
292 for target in ${targets} ; do
293
294 if [ -n "${verbose}" ] ; then
295 echo host \= \"${host}\", target \= \"${target}\".
296 fi
297
298 target_makefile_frag=config/tmake-${target}
299
300 #### configure.in per-target parts come in here.
301
302 ## end of per-target part.
303
304 # Temporarily, we support only direct subdir builds.
305 hostsubdir=Host-${host}
306 targetsubdir=Target-${target}
307
308 if [ -n "${removing}" ] ; then
309 if [ -n "${forcesubdirs}" ] ; then
310 if [ -d "${hostsubdir}" ] ; then
311 rm -rf ${hostsubdir}/${targetsubdir}
312
313 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then
314 rm -rf ${hostsubdir}
315 fi
316 else
317 echo Warning: no `pwd`/${hostsubdir} to remove.
318 fi
319 else
320 rm -f Makefile config.status ${links}
321 fi
322 else
323 if [ -n "${forcesubdirs}" ] ; then
324 # check for existing status before allowing forced subdirs.
325 if [ -f Makefile ] ; then
326 echo "Makefile already exists in source directory. `pwd` not configured."
327 exit 1
328 fi
329
330 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
331 cd ${hostsubdir}
332
333 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
334 cd ${targetsubdir}
335
336 srcdir=../..
337 else
338 # if not subdir builds, then make sure none exist.
339 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
340 echo "Configured subdirs exist. `pwd` not configured."
341 exit 1
342 fi
343 fi
344
345 # Find the source files, if location was not specified.
346 if [ -z "${srcdir}" ] ; then
347 srcdirdefaulted=1
348 srcdir=.
349 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
350 srcdir=..
351 fi
352 fi
353
354 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
355 if [ -z "${srcdirdefaulted}" ] ; then
356 echo "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
357 else
358 echo "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
359 fi
360
361 echo \(At least ${srctrigger} is missing.\) 1>&2
362 exit 1
363 fi
364
365 # Set up the list of links to be made.
366 # ${links} is the list of link names, and ${files} is the list of names to link to.
367
368 # Make the links.
369 while [ -n "${files}" ] ; do
370 # set file to car of files, files to cdr of files
371 set ${files}; file=$1; shift; files=$*
372 set ${links}; link=$1; shift; links=$*
373
374 if [ ! -r ${srcdir}/${file} ] ; then
375 echo "${progname}: cannot create a link \"${link}\"," 1>&2
376 echo "since the file \"${file}\" does not exist." 1>&2
377 exit 1
378 fi
379
380 ${remove} -f ${link}
381 rm -f config.status
382 # Make a symlink if possible, otherwise try a hard link
383 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
384
385 if [ ! -r ${link} ] ; then
386 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
387 exit 1
388 fi
389 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
390 done
391
392 # Create a .gdbinit file which runs the one in srcdir
393 # and tells GDB to look there for source files.
394
395 case ${srcdir} in
396 .)
397 ;;
398 *)
399 echo "dir ." > .gdbinit
400 echo "dir ${srcdir}" >> .gdbinit
401 echo "source ${srcdir}/.gdbinit" >> .gdbinit
402 ;;
403 esac
404
405 # Install a makefile, and make it set VPATH
406 # if necessary so that the sources are found.
407 # Also change its value of srcdir.
408
409 # FIXME-someday: This business of always writing to .tem and mv back
410 # is so that I don't screw things up while developing. Once this
411 # template is stable, these should be optimized. xoxorich.
412
413 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
414 if [ "${host}" != "${target}" ] ; then
415 echo "CROSS=-DCROSS_COMPILE" > Makefile
416 echo "ALL=start.encap" >> Makefile
417 else
418 echo "ALL=all.internal" > Makefile
419 fi
420
421 # set target, host, VPATH
422 echo "host = ${host}" >> Makefile
423 echo "target = ${target}" >> Makefile
424
425 if [ -n "${forcesubdirs}" ] ; then
426 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
427 else
428 echo "subdir =" >> Makefile
429 fi
430
431 # echo "workdir = `pwd`" >> Makefile
432 echo "VPATH = ${srcdir}" >> Makefile
433
434 # add Makefile.in
435 cat ${srcdir}/Makefile.in >> Makefile
436
437 # and shake thoroughly.
438 # Conditionalize the makefile for this host.
439 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
440 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" Makefile > Makefile.tem
441 mv Makefile.tem Makefile
442 fi
443
444 # Conditionalize the makefile for this target.
445 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
446 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" Makefile > Makefile.tem
447 mv Makefile.tem Makefile
448 fi
449
450 # set srcdir
451 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
452 mv Makefile.tem Makefile
453
454 # set destdir
455 if [ -n "${destdir}" ] ; then
456 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
457 mv Makefile.tem Makefile
458 fi
459
460 # Remove all formfeeds, since some Makes get confused by them.
461 sed "s/\f//" Makefile >> Makefile.tem
462 mv Makefile.tem Makefile
463
464 # reset SUBDIRS
465 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
466 mv Makefile.tem Makefile
467
468 # reset NONSUBDIRS
469 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
470 mv Makefile.tem Makefile
471
472 using=
473 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
474 using=" using \"${host_makefile_frag}\""
475 fi
476
477 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
478 if [ -z "${using}" ] ; then
479 andusing=" using \"${target_makefile_frag}\""
480 else
481 andusing="${using} and \"${target_makefile_frag}\""
482 fi
483 else
484 andusing=${using}
485 fi
486
487 echo "Created \"Makefile\"" in `pwd`${andusing}.
488
489 if [ "${host}" = "${target}" ] ; then
490 echo "Links are now set up for use with a ${target}." \
491 > config.status
492 # | tee ${srcdir}/config.status
493 else
494 echo "Links are now set up for host ${host} and target ${target}." \
495 > config.status
496 # | tee ${srcdir}/config.status
497 fi
498
499 originaldir=`pwd`
500 cd ${srcdir}
501 fi
502 done # for each target
503
504 # # Now build a Makefile for this host.
505 # if [ -n "${forcesubdirs}" ] ; then
506 # cd ${hostsubdir}
507 # cat > GNUmakefile << E!O!F
508 ## Makefile generated by configure for host ${host}.
509 #
510 #%:
511 # for i in ${targets} ; do \
512 # $(MAKE) -C Target-\$i \$@
513 #
514 #all clean stage1 stage2 stage3 stage4etags tags TAGS
515 #E!O!F
516 # fi
517 done # for each host
518
519 # If there are subdirectories, then recurse.
520
521 if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
522
523 # configdirs is not null
524 for configdir in ${configdirs} ; do
525 echo Configuring ${configdir}...
526 specifics=
527 commons=
528
529 if [ -n "${defaulttargets}" ] ; then
530 for host in ${hosts} ; do
531 if [ -d ${configdir}.${host} ] ; then
532 newspecifics="${specifics} ${host}"
533 specifics=${newspecifics}
534 else
535 newcommons="${commons} ${host}"
536 commons=${newcommons}
537 fi # if target specific
538 done # for each host
539
540 if [ -n "${commons}" ] ; then
541 if [ -d ${configdir} ] ; then
542 (cd ${configdir} ;
543 ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \
544 | sed 's/^/ /'
545 else
546 echo Warning: directory \"${configdir}\" is missing.
547 fi
548 fi # if any common hosts
549
550 if [ -n "${specifics}" ] ; then
551 for host in ${specifics} ; do
552 echo Configuring target specific directory ${configdir}.${host}...
553 (cd ${configdir}.${host} ;
554 ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \
555 | sed 's/^/ /'
556 done # for host in specifics
557 fi # if there are any specifics
558 else
559
560 for target in ${targets} ; do
561 if [ -d ${configdir}.${target} ] ; then
562 newspecifics="${specifics} ${target}"
563 specifics=${newspecifics}
564 else
565 newcommons="${commons} +target=${target}"
566 commons=${newcommons}
567 fi
568
569 done # check for target specific dir override
570
571 if [ -n "${verbose}" ] ; then
572 echo " "commons=\"${commons}\"
573 echo " "specifics=\"${specifics}\"
574 fi # if verbose
575
576 if [ -n "${commons}" ] ; then
577 if [ -d ${configdir} ] ; then
578 (cd ${configdir} ;
579 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
580 | sed 's/^/ /'
581 else
582 echo Warning: directory \"${configdir}\" is missing.
583 fi
584 fi # if any commons
585
586 if [ -n "${specifics}" ] ; then
587 for target in ${specifics} ; do
588 echo Configuring target specific directory ${configdir}.${target}...
589 (cd ${configdir}.${target} ;
590 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
591 | sed 's/^/ /'
592 done
593 fi # if any specifics
594 fi # not default targets
595 done
596
597 exit 0
598
599 #
600 # $Log$
601 # Revision 1.2 1991/05/27 20:54:50 rich
602 # fixed a bug in multiple targets
603 #
604 # Revision 1.14 1991/05/22 01:44:04 rich
605 # remove gdb until config issues resolve.
606 #
607 # Revision 1.13 1991/05/19 08:00:09 rich
608 # Added gdb.
609 #
610 # Revision 1.12 1991/05/19 00:32:13 rich
611 # Changes to deal with missing subdirs gracefully, and changes dictated
612 # from dropping configure over gdb.
613 #
614 # Revision 1.4 1991/05/19 00:16:45 rich
615 # Configure for gdb.
616 #
617 # Revision 1.10 1991/05/04 00:58:38 rich
618 # Fix program name bug.
619 #
620 # Revision 1.9 1991/05/03 19:14:18 rich
621 # Changed getopt to libiberty, commented out an aborted attempt at host
622 # level Makefiles because it caused errors on +rm, add a warning for
623 # directories expected to be removed on +rm but that don't exist.
624 #
625 # Revision 1.8 1991/04/24 16:50:59 rich
626 # Three staging checkpoint.
627 #
628 # Revision 1.7 1991/04/17 01:34:47 rich
629 # Added getopt for binutils, fixed problem with host dependancies in
630 # configure.template.
631 #
632 # Revision 1.6 1991/04/16 00:18:44 rich
633 # Now handles multiple hosts and targets.
634 #
635 # Revision 1.5 1991/04/15 23:43:44 rich
636 # Now handles multiple hosts and targets.
637 #
638 # Revision 1.4 1991/04/13 02:11:03 rich
639 # Config cut 3. We now almost install a29k.
640 #
641 # Revision 1.3 1991/04/11 02:41:54 rich
642 # Cut 2 config. Subdirs.
643 #
644 #
645 #
646
647 #
648 # Local Variables:
649 # fill-column: 131
650 # End:
651 #
652
653 # end of configure.template