dnl standard setup for vic/vat/etc. autoconf scripts.
dnl $Header$ (LBL)

AC_CANONICAL_SYSTEM

AC_PROG_CC
AC_PROG_CXX
AC_STDC_HEADERS
AC_HAVE_HEADERS(string.h malloc.h)

V_INCLUDE=""
V_LIB=""
V_OBJ=""
V_OBJ_CRYPT=""
V_BROKEN_OBJ="strtol.o strtoul.o"

V_SHELL=""
V_TARCMD="tar cfh"
V_SIGRET="void"

AC_CHECK_LIB(Xbsd, main, [V_LIB="$V_LIB -lXbsd"])
AC_CHECK_LIB(socket, poll, [V_LIB="$V_LIB -lsocket"])

# nsl lib seems to cause problems on IRIX
if test `echo "$target_os" | sed 's/\..*//'` != irix6 ; then
	AC_CHECK_LIB(nsl, gethostbyname, [V_LIB="$V_LIB -lnsl"])
fi

V_TAR_EXTRA=""

V_CCOPT_H261="-O2"

AC_ARG_ENABLE(debug,   --enable-debug		build with debugging enabled, V_CCOPT="-g", V_CCOPT="-O2")

AC_ARG_ENABLE(ipv6,   --enable-ipv6		build with ipv6 enabled, ipv6=yes, ipv6=no)

AC_ARG_WITH(fore,	--with-fore=path	specify a pathname for fore atm, d=$withval, d="")
if test "$d" = "" ; then
	if test -d /usr/src/local/fore ; then
		d=/usr/src/local/fore
	fi
fi
if test "$d" != "" ; then
	if test ! -d $d ; then
		echo "'$d' is not a directory"
		exit 1
	fi
	V_INCLUDE="$V_INCLUDE -I$d/include"
	V_LIB="$V_LIB $d/api/libatm.a"
	V_OBJ="$V_OBJ net-atm.o"
fi

if test -z "$PWD" ; then
    PWD=`pwd`
fi

solaris=""
if test `echo "$target_os" | sed 's/\..*//'` = solaris2 ; then
	solaris="yes"
fi

places="desCore.a \
	/usr/src/local/desCore/desCore.a \
	../desCore/desCore.a"
for f in $places; do
	if test -f $f ; then
		V_LIB="$V_LIB $f"
		V_OBJ_CRYPT="$V_OBJ_CRYPT crypt-des.o"
    		break
	fi
done

aquatcl="no"
aquatk="no"
cygwin="no"
mingw="no"

case "$target" in
  *-*-darwin*)
        aquatcl="yes"
        aquatk="yes"
        ;;
  *-*-cygwin*)
	cygwin="yes"
	;;
  *-*-mingw*)
	mingw="yes"
	;;
esac   

AC_ARG_ENABLE(aquatcl,  --disable-aquatcl	build with aquatcl enabled, aquatcl=no, )
AC_ARG_ENABLE(aquatk,   --disable-aquatk	build with aquatk enabled, aquatk=no, )

builtin(include, configure.in.tk)
