44ab9dc268b5e07157e76541fb72428f781e4320
[deliverable/binutils-gdb.git] / gdb / 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 srcname="GDB"
177 srctrigger=main.c
178
179 if [ -z "${template}" ] ; then
180 make -f Makefile.dist Makefile.in
181 fi
182
183 ## end of common part.
184
185 # are we rebuilding config itself?
186 if [ -n "${template}" ] ; then
187 if [ ! -r ${template} ] ; then
188 echo "Can't find template ${template}."
189 exit 1
190 fi
191
192 # prep the template
193 sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\
194 #### configure.in common parts come in here.\
195 ## end of common part.' \
196 -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\
197 #### configure.in per-host parts come in here.\
198 ## end of per-host part.' \
199 -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\
200 #### configure.in per-target parts come in here.\
201 ## end of per-target part.' \
202 < ${template} > template.new
203
204 if [ -r configure.in ] ; then
205 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
206 echo `pwd`/configure.in has no "per-host:" line.
207 exit 1
208 fi
209
210 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
211 echo `pwd`/configure.in has no "per-target:" line.
212 exit 1
213 fi
214
215 # split configure.in into common, per-host, and per-target parts
216 sed -e '/^# per\-host:/,$d' configure.in > configure.com
217 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
218 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
219
220 # and insert them
221 sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \
222 -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \
223 -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \
224 template.new > configure.new
225
226 rm -f configure.com configure.tgt configure.hst
227 else
228 echo Warning: no configure.in in `pwd`
229 cat ${template} >> configure
230 fi
231
232 chmod a+x configure.new
233 rm template.new
234 # mv configure configure.old
235 mv configure.new configure
236 echo Rebuilt configure in `pwd`
237
238 if [ -z "${norecurse}" ] ; then
239 while [ -n "${configdirs}" ] ; do
240 # set configdir to car of configdirs, configdirs to cdr of configdirs
241 set ${configdirs}; configdir=$1; shift; configdirs=$*
242
243 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
244 targetspecificdirs=${configdir}.*
245 else
246 targetspecificdirs=
247 fi
248
249 for i in ${configdir} ${targetspecificdirs} ; do
250 if [ -d $i ] ; then
251 if [ -r $i/configure ] ; then
252 (cd $i ;
253 ./configure +template=${template} ${verbose})
254 else
255 echo No configure script in `pwd`/$i
256 fi
257 else
258 echo Warning: directory $i is missing.
259 fi
260 done
261 done
262 fi
263
264 exit 0
265 fi
266
267 # some sanity checks on configure.in
268 if [ -z "${srctrigger}" ] ; then
269 echo srctrigger not set in configure.in. `pwd` not configured.
270 exit 1
271 fi
272
273 for host in ${hosts} ; do
274 # Default other arg
275 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
276 targets=${host}
277 defaulttargets=true
278 fi
279
280 #### configure.in per-host parts come in here.
281
282 if [ ! -f xconfig/${host} ]; then
283 echo "No such host ${host}"
284 exit 1
285 fi
286
287 targetfile=`awk '
288 $1 == "XM_FILE=" { print $2 }' <xconfig/$host`
289 if [ "${targetfile}" = "/" ] ; then
290 targetfile=/dev/null
291 fi
292
293 ## end of per-host part.
294
295
296 for target in ${targets} ; do
297
298 if [ -n "${verbose}" ] ; then
299 echo " "target=\"${target}\"
300 fi
301
302 #### configure.in per-target parts come in here.
303
304 if [ ! -f tconfig/${target} ]; then
305 echo "No such target ${target}"
306 exit 1
307 fi
308
309 if [ -z "${removing}" ] ; then
310 cat xconfig/${host} tconfig/${target} | awk '$1 == "#msg" {
311 print substr($0,6)}'
312 fi
313
314 hostfile=`awk '
315 $1 == "TM_FILE=" { print $2 }' <tconfig/$target`
316 if [ "${hostfile}" = "/" ] ; then
317 hostfile=/dev/null
318 fi
319
320 if [ ! -d readline ]; then
321 mkdir readline
322 # This could be a symlink, but getting the name right (because
323 # srcdir can be either relative or absolute) would be hairy.
324 cp ${srcdir}/readline/Makefile readline
325 fi
326
327 host_makefile_frag=xconfig/${host}
328 target_makefile_frag=tconfig/${target}
329
330 files="${hostfile} ${targetfile}"
331 links="xm.h tm.h"
332
333 ## end of per-target part.
334
335 # Temporarily, we support only direct subdir builds.
336 hostsubdir=Host-${host}
337 targetsubdir=Target-${target}
338
339 if [ -n "${removing}" ] ; then
340 if [ -n "${forcesubdirs}" ] ; then
341 if [ -d "${hostsubdir}" ] ; 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 echo Warning: no `pwd`/${hostsubdir} to remove.
349 fi
350 else
351 rm -f Makefile config.status ${links}
352 fi
353 else
354 if [ -n "${forcesubdirs}" ] ; then
355 # check for existing status before allowing forced subdirs.
356 if [ -f Makefile ] ; then
357 echo "Makefile already exists in source directory. `pwd` not configured."
358 exit 1
359 fi
360
361 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
362 cd ${hostsubdir}
363
364 if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi
365 cd ${targetsubdir}
366
367 srcdir=../..
368 else
369 # if not subdir builds, then make sure none exist.
370 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
371 echo "Configured subdirs exist. `pwd` not configured."
372 exit 1
373 fi
374 fi
375
376 # Find the source files, if location was not specified.
377 if [ -z "${srcdir}" ] ; then
378 srcdirdefaulted=1
379 srcdir=.
380 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
381 srcdir=..
382 fi
383 fi
384
385 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
386 if [ -z "${srcdirdefaulted}" ] ; then
387 echo "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
388 else
389 echo "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
390 fi
391
392 echo \(At least ${srctrigger} is missing.\) 1>&2
393 exit 1
394 fi
395
396 # Set up the list of links to be made.
397 # ${links} is the list of link names, and ${files} is the list of names to link to.
398
399 # Make the links.
400 while [ -n "${files}" ] ; do
401 # set file to car of files, files to cdr of files
402 set ${files}; file=$1; shift; files=$*
403 set ${links}; link=$1; shift; links=$*
404
405 if [ ! -r ${srcdir}/${file} ] ; then
406 echo "${progname}: cannot create a link \"${link}\"," 1>&2
407 echo "since the file \"${file}\" does not exist." 1>&2
408 exit 1
409 fi
410
411 ${remove} -f ${link}
412 rm -f config.status
413 # Make a symlink if possible, otherwise try a hard link
414 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
415
416 if [ ! -r ${link} ] ; then
417 echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
418 exit 1
419 fi
420 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
421 done
422
423 # Create a .gdbinit file which runs the one in srcdir
424 # and tells GDB to look there for source files.
425
426 case ${srcdir} in
427 .)
428 ;;
429 *)
430 echo "dir ." > .gdbinit
431 echo "dir ${srcdir}" >> .gdbinit
432 echo "source ${srcdir}/.gdbinit" >> .gdbinit
433 ;;
434 esac
435
436 # Install a makefile, and make it set VPATH
437 # if necessary so that the sources are found.
438 # Also change its value of srcdir.
439
440 # FIXME-someday: This business of always writing to .tem and mv back
441 # is so that I don't screw things up while developing. Once this
442 # template is stable, these should be optimized. xoxorich.
443
444 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
445 if [ "${host}" != "${target}" ] ; then
446 echo "CROSS=-DCROSS_COMPILE" > Makefile
447 echo "ALL=start.encap" >> Makefile
448 else
449 echo "ALL=all.internal" > Makefile
450 fi
451
452 # set target, host, VPATH
453 echo "host = ${host}" >> Makefile
454 echo "target = ${target}" >> Makefile
455
456 if [ -n "${forcesubdirs}" ] ; then
457 echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile
458 else
459 echo "subdir =" >> Makefile
460 fi
461
462 # echo "workdir = `pwd`" >> Makefile
463 echo "VPATH = ${srcdir}" >> Makefile
464
465 # add Makefile.in
466 cat ${srcdir}/Makefile.in >> Makefile
467
468 # and shake thoroughly.
469 if [ -z "${host_makefile_frag}" ] ; then
470 host_makefile_frag=config/hmake-${host}
471 fi
472
473 if [ -z "${target_makefile_frag}" ] ; then
474 target_makefile_frag=config/tmake-${target}
475 fi
476
477 # Conditionalize the makefile for this host.
478 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
479 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" Makefile > Makefile.tem
480 mv Makefile.tem Makefile
481 fi
482
483 # Conditionalize the makefile for this target.
484 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
485 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" Makefile > Makefile.tem
486 mv Makefile.tem Makefile
487 fi
488
489 # set srcdir
490 sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem
491 mv Makefile.tem Makefile
492
493 # set destdir
494 if [ -n "${destdir}" ] ; then
495 sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem
496 mv Makefile.tem Makefile
497 fi
498
499 # Remove all formfeeds, since some Makes get confused by them.
500 sed "s/\f//" Makefile >> Makefile.tem
501 mv Makefile.tem Makefile
502
503 # reset SUBDIRS
504 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem
505 mv Makefile.tem Makefile
506
507 # reset NONSUBDIRS
508 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem
509 mv Makefile.tem Makefile
510
511 using=
512 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
513 using=" using \"${host_makefile_frag}\""
514 fi
515
516 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
517 if [ -z "${using}" ] ; then
518 andusing=" using \"${target_makefile_frag}\""
519 else
520 andusing="${using} and \"${target_makefile_frag}\""
521 fi
522 else
523 andusing=${using}
524 fi
525
526 echo "Created \"Makefile\"" in `pwd`${andusing}.
527
528 if [ "${host}" = "${target}" ] ; then
529 echo "Links are now set up for use with a ${target}." \
530 > config.status
531 # | tee ${srcdir}/config.status
532 else
533 echo "Links are now set up for host ${host} and target ${target}." \
534 > config.status
535 # | tee ${srcdir}/config.status
536 fi
537
538 originaldir=`pwd`
539 cd ${srcdir}
540 fi
541 done # for each target
542
543 # # Now build a Makefile for this host.
544 # if [ -n "${forcesubdirs}" ] ; then
545 # cd ${hostsubdir}
546 # cat > GNUmakefile << E!O!F
547 ## Makefile generated by configure for host ${host}.
548 #
549 #%:
550 # for i in ${targets} ; do \
551 # $(MAKE) -C Target-\$i \$@
552 #
553 #all clean stage1 stage2 stage3 stage4etags tags TAGS
554 #E!O!F
555 # fi
556 done # for each host
557
558 # If there are subdirectories, then recurse.
559
560 if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi
561
562 # configdirs is not null
563 for configdir in ${configdirs} ; do
564 echo Configuring ${configdir}...
565 specifics=
566 commons=
567
568 if [ -n "${defaulttargets}" ] ; then
569 for host in ${hosts} ; do
570 if [ -d ${configdir}.${host} ] ; then
571 newspecifics="${specifics} ${host}"
572 specifics=${newspecifics}
573 else
574 newcommons="${commons} ${host}"
575 commons=${newcommons}
576 fi # if target specific
577 done # for each host
578
579 if [ -n "${commons}" ] ; then
580 if [ -d ${configdir} ] ; then
581 (cd ${configdir} ;
582 ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \
583 | sed 's/^/ /'
584 else
585 echo Warning: directory \"${configdir}\" is missing.
586 fi
587 fi # if any common hosts
588
589 if [ -n "${specifics}" ] ; then
590 for host in ${specifics} ; do
591 echo Configuring target specific directory ${configdir}.${host}...
592 (cd ${configdir}.${host} ;
593 ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \
594 | sed 's/^/ /'
595 done # for host in specifics
596 fi # if there are any specifics
597 else
598
599 for target in ${targets} ; do
600 if [ -d ${configdir}.${target} ] ; then
601 newspecifics="${specifics} ${target}"
602 specifics=${newspecifics}
603 else
604 newcommons="${commons} +target=${target}"
605 commons=${newcommons}
606 fi
607
608 done # check for target specific dir override
609
610 if [ -n "${verbose}" ] ; then
611 echo " "commons=\"${commons}\"
612 echo " "specifics=\"${specifics}\"
613 fi # if verbose
614
615 if [ -n "${commons}" ] ; then
616 if [ -d ${configdir} ] ; then
617 (cd ${configdir} ;
618 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \
619 | sed 's/^/ /'
620 else
621 echo Warning: directory \"${configdir}\" is missing.
622 fi
623 fi # if any commons
624
625 if [ -n "${specifics}" ] ; then
626 for target in ${specifics} ; do
627 echo Configuring target specific directory ${configdir}.${target}...
628 (cd ${configdir}.${target} ;
629 ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \
630 | sed 's/^/ /'
631 done
632 fi # if any specifics
633 fi # not default targets
634 done
635
636 exit 0
637
638 #
639 # $Log$
640 # Revision 1.4 1991/05/19 00:16:45 rich
641 # Configure for gdb.
642 #
643 # Revision 1.10 1991/05/04 00:58:38 rich
644 # Fix program name bug.
645 #
646 # Revision 1.9 1991/05/03 19:14:18 rich
647 # Changed getopt to libiberty, commented out an aborted attempt at host
648 # level Makefiles because it caused errors on +rm, add a warning for
649 # directories expected to be removed on +rm but that don't exist.
650 #
651 # Revision 1.8 1991/04/24 16:50:59 rich
652 # Three staging checkpoint.
653 #
654 # Revision 1.7 1991/04/17 01:34:47 rich
655 # Added getopt for binutils, fixed problem with host dependancies in
656 # configure.template.
657 #
658 # Revision 1.6 1991/04/16 00:18:44 rich
659 # Now handles multiple hosts and targets.
660 #
661 # Revision 1.5 1991/04/15 23:43:44 rich
662 # Now handles multiple hosts and targets.
663 #
664 # Revision 1.4 1991/04/13 02:11:03 rich
665 # Config cut 3. We now almost install a29k.
666 #
667 # Revision 1.3 1991/04/11 02:41:54 rich
668 # Cut 2 config. Subdirs.
669 #
670 #
671 #
672
673 #
674 # Local Variables:
675 # fill-column: 131
676 # End:
677 #
678
679 # end of configure.template
This page took 0.043145 seconds and 4 git commands to generate.