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