Patch for old Sega PR
[deliverable/binutils-gdb.git] / configure
index 296576ca650f27e5ea425df9d15f081500f41ede..784c2804d4c4aec106f569c9df16bfd877868842 100755 (executable)
--- a/configure
+++ b/configure
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-# Please email any bugs, comments, and/or additions to this file to:
-# configure@cygnus.com
-
-# This file was written by K. Richard Pixley.
+# This file was originally written by K. Richard Pixley.
 
 #
 # Shell script to create proper links to machine-dependent files in
@@ -50,6 +47,8 @@ Makefile=Makefile
 Makefile_in=Makefile.in
 arguments=$*
 build_alias=
+cache_file=
+cache_file_option=
 configdirs=
 exec_prefix=
 exec_prefixoption=
@@ -141,7 +140,7 @@ do
                ;;
 # These options have mandatory values.  Since we didn't find an = sign,
 # the value must be in the next argument
-       --b* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
+       --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
                optarg=$1
                shift
                ;;
@@ -158,6 +157,9 @@ do
                   ;;
                esac
                ;;
+       --cache*)
+               cache_file=$optarg
+               ;;
        --disable-*)
                enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
                eval $enableopt=no
@@ -334,17 +336,7 @@ case "${fatal}" in
                                # assume we are running native, and force
                                # the same string for both target and host.
                                case $target_alias in
-                               NOTARGET)
-                                       case $undefs in
-                                       NOUNDEFS) ;;
-                                       *)
-                                           if expr $host_alias : $undefs >/dev/null
-                                           then
-                                               host_alias=$undefs
-                                           fi
-                                           ;;
-                                       esac
-                                       ;;
+                               NOTARGET) ;;
                                *)
                                        if expr $host_alias : $target_alias >/dev/null
                                        then
@@ -384,29 +376,29 @@ esac
 
 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
        exec 1>&2
-       echo Usage: configure [OPTIONS] HOST
+       echo Usage: configure [OPTIONS] [HOST]
        echo
        echo Options: [defaults in brackets]
-       echo ' --prefix=MYDIR            configure for installation of host independent files into MYDIR. ["/usr/local"]'
-       echo ' --exec-prefix=MYDIR       configure for installation of host dependent files into MYDIR. ["/usr/local"]'
-       echo ' --help                    print this message. [normal config]'
-       echo ' --build=BUILD             configure for building on BUILD [BUILD=HOST]'
-       echo ' --host=HOST               configure for HOST [determined via config.guess]'
-       echo ' --norecursion             configure this directory only. [recurse]'
-       echo ' --program-prefix=FOO      install programs with FOO prepended to their names. [ "" ]'
-       echo ' --program-suffix=FOO      install programs with FOO appended to their names. [ "" ]'
-       echo ' --program-transform-name=FOO install programs with names transformed by sed pattern FOO. [ "" ]'
-       echo ' --site=SITE               configure with site specific makefile for SITE'
-       echo ' --srcdir=DIR              find the sources in DIR. ["." or ".."]'
-       echo ' --target=TARGET   configure for TARGET.  [TARGET = HOST]'
-       echo ' --tmpdir=TMPDIR   create temporary files in TMPDIR.  [ TMPDIR = "/tmp" ]'
-       echo ' --nfp                     configure the compilers default to soft floating point. [hard float]'
+       echo ' --prefix=MYDIR            install into MYDIR [/usr/local]'
+       echo ' --exec-prefix=MYDIR       install host-dependent files into MYDIR [/usr/local]'
+       echo ' --help                    print this message [normal config]'
+       echo ' --build=BUILD             configure for building on BUILD [BUILD=HOST]'
+       echo ' --host=HOST               configure for HOST [determined via config.guess]'
+       echo ' --norecursion             configure this directory only [recurse]'
+       echo ' --program-prefix=FOO      prepend FOO to installed program names [""]'
+       echo ' --program-suffix=FOO      append FOO to installed program names [""]'
+       echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
+       echo ' --site=SITE               configure with site-specific makefile for SITE'
+       echo ' --srcdir=DIR              find the sources in DIR [. or ..]'
+       echo ' --target=TARGET   configure for TARGET [TARGET=HOST]'
+       echo ' --tmpdir=TMPDIR   create temporary files in TMPDIR [/tmp]'
+       echo ' --nfp                     configure for software floating point [hard float]'
        echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
        echo ' --without-FOO             package FOO is NOT available'
        echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
        echo ' --disable-FOO             do not include feature FOO'
        echo
