dnl $Header: /afs/net.mit.edu/user/foley/src/CVSROOT/morse/configure.in,v 1.3 1997/08/29 22:31:52 foley Exp $
dnl Process this file with autoconf to produce a configure script.
AC_INIT(beep.h)
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_HOST

AC_ARG_WITH(audio,
	[ --with-audio=PATH	Specify path to audio lib/header],
	[AUDIO="$withval"],
	[AUDIO=${AUDIO-':'}])

AC_ARG_WITH(volume,
	[ --with-volume=VOLUME_LEVEL	Specify default volume level],
	[VOLUME="$withval"],
	[VOLUME=${VOLUME-'0.5'}])

AC_ARG_WITH(debug-flags,
	[ --with-debug-flags=FLAGS	Specify global debugging flags],
	[DEBUG_FLAGS="$withval"],
	[DEBUG_FLAGS=${DEBUG_FLAGS-'-O'}])
if test "$DEBUG_FLAGS" = "no"; then
	DEBUG_FLAGS=""
fi
AC_SUBST(DEBUG_FLAGS)

AC_ARG_WITH(defines,
	[ --with-defines=FLAGS	Specify application specific DEFINES (-DFOO)],
	[DEFINES="$withval"],
	[DEFINES=${DEFINES-''}])
AC_SUBST(DEFINES)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_MSG_CHECKING(location of temporary directory)
if test -d /var/tmp; then
	found_tmp=/var/tmp
elif test -d /usr/tmp; then
	found_tmp=/usr/tmp/
else
	found_tmp=/tmp/
fi
AC_MSG_RESULT(${found_tmp})
AC_SUBST(found_tmp)

dnl Checks for libraries.
MORSE_SET_DEVICE

dnl if AUDIO = yes, path is already dealt with 
dnl if !NEED_AUDIOLIB then we need to check
if test "$NEED_AUDIOLIB" = "yes"; then
	AC_CHECK_LIB(audio, audio_getinfo, ,[AC_MSG_WARN("Unable to find audio_getinfo in libaudio!")], -lm)
	if test "$DEVICE" = "Indigo"; then 
		AC_CHECK_LIB(audio, ALgetfillable, ,[AC_MSG_WARN("Unable to find ALgetfillable in libaudio!")], -lm)
	fi

fi
AC_CHECK_LIB(m, sin)
dnl AC_CHECK_LIB(sunmath, irint)

dnl Checks for header files.
AC_PATH_X
AC_PATH_XTRA
AC_SUBST(X_CFLAGS)
AC_SUBST(X_LIBS)
AC_SUBST(X_EXTRA_LIBS)
AC_SUBST(X_PRE_LIBS)
save_LIBS="${LIBS}"
LIBS="${X_LIBS}"
AC_CHECK_LIB(X11, XBell, ,[AC_MSG_WARN("Cannot find XBell!")], ${X_EXTRA_LIBS})
LIBS="${save_LIBS}"

AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h malloc.h sys/file.h sys/ioctl.h ioctl.h sys/ioctl_compat.h)
AC_CHECK_HEADERS(sys/time.h sys/termio.h termios.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.
AC_CHECK_FUNCS(random lrand48 rand)
AC_CHECK_FUNCS(sighold sigblock strchr memcpy)
AC_CHECK_FUNCS(irint)
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL

if test "${DEVICE}" = "X11"; then
TEMP_CPPFLAGS=\''${X11CFLAGS}'\'
TEMP_LDFLAGS=\''${X11LIBS}'\'
CPPFLAGS="${CPPFLAGS} ${TEMP_CPPFLAGS}"
LSFLAGS="${LDFLAGS} ${TEMP_LDFLAGS}"
fi

AC_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile qso/Makefile morse.h)
