#!/bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically by autoconf.
# modified by Tristan Gingold ( Sun Apr 17 14:57:51 GMT+0100 1994 )
#  for Checker. Use part of gas-2.2/configure
#
# Copyright (C) 1991 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# 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., 59 Temple Place - Suite 330, 
# Boston, MA 02111-1307, USA.

# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [TARGET]
# --gas --nfp --host are ignored.

set +u # Make sure unset variables are ok.

progname=$0
symbolic_link='ln -s'
hard_link=ln
config_files='Makefile machine.h chkr-string.h'
arguments=$*
fatal=
lang=English
prefix=

for arg in $*; do
  # Handle --srcdir with a space before the argument.
  if test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  # Handle --host with a space before the argument.
  elif test x$next_host = xyes; then next_host=
  else
    case $arg in
     --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
	case $srcdir in
	"")
		srcdir=`echo $arg | sed 's/[+-]*s[a-z]*=//'` ;;
	*)
		echo '***' Can only configure for one srcdir at a time.
		fatal=yes ;;
	esac
	;;
     --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
	prefix=`echo $arg | sed 's/[+-]*p[a-z]*=//'` ;;
     --srcdir | --srcdi | --srcd | --src | --sr | --s)
	next_srcdir=yes ;;
     --host=* | --hos=* | --ho=* | --h=*)
	case $host in
	"")
        	host=`echo $arg | sed 's/[+-]*h[a-z]*=//'` ;
		echo $host is ignored ;;
	*)
		echo '***' Can only configure for one host at a time.
		fatal=yes ;;
	esac
	;;
     --host | --hos | --ho | --h)
	next_host=yes ;;
     --gas | --ga | --g) ;;
     --nfp | --nf | --n) ;;
     -help | --help)
	fatal=true ;;
     -norecursion | --no*) ;;
     -with*=* | --with*=*)
	withopt=`echo $arg | sed 's:^-*\(with[^=]*\)=.*$:\1:;s/-/_/g'`
	withval=`echo ${arg} | sed 's:^-*with[^=]*=\(.*\)$:\1:'`
	eval $withopt="$withval"
	;;
     -with* | --with*)
	withopt=`echo ${arg} | sed 's:^-*with:with:;s/-/_/g'`
	eval $withopt=yes
	;;
     --debug)
	set -x ;;
     -*)
	echo Option unknown: $arg
	fatal=true ;;
     *)
	target=`echo $arg | sed 's/[+-]*t[a-z]*=//'` ;;
    esac
  fi
done

if test x$fatal != x; then
        echo "Usage: configure HOST" ;
        echo ;
        echo "Options: [defaults in brackets]" ;
        echo " --prefix=MYDIR            configure for installation of host dependent 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 " --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 " --with-FOO, --with-FOO=BAR specify that FOO is available"
#        echo " --without-FOO             specify that FOO is NOT available"
        echo ;
        echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
        echo ;
#        if test -r config.status ; then
#                cat config.status
#        fi

        exit 1
fi

# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
unique_file=checker.h

# Find the source files, if location was not specified.
if test x$srcdir = x; then
  srcdirdefaulted=yes; srcdir=.
  if test ! -r $unique_file; then srcdir=..; fi
fi
if test ! -r $srcdir/$unique_file; then
  if test x$srcdirdefaulted = xyes; then
    echo "configure: Can not find sources in \`.' or \`..'." 1>&2
  else
    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  fi
  exit 1
