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