3 ### WARNING: this file contains embedded tabs. Do not run untabify on this file.
6 # Copyright (C) 1988, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
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.
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.
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.
22 # This file was originally written by K. Richard Pixley.
25 # Shell script to create proper links to machine-dependent files in
26 # preparation for compilation.
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.
33 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
42 #symbolic_link="echo ln -s"
44 # clear some things potentially inherited from environment.
47 Makefile_in=Makefile.in
56 floating_point=default
63 package_makefile_frag=
70 program_transform_name=
71 program_transform_nameoption=
83 version="$Revision: 1.2 $"
86 ### we might need to use some other shell than /bin/sh for running subshells
88 config_shell=${CONFIG_SHELL-/bin/sh}
90 NO_EDIT="This file was generated automatically by configure. Do not edit."
92 ## this is a little touchy and won't always work, but...
94 ## if the argv[0] starts with a slash then it is an absolute name that can (and
95 ## must) be used as is.
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.
102 # if PWD already has a value, it is probably wrong.
103 if [ -n "$PWD" ]; then PWD=`pwd`; fi
105 case "${progname}" in
109 PATH=$PATH:${PWD=`pwd`} ; export PATH
118 # Break out if there are no more args
125 # Get the first arg, and shuffle
129 # Make all options have two hyphens
130 orig_option=$option # Save original for error messages
133 -*) option=-$option ;;
136 # Split out the argument for options that take them
139 optarg=`echo $option | sed -e 's/^[^=]*=//'`
140 arguments="$arguments $option"
142 # These options have mandatory values. Since we didn't find an = sign,
143 # the value must be in the next argument
144 --bu* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-* | --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
147 arguments="$arguments $option=$optarg"
150 arguments="$arguments -v"
153 arguments="$arguments $option"
157 # Now, process the options
161 case "$build_alias" in
162 "") build_alias=$optarg ;;
163 *) echo '***' Can only configure for one build machine at a time. 1>&2
172 enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
174 disableoptions="$disableoptions $option"
182 enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
183 eval $enableopt="$optarg"
184 enableoptions="$enableoptions $option"
186 --exec-prefix* | --ex*)
188 exec_prefixoption="--exec-prefix=$optarg"
198 NOHOST) host_alias=$optarg ;;
199 *) echo '***' Can only configure for one host at a time. 1>&2
206 floating_pointoption="--nfp"
208 --norecursion | --no*)
213 prefixoption="--prefix=$optarg"
215 --program-prefix* | --program-p*)
216 program_prefix=$optarg
217 program_prefixoption="--program-prefix=$optarg"
219 --program-suffix* | --program-s*)
220 program_suffix=$optarg
221 program_suffixoption="--program-suffix=$optarg"
223 --program-transform-name* | --program-t*)
224 # Double any backslashes or dollar signs in the argument
225 program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
226 program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
231 --silent | --sil* | --quiet | --q*)
232 redirect=">/dev/null"
237 site_option="--site=$optarg"
240 # Remove trailing slashes. Otherwise, when the file name gets
241 # bolted into an object file as debug info, it has two slashes
242 # in it. Ordinarily this is ok, but emacs takes double slash
243 # to mean "forget the first part".
244 srcdir=`echo $optarg | sed -e 's:/$::'`
250 case $target_alias in
251 NOTARGET) target_alias=$optarg ;;
252 *) echo '***' Can only configure for one target at a time. 1>&2
259 tmpdiroption="--tmpdir=$optarg"
261 --verbose | --v | --verb*)
265 --version | --V | --vers*)
266 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
275 withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
276 eval $withopt="$optarg"
277 withoptions="$withoptions $option"
280 withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
282 withoutoptions="$withoutoptions $option"
285 withoptions="$withoptions --with-x"
287 --x-i* | --x-l*) other_options="$other_options $orig_option"
289 --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
290 # These options were added to autoconf for emacs.
293 echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
298 NOUNDEFS) undefs=$option ;;
299 *) echo '***' Can only configure for one host and one target at a time. 1>&2
307 # process host and target
309 # Do some error checking and defaulting for the host and target type.
311 # configure --host=HOST --target=TARGET UNDEFS
314 # 1. You aren't allowed to specify --host, --target, and undefs at the
316 # 2. Host defaults to undefs.
317 # 3. If undefs is not specified, then host defaults to the current host,
318 # as determined by config.guess.
319 # 4. Target defaults to undefs.
320 # 5. If undefs is not specified, then target defaults to host.
324 # Make sure that host, target & undefs aren't all specified at the
326 case $host_alias---$target_alias---$undefs in
327 NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
329 *) echo '***' Can only configure for one host and one target at a time. 1>&2
335 # Now, do defaulting for host.
340 # Neither --host option nor undefs were present.
342 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
343 if host_alias=`${guesssys}`
345 # If the string we are going to use for
346 # the target is a prefix of the string
347 # we just guessed for the host, then
348 # assume we are running native, and force
349 # the same string for both target and host.
350 case $target_alias in
353 if expr $host_alias : $target_alias >/dev/null
355 host_alias=$target_alias
359 echo "Configuring for a ${host_alias} host." 1>&2
360 arguments="--host=$host_alias $arguments"
362 echo 'Config.guess failed to determine the host type. You need to specify one.' 1>&2
368 arguments="--host=$host_alias $arguments"
374 # Do defaulting for target. If --target option isn't present, default
375 # to undefs. If undefs isn't present, default to host.
376 case $target_alias in
380 target_alias=$host_alias
384 arguments="--target=$target_alias $arguments"
392 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
394 echo Usage: configure [OPTIONS] [HOST]
396 echo Options: [defaults in brackets]
397 echo ' --prefix=MYDIR install into MYDIR [/usr/local]'
398 echo ' --exec-prefix=MYDIR install host-dependent files into MYDIR [/usr/local]'
399 echo ' --help print this message [normal config]'
400 echo ' --build=BUILD configure for building on BUILD [BUILD=HOST]'
401 echo ' --host=HOST configure for HOST [determined via config.guess]'
402 echo ' --norecursion configure this directory only [recurse]'
403 echo ' --program-prefix=FOO prepend FOO to installed program names [""]'
404 echo ' --program-suffix=FOO append FOO to installed program names [""]'
405 echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
406 echo ' --site=SITE configure with site-specific makefile for SITE'
407 echo ' --srcdir=DIR find the sources in DIR [. or ..]'
408 echo ' --target=TARGET configure for TARGET [TARGET=HOST]'
409 echo ' --tmpdir=TMPDIR create temporary files in TMPDIR [/tmp]'
410 echo ' --nfp configure for software floating point [hard float]'
411 echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
412 echo ' --without-FOO package FOO is NOT available'
413 echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
414 echo ' --disable-FOO do not include feature FOO'
416 echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
418 if [ -r config.status ] ; then
425 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
426 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
428 # this is a hack. sun4 must always be a valid host alias or this will fail.
429 if ${configsub} sun4 >/dev/null 2>&1 ; then
432 echo '***' cannot find config.sub. 1>&2
437 if ${moveifchange} config.junk config.trash ; then
440 echo '***' cannot find move-if-change. 1>&2
443 rm -f config.junk config.trash
447 if [ -r configure.in ] ; then
450 if [ -r ${progname}.in ] ; then
451 srcdir=`echo ${progname} | sed 's:/configure$::'`
453 echo '***' "Can't find configure.in. Try using --srcdir=some_dir" 1>&2
459 # Set srcdir to "." if that's what it is.
460 # This is important for multilib support.
461 if [ ! -d ${srcdir} ] ; then
462 echo "Invalid source directory ${srcdir}" >&2
466 srcpwd=`cd ${srcdir} ; pwd`
467 if [ "${pwd}" = "${srcpwd}" ] ; then
472 ### warn about some conflicting configurations.
477 if [ -f ${srcdir}/config.status ] ; then
478 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
483 # default exec_prefix
484 case "${exec_prefixoption}" in
485 "") exec_prefix="\$(prefix)" ;;
489 ### break up ${srcdir}/configure.in.
490 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
492 echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
493 # Check for a directory that's been converted to use autoconf since
494 # it was last configured.
495 if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
496 echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
497 if [ -r ${srcdir}/configure ] ; then
498 echo '***' Running the local configure script. 1>&2
499 case "${cache_file}" in
500 "") cache_file_option= ;;
501 *) cache_file_option="--cache-file=${cache_file}" ;;
503 srcdiroption="--srcdir=${srcdir}"
504 case "${build_alias}" in
506 *) buildopt="--build=${build_alias}" ;;
508 eval exec ${config_shell} ${srcdir}/configure ${verbose} \
509 ${buildopt} --host=${host_alias} --target=${target_alias} \
510 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
512 ${program_prefixoption} ${program_suffixoption} \
513 ${program_transform_nameoption} ${site_option} \
514 ${withoptions} ${withoutoptions} \
515 ${enableoptions} ${disableoptions} ${floating_pointoption} \
516 ${cache_file_option} ${removing} ${other_options} ${redirect}
518 echo '***' There is no configure script present though. 1>&2
526 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
528 echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
535 "") TMPDIR=/tmp ; export TMPDIR ;;
539 # keep this filename short for &%*%$*# 14 char file names
540 tmpfile=${TMPDIR}/cONf$$
541 # Note that under many versions of sh a trap handler for 0 will *override* any
542 # exit status you explicitly specify! At this point, the only non-error exit
543 # is at the end of the script; these actions are duplicated there, minus
544 # the "exit 1". Don't use "exit 0" anywhere after this without resetting the
545 # trap handler, or you'll lose.
546 trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
548 # split ${srcdir}/configure.in into common, per-host, per-target,
549 # and post-target parts. Post-target is optional.
550 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
551 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
552 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
553 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
554 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
556 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
560 ### do common part of configure.in
564 # some sanity checks on configure.in
565 case "${srctrigger}" in
567 echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
573 case "${build_alias}" in
575 if result=`${config_shell} ${configsub} ${host_alias}` ; then
576 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
577 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
578 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
579 build=${build_cpu}-${build_vendor}-${build_os}
580 build_alias=${host_alias}
584 if result=`${config_shell} ${configsub} ${build_alias}` ; then
585 buildopt="--build=${build_alias}"
586 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
587 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
588 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
589 build=${build_cpu}-${build_vendor}-${build_os}
591 echo "Unrecognized build system name ${build_alias}." 1>&2
597 if result=`${config_shell} ${configsub} ${host_alias}` ; then
600 echo "Unrecognized host system name ${host_alias}." 1>&2
603 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
604 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
605 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
606 host=${host_cpu}-${host_vendor}-${host_os}
610 if result=`${config_shell} ${configsub} ${target_alias}` ; then
613 echo "Unrecognized target system name ${target_alias}." 1>&2
616 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
617 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
618 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
619 target=${target_cpu}-${target_vendor}-${target_os}
623 # Find the source files, if location was not specified.
628 if [ ! -r ${srctrigger} ] ; then
635 if [ ! -r ${srcdir}/${srctrigger} ] ; then
636 case "${srcdirdefaulted}" in
637 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
638 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
641 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
645 # Some systems (e.g., one of the i386-aix systems the gas testers are
646 # using) don't handle "\$" correctly, so don't use it here.
647 tooldir='$(exec_prefix)'/${target_alias}
649 if [ "${host_alias}" != "${target_alias}" ] ; then
650 if [ "${program_prefixoption}" = "" ] ; then
651 if [ "${program_suffixoption}" = "" ] ; then
652 if [ "${program_transform_nameoption}" = "" ] ; then
653 program_prefix=${target_alias}- ;
659 # Merge program_prefix and program_suffix onto program_transform_name.
660 # (program_suffix used to use $, but it's hard to preserve $ through both
662 if [ "${program_suffix}" != "" ] ; then
663 program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
666 if [ "${program_prefix}" != "" ] ; then
667 program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
670 # If CC and CXX are not set in the environment, and the Makefile
671 # exists, try to extract them from it. This is to handle running
672 # ./config.status by hand.
673 if [ -z "${CC}" -a -r Makefile ]; then
678 /^CC[ ]*=/ s/CC[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
679 CC=`tail -1 Makefile.cc`
683 if [ -z "${CXX}" -a -r Makefile ]; then
688 /^CXX[ ]*=/ s/CXX[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
689 CXX=`tail -1 Makefile.cc`
693 if [ "${build}" != "${host}" ]; then
694 # If we are doing a Canadian Cross, in which the host and build systems
695 # are not the same, we set reasonable default values for the tools.
697 tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
698 tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET"
699 tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET HOST_PREFIX"
700 tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
701 tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
703 for var in ${tools}; do
704 if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then
709 /^'"${var}"'[ ]*=/ s/'"${var}"'[ ]*=[ ]*\(.*\)/\1/p' \
710 < Makefile > Makefile.v
711 t=`tail -1 Makefile.v`
712 if [ -n "${t}" ]; then
719 AR=${AR-${host_alias}-ar}
720 AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
721 AS=${AS-${host_alias}-as}
722 AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
723 CC=${CC-${host_alias}-gcc}
724 CXX=${CXX-${host_alias}-gcc}
725 CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
726 CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
727 CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-gcc}
728 DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
729 DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
730 HOST_PREFIX=${build_alias}-
731 HOST_PREFIX_1=${build_alias}-
732 LD=${LD-${host_alias}-ld}
733 LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
734 MAKEINFO=${MAKEINFO-makeinfo}
735 NM=${NM-${host_alias}-nm}
736 NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
737 RANLIB=${RANLIB-${host_alias}-ranlib}
738 RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
740 if [ -z "${BISON}" ]; then
741 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
743 test -z "$dir" && dir=.
744 if test -f $dir/byacc; then
748 if test -f $dir/bison; then
752 if test -f $dir/yacc; then
761 if [ -z "${LEX}" ]; then
762 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
764 test -z "$dir" && dir=.
765 if test -f $dir/flex; then
769 if test -f $dir/lex; then
778 # Export variables which autoconf might try to set.
787 # If CC is still not set, try to get gcc.
788 if [ x$with_gcc != xno -a -z "${CC}" ]; then
789 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
791 test -z "$dir" && dir=.
792 if test -f $dir/gcc; then
812 # Determine whether gdb needs tk/tcl or not.
813 if [ "$enable_gdbtk" != "no" ]; then
814 GDB_TK="all-tcl all-tk"
819 for subdir in . ${subdirs} ; do
821 # ${subdir} is relative path from . to the directory we're currently
823 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
824 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
826 ### figure out what to do with srcdir
828 ".") # no -srcdir option. We're building in place.
831 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
833 *) # otherwise relative
835 .) makesrcdir=${srcdir} ;;
836 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
841 if [ "${subdir}/" != "./" ] ; then
842 Makefile=${subdir}/Makefile
845 if [ ! -d ${subdir} ] ; then
846 if mkdir ${subdir} ; then
849 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
854 case "${removing}" in
858 *) eval echo Building in ${subdir} ${redirect} ;;
861 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
862 # Set up the list of links to be made.
863 # ${links} is the list of link names, and ${files} is the list of names to link to.
866 configlinks="${links}"
867 if [ -r ${subdir}/config.status ] ; then
868 mv -f ${subdir}/config.status ${subdir}/config.back
870 while [ -n "${files}" ] ; do
871 # set file to car of files, files to cdr of files
872 set ${files}; file=$1; shift; files=$*
873 set ${links}; link=$1; shift; links=$*
875 if [ ! -r ${srcdir}/${file} ] ; then
876 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
877 echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
882 # Make a symlink if possible, otherwise try a hard link
883 if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
886 # We need to re-remove the file because Lynx leaves a
887 # very strange directory there when it fails an NFS symlink.
888 ${remove} -r -f ${link}
889 ${hard_link} ${srcdir}/${file} ${link}
891 if [ ! -r ${link} ] ; then
892 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
896 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
899 # Create a .gdbinit file which runs the one in srcdir
900 # and tells GDB to look there for source files.
902 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
905 *) cat > ${subdir}/.gdbinit <<EOF
909 source ${makesrcdir}/.gdbinit
915 # Install a makefile, and make it set VPATH
916 # if necessary so that the sources are found.
917 # Also change its value of srcdir.
918 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
919 # been somewhat optimized and is perhaps a bit twisty.
921 # code is order so as to try to sed the smallest input files we know.
923 # the four makefile fragments MUST end up in the resulting Makefile in this order:
924 # package, target, host, and site. so do these separately because I don't trust the
925 # order of sed -e expressions.
927 if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
929 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
930 rm -f ${subdir}/Makefile.tem
932 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
934 site_makefile_frag=${srcdir}/config/ms-${site}
936 if [ -f ${site_makefile_frag} ] ; then
937 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
938 > ${subdir}/Makefile.tem
940 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
945 # working copy now in ${subdir}/Makefile.tem
947 # Conditionalize the makefile for this host.
949 case "${host_makefile_frag}" in
950 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
952 if [ ! -f ${host_makefile_frag} ] ; then
953 host_makefile_frag=${srcdir}/${host_makefile_frag}
955 if [ -f ${host_makefile_frag} ] ; then
956 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
958 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
959 echo '***' is missing in ${PWD=`pwd`}. 1>&2
960 mv ${subdir}/Makefile.tem ${Makefile}
963 # working copy now in ${Makefile}
965 # Conditionalize the makefile for this target.
966 rm -f ${subdir}/Makefile.tem
967 case "${target_makefile_frag}" in
968 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
970 if [ ! -f ${target_makefile_frag} ] ; then
971 target_makefile_frag=${srcdir}/${target_makefile_frag}
973 if [ -f ${target_makefile_frag} ] ; then
974 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
976 mv ${Makefile} ${subdir}/Makefile.tem
977 target_makefile_frag=
981 # real copy now in ${subdir}/Makefile.tem
983 # Conditionalize the makefile for this package.
985 case "${package_makefile_frag}" in
986 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
988 if [ ! -f ${package_makefile_frag} ] ; then
989 package_makefile_frag=${srcdir}/${package_makefile_frag}
991 if [ -f ${package_makefile_frag} ] ; then
992 sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
993 rm -f ${subdir}/Makefile.tem
995 echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
996 echo '***' is missing in ${PWD=`pwd`}. 1>&2
997 mv ${subdir}/Makefile.tem ${Makefile}
1000 # working copy now in ${Makefile}
1002 mv ${Makefile} ${subdir}/Makefile.tem
1004 # real copy now in ${subdir}/Makefile.tem
1006 # prepend warning about editting, and a bunch of variables.
1008 cat > ${Makefile} <<EOF
1010 VPATH = ${makesrcdir}
1011 links = ${configlinks}
1012 host_alias = ${host_alias}
1013 host_cpu = ${host_cpu}
1014 host_vendor = ${host_vendor}
1015 host_os = ${host_os}
1016 host_canonical = ${host_cpu}-${host_vendor}-${host_os}
1017 target_alias = ${target_alias}
1018 target_cpu = ${target_cpu}
1019 target_vendor = ${target_vendor}
1020 target_os = ${target_os}
1021 target_canonical = ${target_cpu}-${target_vendor}-${target_os}
1025 *) cat >> ${Makefile} << EOF
1026 build_alias = ${build_alias}
1027 build_cpu = ${build_cpu}
1028 build_vendor = ${build_vendor}
1029 build_os = ${build_os}
1030 build_canonical = ${build_cpu}-${build_vendor}-${build_os}
1034 case "${package_makefile_frag}" in
1036 /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
1037 *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
1040 case "${target_makefile_frag}" in
1042 /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
1043 *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
1046 case "${host_makefile_frag}" in
1048 /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
1049 *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
1052 if [ "${site_makefile_frag}" != "" ] ; then
1053 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
1056 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
1057 # remove any form feeds.
1058 if [ -z "${subdirs}" ]; then
1059 rm -f ${subdir}/Makefile.tem2
1060 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
1061 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
1062 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
1063 rm -f ${subdir}/Makefile.tem
1064 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
1066 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
1067 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
1073 s%^CC[ ]*=.*$%CC = ${CC}%
1080 s%^CXX[ ]*=.*$%CXX = ${CXX}%
1082 -e "s:^SHELL[ ]*=.*$:SHELL = ${config_shell}:" \
1083 -e "s:^GDB_TK[ ]*=.*$:GDB_TK = ${GDB_TK}:" \
1084 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
1086 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
1087 -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \
1088 -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \
1089 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
1090 ${subdir}/Makefile.tem >> ${Makefile}
1092 # If this is a Canadian Cross, preset the values of many more
1094 if [ "${build}" != "${host}" ]; then
1095 for var in ${tools}; do
1096 val=`eval 'echo $'"${var}"`
1097 sed -e "/^${var}[ ]*=/{
1102 s%^${var}[ ]*=.*$%${var} = ${val}%
1103 }" ${Makefile} > ${Makefile}.tem
1104 mv -f ${Makefile}.tem ${Makefile}
1108 # final copy now in ${Makefile}
1111 echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
1114 rm -f ${subdir}/Makefile.tem
1116 case "${host_makefile_frag}" in
1118 *) using="and \"${host_makefile_frag}\"" ;;
1121 case "${target_makefile_frag}" in
1123 *) using="${using} and \"${target_makefile_frag}\"" ;;
1126 case "${site_makefile_frag}" in
1128 *) using="${using} and \"${site_makefile_frag}\"" ;;
1131 newusing=`echo "${using}" | sed 's/and/using/'`
1133 echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
1137 # describe the chosen configuration in config.status.
1138 # Make that file a shellscript which will reestablish
1139 # the same configuration. Used in Makefiles to rebuild
1142 case "${norecursion}" in
1143 "") arguments="${arguments} --norecursion" ;;
1147 if [ ${subdir} = . ] ; then
1150 # This directory was configured as follows:
1151 ${progname}" ${arguments} "
1152 # ${using}" > ${subdir}/config.new
1156 # This directory was configured as follows:
1158 ${progname}" ${arguments} "
1159 # ${using}" > ${subdir}/config.new
1161 chmod a+x ${subdir}/config.new
1162 if [ -r ${subdir}/config.back ] ; then
1163 mv -f ${subdir}/config.back ${subdir}/config.status
1165 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
1168 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
1172 # If there are subdirectories, then recur.
1173 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
1174 for configdir in ${configdirs} ; do
1176 if [ -d ${srcdir}/${configdir} ] ; then
1177 eval echo Configuring ${configdir}... ${redirect}
1181 if [ ! -d ./${configdir} ] ; then
1182 if mkdir ./${configdir} ; then
1185 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
1195 ### figure out what to do with srcdir
1197 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
1199 newsrcdir=${srcdir}/${configdir}
1200 srcdiroption="--srcdir=${newsrcdir}"
1202 *) # otherwise relative
1203 newsrcdir=../${srcdir}/${configdir}
1204 srcdiroption="--srcdir=${newsrcdir}"
1208 # Handle --cache-file=../XXX
1209 case "${cache_file}" in
1213 cache_file_option="--cache-file=${cache_file}"
1216 cache_file_option="--cache-file=../${cache_file}"
1220 ### check for guested configure, otherwise fix possibly relative progname
1221 if [ -f ${newsrcdir}/configure ] ; then
1222 recprog=${newsrcdir}/configure
1223 elif [ -f ${newsrcdir}/configure.in ] ; then
1224 case "${progname}" in
1225 /*) recprog=${progname} ;;
1226 *) recprog=../${progname} ;;
1229 eval echo No configuration information in ${configdir} ${redirect}
1233 ### The recursion line is here.
1234 if [ ! -z "${recprog}" ] ; then
1235 if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
1236 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
1237 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${floating_pointoption} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
1240 echo Configure in `pwd` failed, exiting. 1>&2
1250 # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
1251 # and reset the trap handler.
1252 rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos