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