dnl Process this file with autoconf to produce a configure script.
AC_INIT(lib/765fdc.c)
AC_CONFIG_AUX_DIR(config)
VERSION=0.3.4
UPDATED='1 April 2006'
AM_INIT_AUTOMAKE(lib765, $VERSION)
AM_CONFIG_HEADER(config.h)

dnl Put this before tinkering with the CFLAGS.
AC_PROG_CC

LDSKPATH=
dnl Enable / disable dependence on LibDsk
AC_ARG_WITH(libdsk,
[  --with-libdsk           Use LibDsk for all disc access [default=yes]],
              , with_libdsk=yes)
AC_ARG_WITH(libdsk-path,
[  --with-libdsk-path=PATH Path to LibDsk installation [default=none]],
            [LDSKPATH=$withval], [LDSKPATH= ] )


if test x$with_libdsk = xyes; then
    CFLAGS="$CFLAGS -DENABLE_LIBDSK"
fi

if test ! x$LDSKPATH = x; then
    CPPFLAGS="$CPPFLAGS -I$LDSKPATH/include"
    LDFLAGS="$LDFLAGS -L$LDSKPATH/lib"
fi

dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AM_PROG_LIBTOOL

dnl GCC extra options
if test "$ac_cv_prog_gcc" = "yes"; then
  CFLAGS="-Wall $CFLAGS"
fi

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h sys/ioctl.h sys/stat.h unistd.h fcntl.h)
if test x$with_libdsk = xyes; then
  AC_CHECK_HEADERS(libdsk.h)
fi
dnl Checks for functions
AC_CHECK_FUNCS(strcmpi stricmp strcasecmp, break)

dnl Checks for libraries.
if test x$with_libdsk = xyes; then
  AC_CHECK_LIB(dsk, dsk_open)
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_EXEEXT
AC_OBJEXT

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_HEADER_MAJOR
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(strerror)

AC_OUTPUT(Makefile include/Makefile lib/Makefile)
