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