AC_INIT(lib/flash.h)

# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}

dnl we need to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
dnl are available for $ac_help expansion (don't we all *love* autoconf?)
AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
#
# Making releases:
#   FLASH_MICRO_VERSION += 1;
#   FLASH_INTERFACE_AGE += 1;
#   FLASH_BINARY_AGE += 1;
# if any functions have been added, set FLASH_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set FLASH_BINARY_AGE and FLASH_INTERFACE_AGE to 0.
#
FLASH_MAJOR_VERSION=0
FLASH_MINOR_VERSION=4
FLASH_MICRO_VERSION=10
FLASH_INTERFACE_AGE=0
FLASH_BINARY_AGE=0
FLASH_VERSION=$FLASH_MAJOR_VERSION.$FLASH_MINOR_VERSION.$FLASH_MICRO_VERSION
dnl
AC_DIVERT_POP()dnl

# libtool versioning
LT_RELEASE=$FLASH_MAJOR_VERSION.$FLASH_MINOR_VERSION
LT_CURRENT=`expr $FLASH_MICRO_VERSION - $FLASH_INTERFACE_AGE`
LT_REVISION=$FLASH_INTERFACE_AGE
LT_AGE=`expr $FLASH_BINARY_AGE - $FLASH_INTERFACE_AGE`
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

VERSION=$FLASH_VERSION
PACKAGE=libflash

AM_INIT_AUTOMAKE($PACKAGE, $VERSION)

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"

AC_CANONICAL_HOST

AC_PROG_CXX

dnl Initialize libtool
AC_DISABLE_STATIC
AM_PROG_LIBTOOL

changequote(,)dnl
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi
changequote([,])dnl

AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]],
if eval "test x$enable_debug = xyes"; then
  DEBUGFLAG="-g"
fi)

dnl Test for libjpeg
  if test -z "$LIBJPEG"; then
    AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
      jpeg_ok=yes,
      jpeg_ok=no)
    if test "$jpeg_ok" = yes; then
      AC_CHECK_HEADER(jpeglib.h,
	jpeg_ok=yes,
        jpeg_ok=no)
      if test "$jpeg_ok" = yes; then
	LIBJPEG='-ljpeg'
      else
	AC_MSG_ERROR([*** JPEG header files not found.])
      fi
    else
      AC_MSG_ERROR([*** DirectFB requires libjpeg.])
    fi
  fi

dnl Test for libz
  if test -z "$LIBZ"; then
    AC_CHECK_LIB(z, gzsetparams,
      AC_CHECK_HEADER(zlib.h,
	LIBZ='-lz',
	AC_MSG_ERROR([*** LIBZ header files not found.])),
      AC_MSG_ERROR([*** DirectFB requires libz.]))
  fi

AC_SUBST(LIBJPEG)
AC_SUBST(LIBZ)

AC_OUTPUT([
Makefile
lib/Makefile
])