-       echo 'Where HOST and TARGET are something like "sun4", "decstation", "encore", etc.'
+       echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
        echo
        if [ -r config.status ] ; then
                cat config.status
@@ -472,6 +464,34 @@ esac
 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
 "")
         echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
+       # Check for a directory that's been converted to use autoconf since
+       # it was last configured.
+       if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
+         echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
+         if [ -r ${srcdir}/configure ] ; then
+           echo '***' Running the local configure script. 1>&2
+           case "${cache_file}" in
+           "") cache_file_option= ;;
+           *)  cache_file_option="--cache-file=${cache_file}" ;;
+           esac
+           srcdiroption="--srcdir=${srcdir}"
+           case "${build_alias}" in
+           "") buildopt= ;;
+           *)  buildopt="--build=${build_alias}" ;;
+           esac
+           eval exec ${config_shell} ${srcdir}/configure ${verbose} \
+               ${buildopt} --host=${host_alias} --target=${target_alias} \
+               ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
+               ${srcdiroption} \
+               ${program_prefixoption} ${program_suffixoption} \
+               ${program_transform_nameoption} ${site_option} \
+               ${withoptions} ${withoutoptions} \
+               ${enableoptions} ${disableoptions} \
+               ${cache_file_option} ${removing} ${other_options} ${redirect}
+         else
+           echo '***' There is no configure script present though. 1>&2
+         fi
+       fi
         exit 1
         ;;
 *) ;;
@@ -492,8 +512,12 @@ esac
 
 # keep this filename short for &%*%$*# 14 char file names
 tmpfile=${TMPDIR}/cONf$$
-trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 1 2 15
-trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
+# Note that under many versions of sh a trap handler for 0 will *override* any
+# exit status you explicitly specify!  At this point, the only non-error exit
+# is at the end of the script; these actions are duplicated there, minus
+# the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
+# trap handler, or you'll lose.
+trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
 
 # split ${srcdir}/configure.in into common, per-host, per-target,
 # and post-target parts.  Post-target is optional.
@@ -521,18 +545,35 @@ case "${srctrigger}" in
 esac
 
 case "${build_alias}" in
-"")    ;;
+"")
+       if result=`${config_shell} ${configsub} ${host_alias}` ; then
+           build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+           build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+           build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+           build=${host_cpu}-${host_vendor}-${host_os}
+           build_alias=${host_alias}
+       fi
+       ;;
 *)
-       result=`${configsub} ${build_alias}`
-        buildopt="--build=${build_alias}"
-       build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-       build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-       build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-       build=${build_cpu}-${build_vendor}-${build_os}
+       if result=`${config_shell} ${configsub} ${build_alias}` ; then
+           buildopt="--build=${build_alias}"
+           build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+           build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+           build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+           build=${build_cpu}-${build_vendor}-${build_os}
+       else
+           echo "Unrecognized build system name ${build_alias}." 1>&2
+           exit 1
+       fi
        ;;
 esac
 
-result=`${configsub} ${host_alias}`
+if result=`${config_shell} ${configsub} ${host_alias}` ; then
+    true
+else
+    echo "Unrecognized host system name ${host_alias}." 1>&2
+    exit 1
+fi
 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
@@ -540,7 +581,12 @@ host=${host_cpu}-${host_vendor}-${host_os}
 
 . ${tmpfile}.hst
 
-result=`${configsub} ${target_alias}`
+if result=`${config_shell} ${configsub} ${target_alias}` ; then
+    true
+else
+    echo "Unrecognized target system name ${target_alias}." 1>&2
+    exit 1
+fi
 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
@@ -584,16 +630,59 @@ if [ "${host_alias}" != "${target_alias}" ] ; then
     fi
 fi
 
-# Merge program_prefix and program_suffix onto program_transform_name
-# Use a double $ so that make ignores it
+# Merge program_prefix and program_suffix onto program_transform_name.
+# (program_suffix used to use $, but it's hard to preserve $ through both
+# make and sh.)
 if [ "${program_suffix}" != "" ] ; then
