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