* parse.c (write_dollar_variable): New function.
[deliverable/binutils-gdb.git] / configure
CommitLineData
eb02fd64 1#!/bin/sh
eb02fd64 2
70d3fab7
DZ
3### WARNING: this file contains embedded tabs. Do not run untabify on this file.
4
46f3c7cd 5# Configuration script
9336e47e 6# Copyright (C) 1988, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
eb02fd64 7
063efd10
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
ca2ce3b3 20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
eb02fd64 21
121bdf8f 22# Please report any problems running this configure script to
49b10446 23# configure@cygnus.com
121bdf8f
ILT
24# Please do not send reports about other problems to this address. See
25# gdb/README, gas/README, etc., for info on where and how to report
26# problems about particular tools.
49b10446 27
c1e4672c
RP
28# This file was written by K. Richard Pixley.
29
eb02fd64
RP
30#
31# Shell script to create proper links to machine-dependent files in
0df06ca0 32# preparation for compilation.
eb02fd64
RP
33#
34# If configure succeeds, it leaves its status in config.status.
35# If configure fails after disturbing the status quo,
73f1f5ba 36# config.status is removed.
eb02fd64
RP
37#
38
4d714963 39export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
c297d71e 40
eb02fd64
RP
41remove=rm
42hard_link=ln
43symbolic_link='ln -s'
44
45#for Test
46#remove="echo rm"
47#hard_link="echo ln"
48#symbolic_link="echo ln -s"
49
50# clear some things potentially inherited from environment.
6f8ac2d9
RP
51
52Makefile=Makefile
53Makefile_in=Makefile.in
b8f8fddc 54arguments=$*
24845456 55build_alias=
6109825c
KR
56cache_file=
57cache_file_option=
6f8ac2d9 58configdirs=
c1e4672c
RP
59exec_prefix=
60exec_prefixoption=
0df06ca0 61fatal=
4d714963
RP
62floating_point=default
63gas=default
24845456 64host_alias=NOHOST
3a07a6ac 65host_makefile_frag=
a98e98d3 66moveifchange=
46766962 67norecursion=
9336e47e 68other_options=
34bdab16 69package_makefile_frag=
4d714963 70prefix=/usr/local
49b10446 71progname=
c1e4672c 72program_prefix=
c5108322
ILT
73program_prefixoption=
74program_suffix=
75program_suffixoption=
76program_transform_name=
77program_transform_nameoption=
a98e98d3
RP
78redirect=">/dev/null"
79removing=
0e693d0b 80site=
3a07a6ac 81site_makefile_frag=
a98e98d3 82site_option=
74cc5508 83srcdir=
ec342d7d 84srctrigger=
8becd045 85subdirs=
24845456 86target_alias=NOTARGET
3a07a6ac 87target_makefile_frag=
24845456 88undefs=NOUNDEFS
0c72405d 89version="$Revision$"
4d714963
RP
90x11=default
91
eb4b02ae
DZ
92### we might need to use some other shell than /bin/sh for running subshells
93#
dbb0309d 94config_shell=${CONFIG_SHELL-/bin/sh}
eb4b02ae 95
4d714963
RP
96NO_EDIT="This file was generated automatically by configure. Do not edit."
97
98## this is a little touchy and won't always work, but...
99##
c1e4672c
RP
100## if the argv[0] starts with a slash then it is an absolute name that can (and
101## must) be used as is.
4d714963
RP
102##
103## otherwise, if argv[0] has no slash in it, we can assume that it is on the
104## path. Since PATH might include "." we also add `pwd` to the end of PATH.
105##
4d714963 106
c1e4672c 107progname=$0
5cc24596
PB
108# if PWD already has a value, it is probably wrong.
109if [ -n "$PWD" ]; then PWD=`pwd`; fi
4d714963 110
c1e4672c
RP
111case "${progname}" in
112/*) ;;
113*/*) ;;
114*)
73f1f5ba
DZ
115 PATH=$PATH:${PWD=`pwd`} ; export PATH
116 ;;
c1e4672c 117esac
4d714963 118
24845456
SG
119# Loop over all args
120
121while :
eb02fd64 122do
3509822c 123
24845456
SG
124# Break out if there are no more args
125 case $# in
126 0)
00f56390 127 break
24845456
SG
128 ;;
129 esac
130
131# Get the first arg, and shuffle
132 option=$1
133 shift
134
135# Make all options have two hyphens
136 orig_option=$option # Save original for error messages
137 case $option in
138 --*) ;;
139 -*) option=-$option ;;
140 esac
141
142# Split out the argument for options that take them
143 case $option in
144 --*=*)
145 optarg=`echo $option | sed -e 's/^[^=]*=//'`
146 ;;
147# These options have mandatory values. Since we didn't find an = sign,
148# the value must be in the next argument
5a2400c4 149 --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
24845456
SG
150 optarg=$1
151 shift
152 ;;
153 esac
154
155# Now, process the options
156 case $option in
157
158 --build* | --b*)
159 case "$build_alias" in
160 "") build_alias=$optarg ;;
161 *) echo '***' Can only configure for one build machine at a time. 1>&2
162 fatal=yes
163 ;;
164 esac
165 ;;
5a2400c4 166 --cache*)
6109825c 167 cache_file=$optarg
5a2400c4 168 ;;
bfb08994
DM
169 --disable-*)
170 enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
171 eval $enableopt=no
172 disableoptions="$disableoptions $option"
173 ;;
00f56390
DM
174 --enable-*)
175 case "$option" in
176 *=*) ;;
177 *) optarg=yes ;;
178 esac
179
180 enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
181 eval $enableopt="$optarg"
182 enableoptions="$enableoptions $option"
183 ;;
184 --exec-prefix* | --ex*)
24845456
SG
185 exec_prefix=$optarg
186 exec_prefixoption="--exec-prefix=$optarg"
187 ;;
188 --gas | --g*)
189 gas=yes
190 ;;
191 --help | --he*)
00f56390 192 fatal=yes
24845456
SG
193 ;;
194 --host* | --ho*)
195 case $host_alias in
196 NOHOST) host_alias=$optarg ;;
197 *) echo '***' Can only configure for one host at a time. 1>&2
198 fatal=yes
199 ;;
200 esac
201 ;;
202 --nfp | --nf*)
203 floating_point=no
204 ;;
205 --norecursion | --no*)
00f56390 206 norecursion=yes
24845456
SG
207 ;;
208 --prefix* | --pre*)
209 prefix=$optarg
210 prefixoption="--prefix=$optarg"
211 ;;
212 --program-prefix* | --program-p*)
213 program_prefix=$optarg
214 program_prefixoption="--program-prefix=$optarg"
215 ;;
216 --program-suffix* | --program-s*)
217 program_suffix=$optarg
218 program_suffixoption="--program-suffix=$optarg"
219 ;;
220 --program-transform-name* | --program-t*)
221 # Double any backslashes or dollar signs in the argument
222 program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
4b82ae34 223 program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
24845456
SG
224 ;;
225 --rm)
226 removing=--rm
227 ;;
d2d324f8
DM
228 --silent | --sil* | --quiet | --q*)
229 redirect=">/dev/null"
230 verbose=--silent
231 ;;
232 --site* | --sit*)
24845456
SG
233 site=$optarg
234 site_option="--site=$optarg"
235 ;;
236 --srcdir*/ | --sr*/)
237 # Remove trailing slashes. Otherwise, when the file name gets
d2d324f8
DM
238 # bolted into an object file as debug info, it has two slashes
239 # in it. Ordinarily this is ok, but emacs takes double slash
240 # to mean "forget the first part".
24845456
SG
241 srcdir=`echo $optarg | sed -e 's:/$::'`
242 ;;
243 --srcdir* | --sr*)
244 srcdir=$optarg
245 ;;
246 --target* | --ta*)
247 case $target_alias in
248 NOTARGET) target_alias=$optarg ;;
249 *) echo '***' Can only configure for one target at a time. 1>&2
250 fatal=yes
251 ;;
252 esac
253 ;;
254 --tmpdir* | --tm*)
255 TMPDIR=$optarg
256 tmpdiroption="--tmpdir=$optarg"
257 ;;
258 --verbose | --v | --verb*)
259 redirect=
260 verbose=--verbose
261 ;;
262 --version | --V | --vers*)
263 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
264 exit 0
265 ;;
266 --with-*)
267 case "$option" in
268 *=*) ;;
269 *) optarg=yes ;;
270 esac
271
272 withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
273 eval $withopt="$optarg"
274 withoptions="$withoptions $option"
275 ;;
276 --without-*)
bfb08994 277 withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
24845456
SG
278 eval $withopt=no
279 withoutoptions="$withoutoptions $option"
280 ;;
9336e47e
DM
281 --x) with_x=yes
282 withoptions="$withoptions --with-x"
283 ;;
0ffb871e
DM
284 --x-i* | --x-l*) other_options="$other_options $orig_option"
285 ;;
24845456 286 --*)
d237841c
BC
287 echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
288 exit 1
24845456
SG
289 ;;
290 *)
291 case $undefs in
292 NOUNDEFS) undefs=$option ;;
293 *) echo '***' Can only configure for one host and one target at a time. 1>&2
294 fatal=yes
295 ;;
296 esac
297 ;;
298 esac
eb02fd64
RP
299done
300
4d714963 301# process host and target
24845456 302
00f56390
DM
303# Do some error checking and defaulting for the host and target type.
304# The inputs are:
305# configure --host=HOST --target=TARGET UNDEFS
24845456 306#
00f56390
DM
307# The rules are:
308# 1. You aren't allowed to specify --host, --target, and undefs at the
309# same time.
310# 2. Host defaults to undefs.
311# 3. If undefs is not specified, then host defaults to the current host,
312# as determined by config.guess.
313# 4. Target defaults to undefs.
314# 5. If undefs is not specified, then target defaults to host.
24845456 315
a98bbe58
RP
316case "${fatal}" in
317"")
24845456
SG
318 # Make sure that host, target & undefs aren't all specified at the
319 # same time.
320 case $host_alias---$target_alias---$undefs in
321 NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
322 ;;
323 *) echo '***' Can only configure for one host and one target at a time. 1>&2
324 fatal=yes
325 break 2
326 ;;
327 esac
328
329 # Now, do defaulting for host.
330 case $host_alias in
331 NOHOST)
332 case $undefs in
333 NOUNDEFS)
334 # Neither --host option nor undefs were present.
335 # Call config.guess.
336 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
337 if host_alias=`${guesssys}`
338 then
94028943
ILT
339 # If the string we are going to use for
340 # the target is a prefix of the string
341 # we just guessed for the host, then
342 # assume we are running native, and force
343 # the same string for both target and host.
344 case $target_alias in
64b7bf9f 345 NOTARGET) ;;
94028943
ILT
346 *)
347 if expr $host_alias : $target_alias >/dev/null
348 then
349 host_alias=$target_alias
350 fi
351 ;;
352 esac
24845456
SG
353 echo "Configuring for a ${host_alias} host." 1>&2
354 arguments="--host=$host_alias $arguments"
355 else
356 echo 'Config.guess failed to determine the host type. You need to specify one.' 1>&2
357 fatal=yes
358 fi
359 ;;
360 *)
361 host_alias=$undefs
362 ;;
363 esac
364 esac
365
366 # Do defaulting for target. If --target option isn't present, default
367 # to undefs. If undefs isn't present, default to host.
368 case $target_alias in
369 NOTARGET)
370 case $undefs in
371 NOUNDEFS)
372 target_alias=$host_alias
373 ;;
374 *)
375 target_alias=$undefs
376 ;;
377 esac
378 esac
379 ;;
a98bbe58
RP
380*) ;;
381esac
eb02fd64 382
c1e4672c 383if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
24845456 384 exec 1>&2
64b7bf9f 385 echo Usage: configure [OPTIONS] [HOST]
24845456
SG
386 echo
387 echo Options: [defaults in brackets]
1be96eeb
ILT
388 echo ' --prefix=MYDIR install into MYDIR [/usr/local]'
389 echo ' --exec-prefix=MYDIR install host-dependent files into MYDIR [/usr/local]'
390 echo ' --help print this message [normal config]'
391 echo ' --build=BUILD configure for building on BUILD [BUILD=HOST]'
392 echo ' --host=HOST configure for HOST [determined via config.guess]'
393 echo ' --norecursion configure this directory only [recurse]'
394 echo ' --program-prefix=FOO prepend FOO to installed program names [""]'
395 echo ' --program-suffix=FOO append FOO to installed program names [""]'
396 echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
397 echo ' --site=SITE configure with site-specific makefile for SITE'
398 echo ' --srcdir=DIR find the sources in DIR [. or ..]'
399 echo ' --target=TARGET configure for TARGET [TARGET=HOST]'
400 echo ' --tmpdir=TMPDIR create temporary files in TMPDIR [/tmp]'
5a2400c4 401 echo ' --nfp configure for software floating point [hard float]'
00f56390
DM
402 echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
403 echo ' --without-FOO package FOO is NOT available'
404 echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
bfb08994 405 echo ' --disable-FOO do not include feature FOO'
24845456 406 echo
5a2400c4 407 echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
24845456
SG
408 echo
409 if [ -r config.status ] ; then
410 cat config.status
411 fi
412
413 exit 1
eb02fd64
RP
414fi
415
0c72405d 416configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
196377ee 417moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
7da1d334 418
94c7ae21
RP
419# this is a hack. sun4 must always be a valid host alias or this will fail.
420if ${configsub} sun4 >/dev/null 2>&1 ; then
73f1f5ba 421 true
7da1d334 422else
73f1f5ba
DZ
423 echo '***' cannot find config.sub. 1>&2
424 exit 1
7da1d334
RP
425fi
426
196377ee
RP
427touch config.junk
428if ${moveifchange} config.junk config.trash ; then
73f1f5ba 429 true
196377ee 430else
73f1f5ba
DZ
431 echo '***' cannot find move-if-change. 1>&2
432 exit 1
196377ee
RP
433fi
434rm -f config.junk config.trash
435
a98bbe58
RP
436case "${srcdir}" in
437"")
73f1f5ba
DZ
438 if [ -r configure.in ] ; then
439 srcdir=.
440 else
441 if [ -r ${progname}.in ] ; then
442 srcdir=`echo ${progname} | sed 's:/configure$::'`
443 else
24845456 444 echo '***' "Can't find configure.in. Try using --srcdir=some_dir" 1>&2
73f1f5ba
DZ
445 exit 1
446 fi
447 fi
448 ;;
a98bbe58
RP
449*) ;;
450esac
eb02fd64 451
8fd24008
RP
452### warn about some conflicting configurations.
453
454case "${srcdir}" in
455".") ;;
456*)
73f1f5ba
DZ
457 if [ -f ${srcdir}/config.status ] ; then
458 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
459 exit 1
460 fi
8fd24008 461esac
bc58b41d 462
c1e4672c 463# default exec_prefix
c7f72253 464case "${exec_prefixoption}" in
8becd045 465"") exec_prefix="\$(prefix)" ;;
3a07a6ac
RP
466*) ;;
467esac
468
4d714963 469### break up ${srcdir}/configure.in.
a98bbe58
RP
470case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
471"")
dbb0309d 472 echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
6109825c
KR
473 # Check for a directory that's been converted to use autoconf since
474 # it was last configured.
475 if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
476 echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
477 if [ -r ${srcdir}/configure ] ; then
478 echo '***' Running the local configure script. 1>&2
479 case "${cache_file}" in
480 "") cache_file_option= ;;
481 *) cache_file_option="--cache-file=${cache_file}" ;;
482 esac
483 srcdiroption="--srcdir=${srcdir}"
484 case "${build_alias}" in
485 "") buildopt= ;;
486 *) buildopt="--build=${build_alias}" ;;
487 esac
488 eval exec ${config_shell} ${srcdir}/configure ${verbose} \
489 ${buildopt} --host=${host_alias} --target=${target_alias} \
490 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
491 ${srcdiroption} \
492 ${program_prefixoption} ${program_suffixoption} \
493 ${program_transform_nameoption} ${site_option} \
494 ${withoptions} ${withoutoptions} \
495 ${enableoptions} ${disableoptions} \
496 ${cache_file_option} ${removing} ${other_options} ${redirect}
497 else
498 echo '***' There is no configure script present though. 1>&2
499 fi
500 fi
73f1f5ba
DZ
501 exit 1
502 ;;
a98bbe58
RP
503*) ;;
504esac
49b10446 505
a98bbe58
RP
506case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
507"")
dbb0309d 508 echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
73f1f5ba
DZ
509 exit 1
510 ;;
a98bbe58
RP
511*) ;;
512esac
c5ae5678 513
a98bbe58
RP
514case "${TMPDIR}" in
515"") TMPDIR=/tmp ; export TMPDIR ;;
516*) ;;
517esac
eb02fd64 518
4d714963
RP
519# keep this filename short for &%*%$*# 14 char file names
520tmpfile=${TMPDIR}/cONf$$
121bdf8f
ILT
521# Note that under many versions of sh a trap handler for 0 will *override* any
522# exit status you explicitly specify! At this point, the only non-error exit
523# is at the end of the script; these actions are duplicated there, minus
524# the "exit 1". Don't use "exit 0" anywhere after this without resetting the
525# trap handler, or you'll lose.
ca2ce3b3 526trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
4d714963
RP
527
528# split ${srcdir}/configure.in into common, per-host, per-target,
529# and post-target parts. Post-target is optional.
530sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
531sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
532if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
533 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
534 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
c297d71e 535else
4d714963
RP
536 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
537 echo >${tmpfile}.pos
c297d71e 538fi
eb02fd64 539
c297d71e 540### do common part of configure.in
eb02fd64 541
c5ae5678 542. ${tmpfile}.com
eb02fd64 543
ec342d7d 544# some sanity checks on configure.in
a98bbe58
RP
545case "${srctrigger}" in
546"")
73f1f5ba
DZ
547 echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
548 exit 1
549 ;;
a98bbe58
RP
550*) ;;
551esac
ec342d7d 552
24845456 553case "${build_alias}" in
ca2ce3b3
ILT
554"")
555 if result=`${config_shell} ${configsub} ${host_alias}` ; then
556 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
557 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
558 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
559 build=${host_cpu}-${host_vendor}-${host_os}
560 build_alias=${host_alias}
561 fi
562 ;;
24845456 563*)
121bdf8f
ILT
564 if result=`${config_shell} ${configsub} ${build_alias}` ; then
565 buildopt="--build=${build_alias}"
566 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
567 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
568 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
569 build=${build_cpu}-${build_vendor}-${build_os}
570 else
571 echo "Unrecognized build system name ${build_alias}." 1>&2
572 exit 1
573 fi
24845456
SG
574 ;;
575esac
576
121bdf8f
ILT
577if result=`${config_shell} ${configsub} ${host_alias}` ; then
578 true
579else
580 echo "Unrecognized host system name ${host_alias}." 1>&2
581 exit 1
582fi
c1e4672c
RP
583host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
584host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
585host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
586host=${host_cpu}-${host_vendor}-${host_os}
6c18e393 587
c1e4672c 588. ${tmpfile}.hst
eb02fd64 589
121bdf8f
ILT
590if result=`${config_shell} ${configsub} ${target_alias}` ; then
591 true
592else
593 echo "Unrecognized target system name ${target_alias}." 1>&2
594 exit 1
595fi
c1e4672c
RP
596target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
597target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
598target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
599target=${target_cpu}-${target_vendor}-${target_os}
eb02fd64 600
c1e4672c 601. ${tmpfile}.tgt
49b10446 602
c1e4672c
RP
603# Find the source files, if location was not specified.
604case "${srcdir}" in
605"")
73f1f5ba
DZ
606 srcdirdefaulted=1
607 srcdir=.
608 if [ ! -r ${srctrigger} ] ; then
609 srcdir=..
610 fi
611 ;;
c1e4672c
RP
612*) ;;
613esac
eb02fd64 614
c1e4672c 615if [ ! -r ${srcdir}/${srctrigger} ] ; then
73f1f5ba
DZ
616 case "${srcdirdefaulted}" in
617 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
618 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
619 esac
eb02fd64 620
73f1f5ba
DZ
621 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
622 exit 1
c1e4672c 623fi
131a3881 624
0ed316a0
DZ
625# Some systems (e.g., one of the i386-aix systems the gas testers are
626# using) don't handle "\$" correctly, so don't use it here.
627tooldir='$(exec_prefix)'/${target_alias}
c5108322
ILT
628
629if [ "${host_alias}" != "${target_alias}" ] ; then
d6d49c64
PB
630 if [ "${program_prefixoption}" = "" ] ; then
631 if [ "${program_suffixoption}" = "" ] ; then
632 if [ "${program_transform_nameoption}" = "" ] ; then
73f1f5ba
DZ
633 program_prefix=${target_alias}- ;
634 fi
635 fi
c5108322
ILT
636 fi
637fi
638
121bdf8f
ILT
639# Merge program_prefix and program_suffix onto program_transform_name.
640# (program_suffix used to use $, but it's hard to preserve $ through both
641# make and sh.)
c5108322 642if [ "${program_suffix}" != "" ] ; then
121bdf8f 643 program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
c5108322
ILT
644fi
645
646if [ "${program_prefix}" != "" ] ; then
24845456 647 program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
c5108322
ILT
648fi
649
ca2ce3b3
ILT
650# If CC and CXX are not set in the environment, and the Makefile
651# exists, try to extract them from it. This is to handle running
652# ./config.status by hand.
653if [ -z "${CC}" -a -r Makefile ]; then
654 sed -n -e ':loop
655/\\$/ N
656/\\$/ b loop
657s/\\\n//g
658/^CC[ ]*=/ s/CC[ ]*=\(.*\)/\1/p' < Makefile > Makefile.cc
659 CC=`tail -1 Makefile.cc`
660 rm -f Makefile.cc
661fi
662
663if [ -z "${CXX}" -a -r Makefile ]; then
664 sed -n -e ':loop
665/\\$/ N
666/\\$/ b loop
667s/\\\n//g
668/^CXX[ ]*=/ s/CXX[ ]*=\(.*\)/\1/p' < Makefile > Makefile.cc
669 CXX=`tail -1 Makefile.cc`
670 rm -f Makefile.cc
671fi
672
673# If CC is still not set, try to get gcc.
674if [ -z "${CC}" ]; then
675 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
676 for dir in $PATH; do
677 test -z "$dir" && dir=.
678 if test -f $dir/gcc; then
679 CC="gcc"
680 break
681 fi
682 done
683 IFS="$save_ifs"
684 CC=${CC-cc}
685fi
686
687CXX=${CXX-"g++ -O"}
688
8becd045 689for subdir in . ${subdirs} ; do
eb02fd64 690
8becd045
PB
691 # ${subdir} is relative path from . to the directory we're currently
692 # configuring.
693 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
694 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
131a3881 695
8becd045
PB
696 ### figure out what to do with srcdir
697 case "${srcdir}" in
73f1f5ba
DZ
698 ".") # no -srcdir option. We're building in place.
699 makesrcdir=. ;;
700 /*) # absolute path
701 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
702 ;;
703 *) # otherwise relative
704 case "${subdir}" in
705 .) makesrcdir=${srcdir} ;;
706 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
707 esac
708 ;;
8becd045 709 esac
131a3881 710
8becd045 711 if [ "${subdir}/" != "./" ] ; then
73f1f5ba 712 Makefile=${subdir}/Makefile
8becd045 713 fi
131a3881 714
9546e9b4 715 if [ ! -d ${subdir} ] ; then
73f1f5ba
DZ
716 if mkdir ${subdir} ; then
717 true
09e0b992 718 else
73f1f5ba
DZ
719 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
720 exit 1
09e0b992 721 fi
9546e9b4
RP
722 fi
723
8becd045
PB
724 case "${removing}" in
725 "")
73f1f5ba
DZ
726 case "${subdir}" in
727 .) ;;
728 *) eval echo Building in ${subdir} ${redirect} ;;
729 esac
730
731 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
732 # Set up the list of links to be made.
733 # ${links} is the list of link names, and ${files} is the list of names to link to.
734
735 # Make the links.
736 configlinks="${links}"
737 if [ -r ${subdir}/config.status ] ; then
738 mv -f ${subdir}/config.status ${subdir}/config.back
739 fi
740 while [ -n "${files}" ] ; do
741 # set file to car of files, files to cdr of files
742 set ${files}; file=$1; shift; files=$*
743 set ${links}; link=$1; shift; links=$*
744
745 if [ ! -r ${srcdir}/${file} ] ; then
746 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
747 echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
748 exit 1
749 fi
750
751 ${remove} -f ${link}
d237841c
BC
752 # Make a symlink if possible, otherwise try a hard link
753 if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
754 true
755 else
756 # We need to re-remove the file because Lynx leaves a
757 # very strange directory there when it fails an NFS symlink.
758 ${remove} -r -f ${link}
759 ${hard_link} ${srcdir}/${file} ${link}
760 fi
73f1f5ba
DZ
761 if [ ! -r ${link} ] ; then
762 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
763 exit 1
764 fi
765
766 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
767 done
768
769 # Create a .gdbinit file which runs the one in srcdir
770 # and tells GDB to look there for source files.
771
772 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
773 case ${srcdir} in
774 .) ;;
775 *) cat > ${subdir}/.gdbinit <<EOF
8becd045 776# ${NO_EDIT}
8becd045 777dir ${makesrcdir}
c7f72253 778dir .
8becd045 779source ${makesrcdir}/.gdbinit
3a07a6ac 780EOF
73f1f5ba
DZ
781 ;;
782 esac
783 fi
0df06ca0 784
73f1f5ba
DZ
785 # Install a makefile, and make it set VPATH
786 # if necessary so that the sources are found.
787 # Also change its value of srcdir.
788 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
789 # been somewhat optimized and is perhaps a bit twisty.
0df06ca0 790
73f1f5ba 791 # code is order so as to try to sed the smallest input files we know.
0df06ca0 792
73f1f5ba 793 # the four makefile fragments MUST end up in the resulting Makefile in this order:
34bdab16
DZ
794 # package, target, host, and site. so do these separately because I don't trust the
795 # order of sed -e expressions.
131a3881 796
73f1f5ba
DZ
797 if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
798
e5c6be8f
DZ
799 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
800 rm -f ${subdir}/Makefile.tem
801 case "${site}" in
802 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
803 *)
804 site_makefile_frag=${srcdir}/config/ms-${site}
805
806 if [ -f ${site_makefile_frag} ] ; then
807 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
808 > ${subdir}/Makefile.tem
809 else
810 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
811 site_makefile_frag=
812 fi
813 ;;
814 esac
815 # working copy now in ${subdir}/Makefile.tem
816
817 # Conditionalize the makefile for this host.
818 rm -f ${Makefile}
819 case "${host_makefile_frag}" in
820 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
821 *)
822 if [ ! -f ${host_makefile_frag} ] ; then
823 host_makefile_frag=${srcdir}/${host_makefile_frag}
824 fi
825 if [ -f ${host_makefile_frag} ] ; then
826 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
827 else
828 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
829 echo '***' is missing in ${PWD=`pwd`}. 1>&2
830 mv ${subdir}/Makefile.tem ${Makefile}
831 fi
832 esac
833 # working copy now in ${Makefile}
834
835 # Conditionalize the makefile for this target.
836 rm -f ${subdir}/Makefile.tem
837 case "${target_makefile_frag}" in
838 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
839 *)
840 if [ ! -f ${target_makefile_frag} ] ; then
841 target_makefile_frag=${srcdir}/${target_makefile_frag}
842 fi
843 if [ -f ${target_makefile_frag} ] ; then
844 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
845 else
846 mv ${Makefile} ${subdir}/Makefile.tem
847 target_makefile_frag=
848 fi
849 ;;
850 esac
851 # real copy now in ${subdir}/Makefile.tem
852
853 # Conditionalize the makefile for this package.
854 rm -f ${Makefile}
855 case "${package_makefile_frag}" in
856 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
857 *)
858 if [ ! -f ${package_makefile_frag} ] ; then
859 package_makefile_frag=${srcdir}/${package_makefile_frag}
860 fi
861 if [ -f ${package_makefile_frag} ] ; then
862 sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
e08a7c05 863 rm -f ${subdir}/Makefile.tem
e5c6be8f
DZ
864 else
865 echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
866 echo '***' is missing in ${PWD=`pwd`}. 1>&2
867 mv ${subdir}/Makefile.tem ${Makefile}
868 fi
869 esac
870 # working copy now in ${Makefile}
871
872 mv ${Makefile} ${subdir}/Makefile.tem
873
874 # real copy now in ${subdir}/Makefile.tem
875
876 # prepend warning about editting, and a bunch of variables.
877 rm -f ${Makefile}
878 cat > ${Makefile} <<EOF
3a07a6ac 879# ${NO_EDIT}
8becd045
PB
880VPATH = ${makesrcdir}
881links = ${configlinks}
3a07a6ac
RP
882host_alias = ${host_alias}
883host_cpu = ${host_cpu}
884host_vendor = ${host_vendor}
885host_os = ${host_os}
94028943 886host_canonical = ${host_cpu}-${host_vendor}-${host_os}
3a07a6ac
RP
887target_alias = ${target_alias}
888target_cpu = ${target_cpu}
889target_vendor = ${target_vendor}
890target_os = ${target_os}
5cc24596 891target_canonical = ${target_cpu}-${target_vendor}-${target_os}
3a07a6ac 892EOF
24845456
SG
893 case "${build}" in
894 "") ;;
94028943 895 *) cat >> ${Makefile} << EOF
24845456
SG
896build_alias = ${build_alias}
897build_cpu = ${build_cpu}
898build_vendor = ${build_vendor}
899build_os = ${build_os}
94028943 900build_canonical = ${build_cpu}-${build_vendor}-${build_os}
24845456
SG
901EOF
902 esac
903
e5c6be8f
DZ
904 case "${package_makefile_frag}" in
905 "") ;;
906 /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
907 *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
908 esac
909
910 case "${target_makefile_frag}" in
911 "") ;;
912 /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
913 *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
914 esac
915
916 case "${host_makefile_frag}" in
917 "") ;;
918 /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
919 *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
920 esac
921
922 if [ "${site_makefile_frag}" != "" ] ; then
923 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
924 fi
925
e5c6be8f
DZ
926 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
927 # remove any form feeds.
928 if [ -z "${subdirs}" ]; then
929 rm -f ${subdir}/Makefile.tem2
70d3fab7
DZ
930 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
931 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
e5c6be8f
DZ
932 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
933 rm -f ${subdir}/Makefile.tem
934 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
935 fi
70d3fab7
DZ
936 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
937 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
ca2ce3b3
ILT
938 -e "/^CC[ ]*=/{
939 b chkcc
940 :contcc
941 N
942 :chkcc
943 s/\\\\$//
944 t contcc
945 s%^CC[ ]*=.*$%CC = ${CC}%
946 }" \
947 -e "/^CXX[ ]*=/{
948 b chkcxx
949 :contcxx
950 N
951 :chkcxx
952 s/\\\\$//
953 t contcxx
954 s%^CXX[ ]*=.*$%CXX = ${CXX}%
955 }" \
dbb0309d 956 -e "s:^SHELL[ ]*=.*$:SHELL = ${config_shell}:" \
70d3fab7 957 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
e5c6be8f 958 -e "s/\f//" \
70d3fab7
DZ
959 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
960 -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \
26e4818b 961 -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \
70d3fab7 962 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
e5c6be8f
DZ
963 ${subdir}/Makefile.tem >> ${Makefile}
964 # final copy now in ${Makefile}
965
966 else
26e4818b 967 echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
e5c6be8f 968 fi
73f1f5ba
DZ
969
970 rm -f ${subdir}/Makefile.tem
971
972 case "${host_makefile_frag}" in
973 "") using= ;;
974 *) using="and \"${host_makefile_frag}\"" ;;
975 esac
976
977 case "${target_makefile_frag}" in
978 "") ;;
979 *) using="${using} and \"${target_makefile_frag}\"" ;;
980 esac
981
982 case "${site_makefile_frag}" in
983 "") ;;
984 *) using="${using} and \"${site_makefile_frag}\"" ;;
985 esac
986
987 newusing=`echo "${using}" | sed 's/and/using/'`
988 using=${newusing}
989 echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
990
991 . ${tmpfile}.pos
992
993 # describe the chosen configuration in config.status.
994 # Make that file a shellscript which will reestablish
995 # the same configuration. Used in Makefiles to rebuild
996 # Makefiles.
997
998 case "${norecursion}" in
24845456 999 "") arguments="${arguments} --norecursion" ;;
73f1f5ba
DZ
1000 *) ;;
1001 esac
1002
1003 if [ ${subdir} = . ] ; then
1004 echo "#!/bin/sh
4d714963 1005# ${NO_EDIT}
4347369f 1006# This directory was configured as follows:
4d714963 1007${progname}" ${arguments} "
196377ee 1008# ${using}" > ${subdir}/config.new
73f1f5ba
DZ
1009 else
1010 echo "#!/bin/sh
8becd045 1011# ${NO_EDIT}
4347369f 1012# This directory was configured as follows:
8becd045
PB
1013cd ${invsubdir}
1014${progname}" ${arguments} "
196377ee 1015# ${using}" > ${subdir}/config.new
73f1f5ba
DZ
1016 fi
1017 chmod a+x ${subdir}/config.new
1018 if [ -r ${subdir}/config.back ] ; then
1019 mv -f ${subdir}/config.back ${subdir}/config.status
1020 fi
1021 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
1022 ;;
8becd045 1023
73f1f5ba 1024 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
8becd045
PB
1025 esac
1026done
c1e4672c
RP
1027
1028# If there are subdirectories, then recur.
1029if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
73f1f5ba
DZ
1030 for configdir in ${configdirs} ; do
1031
1032 if [ -d ${srcdir}/${configdir} ] ; then
1033 eval echo Configuring ${configdir}... ${redirect}
1034 case "${srcdir}" in
1035 ".") ;;
1036 *)
1037 if [ ! -d ./${configdir} ] ; then
1038 if mkdir ./${configdir} ; then
1039 true
1040 else
1041 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
1042 exit 1
1043 fi
1044 fi
1045 ;;
1046 esac
1047
1048 POPDIR=${PWD=`pwd`}
1049 cd ${configdir}
c1e4672c
RP
1050
1051### figure out what to do with srcdir
73f1f5ba
DZ
1052 case "${srcdir}" in
1053 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
1054 /*) # absolute path
1055 newsrcdir=${srcdir}/${configdir}
24845456 1056 srcdiroption="--srcdir=${newsrcdir}"
73f1f5ba
DZ
1057 ;;
1058 *) # otherwise relative
1059 newsrcdir=../${srcdir}/${configdir}
24845456 1060 srcdiroption="--srcdir=${newsrcdir}"
73f1f5ba
DZ
1061 ;;
1062 esac
c1e4672c 1063
6109825c
KR
1064 # Handle --cache-file=../XXX
1065 case "${cache_file}" in
1066 "") # empty
1067 ;;
1068 /*) # absolute path
1069 cache_file_option="--cache-file=${cache_file}"
1070 ;;
1071 *) # relative path
1072 cache_file_option="--cache-file=../${cache_file}"
1073 ;;
1074 esac
1075
c1e4672c 1076### check for guested configure, otherwise fix possibly relative progname
73f1f5ba
DZ
1077 if [ -f ${newsrcdir}/configure ] ; then
1078 recprog=${newsrcdir}/configure
eb4b02ae 1079 elif [ -f ${newsrcdir}/configure.in ] ; then
73f1f5ba
DZ
1080 case "${progname}" in
1081 /*) recprog=${progname} ;;
1082 *) recprog=../${progname} ;;
1083 esac
eb4b02ae 1084 else
c0c70966 1085 eval echo No configuration information in ${configdir} ${redirect}
eb4b02ae 1086 recprog=
73f1f5ba 1087 fi
4d714963
RP
1088
1089### The recursion line is here.
eb4b02ae 1090 if [ ! -z "${recprog}" ] ; then
24845456 1091 if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
eb4b02ae 1092 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
6109825c 1093 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
eb4b02ae
DZ
1094 true
1095 else
00f56390 1096 echo Configure in `pwd` failed, exiting. 1>&2
eb4b02ae
DZ
1097 exit 1
1098 fi
1099 fi
73f1f5ba
DZ
1100
1101 cd ${POPDIR}
1102 fi
1103 done
c1e4672c 1104fi
eb02fd64 1105
121bdf8f
ILT
1106# Perform the same cleanup as the trap handler, minus the "exit 1" of course,
1107# and reset the trap handler.
1108rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
1109trap 0
1110
eb02fd64 1111exit 0
74cc5508 1112
0df06ca0
RP
1113#
1114# Local Variables:
1115# fill-column: 131
1116# End:
1117#
74cc5508 1118
46f3c7cd 1119# end of configure
This page took 0.235328 seconds and 4 git commands to generate.