]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - configure
Catch up on today's changes.
[thirdparty/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
6559fbdb 6# Copyright (C) 1988, 1990-1993 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
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=$*
6f8ac2d9 52configdirs=
c1e4672c
RP
53exec_prefix=
54exec_prefixoption=
0df06ca0 55fatal=
4d714963
RP
56floating_point=default
57gas=default
c1e4672c 58host_alias=
3a07a6ac 59host_makefile_frag=
a98e98d3 60moveifchange=
4d714963 61next_host=
3a07a6ac 62next_prefix=
3509822c 63next_site=
4d714963 64next_srcdir=
3509822c
RP
65next_target=
66next_tmpdir=
46766962 67norecursion=
34bdab16 68package_makefile_frag=
4d714963 69prefix=/usr/local
49b10446 70progname=
c1e4672c 71program_prefix=
c5108322
ILT
72program_prefixoption=
73program_suffix=
74program_suffixoption=
75program_transform_name=
76program_transform_nameoption=
a98e98d3
RP
77redirect=">/dev/null"
78removing=
0e693d0b 79site=
3a07a6ac 80site_makefile_frag=
a98e98d3 81site_option=
74cc5508 82srcdir=
ec342d7d 83srctrigger=
8becd045 84subdirs=
c1e4672c 85target_alias=
3a07a6ac 86target_makefile_frag=
4d714963 87undefinedargs=
0c72405d 88version="$Revision$"
4d714963
RP
89x11=default
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
eb02fd64
RP
114for arg in $*;
115do
73f1f5ba
DZ
116 # handle things that might have args following as separate words
117 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
118 elif [ -n "${next_exec_prefix}" ] ; then
119 exec_prefix=${arg}
120 exec_prefixoption="-exec_prefix=${exec_prefix}"
121 next_exec_prefix=
122 elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
123 # remove any possible trailing slash from srcdir. See note below.
124 elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
125 elif [ -n "${next_program_prefix}" ] ; then
126 program_prefix=${arg}
127 program_prefixoption="-program_prefix=${program_prefix}"
128 next_program_prefix=
129 elif [ -n "${next_program_suffix}" ] ; then
130 program_suffix=${arg}
131 program_suffixoption="-program_suffix=${program_suffix}"
132 next_program_suffix=
133 elif [ -n "${next_program_transform_name}" ] ; then
134 # Double any backslashes or dollar signs in the argument
135 program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
136 program_transform_nameoption="${program_transform_nameoption} -program_transform_name='${arg}'"
137 next_program_transform_name=
138 elif [ -n "${next_target}" ] ; then
139 next_target=
140 case "${target_alias}" in
141 "")
142 target_alias="${arg}"
143 ;;
144 *)
145 echo '***' Can only configure for one target at a time. 1>&2
146 fatal=yes
147 ;;
148 esac
149 elif [ -n "${next_tmpdir}" ] ; then
150 next_tmpdir=
151 tmpdiroption="--tmpdir=${arg}"
152 TMPDIR=${arg}
3509822c 153
73f1f5ba
DZ
154 else
155 case ${arg} in
156 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=* | -exec-prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* )
157 exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
158 exec_prefixoption=${arg}
159 ;;
160 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e | -exec-prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec-)
161 next_exec_prefix=yes
162 ;;
163 -gas | --g*)
164 gas=yes
165 ;;
166 -help | --he*)
167 fatal=true
168 ;;
169 -host=* | --host=* | --hos=* | --ho=*)
170 case "${host_alias}" in
171 "")
172 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
173 ;;
174 *)
175 echo '***' Can only configure for one host at a time. 1>&2
176 fatal=yes
177 ;;
178 esac
179 ;;
180 -nfp | --nf*)
181 floating_point=no
182 ;;
183 -norecursion | --no*)
184 norecursion=true
185 ;;
186 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
187 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
188 prefixoption=${arg}
189 ;;
190 -prefix | --prefix | --prefi | --pref | --pre)
191 next_prefix=yes
192 ;;
193 -rm | --rm) removing=${arg} ;;
194 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | -program-prefix=* | --program-prefix=* | --program-prefi=* | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
195 program_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
196 program_prefixoption=${arg}
197 ;;
198 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | -program-prefix | --program-prefix | --program-prefi | --program-pref | --program-pre | --program-pr | --program-p)
199 next_program_prefix=yes
200 ;;
201 -program_suffix=* | --program_suffix=* | --program_suffi=* | --program_suff=* | --program_suf=* | --program_su=* | --program_s=* | -program-suffix=* | --program-suffix=* | --program-suffi=* | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
202 program_suffix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
203 program_suffixoption=${arg}
204 ;;
205 -program_suffix | --program_suffix | --program_suffi | --program_suff | --program_suf | --program_su | --program_s |-program-suffix | --program-suffix | --program-suffi | --program-suff | --program-suf | --program-su | --program-s)
206 next_program_suffix=yes
207 ;;
208 -program_transform_name=* | --program_transform_name=* | --program_transform_nam=* | --program_transform_na=* | --program_transform_n=* | --program_transform_=* | --program_transform=* | --program_transfor=* | --program_transfo=* | --program_transf=* | --program_trans=* | --program_tran=* | --program_tra=* | --program_tr=* | --program_t=* | -program-transform-name=* | --program-transform-name=* | --program-transform-nam=* | --program-transform-na=* | --program-transform-n=* | --program-transform-=* | --program-transform=* | --program-transfor=* | --program-transfo=* | --program-transf=* | --program-trans=* | --program-tran=* | --program-tra=* | --program-tr=* | --program-t=*)
209 # Double any \ or $ in the argument
210 program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/^[-a-z_]*=//' -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
211 program_transform_nameoption="${program_transform_nameoption} -program_transform_name='`echo ${arg} | sed 's/^[-a-z_]*=//'`'"
212 ;;
213 -program_transform_name | --program_transform_name | --program_transform_nam | --program_transform_na | --program_transform_n | --program_transform_ | --program_transform | --program_transfor | --program_transfo | --program_transf | --program_trans | --program_tran | --program_tra | --program_tr | --program_t | -program-transform-name | --program-transform-name | --program-transform-nam | --program-transform-na | --program-transform-n | --program-transform- | --program-transform | --program-transfor | --program-transfo | --program-transf | --program-trans | --program-tran | --program-tra | --program-tr | --program-t)
214 next_program_transform_name=yes
215 ;;
216 -site=* | --site=* | --sit=* | --si=*)
217 site_option=${arg}
218 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
219 ;;
220 -site | --site | --sit)
221 next_site=yes
222 ;;
223 # remove trailing slashes. Otherwise, when the file name gets
224 # bolted into an object file as debug info, it has two slashes in
225 # it. Ordinarily this is ok, but emacs takes double slash to
226 # mean "forget the first part".
227 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
228 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
229 ;;
230 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
231 next_srcdir=yes
232 ;;
233 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
234 case "${target_alias}" in
235 "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
236 *)
237 echo '***' Can only configure for one target at a time. 1>&2
238 fatal=yes
239 ;;
240 esac
241 ;;
242 -target | --target | --targe | --targ | --tar | --ta)
243 next_target=yes
244 ;;
245 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
246 tmpdiroption=${arg}
247 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
248 ;;
249 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
250 next_tmpdir=yes
251 ;;
252 -v | -verbose | --v)
253 redirect=
254 verbose=-v
255 ;;
256 -version | -V | --version | --V)
257 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
258 exit 0
259 ;;
260 -with*=* | --with*=*)
261 withopt=`echo ${arg} | sed 's:^-*\(with[^=]*\)=.*$:\1:;s/-/_/g'`
262 withval=`echo ${arg} | sed 's:^-*with[^=]*=\(.*\)$:\1:'`
263 eval $withopt="$withval"
264 withoptions="$withoptions $arg"
265 ;;
e5c6be8f
DZ
266 -without* | --without*)
267 withopt=`echo ${arg} | sed 's:^-*without:with:;s/-/_/g'`
268 eval $withopt=no
269 withoutoptions="$withoutoptions $arg"
270 ;;
73f1f5ba
DZ
271 -with* | --with*)
272 withopt=`echo ${arg} | sed 's:^-*with:with:;s/-/_/g'`
273 eval $withopt=yes
274 withoptions="$withoptions $arg"
275 ;;
276 -x | --x) ;;
277 -* | --*)
278 (echo ;
279 echo "Unrecognized option: \"${arg}\"". ;
280 echo) 1>&2
281 fatal=true
282 ;;
283 *)
284 case "${undefs}" in
285 "")
286 undefs="${arg}"
287 ;;
288 *)
289 echo '***' Can only configure for one host and one target at a time. 1>&2
290 fatal=yes
291 ;;
292 esac
293 ;;
294 esac
295 fi
eb02fd64
RP
296done
297
4d714963 298# process host and target
a98bbe58
RP
299case "${fatal}" in
300"")
73f1f5ba
DZ
301# # Complain if an arg is missing
302# if [ -z "${host_alias}" ] ; then
303# (echo ;
304# echo "configure: No HOST specified." ;
305# echo) 1>&2
306# fatal=true
307# fi
4d714963
RP
308
309### This is a bit twisted.
310### * if all three are specified, this is an error.
311### * if we have neither hosts, nor unadorned args, this is an error.
312### * if no hosts are specified, then the unadorned args are hosts, but if
313### there were none, this is an error.
314### * if no targets are specified, then the unadorned args are targets, but if
315### there were no unadorned args, then the hosts are also targets.
316
73f1f5ba
DZ
317 if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
318 echo '***' Can only configure for one host and one target at a time. 1>&2
319 fatal=yes
320 elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
321 echo '- You did not tell me what kind of host system you want to configure.
5cc24596 322- I will attempt to guess the kind of system this is.' 1>&2
73f1f5ba
DZ
323 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
324 if tmp_alias=`${guesssys}` ; then
325 echo "- Looks like this is a ${tmp_alias}" 1>&2
326 host_alias=${tmp_alias}
327 target_alias=${tmp_alias}
e5c6be8f 328 arguments="--host=${host_alias} ${arguments}"
73f1f5ba
DZ
329 else
330 echo '- Failed to guess the system type. You need to tell me.' 1>&2
331 fatal=yes
332 fi
333 else
334 case "${host_alias}" in
335 "") host_alias=${undefs} ;;
336 *) ;;
337 esac
338
339 case "${target_alias}" in
340 "")
341 case "${undefs}" in
342 "") target_alias=${host_alias} ;;
343 *) target_alias=${undefs} ;;
344 esac
345 ;;
346 *) ;;
347 esac
348 fi
349 ;;
a98bbe58
RP
350*) ;;
351esac
eb02fd64 352
c1e4672c 353if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
73f1f5ba
DZ
354 (echo "Usage: configure HOST" ;
355 echo ;
356 echo "Options: [defaults in brackets]" ;
e5c6be8f 357 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
73f1f5ba 358 echo " -exec-prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
73f1f5ba 359 echo " -help print this message. [normal config]" ;
73f1f5ba 360 echo " -norecursion configure this directory only. [recurse]" ;
73f1f5ba
DZ
361 echo " -program-prefix=FOO install programs with FOO prepended to their names. [ \"\" ]" ;
362 echo " -program-suffix=FOO install programs with FOO appended to their names. [ \"\" ]" ;
363 echo " -program-transform-name=FOO install programs with names transformed by sed pattern FOO. [ \"\" ]" ;
364 echo " -site=SITE configure with site specific makefile for SITE" ;
365 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
366 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
367 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
e5c6be8f
DZ
368 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
369 echo " -with-FOO, -with-FOO=BAR specify that FOO is available"
370 echo " -without-FOO specify that FOO is NOT available"
73f1f5ba
DZ
371 echo ;
372 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
e5c6be8f 373 echo ;
73f1f5ba 374 ) 1>&2
73f1f5ba
DZ
375 if [ -r config.status ] ; then
376 cat config.status
377 fi
0df06ca0 378
73f1f5ba 379 exit 1
eb02fd64
RP
380fi
381
0c72405d 382configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
196377ee 383moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
7da1d334 384
94c7ae21
RP
385# this is a hack. sun4 must always be a valid host alias or this will fail.
386if ${configsub} sun4 >/dev/null 2>&1 ; then
73f1f5ba 387 true
7da1d334 388else
73f1f5ba
DZ
389 echo '***' cannot find config.sub. 1>&2
390 exit 1
7da1d334
RP
391fi
392
196377ee
RP
393touch config.junk
394if ${moveifchange} config.junk config.trash ; then
73f1f5ba 395 true
196377ee 396else
73f1f5ba
DZ
397 echo '***' cannot find move-if-change. 1>&2
398 exit 1
196377ee
RP
399fi
400rm -f config.junk config.trash
401
a98bbe58
RP
402case "${srcdir}" in
403"")
73f1f5ba
DZ
404 if [ -r configure.in ] ; then
405 srcdir=.
406 else
407 if [ -r ${progname}.in ] ; then
408 srcdir=`echo ${progname} | sed 's:/configure$::'`
409 else
410 echo '***' "Can't find configure.in. Try using -srcdir=some_dir" 1>&2
411 exit 1
412 fi
413 fi
414 ;;
a98bbe58
RP
415*) ;;
416esac
eb02fd64 417
8fd24008
RP
418### warn about some conflicting configurations.
419
420case "${srcdir}" in
421".") ;;
422*)
73f1f5ba
DZ
423 if [ -f ${srcdir}/config.status ] ; then
424 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
425 exit 1
426 fi
8fd24008 427esac
bc58b41d 428
c1e4672c
RP
429# default exec_prefix
430case "${exec_prefix}" in
8becd045 431"") exec_prefix="\$(prefix)" ;;
3a07a6ac
RP
432*) ;;
433esac
434
4d714963 435### break up ${srcdir}/configure.in.
a98bbe58
RP
436case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
437"")
73f1f5ba
DZ
438 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
439 exit 1
440 ;;
a98bbe58
RP
441*) ;;
442esac
49b10446 443
a98bbe58
RP
444case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
445"")
73f1f5ba
DZ
446 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
447 exit 1
448 ;;
a98bbe58
RP
449*) ;;
450esac
c5ae5678 451
a98bbe58
RP
452case "${TMPDIR}" in
453"") TMPDIR=/tmp ; export TMPDIR ;;
454*) ;;
455esac
eb02fd64 456
4d714963
RP
457# keep this filename short for &%*%$*# 14 char file names
458tmpfile=${TMPDIR}/cONf$$
459trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
460
461# split ${srcdir}/configure.in into common, per-host, per-target,
462# and post-target parts. Post-target is optional.
463sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
464sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
465if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
466 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
467 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
c297d71e 468else
4d714963
RP
469 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
470 echo >${tmpfile}.pos
c297d71e 471fi
eb02fd64 472
c297d71e 473### do common part of configure.in
eb02fd64 474
c5ae5678 475. ${tmpfile}.com
eb02fd64 476
ec342d7d 477# some sanity checks on configure.in
a98bbe58
RP
478case "${srctrigger}" in
479"")
73f1f5ba
DZ
480 echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
481 exit 1
482 ;;
a98bbe58
RP
483*) ;;
484esac
ec342d7d 485
c1e4672c
RP
486result=`${configsub} ${host_alias}`
487host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
488host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
489host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
490host=${host_cpu}-${host_vendor}-${host_os}
6c18e393 491
c1e4672c 492. ${tmpfile}.hst
eb02fd64 493
c1e4672c
RP
494result=`${configsub} ${target_alias}`
495target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
496target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
497target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
498target=${target_cpu}-${target_vendor}-${target_os}
eb02fd64 499
c1e4672c 500. ${tmpfile}.tgt
49b10446 501
c1e4672c
RP
502# Find the source files, if location was not specified.
503case "${srcdir}" in
504"")
73f1f5ba
DZ
505 srcdirdefaulted=1
506 srcdir=.
507 if [ ! -r ${srctrigger} ] ; then
508 srcdir=..
509 fi
510 ;;
c1e4672c
RP
511*) ;;
512esac
eb02fd64 513
c1e4672c 514if [ ! -r ${srcdir}/${srctrigger} ] ; then
73f1f5ba
DZ
515 case "${srcdirdefaulted}" in
516 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
517 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
518 esac
eb02fd64 519
73f1f5ba
DZ
520 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
521 exit 1
c1e4672c 522fi
131a3881 523
c5108322
ILT
524tooldir="\$(libdir)/${target_alias}"
525
526if [ "${host_alias}" != "${target_alias}" ] ; then
527 if [ "${program_prefix}" = "" ] ; then
73f1f5ba
DZ
528 if [ "${program_suffix}" = "" ] ; then
529 if [ "${program_transform_name}" = "" ] ; then
530 program_prefix=${target_alias}- ;
531 fi
532 fi
c5108322
ILT
533 fi
534fi
535
536# Merge program_prefix and program_suffix onto program_transform_name
537# Use a double $ so that make ignores it
538if [ "${program_suffix}" != "" ] ; then
539 program_transform_name="-e s/\$\$/${program_suffix}/ ${program_transform_name}"
540fi
541
542if [ "${program_prefix}" != "" ] ; then
543 program_transform_name="-e s/^/${program_prefix}/ ${program_transform_name}"
544fi
545
8becd045 546for subdir in . ${subdirs} ; do
eb02fd64 547
8becd045
PB
548 # ${subdir} is relative path from . to the directory we're currently
549 # configuring.
550 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
551 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
131a3881 552
8becd045
PB
553 ### figure out what to do with srcdir
554 case "${srcdir}" in
73f1f5ba
DZ
555 ".") # no -srcdir option. We're building in place.
556 makesrcdir=. ;;
557 /*) # absolute path
558 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
559 ;;
560 *) # otherwise relative
561 case "${subdir}" in
562 .) makesrcdir=${srcdir} ;;
563 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
564 esac
565 ;;
8becd045 566 esac
131a3881 567
8becd045 568 if [ "${subdir}/" != "./" ] ; then
73f1f5ba 569 Makefile=${subdir}/Makefile
8becd045 570 fi
131a3881 571
9546e9b4 572 if [ ! -d ${subdir} ] ; then
73f1f5ba
DZ
573 if mkdir ${subdir} ; then
574 true
09e0b992 575 else
73f1f5ba
DZ
576 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
577 exit 1
09e0b992 578 fi
9546e9b4
RP
579 fi
580
8becd045
PB
581 case "${removing}" in
582 "")
73f1f5ba
DZ
583 case "${subdir}" in
584 .) ;;
585 *) eval echo Building in ${subdir} ${redirect} ;;
586 esac
587
588 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
589 # Set up the list of links to be made.
590 # ${links} is the list of link names, and ${files} is the list of names to link to.
591
592 # Make the links.
593 configlinks="${links}"
594 if [ -r ${subdir}/config.status ] ; then
595 mv -f ${subdir}/config.status ${subdir}/config.back
596 fi
597 while [ -n "${files}" ] ; do
598 # set file to car of files, files to cdr of files
599 set ${files}; file=$1; shift; files=$*
600 set ${links}; link=$1; shift; links=$*
601
602 if [ ! -r ${srcdir}/${file} ] ; then
603 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
604 echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
605 exit 1
606 fi
607
608 ${remove} -f ${link}
609 # Make a symlink if possible, otherwise try a hard link
610 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
611
612 if [ ! -r ${link} ] ; then
613 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
614 exit 1
615 fi
616
617 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
618 done
619
620 # Create a .gdbinit file which runs the one in srcdir
621 # and tells GDB to look there for source files.
622
623 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
624 case ${srcdir} in
625 .) ;;
626 *) cat > ${subdir}/.gdbinit <<EOF
8becd045 627# ${NO_EDIT}
3a07a6ac 628dir .
8becd045
PB
629dir ${makesrcdir}
630source ${makesrcdir}/.gdbinit
3a07a6ac 631EOF
73f1f5ba
DZ
632 ;;
633 esac
634 fi
0df06ca0 635
73f1f5ba
DZ
636 # Install a makefile, and make it set VPATH
637 # if necessary so that the sources are found.
638 # Also change its value of srcdir.
639 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
640 # been somewhat optimized and is perhaps a bit twisty.
0df06ca0 641
73f1f5ba 642 # code is order so as to try to sed the smallest input files we know.
0df06ca0 643
73f1f5ba 644 # the four makefile fragments MUST end up in the resulting Makefile in this order:
34bdab16
DZ
645 # package, target, host, and site. so do these separately because I don't trust the
646 # order of sed -e expressions.
131a3881 647
73f1f5ba
DZ
648 if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
649
e5c6be8f
DZ
650 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
651 rm -f ${subdir}/Makefile.tem
652 case "${site}" in
653 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
654 *)
655 site_makefile_frag=${srcdir}/config/ms-${site}
656
657 if [ -f ${site_makefile_frag} ] ; then
658 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
659 > ${subdir}/Makefile.tem
660 else
661 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
662 site_makefile_frag=
663 fi
664 ;;
665 esac
666 # working copy now in ${subdir}/Makefile.tem
667
668 # Conditionalize the makefile for this host.
669 rm -f ${Makefile}
670 case "${host_makefile_frag}" in
671 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
672 *)
673 if [ ! -f ${host_makefile_frag} ] ; then
674 host_makefile_frag=${srcdir}/${host_makefile_frag}
675 fi
676 if [ -f ${host_makefile_frag} ] ; then
677 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
678 else
679 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
680 echo '***' is missing in ${PWD=`pwd`}. 1>&2
681 mv ${subdir}/Makefile.tem ${Makefile}
682 fi
683 esac
684 # working copy now in ${Makefile}
685
686 # Conditionalize the makefile for this target.
687 rm -f ${subdir}/Makefile.tem
688 case "${target_makefile_frag}" in
689 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
690 *)
691 if [ ! -f ${target_makefile_frag} ] ; then
692 target_makefile_frag=${srcdir}/${target_makefile_frag}
693 fi
694 if [ -f ${target_makefile_frag} ] ; then
695 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
696 else
697 mv ${Makefile} ${subdir}/Makefile.tem
698 target_makefile_frag=
699 fi
700 ;;
701 esac
702 # real copy now in ${subdir}/Makefile.tem
703
704 # Conditionalize the makefile for this package.
705 rm -f ${Makefile}
706 case "${package_makefile_frag}" in
707 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
708 *)
709 if [ ! -f ${package_makefile_frag} ] ; then
710 package_makefile_frag=${srcdir}/${package_makefile_frag}
711 fi
712 if [ -f ${package_makefile_frag} ] ; then
713 sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
714 else
715 echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
716 echo '***' is missing in ${PWD=`pwd`}. 1>&2
717 mv ${subdir}/Makefile.tem ${Makefile}
718 fi
719 esac
720 # working copy now in ${Makefile}
721
722 mv ${Makefile} ${subdir}/Makefile.tem
723
724 # real copy now in ${subdir}/Makefile.tem
725
726 # prepend warning about editting, and a bunch of variables.
727 rm -f ${Makefile}
728 cat > ${Makefile} <<EOF
3a07a6ac 729# ${NO_EDIT}
8becd045
PB
730VPATH = ${makesrcdir}
731links = ${configlinks}
3a07a6ac
RP
732host_alias = ${host_alias}
733host_cpu = ${host_cpu}
734host_vendor = ${host_vendor}
735host_os = ${host_os}
5cc24596 736host_canonical = ${host_cpu}-${host_vendor}-${host_os}
3a07a6ac
RP
737target_alias = ${target_alias}
738target_cpu = ${target_cpu}
739target_vendor = ${target_vendor}
740target_os = ${target_os}
5cc24596 741target_canonical = ${target_cpu}-${target_vendor}-${target_os}
3a07a6ac 742EOF
e5c6be8f
DZ
743 case "${package_makefile_frag}" in
744 "") ;;
745 /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
746 *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
747 esac
748
749 case "${target_makefile_frag}" in
750 "") ;;
751 /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
752 *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
753 esac
754
755 case "${host_makefile_frag}" in
756 "") ;;
757 /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
758 *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
759 esac
760
761 if [ "${site_makefile_frag}" != "" ] ; then
762 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
763 fi
764
765 # fixme: this shouldn't be in configure.
766 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
767 case "${host_alias}" in
768 "${target_alias}")
769 echo "ALL=all.internal" >> ${Makefile}
770 ;;
771 *)
772 echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
773 echo "ALL=all.cross" >> ${Makefile}
774 ;;
775 esac
776
777 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
778 # remove any form feeds.
779 if [ -z "${subdirs}" ]; then
780 rm -f ${subdir}/Makefile.tem2
70d3fab7
DZ
781 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
782 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
e5c6be8f
DZ
783 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
784 rm -f ${subdir}/Makefile.tem
785 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
786 fi
70d3fab7
DZ
787 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
788 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
789 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
e5c6be8f 790 -e "s/\f//" \
70d3fab7
DZ
791 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
792 -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \
793 -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \
794 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
e5c6be8f
DZ
795 ${subdir}/Makefile.tem >> ${Makefile}
796 # final copy now in ${Makefile}
797
798 else
799 echo "No Makefile.in found in ${srcdir}, unable to configure" 1>&2
800 fi
73f1f5ba
DZ
801
802 rm -f ${subdir}/Makefile.tem
803
804 case "${host_makefile_frag}" in
805 "") using= ;;
806 *) using="and \"${host_makefile_frag}\"" ;;
807 esac
808
809 case "${target_makefile_frag}" in
810 "") ;;
811 *) using="${using} and \"${target_makefile_frag}\"" ;;
812 esac
813
814 case "${site_makefile_frag}" in
815 "") ;;
816 *) using="${using} and \"${site_makefile_frag}\"" ;;
817 esac
818
819 newusing=`echo "${using}" | sed 's/and/using/'`
820 using=${newusing}
821 echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
822
823 . ${tmpfile}.pos
824
825 # describe the chosen configuration in config.status.
826 # Make that file a shellscript which will reestablish
827 # the same configuration. Used in Makefiles to rebuild
828 # Makefiles.
829
830 case "${norecursion}" in
831 "") arguments="${arguments} -norecursion" ;;
832 *) ;;
833 esac
834
835 if [ ${subdir} = . ] ; then
836 echo "#!/bin/sh
4d714963 837# ${NO_EDIT}
4347369f 838# This directory was configured as follows:
4d714963 839${progname}" ${arguments} "
196377ee 840# ${using}" > ${subdir}/config.new
73f1f5ba
DZ
841 else
842 echo "#!/bin/sh
8becd045 843# ${NO_EDIT}
4347369f 844# This directory was configured as follows:
8becd045
PB
845cd ${invsubdir}
846${progname}" ${arguments} "
196377ee 847# ${using}" > ${subdir}/config.new
73f1f5ba
DZ
848 fi
849 chmod a+x ${subdir}/config.new
850 if [ -r ${subdir}/config.back ] ; then
851 mv -f ${subdir}/config.back ${subdir}/config.status
852 fi
853 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
854 ;;
8becd045 855
73f1f5ba 856 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
8becd045
PB
857 esac
858done
c1e4672c
RP
859
860# If there are subdirectories, then recur.
861if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
73f1f5ba
DZ
862 for configdir in ${configdirs} ; do
863
864 if [ -d ${srcdir}/${configdir} ] ; then
865 eval echo Configuring ${configdir}... ${redirect}
866 case "${srcdir}" in
867 ".") ;;
868 *)
869 if [ ! -d ./${configdir} ] ; then
870 if mkdir ./${configdir} ; then
871 true
872 else
873 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
874 exit 1
875 fi
876 fi
877 ;;
878 esac
879
880 POPDIR=${PWD=`pwd`}
881 cd ${configdir}
c1e4672c
RP
882
883### figure out what to do with srcdir
73f1f5ba
DZ
884 case "${srcdir}" in
885 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
886 /*) # absolute path
887 newsrcdir=${srcdir}/${configdir}
888 srcdiroption="-srcdir=${newsrcdir}"
889 ;;
890 *) # otherwise relative
891 newsrcdir=../${srcdir}/${configdir}
892 srcdiroption="-srcdir=${newsrcdir}"
893 ;;
894 esac
c1e4672c
RP
895
896### check for guested configure, otherwise fix possibly relative progname
73f1f5ba
DZ
897 if [ -f ${newsrcdir}/configure ] ; then
898 recprog=${newsrcdir}/configure
899 else
900 case "${progname}" in
901 /*) recprog=${progname} ;;
902 *) recprog=../${progname} ;;
903 esac
904 fi
4d714963
RP
905
906### The recursion line is here.
73f1f5ba
DZ
907 if eval ${recprog} ${verbose} --host=${host_alias} --target=${target_alias} \
908 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
e5c6be8f 909 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${removing} ${redirect} ; then
73f1f5ba
DZ
910 true
911 else
912 exit 1
913 fi
914
915 cd ${POPDIR}
916 fi
917 done
c1e4672c 918fi
eb02fd64 919
eb02fd64 920exit 0
74cc5508 921
0df06ca0
RP
922#
923# Local Variables:
924# fill-column: 131
925# End:
926#
74cc5508 927
46f3c7cd 928# end of configure