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