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