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