dnl Process this file with autoconf to produce a configure script.
AC_INIT(libstroke/stroke.c)

dnl Initialize automake stuff
PACKAGE=libstroke

dnl version
LIBSTROKE_VERSION=0.5

dnl Initialize automake stuff
AM_INIT_AUTOMAKE($PACKAGE, $LIBSTROKE_VERSION, no-define)

dnl Create a configuration header
AM_CONFIG_HEADER(config.h)

dnl Build time sanity check...
AM_SANITY_CHECK

dnl Initialize libtool
AM_PROG_LIBTOOL

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

saved_cflags="$CFLAGS"
saved_ldflags="$LDFLAGS"

dnl Checks for header files.
AC_PATH_X
AC_PATH_XTRA

CFLAGS="$X_CFLAGS $CFLAGS"
LDFLAGS="$X_LDFLAGS $X_LIBS $LDFLAGS"
X_EXTRA_LIBS="$X_EXTRA_LIBS -lX11 -lm"

dnl Check for X libraries.
AC_CHECK_LIB(X11, XOpenDisplay, X11LIB="-lX11", X11LIB=no, $X_EXTRA_LIBS)

if test "$X11LIB" = no; then
	AC_MSG_ERROR(Cannot find -lX11 library)
fi

dnl What I really want to do is this:
dnl AC_CHECK_LIB(,fabs,,,m) 
dnl Check and see if fabs is available w/o linking libm.  If not, check if
dnl it is available with libm, and if so, add -lm to the LIBS.
dnl But this check fails hard.  ;-)
dnl So I do this instead, which I hope will help Tru64 UN*X
AC_CHECK_LIB(m,fabs)

AC_ARG_ENABLE(use_tcl,
[  --enable-tcl    Compile the tcl bindings],
[case "${enableval}" in
  yes) use_tcl=true ;;
  no)  use_tcl=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-tcl) ;;
esac],[use_tcl=false])
AM_CONDITIONAL(ENABLE_TCL, test x$use_tcl = xtrue)


dnl AC_PATH_PROG(ENABLE_TCL, $with_tcl, "foobaz")
dnl AC_SUBST(ENABLE_TCL)

dnl build this variable from the pieces
X_LDFLAGS="${X_LIBS} ${X11LIB}"

dnl How to use this macro?
dnl AM_PATH_GLIB

CFLAGS=$saved_cflags
LDFLAGS=$saved_ldflags

AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h)

AC_ARG_WITH(mouse-footprints,
[  --with-mouse-footprints  Draw mouse footprints in X],
[AC_DEFINE(STROKE_MOUSE_FOOTPRINTS)])

dnl check for GTK
dnl we won't build libgstroke if it's not found
AC_MSG_CHECKING(gtk+ library)
AM_PATH_GTK(1.2.7, HAVE_LIBGTK=yes
  AC_DEFINE(HAVE_LIBGTK, 1, [Define if libgtk is available]),
  AC_MSG_WARN(
***** NOTE: The GNOME stroke support won't be built
)
  HAVE_LIBGTK=no,
)
AM_CONDITIONAL(HAVE_LIBGTK,        test "x$HAVE_LIBGTK" = "xyes")


dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

AC_SUBST(X_CFLAGS)
AC_SUBST(X_LDFLAGS)

dnl if test ${no_gtk}x = yesx
dnl then
dnl    AC_OUTPUT( Makefile
dnl 	  libstroke/Makefile \
dnl           tests/Makefile )
dnl else
dnl   AC_OUTPUT( Makefile
dnl 	  libstroke/Makefile \
dnl 	  libgstroke/Makefile \
dnl           tests/Makefile )
dnl fi

AC_OUTPUT( Makefile
  libstroke/Makefile \
  libgstroke/Makefile \
  doc/Makefile \
  javastroke/Makefile \
  tests/Makefile )
