diff --git a/configure.ac b/configure.ac
index 6b4059e02c23c99be28b04ec8caf1d89f6138305..83e3070ff7e2744f08b902f1304e15f9a67e2a98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -991,6 +991,24 @@ AC_PATH_PROGS( NROFF, gnroff nroff, ,
   $PATH:/usr/bin/:/usr/local/bin )
 AC_SUBST(NROFF)
 
+AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
+MANOPT="-man"
+mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
+if test -z "$mancheck"; then
+  MANOPT="-mandoc"
+  mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
+  if test -z "$mancheck"; then
+    MANOPT=""
+    AC_MSG_RESULT([failed])
+    AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
+  else
+    AC_MSG_RESULT([$MANOPT])
+  fi
+else
+  AC_MSG_RESULT([$MANOPT])
+fi
+AC_SUBST(MANOPT)
+
 AC_PROG_YACC
 
 dnl AC_PATH_PROG( RANLIB, ranlib, /usr/bin/ranlib,