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