#!/bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf.
# Copyright (C) 1991, 1992, 1993 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., 675 Mass Ave, Cambridge, MA 02139, USA.

# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create]
#        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
# --with-PACKAGE unless this script has special code to handle it.


for arg
do
  # Handle --exec-prefix with a space before the argument.
  if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  # Handle --host with a space before the argument.
  elif test x$next_host = xyes; then next_host=
  # Handle --prefix with a space before the argument.
  elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  # Handle --srcdir with a space before the argument.
  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  else
    case $arg in
#     # For backward compatibility, also recognize exact --exec_prefix.
#     -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=*      #| --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
#	exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
#     -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --#exec- | --exec | --exe | --ex | --e)
#	next_exec_prefix=yes ;;

     -gas | --gas | --ga | --g) ;;

     -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
     -host | --host | --hos | --ho | --h)
	next_host=yes ;;

     -nfp | --nfp | --nf) ;;

     -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
        no_create=1 ;;

     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
	prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
	next_prefix=yes ;;

     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
	srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
	next_srcdir=yes ;;

     -with-* | --with-*)
       package=`echo $arg|sed 's/-*with-//'`
       # Delete all the valid chars; see if any are left.
       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
         echo "configure: $package: invalid package name" >&2; exit 1
       fi
       eval "with_`echo $package|sed s/-/_/g`=1" ;;

     -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v)
       verbose=yes ;;

     *) ;;
    esac
  fi
done

trap 'rm -f conftest* core; exit 1' 1 3 15

# Needed for some versions of `tr' so that character classes in `[]' work.
if test "${LANG+set}" = "set" ; then
   LANG=C
fi

rm -f conftest*
compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'

# 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=

# Find the source files, if location was not specified.
if test -z "$srcdir"; then
  srcdirdefaulted=yes
  # Try the directory containing this script, then `..'.
  prog=$0
  confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  test "X$confdir" = "X$prog" && confdir=.
  srcdir=$confdir
  if test ! -r $srcdir/$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 \`${confdir}' or \`..'." 1>&2
  else
    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  fi
  exit 1
fi
# Preserve a srcdir of `.' to avoid automounter screwups with pwd.
# But we can't avoid them for `..', to make subdirectories work.
case $srcdir in
  .|/*|~*) ;;
  *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
esac

if test -z "$CC"; then
  # Extract the first word of `gcc', so it can be a program name with args.
  set dummy gcc; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      CC="gcc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$CC" && CC="cc"
test -n "$CC" -a -n "$verbose" && echo "	setting CC to $CC"

# Find out if we are using GNU C, under whatever name.
cat > conftest.c <<EOF
#ifdef __GNUC__
  yes
#endif
EOF
${CC-cc} -E conftest.c > conftest.out 2>&1
if egrep yes conftest.out >/dev/null 2>&1; then
  GCC=1 # For later tests.
fi
rm -f conftest*

if test -z "${GCC}"; then
echo No GNU Compiler
DEFS="${DEFS} -DNOGNU"
cat > conftest.c <<EOF

int main()
{
  char *arg[5] = { 0, 0, 0, 0, 0 };
  exit(0);
}
EOF
if eval '$CC -c conftest.c > /dev/null 2> /dev/null'; then
:;
else
echo No ANSI Compiler
DEFS="${DEFS} -DNOANSI"
fi
rm -f conftest.c conftest.o
cat > conftest.c <<EOF

int main()
{
  exit(0);
}
EOF
if eval '$CC -c conftest.c -o ./conftest.o> /dev/null 2> /dev/null'; then
:;
else
echo NOOPTFILEDIR defined
DEFS="${DEFS} -DNOOPTFILEDIR"
fi
rm -f conftest.c conftest.o
fi
if test -z "$prefix"
then
  echo checking for gcc to derive installation directory prefix
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="$IFS:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test $dir != . && test -f $dir/gcc; then
      # Not all systems have dirname.
      prefix=`echo $dir|sed 's%/[^/][^/]*$%%'`
      break
    fi
  done
  IFS="$saveifs"
  echo "	chose installation directory prefix ${prefix}"
fi

if test -d /usr/5include; then
  DEFS="-I/usr/5include ${DEFS}"
  echo add -I/usr/5include
fi
LIBS_save="${LIBS}"
LIBS="${LIBS} -lnsl"
have_lib=""
echo checking for -lnsl
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="-lnsl ${LIBS}"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lsocket"
have_lib=""
echo checking for -lsocket
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="-lsocket ${LIBS}"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -linet"
have_lib=""
echo checking for -linet
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="-linet ${LIBS}"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lX11"
have_lib=""
echo checking for -lX11
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="-lX11 ${LIBS}"
else
   :; 
fi

if test -z "$have_lib"
then
  echo libX11.a not in path
  echo searching for libX11.a
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $LD_LIBRARY_PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/libX11.a; then
      LIBS="-L${dir} ${LIBS}"
      echo add -L${dir}
      have_lib="1"
      break
    fi
  done
  IFS="$saveifs"
  if test -z "$have_lib"
  then
    echo running find from root
    echo please wait
    tmp_lib=`find / -name libX11.a -exec ls {} \; -a -exec exit \; 2> /dev/null`
    tmp_lib=`dirname $tmp_lib`
    if test -n "$tmp_lib"; then
	LIBS="-L${tmp_lib} ${LIBS}"
	echo add -L${tmp_lib}
        have_lib="1"
    fi
  fi
  if test -n "$have_lib"
  then
  LIBS_save="${LIBS}"
  LIBS="${LIBS} -lX11"
  have_lib=""
  echo checking for -lX11
  cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="$LIBS -lX11"
else
   :; 
fi
  fi
fi
if test -z "$have_lib"
then
  DEFS="${DEFS} -DNOXWINDOW"
  echo NOXWINDOW defined
  echo $have_lib
else
  for t_dir in /usr/include/*/X11
  do
    if test -d ${t_dir}; then
	tt_dir=`echo ${t_dir} | cut -f 1-4 -d /`
	DEFS="-I${tt_dir} -I${t_dir} ${DEFS}"
    fi
  done
  if test -d /usr/include/X11; then
	DEFS="-I/usr/include/X11 ${DEFS}"
  else
    if test -n "$tmp_lib"; then
      if test -d $tmp_lib/../include; then
	DEFS="-I$tmp_lib/../include ${DEFS}"
      fi
    fi
  fi
fi
if test -d /usr/5lib; then
  LIBS="${LIBS} -L/usr/5lib"
  echo add -L/usr/5lib
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lncurses"
have_lib=""
echo checking for -lncurses
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="${LIBS} -lncurses"
else
   :; 
fi

if test -z "${have_lib}"; then
LIBS_save="${LIBS}"
LIBS="${LIBS} -lcurses"
have_lib=""
echo checking for -lcurses
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="${LIBS} -lcurses"
else
   :; 
fi
fi

if test -n "$have_lib"; then
  cat > conftest.c <<EOF

#include<curses.h>
int main()
{
  char *cur_rc;
  setupterm((char *)0, 1, (int *)0);
  tigetnum("lines");
  tigetstr("key");
  tparm(cur_rc, 0, 0);
  exit(0);
}
EOF
  echo checking for curses functions
  if eval '${CC} -o conftest conftest.c ${LIBS}> /dev/null 2> /dev/null'; then
    have_lib="1"
  else
    have_lib=""
  fi
  rm -f conftest.c conftest
fi
if test -z "$have_lib"; then
  DEFS="${DEFS} -DTERMCAP"
  echo TERMCAP defined
  LIBS_save="${LIBS}"
LIBS="${LIBS} -ltermcap"
have_lib=""
echo checking for -ltermcap
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="${LIBS} -ltermcap"
else
   :; 
fi

fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lcposix"
have_lib=""
echo checking for -lcposix
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="${LIBS} -lcposix"
else
   :; 
fi

cat > conftest.c <<EOF

int main()
{
  char *fl, lnk;
  int n;
  symlink(fl, lnk);
  readlink(fl, lnk, n);
  exit(0);
}
EOF
echo checking for symbolic links
${CC} -o conftest conftest.c ${LIBS}> /dev/null 2> /dev/null
if test -f conftest; then
    have_lib="1"
else
    have_lib=""
fi
rm -f conftest.c conftest
if test -z "$have_lib"; then
    DEFS="${DEFS} -DNOSYMLINKS"
    echo no symbolic links
fi

if test -z "$RANLIB"; then
  # Extract the first word of `ranlib', so it can be a program name with args.
  set dummy ranlib; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      RANLIB="ranlib"
      break
    fi
  done
fi
test -z "$RANLIB" && RANLIB=":"
test -n "$RANLIB" -a -n "$verbose" && echo "	setting RANLIB to $RANLIB"

if test "${RANLIB}" = 'ranlib'; then
  DEFS="${DEFS} -DRANLIB"
fi

word=xdb
IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
  test -z "$dir" && dir=.
  if test -f $dir/$word; then
    DEFS="${DEFS} -DXDB"
    echo debugger \'xdb\' defined
    break
  fi
done
IFS="$saveifs"

cat > conftest.c <<EOF

#include<string.h>
int strstr();
int main()
{
  exit(0);
}
EOF
if eval '$CC -c conftest.c > /dev/null 2> /dev/null'; then
echo need declaration of strstr
DEFS="${DEFS} -DNOSTRSTR"
fi
rm -f conftest.c conftest.o

#!/bin/sh
PRNTCMD=""
word=lpr
IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      PRNTCMD="lpr"
      break
    fi
done
if test -z "$PRNTCMD"; then
  word=lp
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      PRNTCMD="lp"
      break
    fi
  done
fi
IFS="$saveifs"
if test -z "$PRNTCMD"; then
  DEFS="${DEFS} -DNOPRINTER"
  echo no print command defined
else
  DEFS="${DEFS} -D\"PRNTCMD=\\\"${PRNTCMD}\\\"\""
  echo print command is \'$PRNTCMD\'
fi
if man -s 1 ls > /dev/null 2> /dev/null; then
  DEFS="${DEFS} -DMAN_S_OPT"
fi

if eval 'grep -s "[ 	]putc[ 	(]" /usr/include/*.h > /dev/null'; then
:;
else
  DEFS="${DEFS} -DDEFPGC"
  echo putc not defined
fi
if eval 'grep -s "[ 	]VSWTCH[ 	]" /usr/include/*.h /usr/include/sys/t*.h > /dev/null'; then
:;
else
  DEFS="${DEFS} -DNOVSWTCH"
  echo no VSWTCH definition
fi
if test -n "$prefix"; then
  test -z "$exec_prefix" && exec_prefix='${prefix}'
  prsub="s%^prefix\\([ 	]*\\)=\\([ 	]*\\).*$%prefix\\1=\\2$prefix%"
fi
if test -n "$exec_prefix"; then
  prsub="$prsub
s%^exec_prefix\\([ 	]*\\)=\\([ 	]*\\).*$%\
exec_prefix\\1=\\2$exec_prefix%"
fi
DEFS="`echo \"$DEFS\" | sed 's%[&\\\]%\\\&%g'`"

trap 'rm -f config.status; exit 1' 1 3 15
echo creating config.status
rm -f config.status
cat > config.status <<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 | sed 1q`:
#
# $0 $*

for arg
do
  case "\$arg" in
    -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
    exec /bin/sh $0 $* ;;
    *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
  esac
done

trap 'rm -f Makefile; exit 1' 1 3 15
PROGS='$PROGS'
CC='$CC'
RANLIB='$RANLIB'
LIBS='$LIBS'
srcdir='$srcdir'
DEFS='$DEFS'
prefix='$prefix'
exec_prefix='$exec_prefix'
prsub='$prsub'
EOF
cat >> config.status <<\EOF

top_srcdir=$srcdir

# Allow make-time overrides of the generated file list.
test -n "$gen_files" || gen_files="Makefile"

for file in .. $gen_files; do if [ "x$file" != "x.." ]; then
  srcdir=$top_srcdir
  # Remove last slash and all that follows it.  Not all systems have dirname.
  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  if test "$dir" != "$file"; then
    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
    test ! -d $dir && mkdir $dir
  fi
  echo creating $file
  rm -f $file
  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  sed -e "
$prsub
s%@PROGS@%$PROGS%g
s%@CC@%$CC%g
s%@RANLIB@%$RANLIB%g
s%@LIBS@%$LIBS%g
s%@srcdir@%$srcdir%g
s%@DEFS@%$DEFS%
" $top_srcdir/${file}.in >> $file
fi; done

exit 0
EOF
chmod +x config.status
test -n "$no_create" || ./config.status



