AC_PREREQ(2.59)

AC_INIT([psmodule],[0.6.0],[http://pan-starrs.ifa.hawaii.edu/bugzilla])
AC_CONFIG_SRCDIR([psmodule.pc.in])

AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2])
AM_CONFIG_HEADER([src/config.h])
AM_MAINTAINER_MODE

AC_LANG(C)
AC_PROG_CC

dnl AC_SUBST(LDFLAGS)
AC_SUBST(CFLAGS)

AC_MSG_CHECKING([C99 flag])
if test "$GCC" == "yes"
then
CFLAGS="${CFLAGS=} -std=gnu99"
AC_MSG_RESULT([-std=gnu99])
else
CFLAGS="${CFLAGS=} -std=c99"
AC_MSG_RESULT([-std=c99])
fi

AC_GNU_SOURCE

AC_PROG_INSTALL
AM_PROG_LIBTOOL

AC_PREFIX_DEFAULT([`pwd`])
test "$prefix" = NONE && prefix=`pwd`

DOXYGEN="doxygen Doxyfile"
AC_CHECK_PROG(DOXYGEN,doxygen,[echo Doxygen not detected in configure stage.])
AC_SUBST(DOXYGEN,$DOXYGEN)

AC_ARG_WITH(pslib-config,
[  --with-pslib-config=FILE  Specify location of psLib-config script],
[PSLIB_CONFIG=$withval],
[PSLIB_CONFIG=`which pslib-config`])
AC_CHECK_FILE($PSLIB_CONFIG,[],
    [AC_MSG_ERROR([psLib is required.  If not in path, use --with-pslib-config to specify pslib-config script location.])])
AC_MSG_CHECKING([PSLIB cflags])
PSLIB_CFLAGS="`${PSLIB_CONFIG} --cflags`"
AC_MSG_RESULT([${PSLIB_CFLAGS}])
AC_MSG_CHECKING([PSLIB libs])
PSLIB_LIBS="`${PSLIB_CONFIG} --libs`"
AC_MSG_RESULT([${PSLIB_LIBS}])
CFLAGS="${CFLAGS=} ${PSLIB_CFLAGS}"
LDFLAGS="${LDFLAGS=} ${PSLIB_LIBS}"

CFLAGS="${CFLAGS=} -Wall -Werror"

AC_CONFIG_FILES([
  Makefile
  src/Makefile
  test/Makefile
  Doxyfile
  psmodule-config
  psmodule.pc
])

AC_OUTPUT
