* xcoffread.c: Add decl for section_offset to keep prototype happy.
[deliverable/binutils-gdb.git] / gdb / configure
CommitLineData
0df06ca0
RP
1#!/bin/sh
2
5a168a17 3# Configuration script
0df06ca0
RP
4# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
5
6#This file is part of GNU.
7
bdf3621b
JG
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
0df06ca0
RP
21
22# $Id$
23
24#
25# Shell script to create proper links to machine-dependent files in
26# preparation for compilation.
27#
28# If configure succeeds, it leaves its status in config.status.
29# If configure fails after disturbing the status quo,
30# config.status is removed.
31#
32
33remove=rm
34hard_link=ln
35symbolic_link='ln -s'
36
37#for Test
38#remove="echo rm"
39#hard_link="echo ln"
40#symbolic_link="echo ln -s"
41
c4220303
RP
42progname=$0
43
0df06ca0
RP
44# clear some things potentially inherited from environment.
45ansi=
5a168a17 46arguments=$*
c4220303 47defaulttargets=
0df06ca0
RP
48destdir=
49fatal=
50hostsubdir=
bdf3621b
JG
51Makefile=Makefile
52Makefile_in=Makefile.in
5a168a17
RP
53norecursion=
54recurring=
0df06ca0
RP
55removing=
56srcdir=
57srctrigger=
58target=
59targets=
f0b9c976 60commontargets=
5a168a17 61configdirs=
0df06ca0
RP
62targetsubdir=
63template=
64verbose=
65
66for arg in $*;
67do
68 case ${arg} in
f0b9c976 69 -ansi | +a*)
0df06ca0 70 ansi=true
f0b9c976 71 clib=clib
0df06ca0
RP
72 ;;
73 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
74 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
75 ;;
0df06ca0
RP
76 -languages=* | +languages=* | +language=* | +languag=* \
77 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
78 | +l=*)
79 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
80 ;;
f0b9c976 81 -gas | +g*)
0df06ca0
RP
82 gas=yes
83 ;;
f0b9c976 84 -help | +h*)
0df06ca0
RP
85 fatal=true
86 ;;
f0b9c976 87 -nfp | +nf*)
0df06ca0
RP
88 nfp=yes
89 ;;
5a168a17
RP
90 -norecursion | +no*)
91 norecursion=true
0df06ca0 92 ;;
5a168a17
RP
93 -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re)
94 recurring=true
625453dc 95 ;;
5a168a17 96 -rm | +rm)
0df06ca0
RP
97 removing=${arg}
98 ;;
99# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
100# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
101# ;;
f0b9c976
RP
102 -subdirs | +f* | +su*)
103 subdirs=${arg}
104 ;;
105 -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*)
0df06ca0 106 if [ -n "${targets}" ] ; then
f0b9c976 107 subdirs="+subdirs"
0df06ca0
RP
108 fi
109
110 newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
111 targets="${newtargets}"
112 ;;
f0b9c976 113 -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*)
0df06ca0
RP
114 template=`echo ${arg} | sed 's/[+-]template=//'`
115 ;;
f0b9c976 116 -v | -verbose | +v*)
0df06ca0
RP
117 verbose=${arg}
118 ;;
119 -* | +*)
120 (echo ;
121 echo "Unrecognized option: \"${arg}\"". ;
625453dc 122 echo) 1>&2
0df06ca0
RP
123 fatal=true
124 ;;
125 *)
126 if [ -n "${hosts}" ] ; then
f0b9c976 127 subdirs="+subdirs"
0df06ca0
RP
128 fi
129
130 newhosts="${hosts} ${arg}"
131 hosts=${newhosts}
132 ;;
133 esac
134done
135
136if [ -n "${verbose}" ] ; then
137 echo `pwd`/configure $*
0df06ca0
RP
138fi
139
140# process host and target only if not rebuilding configure itself or removing.
141if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
142 # Complain if an arg is missing
143 if [ -z "${hosts}" ] ; then
144 (echo ;
145 echo "configure: No HOST specified." ;
625453dc 146 echo) 1>&2
0df06ca0
RP
147 fatal=true
148 fi
149fi
150
151if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
152 (echo "Usage: configure HOST" ;
153 echo ;
154 echo "Options: [defaults in brackets]" ;
155 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
156 echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ;
f0b9c976 157 echo " +subdirs configure in subdirectories. [in source directories]" ;
0df06ca0
RP
158 echo " +lang=LANG configure to build LANG. [gcc]" ;
159 echo " +help print this message. [normal config]" ;
160 echo " +gas configure the compilers for use with gas. [native as]" ;
161 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
5a168a17 162 echo " +norecursion configure this directory only. [recurse]" ;
0df06ca0
RP
163 echo " +rm remove this configuration. [build a configuration]" ;
164 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
165 echo " +template=TEM rebuild configure using TEM. [normal config]" ;
166 echo ;
167 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
f0b9c976 168 echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ;
625453dc 169 echo "options given will apply to all targets.") 1>&2
0df06ca0
RP
170
171 if [ -r config.status ] ; then
172 cat config.status
173 fi
174
175 exit 1
176fi
177
178#### configure.in common parts come in here.
912e0732
RP
179srcname="GDB"
180srctrigger=main.c
0df06ca0 181
c4220303 182## end of common part.
0df06ca0
RP
183
184# are we rebuilding config itself?
185if [ -n "${template}" ] ; then
186 if [ ! -r ${template} ] ; then
625453dc 187 echo '***' "Can't find template ${template}." 1>&2
0df06ca0
RP
188 exit 1
189 fi
190
c4220303
RP
191# prep the template
192 sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\
193#### configure.in common parts come in here.\
194## end of common part.' \
195 -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\
196#### configure.in per-host parts come in here.\
197## end of per-host part.' \
198 -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\
199#### configure.in per-target parts come in here.\
200## end of per-target part.' \
bdf3621b
JG
201 -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\
202#### configure.in post-target parts come in here.\
203## end of post-target part.' \
c4220303 204 < ${template} > template.new
0df06ca0
RP
205
206 if [ -r configure.in ] ; then
207 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
625453dc 208 echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2
0df06ca0
RP
209 exit 1
210 fi
211
212 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
625453dc 213 echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2
0df06ca0
RP
214 exit 1
215 fi
216
bdf3621b
JG
217 # split configure.in into common, per-host, per-target,
218 # and post-target parts. Post-target is optional.
c4220303
RP
219 sed -e '/^# per\-host:/,$d' configure.in > configure.com
220 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst
bdf3621b
JG
221 if grep -s '^# post-target:' configure.in ; then
222 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt
223 sed -e '1,/^# post\-target:/d' configure.in > configure.pos
224 else
225 sed -e '1,/^# per\-target:/d' configure.in > configure.tgt
226 echo >configure.pos
227 fi
0df06ca0 228
c4220303
RP
229 # and insert them
230 sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \
231 -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \
232 -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \
bdf3621b 233 -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \
c4220303 234 template.new > configure.new
0df06ca0 235
bdf3621b 236 rm -f configure.com configure.tgt configure.hst configure.pos
0df06ca0
RP
237 else
238 echo Warning: no configure.in in `pwd`
239 cat ${template} >> configure
240 fi
241
c4220303
RP
242 chmod a+x configure.new
243 rm template.new
244# mv configure configure.old
245 mv configure.new configure
f0b9c976
RP
246
247 if [ -n "${verbose}" ] ; then
248 echo Rebuilt configure in `pwd`
249 fi
0df06ca0 250
625453dc
SG
251 # Now update config.sub from the template directory.
252 if echo "$template" | grep -s 'configure$' ; then
253 cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new
254 # mv config.sub config.sub.old
255 mv config.sub.new config.sub
256
257 if [ -n "${verbose}" ] ; then
258 echo Rebuilt config.sub in `pwd`
259 fi
260 fi
261
5a168a17
RP
262 if [ -z "${norecursion}" ] ; then
263 # If template is relative path, make it absolute for recurring.
6988f5c0
JG
264 if echo "${template}" | grep -s '^/' ; then
265 true
266 else
267 template=`pwd`/${template}
268 fi
269
0df06ca0
RP
270 while [ -n "${configdirs}" ] ; do
271 # set configdir to car of configdirs, configdirs to cdr of configdirs
272 set ${configdirs}; configdir=$1; shift; configdirs=$*
273
274 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
275 targetspecificdirs=${configdir}.*
276 else
277 targetspecificdirs=
278 fi
279
280 for i in ${configdir} ${targetspecificdirs} ; do
912e0732
RP
281 if [ -d $i ] ; then
282 if [ -r $i/configure ] ; then
283 (cd $i ;
284 ./configure +template=${template} ${verbose})
285 else
f0b9c976 286 echo Warning: No configure script in `pwd`/$i
912e0732 287 fi
0df06ca0 288 else
625453dc
SG
289 if [ -n "${verbose}" ] ; then
290 echo Warning: directory $i is missing.
291 fi
0df06ca0
RP
292 fi
293 done
294 done
295 fi
296
297 exit 0
298fi
299
300# some sanity checks on configure.in
301if [ -z "${srctrigger}" ] ; then
f0b9c976 302 echo Warning: srctrigger not set in configure.in. `pwd` not configured.
0df06ca0
RP
303 exit 1
304fi
305
306for host in ${hosts} ; do
307 # Default other arg
c4220303 308 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
0df06ca0 309 targets=${host}
c4220303 310 defaulttargets=true
0df06ca0
RP
311 fi
312
5a168a17
RP
313 host_alias=${host}
314
625453dc
SG
315 result=`/bin/sh ./config.sub ${host}`
316 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
317 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
318 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
319 host=${host_cpu}-${host_vendor}-${host_os}
391e5612
JG
320 host_makefile_frag=config/hmake-${host}
321
0df06ca0 322#### configure.in per-host parts come in here.
c4220303 323
625453dc
SG
324# map host info into gdb names.
325
326case "${host_cpu}" in
327
328m68k)
329 case "${host_vendor}" in
330 att) gdb_host=3b1 ;;
331 altos)
332 case "${host_os}" in
333 gas) gdb_host=altosgas ;;
334 *) gdb_host=altos ;;
335 esac
336 ;;
337 hp)
338 case ${host_os} in
339 hpux) gdb_host=hp300hpux ;;
340 bsd) gdb_host=hp300bsd ;;
341 esac
342 ;;
343
344 isi) gdb_host=isi ;;
345 sony) gdb_host=news ;;
346 sun)
347 case "${host_os}" in
348 sunos3) gdb_host=sun3os3 ;;
349 sunos4) gdb_host=sun3os4 ;;
350 *) gdb_host=sun3 ;;
351 esac
352 ;;
353 esac
354 ;;
355
356m68000)
357 case "${host_vendor}" in
358 sun)
359 case "${host_os}" in
360 sunos3) gdb_host=sun2os3 ;;
361 sunos4) gdb_host=sun2os4 ;;
362 *) gdb_host=sun2 ;;
363 esac
364 esac
365 ;;
366
367sparc)
368 case "${host_os}" in
369 sunos3) gdb_host=sun4os3 ;;
370 sunos4) gdb_host=sun4os4 ;;
371 *) gdb_host=sun4 ;;
372 esac
373 ;;
374
375m68030)
376 case "${host_vendor}" in
377 sony) gdb_host=news1000 ;;
378 esac
379 ;;
380
381mips)
382 case "${host_vendor}" in
383 sony) gdb_host=bigmips ;;
384 dec) gdb_host=dec3100 ;;
385 little) gdb_host=littlemips ;;
386 sgi) gdb_host=irix3 ;;
387 esac
388 ;;
389
390i386)
391 case "${host_vendor}" in
392 sun) gdb_host=sun386 ;;
393 sco) gdb_host=i386sco ;;
394 sequent) gdb_host=symmetry ;;
395 *)
396 case "${host_os}" in
397 sysv) gdb_host=i386v ;;
398 sysv32) gdb_host=i386v32 ;;
399 esac
400 ;;
401 esac
402 ;;
403
404c1 | c2) gdb_host=convex ;;
405
406ns32k)
407 case "${host_vendor}" in
408 umax) gdb_host=umax ;;
409 esac
410 ;;
411
5a168a17
RP
412romp)
413 gdb_host=rtbsd
414 ;;
415
416a29k)
417 gdb_host=ultra3
418 ;;
419
420arm | vax | m88k | merlin | none | np1 | pn | pyramid | tahoe)
421 gdb_host=${host_cpu}
422 ;;
625453dc
SG
423
424### unhandled hosts
425#altosgas
426#i386v-g
427#i386v32-g
428
429esac
430
431if [ ! -f xconfig/${gdb_host} ]; then
432 echo '***' "Gdb does not support host ${host}" 1>&2
912e0732
RP
433 exit 1
434fi
435
bdf3621b 436# We really shouldn't depend on there being a space after XM_FILE= ...
625453dc 437hostfile=`awk '$1 == "XM_FILE=" { print $2 }' <xconfig/${gdb_host}`
912e0732 438
c4220303 439## end of per-host part.
0df06ca0 440
0df06ca0
RP
441 for target in ${targets} ; do
442
5a168a17 443 target_alias=${target}
625453dc
SG
444 result=`/bin/sh ./config.sub ${target}`
445 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
446 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
447 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
448 target=${target_cpu}-${target_vendor}-${target_os}
391e5612
JG
449 target_makefile_frag=config/tmake-${target}
450
0df06ca0 451#### configure.in per-target parts come in here.
c4220303 452
625453dc
SG
453case "${target_cpu}" in
454
455m68k)
456 case "${target_vendor}" in
457 att) gdb_target=3b1 ;;
458 altos) gdb_target=altos ;;
459 hp)
460 case "${target_os}" in
461 bsd) gdb_target=hp300bsd ;;
462 hpux) gdb_target=hp300hpux ;;
463 esac
464 ;;
465 sun)
466 case "${target_os}" in
467 sunos3) gdb_target=sun3os3 ;;
468 sunos4) gdb_target=sun3os4 ;;
469 *) gdb_target=sun3 ;;
470 esac
471 ;;
472 wrs) gdb_target=vxworks68 ;;
473 isi) gdb_target=isi ;;
474 sony) gdb_target=news ;;
475 esac
476 ;;
477
478m68000)
479 case "${target_vendor}" in
480 sun)
481 case "${target_os}" in
482 sunos3) gdb_target=sun2os3 ;;
483 sunos4) gdb_target=sun2os4 ;;
484 *) gdb_target=sun2 ;;
485 esac
486 esac
487 ;;
488
489m68030)
490 case "${target_vendor}" in
491 sony) gdb_target=news1000 ;;
492 esac
493 ;;
494
5a168a17 495none | arm | tahoe | vax | np1 | pn | np1 | pn | pyramid | merlin | m88k)
625453dc 496 gdb_target=${target_cpu} ;;
625453dc 497
5a168a17
RP
498a29k)
499 case "${target_os}" in
500 none|aout|coff) gdb_target=a29k ;;
501 sym1) gdb_target=ultra3 ;;
502 kern) gdb_target=a29k-kern ;;
503 esac
504 ;;
505
625453dc
SG
506mips)
507 case "${target_vendor}" in
508 sony) gdb_target=bigmips ;;
509 dec) gdb_target=dec3100 ;;
510 little) gdb_target=littlemips ;;
511 sgi) gdb_target=irix3 ;;
512 esac
513 ;;
514
515c1 | c2) gdb_target=convex ;;
516
517sparc)
518 case "${target_vendor}" in
519 sun)
520 case "${target_os}" in
521 sunos3) gdb_target=sun4os3 ;;
522 sunos4) gdb_target=sun4os4 ;;
523 *) gdb_target=sun4 ;;
524 esac
525 ;;
526 esac
527 ;;
528
529
530i386)
531 case "${target_vendor}" in
532 sco) gdb_target=i386sco ;;
533 sun) gdb_target=sun386 ;;
534 sequent) gdb_target=symmetry ;;
535 coff) gdb_target=i386v ;;
536 aout) gdb_target=i386v ;;
537 *)
538 case "${target_os}" in
539 sysv) gdb_target=i386v ;;
540 sysv32) gdb_target=i386v32 ;;
541 esac
542 esac
543 ;;
544
545i960)
546 case "${target_vendor}" in
547 bout | wrs) gdb_target=vxworks960 ;;
548 coff | intel) gdb_target=nindy960 ;;
549 esac
550 ;;
551
552ns32k)
553 case "${target_vendor}" in
554 utek) gdb_target=umax ;;
555 esac
556 ;;
557
558### unhandled targets
559# altosgas
560# i386v-g
561# i386v32-g
562
563esac
564
565if [ ! -f tconfig/${gdb_target} ]; then
566 echo '***' "Gdb does not support target ${target}" 1>&2
912e0732
RP
567 exit 1
568fi
569
570if [ -z "${removing}" ] ; then
625453dc 571 cat xconfig/${gdb_host} tconfig/${gdb_target} | awk '$1 == "#msg" {
912e0732
RP
572 print substr($0,6)}'
573fi
574
bdf3621b 575# We really shouldn't depend on there being a space after TM_FILE= ...
625453dc 576targetfile=`awk '$1 == "TM_FILE=" { print $2 }' <tconfig/${gdb_target}`
912e0732 577
625453dc
SG
578host_makefile_frag=xconfig/${gdb_host}
579target_makefile_frag=tconfig/${gdb_target}
912e0732 580
bdf3621b 581# If hostfile (XM_FILE) and/or targetfile (TM_FILE) is not set in the
4101d868
RP
582# ?config/* file, we don't make the corresponding links. But we have
583# to remove the xm.h files and tm.h files anyway, e.g. when switching
584# from "configure host" to "configure none".
bdf3621b
JG
585files=
586links=
4101d868 587rm -f xm.h
bdf3621b
JG
588if [ "${hostfile}" != "" ]; then
589 files="${files} ${hostfile}"
590 links="${links} xm.h"
591fi
4101d868 592rm -f tm.h
bdf3621b
JG
593if [ "${targetfile}" != "" ]; then
594 files="${files} ${targetfile}"
595 links="${links} tm.h"
596fi
912e0732 597
c4220303 598## end of per-target part.
0df06ca0
RP
599
600 # Temporarily, we support only direct subdir builds.
5a168a17
RP
601 hostsubdir=H-${host_alias}
602 targetsubdir=T-${target_alias}
0df06ca0
RP
603
604 if [ -n "${removing}" ] ; then
f0b9c976 605 if [ -n "${subdirs}" ] ; then
c4220303
RP
606 if [ -d "${hostsubdir}" ] ; then
607 rm -rf ${hostsubdir}/${targetsubdir}
0df06ca0 608
f0b9c976 609 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then
c4220303
RP
610 rm -rf ${hostsubdir}
611 fi
612 else
613 echo Warning: no `pwd`/${hostsubdir} to remove.
0df06ca0
RP
614 fi
615 else
bdf3621b 616 rm -f ${Makefile} config.status ${links}
0df06ca0
RP
617 fi
618 else
f0b9c976 619 if [ -n "${subdirs}" ] ; then
0df06ca0 620 # check for existing status before allowing forced subdirs.
bdf3621b 621 if [ -f ${Makefile} ] ; then
625453dc 622 echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2
0df06ca0
RP
623 exit 1
624 fi
625
626 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
627 cd ${hostsubdir}
628
f0b9c976
RP
629 if [ ! -d ${targetsubdir} ] ; then
630 if [ -z "${commontargets}" ] ; then
631 mkdir ${targetsubdir}
632 else
633 if [ ! -d Target-independent ] ; then
634 mkdir Target-independent
635 fi
636
637 ${symbolic_link} Target-independent ${targetsubdir}
638 fi # if target independent
639 fi # if no target dir yet
640
0df06ca0
RP
641 cd ${targetsubdir}
642
643 srcdir=../..
644 else
645 # if not subdir builds, then make sure none exist.
646 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
625453dc 647 echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2
0df06ca0
RP
648 exit 1
649 fi
650 fi
651
652 # Find the source files, if location was not specified.
653 if [ -z "${srcdir}" ] ; then
654 srcdirdefaulted=1
655 srcdir=.
656 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
657 srcdir=..
658 fi
659 fi
660
661 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
662 if [ -z "${srcdirdefaulted}" ] ; then
625453dc 663 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
0df06ca0 664 else
625453dc 665 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
0df06ca0
RP
666 fi
667
625453dc 668 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
0df06ca0
RP
669 exit 1
670 fi
671
672 # Set up the list of links to be made.
673 # ${links} is the list of link names, and ${files} is the list of names to link to.
674
675 # Make the links.
676 while [ -n "${files}" ] ; do
677 # set file to car of files, files to cdr of files
678 set ${files}; file=$1; shift; files=$*
679 set ${links}; link=$1; shift; links=$*
680
681 if [ ! -r ${srcdir}/${file} ] ; then
625453dc
SG
682 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
683 echo '***' "since the file \"${file}\" does not exist." 1>&2
0df06ca0
RP
684 exit 1
685 fi
686
687 ${remove} -f ${link}
688 rm -f config.status
689 # Make a symlink if possible, otherwise try a hard link
690 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
691
692 if [ ! -r ${link} ] ; then
625453dc 693 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
0df06ca0
RP
694 exit 1
695 fi
f0b9c976
RP
696
697 if [ -n "${verbose}" ] ; then
698 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
699 fi
0df06ca0
RP
700 done
701
702 # Create a .gdbinit file which runs the one in srcdir
703 # and tells GDB to look there for source files.
704
705 case ${srcdir} in
706 .)
707 ;;
708 *)
709 echo "dir ." > .gdbinit
710 echo "dir ${srcdir}" >> .gdbinit
711 echo "source ${srcdir}/.gdbinit" >> .gdbinit
712 ;;
713 esac
714
715 # Install a makefile, and make it set VPATH
716 # if necessary so that the sources are found.
717 # Also change its value of srcdir.
718
719 # FIXME-someday: This business of always writing to .tem and mv back
720 # is so that I don't screw things up while developing. Once this
721 # template is stable, these should be optimized. xoxorich.
722
723 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
724 if [ "${host}" != "${target}" ] ; then
bdf3621b
JG
725 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
726 echo "ALL=start.encap" >> ${Makefile}
0df06ca0 727 else
bdf3621b 728 echo "ALL=all.internal" > ${Makefile}
0df06ca0
RP
729 fi
730
731 # set target, host, VPATH
5a168a17
RP
732 echo "host_alias = ${host_alias}" >> ${Makefile}
733 echo "host_cpu = ${host_cpu}" >> ${Makefile}
734 echo "host_vendor = ${host_vendor}" >> ${Makefile}
735 echo "host_os = ${host_os}" >> ${Makefile}
736
737 echo "target_alias = ${target_alias}" >> ${Makefile}
738 echo "target_cpu = ${target_cpu}" >> ${Makefile}
739 echo "target_vendor = ${target_vendor}" >> ${Makefile}
740 echo "target_os = ${target_os}" >> ${Makefile}
0df06ca0 741
f0b9c976 742 if [ -n "${subdirs}" ] ; then
bdf3621b 743 echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile}
0df06ca0 744 else
bdf3621b 745 echo "subdir =" >> ${Makefile}
0df06ca0
RP
746 fi
747
bdf3621b
JG
748 # echo "workdir = `pwd`" >> ${Makefile}
749 echo "VPATH = ${srcdir}" >> ${Makefile}
0df06ca0 750
bdf3621b
JG
751 # add "Makefile.in" (or whatever it's called)
752 cat ${srcdir}/${Makefile_in} >> ${Makefile}
0df06ca0 753
0df06ca0 754 # Conditionalize the makefile for this host.
912e0732 755 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
5a168a17
RP
756 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
757 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
bdf3621b 758 mv Makefile.tem ${Makefile}
0df06ca0
RP
759 fi
760
761 # Conditionalize the makefile for this target.
912e0732 762 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
5a168a17
RP
763 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
764 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
bdf3621b 765 mv Makefile.tem ${Makefile}
0df06ca0
RP
766 fi
767
768 # set srcdir
bdf3621b
JG
769 sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
770 mv Makefile.tem ${Makefile}
0df06ca0
RP
771
772 # set destdir
773 if [ -n "${destdir}" ] ; then
bdf3621b
JG
774 sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem
775 mv Makefile.tem ${Makefile}
0df06ca0
RP
776 fi
777
0df06ca0 778 # reset SUBDIRS
bdf3621b
JG
779 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
780 mv Makefile.tem ${Makefile}
0df06ca0
RP
781
782 # reset NONSUBDIRS
bdf3621b
JG
783 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
784 mv Makefile.tem ${Makefile}
0df06ca0
RP
785
786 using=
912e0732
RP
787 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
788 using=" using \"${host_makefile_frag}\""
0df06ca0
RP
789 fi
790
5a168a17
RP
791 # remove any form feeds.
792 sed -e "s/\f//" ${Makefile} > Makefile.tem
793 mv Makefile.tem ${Makefile}
794
912e0732 795 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
0df06ca0 796 if [ -z "${using}" ] ; then
912e0732 797 andusing=" using \"${target_makefile_frag}\""
0df06ca0 798 else
912e0732 799 andusing="${using} and \"${target_makefile_frag}\""
0df06ca0
RP
800 fi
801 else
802 andusing=${using}
803 fi
804
5a168a17 805 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
f0b9c976
RP
806 echo "Created \"${Makefile}\"" in `pwd`${andusing}.
807 fi
bdf3621b
JG
808
809#### configure.in post-target parts come in here.
810
811case ${srcdir} in
812 .)
813 ;;
814 *)
815 grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \
816 echo "source ${srcdir}/.gdbinit" >> .gdbinit
817esac
818
4101d868 819cat ${srcdir}/alldeps.mak ${srcdir}/depend >>Makefile
bdf3621b 820## end of post-target part.
0df06ca0 821
5a168a17
RP
822 # describe the chosen configuration in config.status.
823 # Make that file a shellscript which will reestablish
824 # the same configuration. Used in Makefiles to rebuild
825 # Makefiles.
826
827 echo "#!/bin/sh
828# ${srcname} was configured as follows:
829${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status
830 chmod a+x config.status
0df06ca0
RP
831
832 originaldir=`pwd`
833 cd ${srcdir}
834 fi
625453dc
SG
835
836 # If there are subdirectories, then recurse.
5a168a17 837 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
625453dc
SG
838 for configdir in ${configdirs} ; do
839 if [ -n "${verbose}" ] ; then
840 echo Configuring ${configdir}...
841 fi
842
843 if [ -d ${configdir} ] ; then
844 (cd ${configdir} ;
5a168a17 845 ./configure +recurring ${host_alias} +target=${target_alias} \
625453dc
SG
846 ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \
847 | sed 's/^/ /'
848 else
849 if [ -n "${verbose}" ] ; then
850 echo Warning: directory \"${configdir}\" is missing.
851 fi
852 fi
853 done
854 fi
c4220303
RP
855 done # for each target
856
4101d868 857 # Now build a Makefile for this host.
f0b9c976 858 if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
4101d868
RP
859 cd ${hostsubdir}
860 cat > GNUmakefile << E!O!F
5a168a17 861# Makefile generated by configure for host ${host_alias}.
4101d868
RP
862
863ALL := $(shell ls -d Target-*)
864
865%:
866 $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
867
868all:
869E!O!F
870 cd ..
871 fi
c4220303 872done # for each host
0df06ca0 873
0df06ca0
RP
874exit 0
875
0df06ca0
RP
876#
877# Local Variables:
878# fill-column: 131
879# End:
880#
881
5a168a17 882# end of configure
This page took 0.097033 seconds and 4 git commands to generate.