dnl 'autoconf' input file for the LBL/UCB vat tool
dnl $Header: configure.in,v 1.27 96/05/16 05:20:59 van Exp $ (LBL)

AC_INIT(main.cc)

V_PROG="vat"
V_ALL="$V_PROG"
V_SHM=""

builtin(include, configure.in.head)

# lots of hairy special cases for detecting which audio device
# support to compile in
#
V_LIB_AUDIO=""
V_INCLUDE_AUDIO=""
V_OBJ_AUDIO=""

AC_ARG_WITH(gsm,	--with-gsm=path	specify a pathname for gsm, d=$withval, d="")
if test "$d" != "" ; then
	if test ! -d $d ; then 
		echo "'$d' is not a directory"
		exit 1
	fi
	V_LIB_GSM=$d/lib/libgsm.a
	if test ! -r $V_LIB_GSM ; then
		echo "can't find libgsm.a in $d/lib"
		exit 1
	fi
	V_INCLUDE_GSM=-I$d/inc
	if test ! -r $d/inc/private.h ; then
		echo "can't find gsm includes in $d/inc"
		exit 1
	fi
else
	echo "checking for -lgsm"
	V_LIB_GSM=FAIL
	V_INCLUDE_GSM=FAIL
	AC_CHECK_LIB(gsm, gsm_create, V_LIB_GSM="-lgsm")
	AC_CHECK_HEADERS(private.h)
	if test "$ac_cv_header_private_h" = "yes"; then
		V_INCLUDE_GSM=
	fi
	if test "$V_LIB_GSM" = FAIL || test "$V_INCLUDES_GSM" = FAIL ; then
		echo "configure: can't find gsm library ... you can get it at"
		echo "   http://www.cs.tu-berlin.de/~jutta/toast.html"
		exit 1
	fi
fi
AC_SUBST(V_LIB_GSM)
AC_SUBST(V_INCLUDE_GSM)

AC_ARG_WITH(af,	--with-af=path	specify a pathname for AudioFile, d=$withval, d="")
if test "$d" != "" ; then
	if test ! -d $d ; then 
		echo "'$d' is not a directory"
		exit 1
	fi
	if test ! -r $d/AF/lib/AF/libAF.a ; then
		echo "can't find libAF.a in $d/AF/lib/AF"
		exit 1
	fi
	if test ! -r $d/AF/lib/AF/AFlib.h ; then
		echo "can't find AFlib.h in $d/AF/lib/AF"
		exit 1
	fi
	V_LIB="$V_LIB $d/AF/lib/AF/libAF.a"
	V_INCLUDE="$V_INCLUDE -I$d/AF/lib -I$d/AF"
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-af.o"
else
	echo "checking for AudioFile"
	places="../AudioFile-3.1 \
		../AudioFile-3 \
		../AudioFile \
		/usr/src/local/AudioFile-3.1 \
		/usr/src/local/AudioFile-3 \
		/usr/src/local/AudioFile"
	V_AF=FAIL
	for d in $places; do
		if test -f $d/AF/lib/AF/libAF.a -a -f $d/AF/lib/AF/AFlib.h; then
			V_LIB="$V_LIB $d/AF/lib/AF/libAF.a"
			V_INCLUDE="$V_INCLUDE -I$d/AF/lib -I$d/AF"
			V_OBJ_AUDIO="$V_OBJ_AUDIO audio-af.o"
			V_AF=$d
			break
		fi
	done
	if test $V_AF = FAIL ; then
		echo "can't find AudioFile - vat AF support won't be compiled"
	fi
fi

AC_TEST_CPP([#include <sys/audioio.h>], x=audio-sun.o, x="")
V_OBJ_AUDIO="$V_OBJ_AUDIO $x"

AC_TEST_CPP([#include <sun/audioio.h>], x=audio-sun.o, x="")
V_OBJ_AUDIO="$V_OBJ_AUDIO $x"

V_TABCC='$(CC) -O0'

if test "$V_OBJ_CRYPT" != "" ; then
	V_OBJ_CRYPT="$V_OBJ_CRYPT crypt-vat.o"
fi

case "$target" in 
*-dec-*)
	;;
sparc-sun-solaris*)
	if test $CC = gcc ; then
		V_DEFINE="$V_DEFINE -mv8 -msupersparc"
	fi
	V_DEFINE="$V_DEFINE -D__svr4__"
	;;
sparc-sun-sunos*)
	V_DEFINE="$V_DEFINE -DNEED_SUNOS_PROTOS"
	V_STATIC="-static"
	;;
*-sgi-irix*)
	V_DEFINE="$V_DEFINE -D_BSD_SIGNALS -D_BSD_COMPAT"
	if test "$target_os" = irix6.2 ; then
		V_DEFINE="$V_DEFINE -DSIGARGS=__sigargs"
	fi
	V_TARCMD="tar cfL"
	V_SHELL="SHELL = /bin/sh"
	if test $CC != gcc ; then
		V_DEFINE="$V_DEFINE -signed -g3"
		CC="cc -Dinline="
		if test "$target_os" = irix5.2 ; then
			CC="$CC -xansi -D__STDC__"
		fi
		CXX="CC +p -float -woff 3262 -DSGI_COMPAT"
	fi
	V_LIB_AUDIO="$V_LIB_AUDIO -laudio"
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-sgi.o"
	;;
*-*-bsdi1*)
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-pc.o"
	;;
*-*-bsdi2.0*)
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-pc.o"
	;;
*-*-bsdi*)
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-voxware.o"
	V_TARCMD="tar cfL"
	V_CCOPT="-O2 -m486"
	;;
*-*-freebsd*)
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-voxware.o"
	;;
*-*-sco*)
	V_DEFINE="$V_DEFINE -DSIGARGS=int -Dsco"
	if test $CC != gcc ; then
		CC="cc -Dinline="
		CXX="CC +.cc"
	fi
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-voxware.o"
	V_BROKEN_OBJ=
	;;
*-*-netbsd*)
	V_TARCMD="tar -h -c -f"
	V_LIB="${LDFLAGS} $V_LIB -lossaudio"
	V_OBJ_AUDIO="audio-voxware.o"
	V_CCOPT="${CPPFLAGS}"
	;;
*-*-hpux*)
	V_DEFINE="$V_DEFINE"
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-hp.o"
	;;
*-*-aix3*)
	V_DEFINE="$V_DEFINE -DSIGARGS=int"
	CXX="xlC -+ -qlanglvl=compat -I/usr/lpp/xlC/include -I/usr/include"
	CC="cc -Dinline="
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-ibm.o"
	V_LIB="$V_LIB -lm -lbsd"
	;;
*-*-aix4*)
	V_DEFINE="$V_DEFINE -DSIGARGS=int -D_AIX41"
	CXX="xlC -+"
	;;
*-*-linux*)
	V_OBJ_AUDIO="$V_OBJ_AUDIO audio-voxware.o"
	V_CCOPT="-O2 -m486"
	V_BROKEN_OBJ=
	;;
esac

AC_SUBST(V_LIB_AUDIO)
AC_SUBST(V_INCLUDE_AUDIO)
AC_SUBST(V_OBJ_AUDIO)
AC_SUBST(V_TABCC)

builtin(include, configure.in.tail)
