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