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