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