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