#!/bin/sh
#
# Do not edit!
# File generated from configure.in by csoft-mk 2.0.
#
# Copyright (c) 2001, 2002, 2003, 2004 CubeSoft Communications, Inc.
# <http://www.csoft.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

optarg=
for arg
do
	case "$arg" in
	-*=*)
	    optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'`
	    ;;
	*)
	    optarg=
	    ;;
	esac

	case "$arg" in
	--prefix=*)
	    prefix=$optarg
	    ;;
	--sysconfdir=*)
	    sysconfdir=$optarg
	    ;;
	--sharedir=*)
	    sharedir=$optarg
	    ;;
	--localedir=*)
	    localedir=$optarg
	    ;;
	--enable-*)
	    option=`echo $arg | sed -e 's/--enable-//' -e 's/=.*//'`
	    option=`echo $option | sed 's/-/_/g'`
	    case "$option" in
	        *=*)
	            eval "enable_${option}='$optarg'"
		    ;;
		*)
	            eval "enable_${option}=yes"
		    ;;
	    esac
	    ;;
	--disable-*)
	    option=`echo $arg | sed -e 's/--disable-//'`;
	    option=`echo $option | sed 's/-/_/g'`
	    eval "enable_${option}=no"
	    ;;
	--with-*)
	    option=`echo $arg | sed -e 's/--with-//' -e 's/=.*//'`
	    option=`echo $option | sed 's/-/_/g'`
	    case "$option" in
	        *=*)
	            eval "with_${option}='$optarg'"
		    ;;
		*)
	            eval "with_${option}=yes"
		    ;;
	    esac
	    ;;
	--without-*)
	    option=`echo $arg | sed -e 's/--without-//'`;
	    option=`echo $option | sed 's/-/_/g'`
	    eval "with_${option}=no"
	    ;;
	--help)
	    help=yes
	    ;;
	--srcdir=*)
	    srcdir=$optarg
	    ;;
	*)
	    echo "invalid argument: $arg"
	    echo "try ./configure --help"
	    exit 1
	    ;;
	esac
done

if [ "${prefix}" != "" ]; then
    PREFIX="$prefix"
else
    PREFIX="/usr/local"
fi

if [ "${srcdir}" != "" ]; then
	echo "concurrent build (source in ${srcdir})"
#	if [ ! -e "${srcdir}" ]; then
#		echo "Cannot find source directory: ${srcdir}"
#		exit 1
#	fi
#	if [ ! -e "${srcdir}/configure.in" ]; then
#		echo "Invalid source directory: ${srcdir}"
#		exit 1
#	fi
#	if [ -e "${srcdir}/config" ]; then
#		echo "Source directory is already configured: ${srcdir}"
#		exit 1
#	fi
	SRC=${srcdir}

	perl ${SRC}/mk/mkconcurrent.pl ${SRC}
	if [ $? != 0 ]; then
		exit 1;
	fi
else
	SRC=`pwd`
fi
if [ "${help}" = "yes" ]; then
echo "Usage: ./configure [args]"
echo "    --prefix                       Installation prefix [/usr/local]"
echo "    --sysconfdir                   System-wide configuration prefix [/etc]"
echo "    --sharedir                     Share prefix [$PREFIX/share]"
echo "    --localedir                    Locale prefix [$PREFIX/share/locale]"
echo "    --srcdir                       Source tree for concurrent build [.]"
echo "    --help                         Display this message"
echo "    --enable-nls                   Native Language Support [no]"
echo "    --with-gettext                 Use gettext tools (msgmerge, ...) [check]"
echo "    --with-manpages                Manual pages (-mdoc) [yes]"
echo "    --with-docs                    Printable docs (-me/tbl/eqn/pic/refer) [no]"
echo "    --enable-debug                 Include debugging code [no]"
echo "    --enable-warnings              Enable compiler warnings [default: no]"
exit 1
fi

MACHINE=`uname -m 2>/dev/null` || MACHINE=unknown
RELEASE=`uname -r 2>/dev/null` || RELEASE=unknown
SYSTEM=`uname -s 2>/dev/null` || SYSTEM=unknown
HOST="$SYSTEM-$RELEASE-$MACHINE"
echo "Host: $HOST"

echo "# File generated by csoft-mk 2.0." > Makefile.config
echo "Machine: $MACHINE" > config.log
echo "Release: $RELEASE" >> config.log
echo "System: $SYSTEM" >> config.log
mkdir config 1>/dev/null 2>&1

if [ "${with_manpages}" = "no" ]; then
    echo "NOMAN=yes" >> Makefile.config
    echo "NOMANLINKS=yes" >> Makefile.config
fi
if [ "${with_docs}" = "no" ]; then
    echo "NODOC=yes" >> Makefile.config
fi
if [ "${enable_debug}" = "yes" ]; then
	echo "LDFLAGS+=-g" >> Makefile.config
	echo "#ifndef DEBUG" > config/debug.h
	echo "#define DEBUG 1" >> config/debug.h
	echo "#endif /* DEBUG */" >> config/debug.h
else
	echo "#undef DEBUG" > config/debug.h
fi

if [ "${enable_nls}" = "yes" ]; then
	ENABLE_NLS="yes"
	echo "#ifndef ENABLE_NLS" > config/enable_nls.h
	echo "#define ENABLE_NLS 1" >> config/enable_nls.h
	echo "#endif /* ENABLE_NLS */" >> config/enable_nls.h
	msgfmt=""
	for path in `echo $PATH | sed 's/:/ /g'`; do
		if [ -x "${path}/msgfmt" ]; then
			msgfmt=${path}/msgfmt
		fi
	done
	if [ "${msgfmt}" != "" ]; then
		HAVE_GETTEXT="yes"
	else
		HAVE_GETTEXT="no"
	fi
else
	ENABLE_NLS="no"
	HAVE_GETTEXT="no"
	echo "#undef ENABLE_NLS" > config/enable_nls.h
fi
echo "ENABLE_NLS=${ENABLE_NLS}" >> Makefile.config
echo "HAVE_GETTEXT=${HAVE_GETTEXT}" >> Makefile.config

echo "PREFIX?=${PREFIX}" >> Makefile.config
echo "#ifndef PREFIX" > config/prefix.h
echo "#define PREFIX \"${PREFIX}\"" >> config/prefix.h
echo "#endif /* PREFIX */" >> config/prefix.h

if [ "${sharedir}" != "" ]; then
	echo "SHAREDIR=${sharedir}" >> Makefile.config
	echo "#ifndef SHAREDIR" > config/sharedir.h
	echo "#define SHAREDIR \"${sharedir}\"" >> config/sharedir.h
	echo "#endif /* SHAREDIR */" >> config/sharedir.h
	SHAREDIR="${sharedir}"
else
	echo "SHAREDIR=\${PREFIX}/share" >> Makefile.config
	echo "#ifndef SHAREDIR" > config/sharedir.h
	echo "#define SHAREDIR \"${SHAREDIR}\"" >> config/sharedir.h
	echo "#endif /* SHAREDIR */" >> config/sharedir.h
	SHAREDIR="${PREFIX}/share"
fi

if [ "${localedir}" != "" ]; then
	LOCALEDIR="${localedir}"
	echo "LOCALEDIR=${LOCALEDIR}" >> Makefile.config
	echo "#ifndef LOCALEDIR" > config/localedir.h
	echo "#define LOCALEDIR \"${LOCALEDIR}\"" >> config/localedir.h
	echo "#endif /* LOCALEDIR */" >> config/localedir.h
else
	LOCALEDIR="${SHAREDIR}/locale"
	echo "LOCALEDIR=\${SHAREDIR}/locale" >> Makefile.config
	echo "#ifndef LOCALEDIR" > config/localedir.h
	echo "#define LOCALEDIR \"${LOCALEDIR}\"" >> config/localedir.h
	echo "#endif /* LOCALEDIR */" >> config/localedir.h
fi

if [ "${sysconfdir}" != "" ]; then
	SYSCONFDIR="${sysconfdir}"
	echo "SYSCONFDIR=${sysconfdir}" >> Makefile.config
	echo "#ifndef SYSCONFDIR" > config/sysconfdir.h
	echo "#define SYSCONFDIR \"${SYSCONFDIR}\"" >> config/sysconfdir.h
	echo "#endif /* SYSCONFDIR */" >> config/sysconfdir.h
else
	SYSCONFDIR="${PREFIX}/etc"
	echo "SYSCONFDIR=\${PREFIX}/etc" >> Makefile.config
	echo "#ifndef SYSCONFDIR" > config/sysconfdir.h
	echo "#define SYSCONFDIR \"${SYSCONFDIR}\"" >> config/sysconfdir.h
	echo "#endif /* SYSCONFDIR */" >> config/sysconfdir.h
fi

VERSION="\"1.0-beta\""
echo "#ifndef VERSION" > config/version.h
echo "#define VERSION" $VERSION >> config/version.h
echo "#endif" >> config/version.h
RELEASE="\"Wall of Water\""
echo "#ifndef RELEASE" > config/release.h
echo "#define RELEASE" $RELEASE >> config/release.h
echo "#endif" >> config/release.h
echo -n "checking for a usable C compiler..."
echo -n "checking for a usable C compiler..." >> config.log
if [ "$CC" = "" ]; then
	for i in `echo $PATH |sed 's/:/ /g'`; do
		if [ -x "${i}/cc" ]; then
			CC="${i}/cc"
		elif [ -x "${i}/gcc" ]; then
			CC="${i}/gcc"
		fi
	done
	if [ "$CC" = "" ]; then
		echo "Could not find a C compiler, try setting CC."
		echo "CC is unset and cc/gcc is not in PATH." >> config.log
		exit 1
	fi
fi

cat << 'EOT' > cc-test.c
int
main(int argc, char *argv[])
{
	return (0);
}
EOT

$CC -o cc-test cc-test.c 2>>config.log
if [ $? != 0 ]; then
    echo "no"
	echo "The test C program failed to compile."
	rm -f cc-test cc-test.c
    exit 1
fi
echo "yes"
rm -f cc-test cc-test.c
TEST_CFLAGS=""
echo -n "checking for compiler warnings..."
echo -n "checking for compiler warnings..." >> config.log
cat << EOT > conftest.c
int main(int argc, char *argv[]) { return (0); }

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o conftest conftest.c " >>config.log
$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o conftest conftest.c  2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_CC_WARNINGS" > config/have_cc_warnings.h
echo "#define HAVE_CC_WARNINGS" $HAVE_CC_WARNINGS >> config/have_cc_warnings.h
echo "#endif" >> config/have_cc_warnings.h

	HAVE_CC_WARNINGS=yes

	echo "yes"
else
	echo "#undef HAVE_CC_WARNINGS" > config/have_cc_warnings.h

	echo "no"
fi
if [ "${HAVE_CC_WARNINGS}" = "yes" ]; then
TEST_CFLAGS="-Wall -Werror"
fi;
echo -n "checking for floating point types..."
echo -n "checking for floating point types..." >> config.log
cat << EOT > conftest.c
int
main(int argc, char *argv[])
{
	float f = 1.5;
	double d = 2.5;

	f = 0;
	d = 0;
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c " >>config.log
$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c  2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_IEEE754" > config/have_ieee754.h
echo "#define HAVE_IEEE754" $HAVE_IEEE754 >> config/have_ieee754.h
echo "#endif" >> config/have_ieee754.h

	HAVE_IEEE754=yes

	echo "yes"
else
	echo "#undef HAVE_IEEE754" > config/have_ieee754.h

	echo "no"
fi
echo -n "checking __bounded__ attribute..."
echo -n "checking __bounded__ attribute..." >> config.log
cat << EOT > conftest.c
void foo(char *, int) __attribute__ ((__bounded__(__string__,1,2)));
void foo(char *a, int c) { }
int main(int argc, char *argv[])
{
	char buf[32];
	foo(buf, sizeof(buf));
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c " >>config.log
$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c  2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_BOUNDED_ATTRIBUTE" > config/have_bounded_attribute.h
echo "#define HAVE_BOUNDED_ATTRIBUTE" $HAVE_BOUNDED_ATTRIBUTE >> config/have_bounded_attribute.h
echo "#endif" >> config/have_bounded_attribute.h

	HAVE_BOUNDED_ATTRIBUTE=yes

	echo "yes"
else
	echo "#undef HAVE_BOUNDED_ATTRIBUTE" > config/have_bounded_attribute.h

	echo "no"
fi
echo -n "checking __format__ attribute..."
echo -n "checking __format__ attribute..." >> config.log
cat << EOT > conftest.c
#include <stdarg.h>
void foo1(char *, ...)
     __attribute__((__format__ (printf, 1, 2)));
void foo2(char *, ...)
     __attribute__((__format__ (__printf__, 1, 2)))
     __attribute__((__nonnull__ (1)));
void foo1(char *a, ...) {}
void foo2(char *a, ...) {}
int main(int argc, char *argv[])
{
	foo1("foo %s", "bar");
	foo2("foo %d", 1);
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c " >>config.log
$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c  2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_FORMAT_ATTRIBUTE" > config/have_format_attribute.h
echo "#define HAVE_FORMAT_ATTRIBUTE" $HAVE_FORMAT_ATTRIBUTE >> config/have_format_attribute.h
echo "#endif" >> config/have_format_attribute.h

	HAVE_FORMAT_ATTRIBUTE=yes

	echo "yes"
else
	echo "#undef HAVE_FORMAT_ATTRIBUTE" > config/have_format_attribute.h

	echo "no"
fi
echo -n "checking __nonnull__ attribute..."
echo -n "checking __nonnull__ attribute..." >> config.log
cat << EOT > conftest.c
void foo(char *) __attribute__((__nonnull__ (1)));
void foo(char *a) { }
int main(int argc, char *argv[])
{
	foo("foo");
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o conftest conftest.c" >>config.log
$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o conftest conftest.c 2>>config.log
if [ $? != 0 ]; then
	echo "-> failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_NONNULL_ATTRIBUTE" > config/have_nonnull_attribute.h
echo "#define HAVE_NONNULL_ATTRIBUTE" $HAVE_NONNULL_ATTRIBUTE >> config/have_nonnull_attribute.h
echo "#endif" >> config/have_nonnull_attribute.h

	echo "yes"
else
    echo "#undef HAVE_NONNULL_ATTRIBUTE" > config/have_nonnull_attribute.h

	echo "no"
fi
echo -n "checking for long double..."
echo -n "checking for long double..." >> config.log
cat << EOT > conftest.c
int
main(int argc, char *argv[])
{
	long double ld = 0.1;

	ld = 0;
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS -o conftest conftest.c" >>config.log
$CC $CFLAGS $TEST_CFLAGS -o conftest conftest.c 2>>config.log
if [ $? != 0 ]; then
	echo "-> failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_LONG_DOUBLE" > config/have_long_double.h
echo "#define HAVE_LONG_DOUBLE" $HAVE_LONG_DOUBLE >> config/have_long_double.h
echo "#endif" >> config/have_long_double.h

	HAVE_LONG_DOUBLE="yes"
	echo "yes"
else
    echo "#undef HAVE_LONG_DOUBLE" > config/have_long_double.h

	HAVE_LONG_DOUBLE="no"
	echo "no"
fi
echo -n "checking for cygwin environment..."
echo -n "checking for cygwin environment..." >> config.log
cat << EOT > conftest.c
#include <sys/types.h>
#include <sys/stat.h>
#include <windows.h>

int
main(int argc, char *argv[]) {
	struct stat sb;
	DWORD rv;
	rv = GetFileAttributes("foo");
	stat("foo", &sb);
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS -mcygwin -o conftest conftest.c" >>config.log
$CC $CFLAGS $TEST_CFLAGS -mcygwin -o conftest conftest.c 2>>config.log
if [ $? != 0 ]; then
	echo "-> failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_CYGWIN" > config/have_cygwin.h
echo "#define HAVE_CYGWIN" $HAVE_CYGWIN >> config/have_cygwin.h
echo "#endif" >> config/have_cygwin.h

	echo "yes"
else
    echo "#undef HAVE_CYGWIN" > config/have_cygwin.h

	echo "no"
fi
echo -n "checking for mingw environment..."
echo -n "checking for mingw environment..." >> config.log
cat << EOT > conftest.c
#include <sys/types.h>
#include <sys/stat.h>
#include <windows.h>

int
main(int argc, char *argv[]) {
	struct stat sb;
	DWORD rv;
	rv = GetFileAttributes("foo");
	stat("foo", &sb);
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c" >>config.log
$CC $CFLAGS $TEST_CFLAGS  -o conftest conftest.c 2>>config.log
if [ $? != 0 ]; then
	echo "-> failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_MINGW" > config/have_mingw.h
echo "#define HAVE_MINGW" $HAVE_MINGW >> config/have_mingw.h
echo "#endif" >> config/have_mingw.h

	echo "yes"
else
    echo "#undef HAVE_MINGW" > config/have_mingw.h

	echo "no"
fi
if [ "${compile}" = "ok" ]; then
	CFLAGS="$CFLAGS -mno-cygwin"
	echo "CFLAGS=$CFLAGS" >> Makefile.config
fi
echo -n "checking for Agar (http://hypertriton.com/agar/)..."
echo -n "checking for Agar (http://hypertriton.com/agar/)..." >> config.log
agar_version=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-config" ]; then
		agar_version=`${path}/agar-config --version`
	fi
done
AGAR_CFLAGS=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-config" ]; then
		AGAR_CFLAGS=`${path}/agar-config --cflags`
	fi
done
AGAR_LIBS=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-config" ]; then
		AGAR_LIBS=`${path}/agar-config --libs`
	fi
done
if [ "${agar_version}" != "" ]; then
echo "yes"
echo "yes" >> config.log
echo "AGAR_CFLAGS=$AGAR_CFLAGS" >> Makefile.config
echo "AGAR_LIBS=$AGAR_LIBS" >> Makefile.config
echo "#ifndef HAVE_AGAR" > config/have_agar.h
echo "#define HAVE_AGAR" $HAVE_AGAR >> config/have_agar.h
echo "#endif" >> config/have_agar.h
echo "#ifndef AGAR_CFLAGS" > config/agar_cflags.h
echo "#define AGAR_CFLAGS \"$AGAR_CFLAGS\"" >> config/agar_cflags.h
echo "#endif" >> config/agar_cflags.h
echo "#ifndef AGAR_LIBS" > config/agar_libs.h
echo "#define AGAR_LIBS \"$AGAR_LIBS\"" >> config/agar_libs.h
echo "#endif" >> config/agar_libs.h
else
echo "no"
echo "no" >> config.log
echo "#undef HAVE_AGAR" > config/have_agar.h
echo "#undef AGAR_CFLAGS" > config/agar_cflags.h
echo "#undef AGAR_LIBS" > config/agar_libs.h
fi
echo -n "checking whether Agar works..."
echo -n "checking whether Agar works..." >> config.log
cat << EOT > conftest.c
#include <agar/core.h>

int
main(int argc, char *argv[])
{
	AG_InitCore("conf-test", 0);
	AG_InitVideo(320, 240, 32, 0);
	AG_EventLoop();
	AG_Quit();
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS ${AGAR_CFLAGS} -o conftest conftest.c ${AGAR_LIBS}" >>config.log
$CC $CFLAGS $TEST_CFLAGS ${AGAR_CFLAGS} -o conftest conftest.c ${AGAR_LIBS} 2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_AGAR" > config/have_agar.h
echo "#define HAVE_AGAR" $HAVE_AGAR >> config/have_agar.h
echo "#endif" >> config/have_agar.h

	HAVE_AGAR=yes

	echo "yes"
else
	echo "#undef HAVE_AGAR" > config/have_agar.h

	echo "no"
fi
if [ "${HAVE_AGAR}" = "yes" ]; then
NONE=1
else
echo "The Agar test application failed to compile."
exit 1
fi
echo -n "checking for agar-net (http://hypertriton.com/agar-net/)..."
echo -n "checking for agar-net (http://hypertriton.com/agar-net/)..." >> config.log
AGAR_NET_VERSION=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-net-config" ]; then
		AGAR_NET_VERSION=`${path}/agar-net-config --version`
	fi
done
if [ "${AGAR_NET_VERSION}" != "" ]; then
echo "yes"
echo "yes" >> config.log
AGAR_NET_CFLAGS=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-net-config" ]; then
		AGAR_NET_CFLAGS=`${path}/agar-net-config --cflags`
	fi
done
AGAR_NET_LIBS=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/agar-net-config" ]; then
		AGAR_NET_LIBS=`${path}/agar-net-config --libs`
	fi
done
echo -n "checking whether agar-net works..."
echo -n "checking whether agar-net works..." >> config.log
cat << EOT > conftest.c
#include <agar/core.h>
#include <agar/net.h>
#
int main(int argc, char *argv[]) {
	NC_Session sess;
	NC_Init(&sess, "foo", "bar");
	NC_Destroy(&sess);
	return (0);
}

EOT
compile="ok"
echo "$CC $CFLAGS $TEST_CFLAGS ${AGAR_CFLAGS} ${AGAR_NET_CFLAGS} -o conftest conftest.c ${AGAR_LIBS} ${AGAR_NET_LIBS}" >>config.log
$CC $CFLAGS $TEST_CFLAGS ${AGAR_CFLAGS} ${AGAR_NET_CFLAGS} -o conftest conftest.c ${AGAR_LIBS} ${AGAR_NET_LIBS} 2>>config.log
if [ $? != 0 ]; then
	echo "failed ($?)" >> config.log
	compile="failed"
fi
rm -f conftest conftest.c
if [ "${compile}" = "ok" ]; then
	echo "ok" >> config.log
	echo "#ifndef HAVE_AGAR_NET" > config/have_agar_net.h
echo "#define HAVE_AGAR_NET" $HAVE_AGAR_NET >> config/have_agar_net.h
echo "#endif" >> config/have_agar_net.h

	HAVE_AGAR_NET=yes

	echo "yes"
else
	echo "#undef HAVE_AGAR_NET" > config/have_agar_net.h

	echo "no"
fi
if [ "${HAVE_AGAR_NET}" = "yes" ]; then
echo "AGAR_NET_CFLAGS=$AGAR_NET_CFLAGS" >> Makefile.config
echo "AGAR_NET_LIBS=$AGAR_NET_LIBS" >> Makefile.config
echo "#ifndef AGAR_NET_CFLAGS" > config/agar_net_cflags.h
echo "#define AGAR_NET_CFLAGS \"$AGAR_NET_CFLAGS\"" >> config/agar_net_cflags.h
echo "#endif" >> config/agar_net_cflags.h
echo "#ifndef AGAR_NET_LIBS" > config/agar_net_libs.h
echo "#define AGAR_NET_LIBS \"$AGAR_NET_LIBS\"" >> config/agar_net_libs.h
echo "#endif" >> config/agar_net_libs.h
else
echo "#undef AGAR_NET_CFLAGS" > config/agar_net_cflags.h
echo "#undef AGAR_NET_LIBS" > config/agar_net_libs.h
fi;
else
echo "#undef HAVE_AGAR_NET" > config/have_agar_net.h
echo "no"
echo "no" >> config.log
fi;
if [ "${HAVE_AGAR}" != "yes" ]
 then
	echo "This program requires Agar (http://agar.csoft.org/)"
	exit 1
fi
if [ "${HAVE_AGAR_NET}" != "yes" ]
 then
	echo "This program requires that Agar be compiled with network"
	echo "server support (--enable-network --enable-server)"
	exit 1
fi
CFLAGS="$CFLAGS -I$SRC"
echo "CFLAGS=$CFLAGS" >> Makefile.config
if [ "${enable_warnings}" = "yes" ]
 then
CFLAGS="$CFLAGS -Wall -Werror -Wmissing-prototypes"
echo "CFLAGS=$CFLAGS" >> Makefile.config
CFLAGS="$CFLAGS -Wno-unused"
echo "CFLAGS=$CFLAGS" >> Makefile.config
fi
echo "Don't forget to run \"make depend\"."
echo "Don't forget to run \"make depend\"." >> config.log
