Many small changes including the removal of configure.template. Any
[deliverable/binutils-gdb.git] / gas / configure
CommitLineData
fecd2382 1#!/bin/sh
74cc5508
RP
2# Please do not edit this file. It is generated automatically from
3# configure.in and a configure template.
fecd2382
RP
4configdirs=
5
6#!/bin/sh
fecd2382
RP
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
74cc5508
RP
27# $Id$
28
fecd2382
RP
29#
30# Shell script to create proper links to machine-dependent files in
3d6f0983 31# preparation for compilation.
fecd2382
RP
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
fecd2382
RP
38remove=rm
39hard_link=ln
40symbolic_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.
fecd2382 48ansi=
3d6f0983 49defaulttargets=
ec342d7d 50destdir=
3d6f0983 51fatal=
61907f51
RP
52hostsubdir=
53norecurse=
54removing=
74cc5508 55srcdir=
ec342d7d 56srctrigger=
61907f51 57target=
3d6f0983 58targets=
61907f51
RP
59targetsubdir=
60template=
3d6f0983 61verbose=
fecd2382
RP
62
63for arg in $*;
64do
ec342d7d 65 case ${arg} in
fecd2382
RP
66 -ansi | +ansi)
67 ansi=true
68 ;;
ec342d7d
RP
69 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
70 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
71 ;;
3d6f0983 72 -forcesubdirs | +forcesubdirs | +f)
61907f51 73 forcesubdirs=${arg}
fecd2382 74 ;;
74cc5508
RP
75 -languages=* | +languages=* | +language=* | +languag=* \
76 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
77 | +l=*)
ec342d7d 78 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
fecd2382
RP
79 ;;
80 -gas | +gas | +ga | +g)
81 gas=yes
82 ;;
3d6f0983
RP
83 -help | +h | +help)
84 fatal=true
85 ;;
fecd2382
RP
86 -nfp | +nfp | +nf | +n)
87 nfp=yes
88 ;;
61907f51
RP
89 -norecurse | +norecurse)
90 norecurse=true
91 ;;
92 -rm | +rm)
ec342d7d 93 removing=${arg}
61907f51 94 ;;
3d6f0983
RP
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}"
61907f51
RP
105 ;;
106 -template=* | +template=*)
ec342d7d 107 template=`echo ${arg} | sed 's/[+-]template=//'`
61907f51 108 ;;
3d6f0983
RP
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 ;;
fecd2382 118 *)
3d6f0983
RP
119 if [ -n "${hosts}" ] ; then
120 forcesubdirs="+forcesubdirs"
121 fi
122
123 newhosts="${hosts} ${arg}"
124 hosts=${newhosts}
fecd2382
RP
125 ;;
126 esac
127done
128
3d6f0983
RP
129if [ -n "${verbose}" ] ; then
130 echo `pwd`/configure $*
131 echo targets=\"${targets}\"
132fi
133
61907f51 134# process host and target only if not rebuilding configure itself or removing.
3d6f0983 135if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
fecd2382 136 # Complain if an arg is missing
3d6f0983
RP
137 if [ -z "${hosts}" ] ; then
138 (echo ;
139 echo "configure: No HOST specified." ;
140 echo) 2>&1
141 fatal=true
fecd2382 142 fi
61907f51 143fi
fecd2382 144
3d6f0983
RP
145if [ -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
fecd2382
RP
170fi
171
3d6f0983 172#### configure.in common parts come in here.
fecd2382
RP
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
178srctrigger=as.c
179srcname="gas"
180
3d6f0983 181## end of common part
fecd2382
RP
182
183# are we rebuilding config itself?
3d6f0983
RP
184if [ -n "${template}" ] ; then
185 if [ ! -r ${template} ] ; then
fecd2382
RP
186 echo "Can't find template ${template}."
187 exit 1
188 fi
189
190 mv configure configure.old
191 echo "#!/bin/sh" > configure
74cc5508
RP
192 echo "# Please do not edit this file. It is generated automatically from" >> configure
193 echo "# configure.in and a configure template." >> configure
fecd2382
RP
194 echo "configdirs=" >> configure
195 echo >> configure
196
3d6f0983
RP
197 if [ -r configure.in ] ; then
198 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
199 echo `pwd`/configure.in has no "per-host:" line.
200 exit 1
201 fi
202
203 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
204 echo `pwd`/configure.in has no "per-target:" line.
205 exit 1
206 fi
207
04dc1a62
RP
208 # split configure.in into common, per-host, and per-target parts
209 sed -e '/^# per\-host:/,$d' configure.in > configure.com
210 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
3d6f0983
RP
211 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
212
04dc1a62
RP
213 # and insert them
214 sed -e '/^#### configure.in common part/ r configure.com' \
215 -e '/^#### configure.in per\-host part/ r configure.hst' \
216 -e '/^#### configure.in per\-target part/ r configure.tgt' \
3d6f0983
RP
217 ${template} >> configure
218
219 rm -f configure.com configure.tgt configure.hst
fecd2382 220 else
ec342d7d
RP
221 echo Warning: no configure.in in `pwd`
222 cat ${template} >> configure
fecd2382
RP
223 fi
224
225 chmod a+x configure
226 rm configure.old
fecd2382
RP
227 echo Rebuilt configure in `pwd`
228
3d6f0983
RP
229 if [ -z "${norecurse}" ] ; then
230 while [ -n "${configdirs}" ] ; do
fecd2382 231 # set configdir to car of configdirs, configdirs to cdr of configdirs
ec342d7d 232 set ${configdirs}; configdir=$1; shift; configdirs=$*
fecd2382 233
3d6f0983 234 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
fecd2382
RP
235 targetspecificdirs=${configdir}.*
236 else
237 targetspecificdirs=
238 fi
239
3d6f0983
RP
240 for i in ${configdir} ${targetspecificdirs} ; do
241 if [ -r $i/configure ] ; then
fecd2382 242 (cd $i ;
3d6f0983 243 ./configure +template=${template} ${verbose})
fecd2382
RP
244 else
245 echo No configure script in `pwd`/$i
246 fi
247 done
248 done
249 fi
250
251 exit 0
252fi
253
ec342d7d 254# some sanity checks on configure.in
3d6f0983 255if [ -z "${srctrigger}" ] ; then
ec342d7d
RP
256 echo srctrigger not set in configure.in. `pwd` not configured.
257 exit 1
258fi
259
3d6f0983
RP
260for host in ${hosts} ; do
261 # Default other arg
262 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
263 targets=${host}
264 defaulttargets=true
265 fi
fecd2382 266
3d6f0983 267#### configure.in per-host parts come in here.
fecd2382 268
3d6f0983
RP
269## end of per-target part
270
271
272 for target in ${targets} ; do
273
274 if [ -n "${verbose}" ] ; then
275 echo " "target=\"${target}\"
74cc5508 276 fi
3d6f0983
RP
277
278#### configure.in per-target parts come in here.
279
280# assign cpu type
281case ${target} in
282sun4* | sparc*)
283 cpu_type=sparc
284 ;;
285sun3*)
286 cpu_type=m68k
287 ;;
288i386*)
289 cpu_type=i386
290 ;;
291i960*)
292 cpu_type=i960
293 ;;
294a29k*)
295 cpu_type=a29k
296 ;;
297*)
298 cpu_type=generic
299 ;;
300esac
301
302# assign object format
303case ${target} in
304*-coff)
305 obj_format=coff
306 ;;
307*-bout)
308 obj_format=bout
309 ;;
310generic)
311 obj_format=generic
312 ;;
313*)
314 obj_format=aout
315 ;;
316esac
317
318# assign floating point type
319case ${target} in
320vax)
321 atof=vax
322 ;;
323*)
324 atof=ieee
325 ;;
326esac
327
328files="config/ho-${host}.h config/tc-${cpu_type}.c \
329 config/tc-${cpu_type}.h config/te-generic.h \
330 config/obj-${obj_format}.h config/obj-${obj_format}.c \
331 config/atof-${atof}.c"
332
333links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c"
334## end of per-target part
335
336 # Temporarily, we support only direct subdir builds.
337 hostsubdir=Host-${host}
338 targetsubdir=Target-${target}
339
340 if [ -n "${removing}" ] ; then
341 if [ -d "${hostsubdir}/${targetsubdir}" ] ; then
342 rm -rf ${hostsubdir}/${targetsubdir}
343
344 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then
345 rm -rf ${hostsubdir}
346 fi
347 else
348 rm -f Makefile config.status ${links}
349 fi
74cc5508 350 else
3d6f0983
RP
351 if [ -n "${forcesubdirs}" ] ; then
352 # check for existing status before allowing forced subdirs.
353 if [ -f Makefile ] ; then
354 echo "Makefile already exists in source directory. `pwd` not configured."
355 exit 1
356 fi
fecd2382 357
3d6f0983
RP
358 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
359 cd ${hostsubdir}
fecd2382 360
3d6f0983
RP
361 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
362 cd ${targetsubdir}
fecd2382 363
3d6f0983
RP
364 srcdir=../..
365 else
366 # if not subdir builds, then make sure none exist.
367 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
368 echo "Configured subdirs exist. `pwd` not configured."
369 exit 1
370 fi
371 fi
fecd2382 372
3d6f0983
RP
373 # Find the source files, if location was not specified.
374 if [ -z "${srcdir}" ] ; then
375 srcdirdefaulted=1
376 srcdir=.
377 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
378 srcdir=..
379 fi
380 fi
fecd2382 381
3d6f0983
RP
382 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
383 if [ -z "${srcdirdefaulted}" ] ; then
384 echo "${progname}: Can't find ${srcname} sources in \`${srcdir}'." 1>&2
385 else
386 echo "${progname}: Can't find ${srcname} sources in \`.' or \`..'." 1>&2
387 fi
388
389 exit 1
390 fi
fecd2382 391
3d6f0983
RP
392 # Set up the list of links to be made.
393 # ${links} is the list of link names, and ${files} is the list of names to link to.
61907f51 394
3d6f0983
RP
395 # Make the links.
396 while [ -n "${files}" ] ; do
397 # set file to car of files, files to cdr of files
398 set ${files}; file=$1; shift; files=$*
399 set ${links}; link=$1; shift; links=$*
fecd2382 400
3d6f0983
RP
401 if [ ! -r ${srcdir}/${file} ] ; then
402 echo "${progname}: cannot create a link \"${link}\"," 1>&2
403 echo "since the file \"${file}\" does not exist." 1>&2
404 exit 1
405 fi
61907f51 406
3d6f0983
RP
407 ${remove} -f ${link}
408 rm -f config.status
409 # Make a symlink if possible, otherwise try a hard link
410 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
61907f51 411
3d6f0983
RP
412 if [ ! -r ${link} ] ; then
413 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
414 exit 1
415 fi
416 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
417 done
61907f51 418
3d6f0983
RP
419 # Create a .gdbinit file which runs the one in srcdir
420 # and tells GDB to look there for source files.
421
422 case ${srcdir} in
423 .)
424 ;;
425 *)
426 echo "dir ." > .gdbinit
427 echo "dir ${srcdir}" >> .gdbinit
428 echo "source ${srcdir}/.gdbinit" >> .gdbinit
429 ;;
430 esac
431
432 # Install a makefile, and make it set VPATH
433 # if necessary so that the sources are found.
434 # Also change its value of srcdir.
435
436 # FIXME-someday: This business of always writing to .tem and mv back
437 # is so that I don't screw things up while developing. Once this
438 # template is stable, these should be optimized. xoxorich.
439
440 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
441 if [ "${host}" != "${target}" ] ; then
442 echo "CROSS=-DCROSS_COMPILE" > Makefile
443 echo "ALL=start.encap" >> Makefile
444 else
445 echo "ALL=all.internal" > Makefile
446 fi
61907f51 447
3d6f0983
RP
448 # set target, host, VPATH
449 echo "host = ${host}" >> Makefile
450 echo "target = ${target}" >> Makefile
61907f51 451
3d6f0983
RP
452 if [ -n "${forcesubdirs}" ] ; then
453 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
454 else
455 echo "subdir =" >> Makefile
456 fi
61907f51 457
3d6f0983
RP
458 # echo "workdir = `pwd`" >> Makefile
459 echo "VPATH = ${srcdir}" >> Makefile
61907f51 460
3d6f0983
RP
461 # add Makefile.in
462 cat ${srcdir}/Makefile.in >> Makefile
fecd2382 463
3d6f0983
RP
464 # and shake thoroughly.
465 host_var_file=hmake-${host}
466 target_var_file=tmake-${target}
fecd2382 467
3d6f0983
RP
468 # Conditionalize the makefile for this host.
469 if [ -f ${srcdir}/config/${host_var_file} ] ; then
470 sed -e "/^####/ r ${srcdir}/config/${host_var_file}" Makefile > Makefile.tem
471 mv Makefile.tem Makefile
472 fi
fecd2382 473
3d6f0983
RP
474 # Conditionalize the makefile for this target.
475 if [ -f ${srcdir}/config/${target_var_file} ] ; then
476 sed -e "/^####/ r ${srcdir}/config/${target_var_file}" Makefile > Makefile.tem
477 mv Makefile.tem Makefile
478 fi
61907f51 479
3d6f0983
RP
480 # set srcdir
481 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
482 mv Makefile.tem Makefile
ec342d7d 483
3d6f0983
RP
484 # set destdir
485 if [ -n "${destdir}" ] ; then
486 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
487 mv Makefile.tem Makefile
488 fi
fecd2382 489
3d6f0983
RP
490 # Remove all formfeeds, since some Makes get confused by them.
491 sed "s/\f//" Makefile >> Makefile.tem
492 mv Makefile.tem Makefile
fecd2382 493
3d6f0983
RP
494 # reset SUBDIRS
495 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
496 mv Makefile.tem Makefile
fecd2382 497
3d6f0983
RP
498 # reset NONSUBDIRS
499 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
500 mv Makefile.tem Makefile
fecd2382 501
3d6f0983
RP
502 using=
503 if [ -f ${srcdir}/config/${host_var_file} ] ; then
504 using=" using \"${host_var_file}\""
505 fi
fecd2382 506
3d6f0983
RP
507 if [ -f ${srcdir}/config/${target_var_file} ] ; then
508 if [ -z "${using}" ] ; then
509 andusing=" using \"${target_var_file}\""
510 else
511 andusing="${using} and \"${target_var_file}\""
512 fi
513 else
514 andusing=${using}
515 fi
fecd2382 516
3d6f0983 517 echo "Created \"Makefile\"" in `pwd`${andusing}.
fecd2382 518
3d6f0983
RP
519 if [ "${host}" = "${target}" ] ; then
520 echo "Links are now set up for use with a ${target}." \
521 > config.status
522 # | tee ${srcdir}/config.status
523 else
524 echo "Links are now set up for host ${host} and target ${target}." \
525 > config.status
526 # | tee ${srcdir}/config.status
527 fi
528
529 originaldir=`pwd`
530 cd ${srcdir}
531 fi
532 done
533done
fecd2382
RP
534
535# If there are subdirectories, then recurse.
536
3d6f0983 537if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
fecd2382 538
3d6f0983
RP
539# configdirs is not null
540for configdir in ${configdirs} ; do
fecd2382 541 echo Configuring ${configdir}...
3d6f0983
RP
542 specifics=
543 commons=
544
545 if [ -n "${defaulttargets}" ] ; then
546 for host in ${hosts} ; do
547 if [ -d ${configdir}.${host} ] ; then
548 newspecifics="${specifics} ${host}"
549 specifics=${newspecifics}
550 else
551 newcommons="${commons} ${host}"
552 commons=${newcommons}
553 fi # if target specific
554 done # for each host
555
556 if [ -n "${commons}" ] ; then
557 (cd ${configdir} ;
558 ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \
559 | sed 's/^/ /'
560 fi # if any common hosts
561
562 if [ -n "${specifics}" ] ; then
563 for host in ${specifics} ; do
564 echo Configuring target specific directory ${configdir}.${host}...
565 (cd ${configdir}.${host} ;
566 ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \
567 | sed 's/^/ /'
568 done # for host in specifics
569 fi # if there are any specifics
570 else
571
572 for target in ${targets} ; do
573 if [ -d ${configdir}.${target} ] ; then
574 newspecifics="${specifics} ${target}"
575 specifics=${newspecifics}
576 else
577 newcommons="${commons} +target=${target}"
578 commons=${newcommons}
579 fi
580
581 done # check for target specific dir override
582
583 if [ -n "${verbose}" ] ; then
584 echo " "commons=\"${commons}\"
585 echo " "specifics=\"${specifics}\"
586 fi # if verbose
587
588 if [ -n "${commons}" ] ; then
589 (cd ${configdir} ;
590 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
591 | sed 's/^/ /'
592 fi # if any commons
593
594 if [ -n "${specifics}" ] ; then
595 for target in ${specifics} ; do
596 echo Configuring target specific directory ${configdir}.${target}...
597 (cd ${configdir}.${target} ;
598 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
599 | sed 's/^/ /'
600 done
601 fi # if any specifics
602 fi # not default targets
fecd2382
RP
603done
604
605exit 0
74cc5508
RP
606
607#
608# $Log$
04dc1a62
RP
609# Revision 1.8 1991/04/17 01:40:45 rich
610# Fixed a problem with host dependent parts.
611#
612# Revision 1.6 1991/04/16 00:18:44 rich
3d6f0983
RP
613# Now handles multiple hosts and targets.
614#
615# Revision 1.5 1991/04/15 23:43:44 rich
616# Now handles multiple hosts and targets.
617#
618# Revision 1.4 1991/04/13 02:11:03 rich
ec342d7d
RP
619# Config cut 3. We now almost install a29k.
620#
621# Revision 1.3 1991/04/11 02:41:54 rich
61907f51 622# Cut 2 config. Subdirs.
74cc5508
RP
623#
624#
625#
626
3d6f0983
RP
627#
628# Local Variables:
629# fill-column: 131
630# End:
631#
74cc5508
RP
632
633# end of configure.template
This page took 0.051904 seconds and 4 git commands to generate.