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