fixed a bug in multiple targets
[deliverable/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 # 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 that supplies the information necessary
180 # to tailor a template configure script into the configure script
181 # appropriate for this directory. For more information, check any
182 # existing configure script.
183
184 srctrigger=libbfd.c
185 srcname="bfd"
186
187 ## end of common part.
188
189 # are we rebuilding config itself?
190 if [ -n "${template}" ] ; then
191 if [ ! -r ${template} ] ; then
192 echo "Can't find template ${template}."
193 exit 1
194 fi
195
196 # prep the template
197 sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\
198 #### configure.in common parts come in here.\
199 ## end of common part.' \
200 -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\
201 #### configure.in per-host parts come in here.\
202 ## end of per-host part.' \
203 -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\
204 #### configure.in per-target parts come in here.\
205 ## end of per-target part.' \
206 < ${template} > template.new
207
208 if [ -r configure.in ] ; then
209 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
210 echo `pwd`/configure.in has no "per-host:" line.
211 exit 1
212 fi
213
214 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
215 echo `pwd`/configure.in has no "per-target:" line.
216 exit 1
217 fi
218
219 # split configure.in into common, per-host, and per-target parts
220 sed -e '/^# per\-host:/,$d' configure.in > configure.com
221 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
222 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
223
224 # and insert them
225 sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \
226 -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \
227 -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \
228 template.new > configure.new
229
230 rm -f configure.com configure.tgt configure.hst
231 else
232 echo Warning: no configure.in in `pwd`
233 cat ${template} >> configure
234 fi
235
236 chmod a+x configure.new
237 rm template.new
238 # mv configure configure.old
239 mv configure.new configure
240 echo Rebuilt configure in `pwd`
241
242 if [ -z "${norecurse}" ] ; then
243 while [ -n "${configdirs}" ] ; do
244 # set configdir to car of configdirs, configdirs to cdr of configdirs
245 set ${configdirs}; configdir=$1; shift; configdirs=$*
246
247 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
248 targetspecificdirs=${configdir}.*
249 else
250 targetspecificdirs=
251 fi
252
253 for i in ${configdir} ${targetspecificdirs} ; do
254 if [ -d $i ] ; then
255 if [ -r $i/configure ] ; then
256 (cd $i ;
257 ./configure +template=${template} ${verbose})
258 else
259 echo No configure script in `pwd`/$i
260 fi
261 else
262 echo Warning: directory $i is missing.
263 fi
264 done
265 done
266 fi
267
268 exit 0
269 fi
270
271 # some sanity checks on configure.in
272 if [ -z "${srctrigger}" ] ; then
273 echo srctrigger not set in configure.in. `pwd` not configured.
274 exit 1
275 fi
276
277 for host in ${hosts} ; do
278 # Default other arg
279 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
280 targets=${host}
281 defaulttargets=true
282 fi
283
284 host_makefile_frag=config/hmake-${host}
285
286 #### configure.in per-host parts come in here.
287
288 ## end of per-host part.
289
290
291 for target in ${targets} ; do
292
293 if [ -n "${verbose}" ] ; then
294 echo host \= \"${host}\", target \= \"${target}\".
295 fi
296
297 target_makefile_frag=config/tmake-${target}
298
299 #### configure.in per-target parts come in here.
300
301 files=
302 links=
303 ## end of per-target part.
304
305 # Temporarily, we support only direct subdir builds.
306 hostsubdir=Host-${host}
307 targetsubdir=Target-${target}
308
309 if [ -n "${removing}" ] ; then
310 if [ -n "${forcesubdirs}" ] ; then
311 if [ -d "${hostsubdir}" ] ; then
312 rm -rf ${hostsubdir}/${targetsubdir}
313
314 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then
315 rm -rf ${hostsubdir}
316 fi
317 else
318 echo Warning: no `pwd`/${hostsubdir} to remove.
319 fi
320 else
321 rm -f Makefile config.status ${links}
322 fi
323 else
324 if [ -n "${forcesubdirs}" ] ; then
325 # check for existing status before allowing forced subdirs.
326 if [ -f Makefile ] ; then
327 echo "Makefile already exists in source directory. `pwd` not configured."
328 exit 1
329 fi
330
331 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
332 cd ${hostsubdir}
333
334 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
335 cd ${targetsubdir}
336
337 srcdir=../..
338 else
339 # if not subdir builds, then make sure none exist.
340 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
341 echo "Configured subdirs exist. `pwd` not configured."
342 exit 1
343 fi
344 fi
345
346 # Find the source files, if location was not specified.
347 if [ -z "${srcdir}" ] ; then
348 srcdirdefaulted=1
349 srcdir=.
350 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
351 srcdir=..
352 fi
353 fi
354
355 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
356 if [ -z "${srcdirdefaulted}" ] ; then
357 echo "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
358 else
359 echo "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
360 fi
361
362 echo \(At least ${srctrigger} is missing.\) 1>&2
363 exit 1
364 fi
365
366 # Set up the list of links to be made.
367 # ${links} is the list of link names, and ${files} is the list of names to link to.
368
369 # Make the links.
370 while [ -n "${files}" ] ; do
371 # set file to car of files, files to cdr of files
372 set ${files}; file=$1; shift; files=$*
373 set ${links}; link=$1; shift; links=$*
374
375 if [ ! -r ${srcdir}/${file} ] ; then
376 echo "${progname}: cannot create a link \"${link}\"," 1>&2
377 echo "since the file \"${file}\" does not exist." 1>&2
378 exit 1
379 fi
380
381 ${remove} -f ${link}
382 rm -f config.status
383 # Make a symlink if possible, otherwise try a hard link
384 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
385
386 if [ ! -r ${link} ] ; then
387 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
388 exit 1
389 fi
390 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
391 done
392
393 # Create a .gdbinit file which runs the one in srcdir
394 # and tells GDB to look there for source files.
395
396 case ${srcdir} in
397 .)
398 ;;
399 *)
400 echo "dir ." > .gdbinit
401 echo "dir ${srcdir}" >> .gdbinit
402 echo "source ${srcdir}/.gdbinit" >> .gdbinit
403 ;;
404 esac
405
406 # Install a makefile, and make it set VPATH
407 # if necessary so that the sources are found.
408 # Also change its value of srcdir.
409
410 # FIXME-someday: This business of always writing to .tem and mv back
411 # is so that I don't screw things up while developing. Once this
412 # template is stable, these should be optimized. xoxorich.
413
414 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
415 if [ "${host}" != "${target}" ] ; then
416 echo "CROSS=-DCROSS_COMPILE" > Makefile
417 echo "ALL=start.encap" >> Makefile
418 else
419 echo "ALL=all.internal" > Makefile
420 fi
421
422 # set target, host, VPATH
423 echo "host = ${host}" >> Makefile
424 echo "target = ${target}" >> Makefile
425
426 if [ -n "${forcesubdirs}" ] ; then
427 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
428 else
429 echo "subdir =" >> Makefile
430 fi
431
432 # echo "workdir = `pwd`" >> Makefile
433 echo "VPATH = ${srcdir}" >> Makefile
434
435 # add Makefile.in
436 cat ${srcdir}/Makefile.in >> Makefile
437
438 # and shake thoroughly.
439 # Conditionalize the makefile for this host.
440 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
441 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" Makefile > Makefile.tem
442 mv Makefile.tem Makefile
443 fi
444
445 # Conditionalize the makefile for this target.
446 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
447 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" Makefile > Makefile.tem
448 mv Makefile.tem Makefile
449 fi
450
451 # set srcdir
452 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
453 mv Makefile.tem Makefile
454
455 # set destdir
456 if [ -n "${destdir}" ] ; then
457 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
458 mv Makefile.tem Makefile
459 fi
460
461 # Remove all formfeeds, since some Makes get confused by them.
462 sed "s/\f//" Makefile >> Makefile.tem
463 mv Makefile.tem Makefile
464
465 # reset SUBDIRS
466 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
467 mv Makefile.tem Makefile
468
469 # reset NONSUBDIRS
470 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
471 mv Makefile.tem Makefile
472
473 using=
474 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
475 using=" using \"${host_makefile_frag}\""
476 fi
477
478 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
479 if [ -z "${using}" ] ; then
480 andusing=" using \"${target_makefile_frag}\""
481 else
482 andusing="${using} and \"${target_makefile_frag}\""
483 fi
484 else
485 andusing=${using}
486 fi
487
488 echo "Created \"Makefile\"" in `pwd`${andusing}.
489
490 if [ "${host}" = "${target}" ] ; then
491 echo "Links are now set up for use with a ${target}." \
492 > config.status
493 # | tee ${srcdir}/config.status
494 else
495 echo "Links are now set up for host ${host} and target ${target}." \
496 > config.status
497 # | tee ${srcdir}/config.status
498 fi
499
500 originaldir=`pwd`
501 cd ${srcdir}
502 fi
503 done # for each target
504
505 # # Now build a Makefile for this host.
506 # if [ -n "${forcesubdirs}" ] ; then
507 # cd ${hostsubdir}
508 # cat > GNUmakefile << E!O!F
509 ## Makefile generated by configure for host ${host}.
510 #
511 #%:
512 # for i in ${targets} ; do \
513 # $(MAKE) -C Target-\$i \$@
514 #
515 #all clean stage1 stage2 stage3 stage4etags tags TAGS
516 #E!O!F
517 # fi
518 done # for each host
519
520 # If there are subdirectories, then recurse.
521
522 if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
523
524 # configdirs is not null
525 for configdir in ${configdirs} ; do
526 echo Configuring ${configdir}...
527 specifics=
528 commons=
529
530 if [ -n "${defaulttargets}" ] ; then
531 for host in ${hosts} ; do
532 if [ -d ${configdir}.${host} ] ; then
533 newspecifics="${specifics} ${host}"
534 specifics=${newspecifics}
535 else
536 newcommons="${commons} ${host}"
537 commons=${newcommons}
538 fi # if target specific
539 done # for each host
540
541 if [ -n "${commons}" ] ; then
542 if [ -d ${configdir} ] ; then
543 (cd ${configdir} ;
544 ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \
545 | sed 's/^/ /'
546 else
547 echo Warning: directory \"${configdir}\" is missing.
548 fi
549 fi # if any common hosts
550
551 if [ -n "${specifics}" ] ; then
552 for host in ${specifics} ; do
553 echo Configuring target specific directory ${configdir}.${host}...
554 (cd ${configdir}.${host} ;
555 ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \
556 | sed 's/^/ /'
557 done # for host in specifics
558 fi # if there are any specifics
559 else
560
561 for target in ${targets} ; do
562 if [ -d ${configdir}.${target} ] ; then
563 newspecifics="${specifics} ${target}"
564 specifics=${newspecifics}
565 else
566 newcommons="${commons} +target=${target}"
567 commons=${newcommons}
568 fi
569
570 done # check for target specific dir override
571
572 if [ -n "${verbose}" ] ; then
573 echo " "commons=\"${commons}\"
574 echo " "specifics=\"${specifics}\"
575 fi # if verbose
576
577 if [ -n "${commons}" ] ; then
578 if [ -d ${configdir} ] ; then
579 (cd ${configdir} ;
580 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
581 | sed 's/^/ /'
582 else
583 echo Warning: directory \"${configdir}\" is missing.
584 fi
585 fi # if any commons
586
587 if [ -n "${specifics}" ] ; then
588 for target in ${specifics} ; do
589 echo Configuring target specific directory ${configdir}.${target}...
590 (cd ${configdir}.${target} ;
591 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
592 | sed 's/^/ /'
593 done
594 fi # if any specifics
595 fi # not default targets
596 done
597
598 exit 0
599
600 #
601 # $Log$
602 # Revision 1.10 1991/05/27 20:54:38 rich
603 # fixed a bug in multiple targets
604 #
605 # Revision 1.14 1991/05/22 01:44:04 rich
606 # remove gdb until config issues resolve.
607 #
608 # Revision 1.13 1991/05/19 08:00:09 rich
609 # Added gdb.
610 #
611 # Revision 1.12 1991/05/19 00:32:13 rich
612 # Changes to deal with missing subdirs gracefully, and changes dictated
613 # from dropping configure over gdb.
614 #
615 # Revision 1.4 1991/05/19 00:16:45 rich
616 # Configure for gdb.
617 #
618 # Revision 1.10 1991/05/04 00:58:38 rich
619 # Fix program name bug.
620 #
621 # Revision 1.9 1991/05/03 19:14:18 rich
622 # Changed getopt to libiberty, commented out an aborted attempt at host
623 # level Makefiles because it caused errors on +rm, add a warning for
624 # directories expected to be removed on +rm but that don't exist.
625 #
626 # Revision 1.8 1991/04/24 16:50:59 rich
627 # Three staging checkpoint.
628 #
629 # Revision 1.7 1991/04/17 01:34:47 rich
630 # Added getopt for binutils, fixed problem with host dependancies in
631 # configure.template.
632 #
633 # Revision 1.6 1991/04/16 00:18:44 rich
634 # Now handles multiple hosts and targets.
635 #
636 # Revision 1.5 1991/04/15 23:43:44 rich
637 # Now handles multiple hosts and targets.
638 #
639 # Revision 1.4 1991/04/13 02:11:03 rich
640 # Config cut 3. We now almost install a29k.
641 #
642 # Revision 1.3 1991/04/11 02:41:54 rich
643 # Cut 2 config. Subdirs.
644 #
645 #
646 #
647
648 #
649 # Local Variables:
650 # fill-column: 131
651 # End:
652 #
653
654 # end of configure.template
This page took 0.0557 seconds and 4 git commands to generate.