dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h paths.h)
AC_CHECK_FUNCS(usleep)

giflib_header="no"
KDE_CHECK_HEADERS(gif_lib.h, giflib_header="yes")
if test "$giflib_header" = "no" ; then
	DO_NOT_COMPILE="$DO_NOT_COMPILE pixieplus"
fi

tiff_headers="no"
AC_DEFUN([CHECK_TIFF],[
  AC_REQUIRE([AC_FIND_TIFF])
])

CHECK_TIFF

if test -z "$LIBTIFF"; then
		DO_NOT_COMPILE="$DO_NOT_COMPILE pixieplus"
	else
		tiff_headers="yes"
fi

magick_config="no"
KDE_FIND_PATH(Magick-config, MAGICK_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [AC_MSG_WARN([Could not find ImageMagick anywhere, check http://www.imagemagick.org/ for ImageMagick >= 6.0.0])])

if test -n "$MAGICK_CONFIG"; then
	vers=`$MAGICK_CONFIG --version 2>/dev/null | $AWK 'BEGIN { FS = "."; } { printf "%d",$1 ;}'`
	if test -n "$vers" && test "$vers" -ge 6; then
		magick_config="yes"	
		LIBMAGICK_LIBS="`$MAGICK_CONFIG --libs`"
		LIBMAGICK_LDFLAGS="`$MAGICK_CONFIG --ldflags`"
		LIBMAGICK_RPATH=""

		for args in $LIBMAGICK_LIBS; do
			case $args in
				-L*)
				LIBMAGICK_RPATH="$LIBMAGICK_RPATH $args"
				;;
			esac
		done
	fi

		LIBMAGICK_RPATH=`echo $LIBMAGICK_RPATH | $SED -e "s/-L/-R/g"`
		LIBMAGICK_CPPFLAGS="`$MAGICK_CONFIG --cppflags`"
fi

if test ! "$USE_RPATH" = "yes"; then
    LIBMAGICK_RPATH=
fi

AC_SUBST(LIBMAGICK_LIBS)
AC_SUBST(LIBMAGICK_LDFLAGS)
AC_SUBST(LIBMAGICK_CPPFLAGS)
AC_SUBST(LIBMAGICK_RPATH)

