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=
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
207 --norecursion | --no*)
212 prefixoption="--prefix=$optarg"
214 --program-prefix* | --program-p*)
215 program_prefix=$optarg
216 program_prefixoption="--program-prefix=$optarg"
218 --program-suffix* | --program-s*)
219 program_suffix=$optarg
220 program_suffixoption="--program-suffix=$optarg"
222 --program-transform-name* | --program-t*)
223 # Double any backslashes or dollar signs in the argument
224 program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
225 program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
230 --silent | --sil* | --quiet | --q*)
231 redirect=">/dev/null"
236 site_option="--site=$optarg"
239 # Remove trailing slashes. Otherwise, when the file name gets
240 # bolted into an object file as debug info, it has two slashes
241 # in it. Ordinarily this is ok, but emacs takes double slash
242 # to mean "forget the first part".
243 srcdir=`echo $optarg | sed -e 's:/$::'`
249 case $target_alias in
250 NOTARGET) target_alias=$optarg ;;
251 *) echo '***' Can only configure for one target at a time. 1>&2
258 tmpdiroption="--tmpdir=$optarg"
260 --verbose | --v | --verb*)
264 --version | --V | --vers*)
265 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
274 withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
275 eval $withopt="$optarg"
276 withoptions="$withoptions $option"
279 withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
281 withoutoptions="$withoutoptions $option"
284 withoptions="$withoptions --with-x"
286 --x-i* | --x-l*) other_options="$other_options $orig_option"
288 --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
289 # These options were added to autoconf for emacs.
292 echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
297 NOUNDEFS) undefs=$option ;;
298 *) echo '***' Can only configure for one host and one target at a time. 1>&2
306 # process host and target
308 # Do some error checking and defaulting for the host and target type.
310 # configure --host=HOST --target=TARGET UNDEFS
313 # 1. You aren't allowed to specify --host, --target, and undefs at the
315 # 2. Host defaults to undefs.
316 # 3. If undefs is not specified, then host defaults to the current host,
317 # as determined by config.guess.
318 # 4. Target defaults to undefs.
319 # 5. If undefs is not specified, then target defaults to host.
323 # Make sure that host, target & undefs aren't all specified at the
325 case $host_alias---$target_alias---$undefs in
326 NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
328 *) echo '***' Can only configure for one host and one target at a time. 1>&2
334 # Now, do defaulting for host.
339 # Neither --host option nor undefs were present.
341 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
342 if host_alias=`${guesssys}`
344 # If the string we are going to use for
345 # the target is a prefix of the string
346 # we just guessed for the host, then
347 # assume we are running native, and force
348 # the same string for both target and host.
349 case $target_alias in
352 if expr $host_alias : $target_alias >/dev/null
354 host_alias=$target_alias
358 echo "Configuring for a ${host_alias} host." 1>&2
359 arguments="--host=$host_alias $arguments"
361 echo 'Config.guess failed to determine the host type. You need to specify one.' 1>&2
367 arguments="--host=$host_alias $arguments"
373 # Do defaulting for target. If --target option isn't present, default
374 # to undefs. If undefs isn't present, default to host.
375 case $target_alias in
379 target_alias=$host_alias
383 arguments="--target=$target_alias $arguments"
391 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
393 echo Usage: configure [OPTIONS] [HOST]
395 echo Options: [defaults in brackets]
396 echo ' --prefix=MYDIR install into MYDIR [/usr/local]'
397 echo ' --exec-prefix=MYDIR install host-dependent files into MYDIR [/usr/local]'
398 echo ' --help print this message [normal config]'
399 echo ' --build=BUILD configure for building on BUILD [BUILD=HOST]'
400 echo ' --host=HOST configure for HOST [determined via config.guess]'
401 echo ' --norecursion configure this directory only [recurse]'
402 echo ' --program-prefix=FOO prepend FOO to installed program names [""]'
403 echo ' --program-suffix=FOO append FOO to installed program names [""]'
404 echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
405 echo ' --site=SITE configure with site-specific makefile for SITE'
406 echo ' --srcdir=DIR find the sources in DIR [. or ..]'
407 echo ' --target=TARGET configure for TARGET [TARGET=HOST]'
408 echo ' --tmpdir=TMPDIR create temporary files in TMPDIR [/tmp]'
409 echo ' --nfp configure for software floating point [hard float]'
410 echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
411 echo ' --without-FOO package FOO is NOT available'
412 echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
413 echo ' --disable-FOO do not include feature FOO'
415 echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
417 if [ -r config.status ] ; then
424 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
425 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
427 # this is a hack. sun4 must always be a valid host alias or this will fail.
428 if ${configsub} sun4 >/dev/null 2>&1 ; then
431 echo '***' cannot find config.sub. 1>&2
436 if ${moveifchange} config.junk config.trash ; then
439 echo '***' cannot find move-if-change. 1>&2
442 rm -f config.junk config.trash
446 if [ -r configure.in ] ; then
449 if [ -r ${progname}.in ] ; then
450 srcdir=`echo ${progname} | sed 's:/configure$::'`
452 echo '***' "Can't find configure.in. Try using --srcdir=some_dir" 1>&2
458 # Set srcdir to "." if that's what it is.
459 # This is important for multilib support.
460 if [ ! -d ${srcdir} ] ; then
461 echo "Invalid source directory ${srcdir}" >&2
465 srcpwd=`cd ${srcdir} ; pwd`
466 if [ "${pwd}" = "${srcpwd}" ] ; then
471 ### warn about some conflicting configurations.
476 if [ -f ${srcdir}/config.status ] ; then
477 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
482 # default exec_prefix
483 case "${exec_prefixoption}" in
484 "") exec_prefix="\$(prefix)" ;;
488 ### break up ${srcdir}/configure.in.
489 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
491 echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
492 # Check for a directory that's been converted to use autoconf since
493 # it was last configured.
494 if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
495 echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
496 if [ -r ${srcdir}/configure ] ; then
497 echo '***' Running the local configure script. 1>&2
498 case "${cache_file}" in
499 "") cache_file_option= ;;
500 *) cache_file_option="--cache-file=${cache_file}" ;;
502 srcdiroption="--srcdir=${srcdir}"
503 case "${build_alias}" in
505 *) buildopt="--build=${build_alias}" ;;
507 eval exec ${config_shell} ${srcdir}/configure ${verbose} \
508 ${buildopt} --host=${host_alias} --target=${target_alias} \
509 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
511 ${program_prefixoption} ${program_suffixoption} \
512 ${program_transform_nameoption} ${site_option} \
513 ${withoptions} ${withoutoptions} \
514 ${enableoptions} ${disableoptions} \
515 ${cache_file_option} ${removing} ${other_options} ${redirect}
517 echo '***' There is no configure script present though. 1>&2
525 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
527 echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
534 "") TMPDIR=/tmp ; export TMPDIR ;;
538 # keep this filename short for &%*%$*# 14 char file names
539 tmpfile=${TMPDIR}/cONf$$
540 # Note that under many versions of sh a trap handler for 0 will *override* any
541 # exit status you explicitly specify! At this point, the only non-error exit
542 # is at the end of the script; these actions are duplicated there, minus
543 # the "exit 1". Don't use "exit 0" anywhere after this without resetting the
544 # trap handler, or you'll lose.
545 trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
547 # split ${srcdir}/configure.in into common, per-host, per-target,
548 # and post-target parts. Post-target is optional.
549 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
550 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
551 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
552 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
553 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
555 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
559 ### do common part of configure.in
563 # some sanity checks on configure.in
564 case "${srctrigger}" in
566 echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
572 case "${build_alias}" in
574 if result=`${config_shell} ${configsub} ${host_alias}` ; then
575 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
576 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
577 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
578 build=${build_cpu}-${build_vendor}-${build_os}
579 build_alias=${host_alias}
583 if result=`${config_shell} ${configsub} ${build_alias}` ; then
584 buildopt="--build=${build_alias}"
585 build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
586 build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
587 build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
588 build=${build_cpu}-${build_vendor}-${build_os}
590 echo "Unrecognized build system name ${build_alias}." 1>&2
596 if result=`${config_shell} ${configsub} ${host_alias}` ; then
599 echo "Unrecognized host system name ${host_alias}." 1>&2
602 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
603 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
604 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
605 host=${host_cpu}-${host_vendor}-${host_os}
609 if result=`${config_shell} ${configsub} ${target_alias}` ; then
612 echo "Unrecognized target system name ${target_alias}." 1>&2
615 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
616 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
617 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
618 target=${target_cpu}-${target_vendor}-${target_os}
622 # Find the source files, if location was not specified.
627 if [ ! -r ${srctrigger} ] ; then
634 if [ ! -r ${srcdir}/${srctrigger} ] ; then
635 case "${srcdirdefaulted}" in
636 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
637 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
640 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
644 # Some systems (e.g., one of the i386-aix systems the gas testers are
645 # using) don't handle "\$" correctly, so don't use it here.
646 tooldir='$(exec_prefix)'/${target_alias}
648 if [ "${host_alias}" != "${target_alias}" ] ; then
649 if [ "${program_prefixoption}" = "" ] ; then
650 if [ "${program_suffixoption}" = "" ] ; then
651 if [ "${program_transform_nameoption}" = "" ] ; then
652 program_prefix=${target_alias}- ;
658 # Merge program_prefix and program_suffix onto program_transform_name.
659 # (program_suffix used to use $, but it's hard to preserve $ through both
661 if [ "${program_suffix}" != "" ] ; then
662 program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
665 if [ "${program_prefix}" != "" ] ; then
666 program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
669 # If CC and CXX are not set in the environment, and the Makefile
670 # exists, try to extract them from it. This is to handle running
671 # ./config.status by hand.
672 if [ -z "${CC}" -a -r Makefile ]; then
677 /^CC[ ]*=/ s/CC[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
678 CC=`tail -1 Makefile.cc`
682 if [ -z "${CXX}" -a -r Makefile ]; then
687 /^CXX[ ]*=/ s/CXX[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc
688 CXX=`tail -1 Makefile.cc`
692 if [ "${build}" != "${host}" ]; then
693 # If we are doing a Canadian Cross, in which the host and build systems
694 # are not the same, we set reasonable default values for the tools.
696 tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
697 tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET"
698 tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET HOST_PREFIX"
699 tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
700 tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
702 for var in ${tools}; do
703 if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then
708 /^'"${var}"'[ ]*=/ s/'"${var}"'[ ]*=[ ]*\(.*\)/\1/p' \
709 < Makefile > Makefile.v
710 t=`tail -1 Makefile.v`
711 if [ -n "${t}" ]; then
718 AR=${AR-${host_alias}-ar}
719 AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
720 AS=${AS-${host_alias}-as}
721 AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
722 CC=${CC-${host_alias}-gcc}
723 CXX=${CXX-${host_alias}-gcc}
724 CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
725 CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
726 CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-gcc}
727 DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
728 DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
729 HOST_PREFIX=${build_alias}-
730 HOST_PREFIX_1=${build_alias}-
731 LD=${LD-${host_alias}-ld}
732 LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
733 MAKEINFO=${MAKEINFO-makeinfo}
734 NM=${NM-${host_alias}-nm}
735 NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
736 RANLIB=${RANLIB-${host_alias}-ranlib}
737 RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
739 if [ -z "${BISON}" ]; then
740 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
742 test -z "$dir" && dir=.
743 if test -f $dir/byacc; then
747 if test -f $dir/bison; then
751 if test -f $dir/yacc; then
760 if [ -z "${LEX}" ]; then
761 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
763 test -z "$dir" && dir=.
764 if test -f $dir/flex; then
768 if test -f $dir/lex; then
777 # Export variables which autoconf might try to set.
786 # If CC is still not set, try to get gcc.
787 if [ -z "${CC}" ]; then
788 IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
790 test -z "$dir" && dir=.
791 if test -f $dir/gcc; then
811 # Determine whether gdb needs tk/tcl or not.
812 if [ "$enable_gdbtk" != "no" ]; then
813 GDB_TK="all-tcl all-tk"
818 for subdir in . ${subdirs} ; do
820 # ${subdir} is relative path from . to the directory we're currently
822 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
823 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
825 ### figure out what to do with srcdir
827 ".") # no -srcdir option. We're building in place.
830 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
832 *) # otherwise relative
834 .) makesrcdir=${srcdir} ;;
835 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
840 if [ "${subdir}/" != "./" ] ; then
841 Makefile=${subdir}/Makefile
844 if [ ! -d ${subdir} ] ; then
845 if mkdir ${subdir} ; then
848 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
853 case "${removing}" in
857 *) eval echo Building in ${subdir} ${redirect} ;;
860 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
861 # Set up the list of links to be made.
862 # ${links} is the list of link names, and ${files} is the list of names to link to.
865 configlinks="${links}"
866 if [ -r ${subdir}/config.status ] ; then
867 mv -f ${subdir}/config.status ${subdir}/config.back
869 while [ -n "${files}" ] ; do
870 # set file to car of files, files to cdr of files
871 set ${files}; file=$1; shift; files=$*
872 set ${links}; link=$1; shift; links=$*
874 if [ ! -r ${srcdir}/${file} ] ; then
875 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
876 echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
881 # Make a symlink if possible, otherwise try a hard link
882 if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
885 # We need to re-remove the file because Lynx leaves a
886 # very strange directory there when it fails an NFS symlink.
887 ${remove} -r -f ${link}
888 ${hard_link} ${srcdir}/${file} ${link}
890 if [ ! -r ${link} ] ; then
891 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
895 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
898 # Create a .gdbinit file which runs the one in srcdir
899 # and tells GDB to look there for source files.
901 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
904 *) cat > ${subdir}/.gdbinit <<EOF
908 source ${makesrcdir}/.gdbinit
914 # Install a makefile, and make it set VPATH
915 # if necessary so that the sources are found.
916 # Also change its value of srcdir.
917 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
918 # been somewhat optimized and is perhaps a bit twisty.
920 # code is order so as to try to sed the smallest input files we know.
922 # the four makefile fragments MUST end up in the resulting Makefile in this order:
923 # package, target, host, and site. so do these separately because I don't trust the
924 # order of sed -e expressions.
926 if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
928 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
929 rm -f ${subdir}/Makefile.tem
931 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
933 site_makefile_frag=${srcdir}/config/ms-${site}
935 if [ -f ${site_makefile_frag} ] ; then
936 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
937 > ${subdir}/Makefile.tem
939 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
944 # working copy now in ${subdir}/Makefile.tem
946 # Conditionalize the makefile for this host.
948 case "${host_makefile_frag}" in
949 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
951 if [ ! -f ${host_makefile_frag} ] ; then
952 host_makefile_frag=${srcdir}/${host_makefile_frag}
954 if [ -f ${host_makefile_frag} ] ; then
955 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
957 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
958 echo '***' is missing in ${PWD=`pwd`}. 1>&2
959 mv ${subdir}/Makefile.tem ${Makefile}
962 # working copy now in ${Makefile}
964 # Conditionalize the makefile for this target.
965 rm -f ${subdir}/Makefile.tem
966 case "${target_makefile_frag}" in
967 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
969 if [ ! -f ${target_makefile_frag} ] ; then
970 target_makefile_frag=${srcdir}/${target_makefile_frag}
972 if [ -f ${target_makefile_frag} ] ; then
973 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
975 mv ${Makefile} ${subdir}/Makefile.tem
976 target_makefile_frag=
980 # real copy now in ${subdir}/Makefile.tem
982 # Conditionalize the makefile for this package.
984 case "${package_makefile_frag}" in
985 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
987 if [ ! -f ${package_makefile_frag} ] ; then
988 package_makefile_frag=${srcdir}/${package_makefile_frag}
990 if [ -f ${package_makefile_frag} ] ; then
991 sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
992 rm -f ${subdir}/Makefile.tem
994 echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
995 echo '***' is missing in ${PWD=`pwd`}. 1>&2
996 mv ${subdir}/Makefile.tem ${Makefile}
999 # working copy now in ${Makefile}
1001 mv ${Makefile} ${subdir}/Makefile.tem
1003 # real copy now in ${subdir}/Makefile.tem
1005 # prepend warning about editting, and a bunch of variables.
1007 cat > ${Makefile} <<EOF
1009 VPATH = ${makesrcdir}
1010 links = ${configlinks}
1011 host_alias = ${host_alias}
1012 host_cpu = ${host_cpu}
1013 host_vendor = ${host_vendor}
1014 host_os = ${host_os}
1015 host_canonical = ${host_cpu}-${host_vendor}-${host_os}
1016 target_alias = ${target_alias}
1017 target_cpu = ${target_cpu}
1018 target_vendor = ${target_vendor}
1019 target_os = ${target_os}
1020 target_canonical = ${target_cpu}-${target_vendor}-${target_os}
1024 *) cat >> ${Makefile} << EOF
1025 build_alias = ${build_alias}
1026 build_cpu = ${build_cpu}
1027 build_vendor = ${build_vendor}
1028 build_os = ${build_os}
1029 build_canonical = ${build_cpu}-${build_vendor}-${build_os}
1033 case "${package_makefile_frag}" in
1035 /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
1036 *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
1039 case "${target_makefile_frag}" in
1041 /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
1042 *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
1045 case "${host_makefile_frag}" in
1047 /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
1048 *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
1051 if [ "${site_makefile_frag}" != "" ] ; then
1052 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
1055 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
1056 # remove any form feeds.
1057 if [ -z "${subdirs}" ]; then
1058 rm -f ${subdir}/Makefile.tem2
1059 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
1060 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
1061 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
1062 rm -f ${subdir}/Makefile.tem
1063 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
1065 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
1066 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
1072 s%^CC[ ]*=.*$%CC = ${CC}%
1079 s%^CXX[ ]*=.*$%CXX = ${CXX}%
1081 -e "s:^SHELL[ ]*=.*$:SHELL = ${config_shell}:" \
1082 -e "s:^GDB_TK[ ]*=.*$:GDB_TK = ${GDB_TK}:" \
1083 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
1085 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
1086 -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \
1087 -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \
1088 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
1089 ${subdir}/Makefile.tem >> ${Makefile}
1091 # If this is a Canadian Cross, preset the values of many more
1093 if [ "${build}" != "${host}" ]; then
1094 for var in ${tools}; do
1095 val=`eval 'echo $'"${var}"`
1096 sed -e "/^${var}[ ]*=/{
1101 s%^${var}[ ]*=.*$%${var} = ${val}%
1102 }" ${Makefile} > ${Makefile}.tem
1103 mv -f ${Makefile}.tem ${Makefile}
1107 # final copy now in ${Makefile}
1110 echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
1113 rm -f ${subdir}/Makefile.tem
1115 case "${host_makefile_frag}" in
1117 *) using="and \"${host_makefile_frag}\"" ;;
1120 case "${target_makefile_frag}" in
1122 *) using="${using} and \"${target_makefile_frag}\"" ;;
1125 case "${site_makefile_frag}" in
1127 *) using="${using} and \"${site_makefile_frag}\"" ;;
1130 newusing=`echo "${using}" | sed 's/and/using/'`
1132 echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
1136 # describe the chosen configuration in config.status.
1137 # Make that file a shellscript which will reestablish
1138 # the same configuration. Used in Makefiles to rebuild
1141 case "${norecursion}" in
1142 "") arguments="${arguments} --norecursion" ;;
1146 if [ ${subdir} = . ] ; then
1149 # This directory was configured as follows:
1150 ${progname}" ${arguments} "
1151 # ${using}" > ${subdir}/config.new
1155 # This directory was configured as follows:
1157 ${progname}" ${arguments} "
1158 # ${using}" > ${subdir}/config.new
1160 chmod a+x ${subdir}/config.new
1161 if [ -r ${subdir}/config.back ] ; then
1162 mv -f ${subdir}/config.back ${subdir}/config.status
1164 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
1167 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
1171 # If there are subdirectories, then recur.
1172 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
1173 for configdir in ${configdirs} ; do
1175 if [ -d ${srcdir}/${configdir} ] ; then
1176 eval echo Configuring ${configdir}... ${redirect}
1180 if [ ! -d ./${configdir} ] ; then
1181 if mkdir ./${configdir} ; then
1184 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
1194 ### figure out what to do with srcdir
1196 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
1198 newsrcdir=${srcdir}/${configdir}
1199 srcdiroption="--srcdir=${newsrcdir}"
1201 *) # otherwise relative
1202 newsrcdir=../${srcdir}/${configdir}
1203 srcdiroption="--srcdir=${newsrcdir}"
1207 # Handle --cache-file=../XXX
1208 case "${cache_file}" in
1212 cache_file_option="--cache-file=${cache_file}"
1215 cache_file_option="--cache-file=../${cache_file}"
1219 ### check for guested configure, otherwise fix possibly relative progname
1220 if [ -f ${newsrcdir}/configure ] ; then
1221 recprog=${newsrcdir}/configure
1222 elif [ -f ${newsrcdir}/configure.in ] ; then
1223 case "${progname}" in
1224 /*) recprog=${progname} ;;
1225 *) recprog=../${progname} ;;
1228 eval echo No configuration information in ${configdir} ${redirect}
1232 ### The recursion line is here.
1233 if [ ! -z "${recprog}" ] ; then
1234 if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
1235 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
1236 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
1239 echo Configure in `pwd` failed, exiting. 1>&2
1249 # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
1250 # and reset the trap handler.
1251 rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos