1dnl ---------------------------------------------------------------------------
2dnl w3m: This program is needed for converting HTML to text.
3dnl ---------------------------------------------------------------------------
4AC_DEFUN([GP_CHECK_W3M],
5[
6
7try_w3m=true
8have_w3m=false
9AC_ARG_WITH(w3m, [  --without-w3m         Don't use w3m],[
10	if test "x$withval" = "xno"; then
11		try_w3m=false
12	fi])
13if $try_w3m; then
14	AC_PATH_PROG(W3M,w3m)
15	if test -n "${W3M}"; then
16		have_w3m=true
17	fi
18fi
19if $have_w3m; then
20	AC_MSG_CHECKING([whether ${W3M} works])
21        cat > html2text-test.xxxhtml 2> /dev/null <<EOF
22<html>
23<title>
24<h1>HTML2TEXT Test</h1>
25</title>
26<body>
27<p>This is a test.</p>
28</body>
29</html>
30EOF
31	${W3M} -T text/html -cols 78 -dump html2text-test.xxxhtml > html2text-test.txt
32        if test $? != 0 || test ! -f html2text-test.txt || test ! -s html2text-test.txt
33        then
34                have_w3m=false
35		AC_MSG_RESULT([no (see http://www.w3m.org/ or http://w3m.sourceforge.net/ ...)])
36		W3M=false
37		AC_SUBST(W3M)
38	else
39		AC_MSG_RESULT([yes])
40		AC_SUBST(W3M)
41        fi
42fi
43AM_CONDITIONAL([HAVE_W3M], [$have_w3m])
44
45])
46