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