dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)

AC_INIT([psphot], [0.0.1], [http://pan-starrs.ifa.hawaii.edu])
AC_CONFIG_SRCDIR([src])

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

AC_LANG(C)
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LIBTOOL

dnl enable largefile supports
AC_SYS_LARGEFILE

dnl handle debug building
AC_ARG_ENABLE(optimize,
  [AS_HELP_STRING(--enable-optimize,enable compiler optimization)],
  [AC_MSG_RESULT(compile optimization enabled)
   CFLAGS="-O2"],
  [AC_MSG_RESULT([compile optimization disabled])
   CFLAGS="-O0 -g"]
)

dnl handle profiler building
AC_ARG_ENABLE(profile,
  [AS_HELP_STRING(--enable-profile,enable compiler profiler information inclusion)],
  [AC_MSG_RESULT(compile optimization enabled)
   CFLAGS="${CFLAGS=} -pg"]
)

dnl ------------------------------------------------------------

AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
if test "$ERRORCODES" = "missing" ; then
  AC_MSG_ERROR([psParseErrorCodes is required])
fi

PKG_CHECK_MODULES(PSLIB, pslib >= 0.12.99)
PKG_CHECK_MODULES(PSMODULE, psmodules >= 0.12.99)

dnl Set CFLAGS for build
CFLAGS="${CFLAGS} -Wall -Werror -std=c99"

AC_SUBST([PSPHOT_CFLAGS])
AC_SUBST([PSPHOT_LIBS])

AC_CONFIG_FILES([
  Makefile
  src/Makefile
  psphot.pc
])

AC_OUTPUT
