AC_PATH_PROG(BISON, bison,bison)
AC_PATH_PROG(HELP2MAN, help2man, help2man)
-# Check for a GNU m4 that supports --prefix-builtins
-
-AC_PATH_PROGS(M4, gm4 gnum4 m4, m4)
-
-if test x"$M4" != x; then
- AC_MSG_CHECKING([for GNU m4])
- case `$M4 --help < /dev/null 2>&1` in
- *prefix-builtins*) AC_MSG_RESULT(yes) ;;
- *) AC_MSG_RESULT(no) ;
- AC_MSG_ERROR([GNU M4 1.4 is required]) ;;
- esac
-else
- AC_MSG_ERROR([GNU M4 1.4 is required]) ;
-fi
-
-AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
+# Check for a m4 that supports -P
+
+AC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
+[AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
+ [[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
+ [test "x$m4out" = x0 \
+ && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
+ [AC_MSG_ERROR([could not find m4 that supports -P])])])
+AC_SUBST([M4], [$ac_cv_path_M4])
+AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
AC_PATH_PROG(INDENT, indent, indent)
# if INDENT is set to 'indent' then we didn't find indent