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