fi
SRCDIR=$srcdir
if test $srcdir != .; then
  VPATH='VPATH = $(srcdir)' ;
  case $srcdir in
    /*|~*) ;;
    *) srcdir=`pwd`/$srcdir ;; # Make relative path absolute.
  esac
fi

# The Bourne shell writes "command not found" to /dev/tty, so if we get
# a usage message on stderr, we have the program.
#
# ksh and zsh write "command not found" to stderr, but test -n does not
# want any output if there is no program.  So we use the `type' builtin
# instead for them (and bash).
if test "$RANDOM" = "$RANDOM"; then
  checkfor='test -n "`$checkprog $checkargs 2>&1`"'
else
  checkfor='type $checkprog >/dev/null'
fi

if test x$target = x; then
  echo " Guess your system"
  guessprg=`echo $progname | sed 's/configure/config.guess/'`
  target=`$guessprg`
  arguments="$arguments $target"
fi

echo " Checking for gcc"
checkprog=gcc checkargs=''
test -z "$CC" && eval $checkfor && CC='gcc'
CC=${CC-cc}

# Make sure to not get the incompatible SysV /etc/install and
# /usr/sbin/install, which might be in PATH before a BSD-like install,
# or the SunOS /usr/etc/install directory, or the AIX /bin/install,
# or the AFS install, which mishandles nonexistent args.  (Sigh.)
if test -z "$INSTALL"; then
  echo " Checking for install"
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    case $dir in
    /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;;
    *)
      if test -f $dir/install; then
	if grep dspmsg $dir/install >/dev/null 2>&1; then
	  : # AIX
	else
	  INSTALL="$dir/install -c"
	  INSTALL_PROGRAM='$(INSTALL)'
	  INSTALL_DATA='$(INSTALL) -m 644'
	  break
	fi
      fi
      ;;
    esac
  done
  IFS="$saveifs"
fi
INSTALL=${INSTALL-cp}
INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}

# Try to know the language.
if test x$with_lang != x; then
  language=$with_lang
fi
if test x$with_language != x; then
  language=$with_language
fi
case $language in
  English | english | American | american | Eng | eng | US)
	echo "Your language is English" ;
	lang=English ;;
  French | french | francais | Fr | fr)
	echo "Your language is French" ;
	lang=French ;;
  yes)
	echo "Please, specify a language (-with-language=xxx)" ;;
  "")
	lang=English;;
  *)
	echo "Warning: Checker doesn't support this language: $language" ;
	echo "         Checker only knows English and French" ;;
     
esac

case $target in
  [Ii][3456]86-*-[Ll]inuxaout | [Ii][345]86-[Ll]inuxaout | linuxaout)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/usr/local} ;
	confdir=$SRCDIR/config/i386/Linux ;
	machine_h=$confdir/tm-linux.h ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$SRCDIR/config/i386/bitops.h ;
	makefile_frag=$SRCDIR/config/i386/Linux/linux-aout.t ;;
  [Ii][3456]86-*-linuxoldld)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/usr/local} ;
	confdir=$SRCDIR/config/i386/Linux ;
	machine_h=$confdir/tm-linux.h ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$SRCDIR/config/i386/bitops.h ;
	makefile_frag=$SRCDIR/config/i386/Linux/linux-oldld.t ;;
  [Ii][3456]86-*-[Ll]inux | [Ii][345]86-[Ll]inux | linuxelf)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/usr/local} ;
	confdir=$SRCDIR/config/i386/Linux ;
	machine_h=$confdir/tm-linux.h ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$SRCDIR/config/i386/bitops.h ;
	available_stubs_h=$confdir/available-stubs.h ;
	makefile_frag=$SRCDIR/config/i386/Linux/linux-elf.t ;;
  sparc-sun-solaris2*)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/opt/checker} ;
	confdir=$SRCDIR/config/sparc/solaris2 ;
	machine_h=$confdir/tm-solaris2.h ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$SRCDIR/config/sparc/bitops.h ;
	available_stubs_h=$confdir/available-stubs.h ;
	makefile_frag=$SRCDIR/config/sparc/solaris2/solaris2.t ;;
  sparc-sun-sunos4*)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/usr/local} ;
	confdir=$SRCDIR/config/sparc/sunos ;
	machine_h=$confdir/tm-sunos4.h ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$SRCDIR/config/sparc/bitops.h ;
	available_stubs_h=$confdir/available-stubs.h ;
	makefile_frag=$SRCDIR/config/sparc/sunos/sunos.t ;;
  generic*)
	echo This target \( $target \) is known. ;
	prefix=${prefix:-/usr/local} ;
	machine_h= ;
	confdir=$SRCDIR/config/generic ;
	string_h=$confdir/string.h ;
	syscall_h=$confdir/chkrsyscall.h ;
	bitops_h=$confdir/bitops.h ;
#	available_stubs_h=$confdir/available-stubs.h ;
	dont_need_stubs=1 ;
	makefile_frag=$SRCDIR/config/generic/generic.t ;;
  *)
	echo "\`$target' unknown." ;
	echo "You can try \`$progname generic'" ;
	exit 1 ;;
esac

rm -f machine.h chkr-string.h bitops.h chkrsyscall.h available-stubs.h
if test x$machine_h != x; then
  echo " Link $machine_h to machine.h";
  $symbolic_link $machine_h machine.h 2> /dev/null || $hard_link $machine_h machine.h;
fi
if test x$available_stubs_h != x; then
  echo " Link $available_stubs_h to available-stubs.h";
  $symbolic_link $available_stubs_h available-stubs.h 2> /dev/null || $hard_link $available_stubs_h available-stubs.h;
fi
echo " Link $string_h to chkr-string.h"
$symbolic_link $string_h chkr-string.h 2> /dev/null || $hard_link $string_h chkr-string.h
echo " Link $bitops_h to bitops.h"
$symbolic_link $bitops_h bitops.h 2> /dev/null || $hard_link $bitops_h bitops.h
echo " Link $syscall_h to chkrsyscall.h"
$symbolic_link $syscall_h chkrsyscall.h 2> /dev/null || $hard_link $syscall_h chkrsyscall.h

if test "x$dont_need_stubs" != "x"; then
 sed_stubs_cmd=""
else
 sed_stubs_cmd="/^#### include-stubs-Makefile/r $SRCDIR/stubs/SubMakefile"
fi

trap 'rm -f MakeMakefile; exit 1' 1 3 15
echo " Creating MakeMakefile"
rm -f MakeMakefile
cat > MakeMakefile <<EOF
#!/bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host `(hostname || uname -n) 2>/dev/null`:
#
# $0 $*

progname=\$0
file=$makefile_frag
option=
fatal=
temp_file=./mmtmp.\$\$
temp_file_decl="\$temp_file"_decl
temp_file_rules="\$temp_file"_rules

for arg
do
  case "\$arg" in
    -h | --help)
      echo "Try \$progname <option>" ;
      grep "^##-conf" \$file | sed -e "s/##-conf[. ]//g
s/@\*/\\\\
/g" ;
      exit 0;;
    *)
      if test x\$option = x; then
        option=\$arg
      else
        fatal=true;
      fi ;;
  esac
