+# --- library functions ---
+runtest dirent-namlen DIRENT_NAMLEN || true
+runtest fgetln FGETLN || true
+runtest fts FTS || true
+runtest getsubopt GETSUBOPT || true
+runtest mmap MMAP || true
+runtest reallocarray REALLOCARRAY || true
+runtest strcasestr STRCASESTR || true
+runtest strlcat STRLCAT || true
+runtest strlcpy STRLCPY || true
+runtest strptime STRPTIME || true
+runtest strsep STRSEP || true
+runtest wchar WCHAR || true
+
+# --- sqlite3 ---
+DETECTLIB=
+if [ ${BUILD_DB} -eq 0 ]; then
+ echo "BUILD_DB=0 (manual)" 1>&2
+ echo "BUILD_DB=0 (manual)" 1>&3
+ echo 1>&3
+ HAVE_SQLITE3=0
+elif ismanual sqlite3 "${HAVE_SQLITE3}"; then
+ DETECTLIB="-lsqlite3"
+elif [ -n "${DBLIB}" ]; then
+ runtest sqlite3 SQLITE3 "${DBLIB}" || true
+elif singletest sqlite3 SQLITE3 "-lsqlite3"; then
+ DETECTLIB="-lsqlite3"
+elif runtest sqlite3 SQLITE3 \
+ "-I/usr/local/include -L/usr/local/lib -lsqlite3"; then
+ DETECTLIB="-L/usr/local/lib -lsqlite3"
+ CFLAGS="${CFLAGS} -I/usr/local/include"
+fi
+if [ ${BUILD_DB} -gt 0 -a ${HAVE_SQLITE3} -eq 0 ]; then
+ echo "BUILD_DB=0 (no sqlite3)" 1>&2
+ echo "BUILD_DB=0 (no sqlite3)" 1>&3
+ echo 1>&3
+ BUILD_DB=0
+fi
+
+# --- sqlite3_errstr ---
+if [ ${BUILD_DB} -eq 0 ]; then
+ HAVE_SQLITE3_ERRSTR=1
+elif ismanual sqlite3_errstr "${HAVE_SQLITE3_ERRSTR}"; then
+ :
+elif [ -n "${DBLIB}" ]; then
+ runtest sqlite3_errstr SQLITE3_ERRSTR "${DBLIB}" || true
+else
+ runtest sqlite3_errstr SQLITE3_ERRSTR "${DETECTLIB}" || true
+fi
+
+# --- ohash ---
+if [ ${BUILD_DB} -eq 0 ]; then
+ HAVE_OHASH=1
+elif ismanual ohash "${HAVE_OHASH}"; then
+ :
+elif [ -n "${DBLIB}" ]; then
+ runtest ohash OHASH "${DBLIB}" || true
+elif singletest ohash OHASH; then
+ :
+elif runtest ohash OHASH "-lutil"; then
+ DETECTLIB="${DETECTLIB} -lutil"
+fi
+
+# --- DBLIB ---
+if [ ${BUILD_DB} -eq 0 ]; then
+ DBLIB=
+elif [ -z "${DBLIB}" ]; then
+ DBLIB="${DETECTLIB}"
+ echo "DBLIB=\"${DBLIB}\"" 1>&2
+ echo "DBLIB=\"${DBLIB}\"" 1>&3
+ echo 1>&3
+fi
+
+# --- manpath ---
+if [ ${BUILD_DB} -eq 0 ]; then
+ HAVE_MANPATH=0
+elif ismanual manpath "${HAVE_MANPATH}"; then
+ :
+elif manpath 1>&3 2>&3; then
+ echo "manpath: yes" 1>&2
+ echo "manpath: yes" 1>&3
+ echo 1>&3
+ HAVE_MANPATH=1
+else
+ echo "manpath: no" 1>&2
+ echo "manpath: no" 1>&3
+ echo 1>&3
+ HAVE_MANPATH=0
+fi
+
+# --- write config.h ---
+
+exec > config.h
+
+cat << __HEREDOC__
+#ifndef MANDOC_CONFIG_H
+#define MANDOC_CONFIG_H
+
+#if defined(__linux__) || defined(__MINT__)
+#define _GNU_SOURCE /* See test-*.c what needs this. */
+#endif
+
+__HEREDOC__
+
+[ ${HAVE_FGETLN} -eq 0 -o ${HAVE_REALLOCARRAY} -eq 0 -o \
+ ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 ] \
+ && echo "#include <sys/types.h>"
+[ ${HAVE_FGETLN} -eq 0 ] && echo "#include <stdio.h>"
+