1dnl ---------------------------------------------------------------------------
2dnl pstoimg: This program is needed for processing images. If not found,
3dnl          documentation can still be built, but without figures.
4dnl ---------------------------------------------------------------------------
5AC_DEFUN([GP_CHECK_PSTOIMG],
6[
7AC_REQUIRE([GP_CHECK_DOT])dnl for creating tesseract.ps
8
9try_pstoimg=true
10have_pstoimg=false
11AC_ARG_WITH(pstoimg, AS_HELP_STRING([--without-pstoimg], [Do not use pstoimg]),[
12	if test "x$withval" = "xno"; then
13		try_pstoimg=false
14	fi])
15if $try_pstoimg; then
16	AC_PATH_PROG(PSTOIMG,pstoimg)
17	if test -n "${PSTOIMG}"; then
18		have_pstoimg=true
19	fi
20fi
21if $have_pstoimg; then
22	AC_SUBST(PSTOIMG)
23	AC_MSG_CHECKING([whether ${PSTOIMG} works])
24	rm -f tesseract.png
25        ${PSTOIMG} -type png -scale 1.2 -antialias -crop a tesseract.ps > /dev/null
26        if test $? != 0 || test ! -f tesseract.png; then
27                have_pstoimg=false
28		AC_MSG_RESULT(no)
29	else
30		AC_MSG_RESULT(yes)
31        fi
32	rm -f tesseract.png
33fi
34AM_CONDITIONAL(ENABLE_PSTOIMG, $have_pstoimg)
35
36])
37