done

if test x\$fatal != x || test x\$option = x ; then
  echo "Usage: \$0 --help | option" 2>&1;
  exit 1;
fi

if grep "##-conf.\$option:" \$file 2>&1 > /dev/null; then
  echo "Building \\\`Makefile' for \$option" ;
else
  echo "\\\`\$option' unknown.  Try \\\`\$progname --help' for the list of options." ;
  exit 1;
fi

trap 'rm -f Makefile \$temp_file \$temp_file_decl \$temp_file_rules; exit 1' 1 2 3 15

sed -e "1,/^ifcommon\\\$/d" \
    -e "/^endifcommon\\\$/,/^if\$option\\\$/d" \
    -e "/^endif\$option\\\$/,\\\$d" < \$file > \$temp_file
sed -e "1d" \
    -e "/^@rules\\\$/,/^@decl\\\$/d" < \$temp_file > \$temp_file_decl
sed -e "/^@decl\\\$/,/^@rules\\\$/d" < \$temp_file > \$temp_file_rules

CC='$CC'
INSTALL='$INSTALL'
INSTALL_PROGRAM='$INSTALL_PROGRAM'
INSTALL_DATA='$INSTALL_DATA'
LIBS='$LIBS'
SRCDIR='$SRCDIR'
DEFS='$DEFS'
prefix='$prefix'
exec_prefix='$exec_prefix'
confdir='$confdir'
config_files='$config_files'
lang='$lang'
srcdir='$SRCDIR'
target='$target'
sed_stubs_cmd='$sed_stubs_cmd'
EOF

cat >> MakeMakefile <<\EOF

top_srcdir=$srcdir
for mfile in .. Makefile; do if test "x$mfile" != "x.." ; then
  srcdir=$top_srcdir
  # Remove last slash and all that follows it.  Not all systems have dirname.
  dir=`echo $mfile|sed 's%/[^/][^/]*$%%'`
  if test "$dir" != "$mfile"; then
    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
    test ! -d $dir && mkdir $dir
  fi
  echo creating $mfile
  rm -f $mfile
  echo "# Generated automatically from `echo $mfile|sed 's|.*/||'`.in by MakeMakefile." > $mfile
  sed -e "
s,@VPATH@,$VPATH,g
s,@SRCDIR@,$SRCDIR,g
s,@CONFDIR@,$confdir,g
s,@CC@,$CC,g
s,@INSTALL@,$INSTALL,g
s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,g
s,@INSTALL_DATA@,$INSTALL_DATA,g
s,@CONFIG_FILES@,$config_files,g
s,@LANGUAGE@,$lang,g
s,@TARGET@,$target,g
s,@OPTION@,$option,g
s,@MAKEFILE_FRAG@,$file,g
s,@PREFIX@,$prefix,g
/^#### HOST-decl/r $temp_file_decl
/^#### HOST-rules/r $temp_file_rules
/^#### include-l-malloc-Makefile/r $SRCDIR/l-malloc/SubMakefile
/^#### include-lib-Makefile/r $SRCDIR/lib/SubMakefile
/^#### include-confdir-Makefile/r $confdir/SubMakefile
$sed_stubs_cmd
" $top_srcdir/${mfile}.in >> $mfile
fi; done

rm -f $temp_file $temp_file_decl $temp_file_rules

exit 0
EOF

chmod +x MakeMakefile

default_option=`grep "##-conf.default: " $makefile_frag \
	| sed -e "s/##-conf.default: //g"`

if test x$default_option != x ; then
  echo ;
  echo "Configuring for \`$default_option'" ;
  ./MakeMakefile $default_option ;
  echo ;
  echo "To compile Checker, do 'make'" ;
  echo "To install Checker, do 'make install'" ;
else
  echo "No default option. Try \`./MakeMakefile --help'" ;
fi

# EOF
