dnl
dnl autoconf input for WRaster library
dnl

AC_INIT(raster.c)
AM_INIT_AUTOMAKE(wrlib, 0.3)


CFLAGS="$CFLAGS -O2"

dnl Checks for programs.
dnl ===================
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL


dnl Checks for library functions.
dnl ============================
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF

AC_PATH_XTRA

XCFLAGS="$X_CFLAGS"

_XLIBS="$X_LIBS $X_EXTRA_LIBS -lX11"
XLIBS="$X_EXTRA_LIBS -lX11"

XLFLAGS=$X_LIBS

AC_SUBST(XCFLAGS)
AC_SUBST(XLFLAGS)

dnl Pixmap Support
dnl ==============
xpm=yes
AC_ARG_ENABLE(xpm, 
[  --disable-xpm	  	  disable XPM support through libXpm],
	xpm=$enableval, xpm=yes)
	
GFXFLAGS=""
GFXLIBS=""

if test "$xpm" = yes; then
    AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,
		[GFXFLAGS=-DUSE_XPM GFXLIBS=-lXpm], ,$_XLIBS)
fi


dnl test for zlib
dnl =============

AC_CHECK_LIB(z, gzread, zlib=yes, zlib=no)


dnl PNG Support
dnl ===========
png=yes
AC_ARG_ENABLE(png, 
[  --disable-png	  	  disable PNG support through libpng],
	png=$enableval, png=yes)
	
if test "$png" = yes; then
    if test "$zlib" = yes; then
    	AC_CHECK_LIB(png, png_get_valid, [GFXFLAGS="$GFXFLAGS -DUSE_PNG"
		GFXLIBS="$GFXLIBS -lpng -lz"], , -lz -lm)
    fi
fi

dnl TIFF Support
dnl ============
tif=yes
AC_ARG_ENABLE(tif, 
[  --disable-tiff	disable use of TIFF images through libtiff],
	tif=$enableval, tif=yes)

if test "$tif" = yes; then
    AC_CHECK_LIB(tiff, TIFFGetVersion, 
    	[GFXFLAGS="$GFXFLAGS -DUSE_TIFF" GFXLIBS="$GFXLIBS -ltiff"],, -lm)
fi


AC_SUBST(GFXFLAGS)
AC_SUBST(GFXLIBS)

AC_SUBST(XLIBS)


if test "${prefix}" = "NONE"; then
    prefix="/usr/local"
fi
if test "${exec_prefix}" = "NONE"; then
    exec_prefix=$prefix
fi


AC_C_CONST

AC_OUTPUT(Makefile config.h) 

