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