Use gcc -E to preprocess db.h before grepping for version macros; plain
grep fails on hardened systems where the macros are not defined literally
at the top level of db.h.

Refreshed for 3.2.0: the grep lines are now inside the else-branch of the
new --with-libbdb-ro conditional introduced upstream.

--- a/m4/db.m4
+++ b/m4/db.m4
@@ -128,9 +128,9 @@
 db_ver_min=3
 db_ver_pat=0
 else
-db_ver_maj=`grep DB_VERSION_MAJOR $db_incdir/db.h | awk '{print $3}'`
-db_ver_min=`grep DB_VERSION_MINOR $db_incdir/db.h | awk '{print $3}'`
-db_ver_pat=`grep DB_VERSION_PATCH $db_incdir/db.h | awk '{print $3}'`
+db_ver_maj=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_MAJOR | awk '{print $3}'`
+db_ver_min=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_MINOR | awk '{print $3}'`
+db_ver_pat=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_PATCH | awk '{print $3}'`
 fi

 dnl Ensure that we have libdb at least 4.7, older versions aren't supported