-    program_transform_name="-e s,\$\$,${program_suffix}, ${program_transform_name}"
+    program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
 fi
 
 if [ "${program_prefix}" != "" ] ; then
     program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
 fi
 
+# If CC and CXX are not set in the environment, and the Makefile
+# exists, try to extract them from it.  This is to handle running
+# ./config.status by hand.
+if [ -z "${CC}" -a -r Makefile ]; then
+  sed -n -e ':loop
+/\\$/ N
+/\\$/ b loop
+s/\\\n//g
+/^CC[  ]*=/ s/CC[      ]*=\(.*\)/\1/p' < Makefile > Makefile.cc
+  CC=`tail -1 Makefile.cc`
+  rm -f Makefile.cc
+fi
+
+if [ -z "${CXX}" -a -r Makefile ]; then
+  sed -n -e ':loop
+/\\$/ N
+/\\$/ b loop
+s/\\\n//g
+/^CXX[         ]*=/ s/CXX[     ]*=\(.*\)/\1/p' < Makefile > Makefile.cc
+  CXX=`tail -1 Makefile.cc`
+  rm -f Makefile.cc
+fi
+
+# If CC is still not set, try to get gcc.
+if [ -z "${CC}" ]; then
+  IFS="${IFS=  }"; save_ifs="$IFS"; IFS="${IFS}:"
+  for dir in $PATH; do
+    test -z "$dir" && dir=.
+    if test -f $dir/gcc; then
+      CC="gcc"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+  CC=${CC-cc}
+fi
+
+CXX=${CXX-"g++ -O"}
+
+export CC
+export CXX
+
 for subdir in . ${subdirs} ; do
 
     # ${subdir} is relative path from . to the directory we're currently
@@ -831,11 +920,6 @@ EOF
                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
             fi 
 
-           # make sure that some sort of reasonable default exists for these 
-           # two variables
-           CXX=${CXX-"g++ -O"}
-           CC=${CC-cc}
-
             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
             # remove any form feeds.
             if [ -z "${subdirs}" ]; then
@@ -848,6 +932,20 @@ EOF
             fi
             sed -e "s:^prefix[         ]*=.*$:prefix = ${prefix}:" \
                     -e "s:^exec_prefix[        ]*=.*$:exec_prefix = ${exec_prefix}:" \
+                   -e "/^CC[   ]*=/{
+                       :loop1
+                       /\\\\$/ N
+                       /\\\\$/ b loop1
+                       s/\\\\\\n//g
+                       s%^CC[  ]*=.*$%CC = ${CC}%
+                       }" \
+                   -e "/^CXX[  ]*=/{
+                       :loop2
+                       /\\\\$/ N
+                       /\\\\$/ b loop2
+                       s/\\\\\\n//g
+                       s%^CXX[         ]*=.*$%CXX = ${CXX}%
+                       }" \
                    -e "s:^SHELL[        ]*=.*$:SHELL = ${config_shell}:" \
                     -e "s:^srcdir[     ]*=.*$:srcdir = ${makesrcdir}:" \
                     -e "s/\f//" \
@@ -956,6 +1054,18 @@ if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
                                 ;;
                         esac
 
+                       # Handle --cache-file=../XXX
+                       case "${cache_file}" in
+                       "") # empty
+                               ;;
+                       /*) # absolute path
+                               cache_file_option="--cache-file=${cache_file}"
+                               ;;
+                       *) # relative path
+                               cache_file_option="--cache-file=../${cache_file}"
+                               ;;
+                       esac
+
 ### check for guested configure, otherwise fix possibly relative progname
                         if [ -f ${newsrcdir}/configure ] ; then
                                 recprog=${newsrcdir}/configure
@@ -973,7 +1083,7 @@ if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
                        if [ ! -z "${recprog}" ] ; then
                                if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
                                        ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
-                                       ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${removing} ${other_options} ${redirect} ; then
+                                       ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
                                        true
                                else
                                        echo Configure in `pwd` failed, exiting. 1>&2
@@ -986,6 +1096,11 @@ if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
         done
 fi
 
+# Perform the same cleanup as the trap handler, minus the "exit 1" of course,
+# and reset the trap handler.
+rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+trap 0
+
 exit 0
 
 #
This page took 0.027901 seconds and 4 git commands to generate.