X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/9b7d66dd614cbd7d82a8512379216218ac547d5d..0ff0ed9ccba23c2bb72acd03d35240498c7dff6e:/configure

diff --git a/configure b/configure
index 000d11ec..90eacc83 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,8 @@
 #!/bin/sh
 #
-# Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+# $Id: configure,v 1.67 2018/08/15 02:15:52 schwarze Exp $
+#
+# Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
 #
 # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -16,8 +18,8 @@
 
 set -e
 
-[ -e config.log ] && mv config.log config.log.old
-[ -e config.h   ] && mv config.h config.h.old
+[ -w config.log ] && mv config.log config.log.old
+[ -w config.h   ] && mv config.h config.h.old
 
 # Output file descriptor usage:
 # 1 (stdout): config.h, Makefile.local
@@ -25,48 +27,79 @@ set -e
 # 3: config.log
 
 exec 3> config.log
-echo "config.log: writing..."
+echo "file config.log: writing..."
 
 # --- default settings -------------------------------------------------
 # Initialize all variables here,
 # such that nothing can leak in from the environment.
 
+SOURCEDIR=`dirname "$0"`
+
+MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
+MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
 OSNAME=
+UTF8_LOCALE=
 
-CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make -f -`
-CFLAGS="-g -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings"
-DBLIB=
-STATIC="-static"
+CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -`
+CFLAGS=
+LDADD=
+LDFLAGS=
+LD_NANOSLEEP=
+LD_OHASH=
+LD_RECVMSG=
+STATIC=
 
-BUILD_DB=1
 BUILD_CGI=0
+BUILD_CATMAN=0
+INSTALL_LIBMANDOC=0
 
+HAVE_CMSG=
+HAVE_CMSG_XPG42=0
 HAVE_DIRENT_NAMLEN=
-HAVE_FGETLN=
+HAVE_EFTYPE=
+HAVE_ENDIAN=
+HAVE_ERR=
 HAVE_FTS=
+HAVE_FTS_COMPARE_CONST=
+HAVE_GETLINE=
 HAVE_GETSUBOPT=
-HAVE_MMAP=
+HAVE_ISBLANK=
+HAVE_MKDTEMP=
+HAVE_NANOSLEEP=
+HAVE_NTOHL=
+HAVE_O_DIRECTORY=
+HAVE_OHASH=
+HAVE_PATH_MAX=
+HAVE_PLEDGE=
+HAVE_PROGNAME=
 HAVE_REALLOCARRAY=
+HAVE_RECALLOCARRAY=
+HAVE_RECVMSG=
+HAVE_REWB_BSD=
+HAVE_REWB_SYSV=
+HAVE_SANDBOX_INIT=
 HAVE_STRCASESTR=
+HAVE_STRINGLIST=
 HAVE_STRLCAT=
 HAVE_STRLCPY=
+HAVE_STRNDUP=
 HAVE_STRPTIME=
 HAVE_STRSEP=
 HAVE_STRTONUM=
+HAVE_SYS_ENDIAN=
+HAVE_VASPRINTF=
 HAVE_WCHAR=
 
-HAVE_SQLITE3=
-HAVE_SQLITE3_ERRSTR=
-HAVE_OHASH=
-HAVE_MANPATH=
+NEED_GNU_SOURCE=0
+NEED_OPENBSD_SOURCE=0
 
 PREFIX="/usr/local"
 BINDIR=
 SBINDIR=
+BIN_FROM_SBIN=
 INCLUDEDIR=
 LIBDIR=
 MANDIR=
-EXAMPLEDIR=
 HOMEBREWDIR=
 
 WWWPREFIX="/var/www"
@@ -74,10 +107,13 @@ HTDOCDIR=
 CGIBINDIR=
 
 BINM_APROPOS="apropos"
+BINM_CATMAN="catman"
+BINM_MAKEWHATIS="makewhatis"
 BINM_MAN="man"
+BINM_SOELIM="soelim"
 BINM_WHATIS="whatis"
-BINM_MAKEWHATIS="makewhatis"
 MANM_MAN="man"
+MANM_MANCONF="man.conf"
 MANM_MDOC="mdoc"
 MANM_ROFF="roff"
 MANM_EQN="eqn"
@@ -88,31 +124,30 @@ INSTALL_PROGRAM=
 INSTALL_LIB=
 INSTALL_MAN=
 INSTALL_DATA=
+LN="ln -f"
 
 # --- manual settings from configure.local -----------------------------
 
-if [ -e ./configure.local ]; then
-	echo "configure.local: reading..." 1>&2
-	echo "configure.local: reading..." 1>&3
+if [ -r ./configure.local ]; then
+	echo "file configure.local: reading..." 1>&2
+	echo "file configure.local: reading..." 1>&3
 	cat ./configure.local 1>&3
 	. ./configure.local
 else
-	echo "configure.local: no (fully automatic configuration)" 1>&2
-	echo "configure.local: no (fully automatic configuration)" 1>&3
+	echo "file configure.local: no (fully automatic configuration)" 1>&2
+	echo "file configure.local: no (fully automatic configuration)" 1>&3
 fi
 echo 1>&3
 
-# --- tests for config.h  ----------------------------------------------
-
-COMP="${CC} ${CFLAGS} -Wno-unused -Werror"
+# --- tests functions --------------------------------------------------
 
 # Check whether this HAVE_ setting is manually overridden.
 # If yes, use the override, if no, do not decide anything yet.
-# Arguments: lower-case test name, manual value
+# Arguments: test file name, test var name, manual value
 ismanual() {
-	[ -z "${2}" ] && return 1
-	echo "${1}: manual (${2})" 1>&2
-	echo "${1}: manual (${2})" 1>&3
+	[ -z "${3}" ] && return 1
+	echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&2
+	echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&3
 	echo 1>&3
 	return 0
 }
@@ -120,30 +155,36 @@ ismanual() {
 # Run a single autoconfiguration test.
 # In case of success, enable the feature.
 # In case of failure, do not decide anything yet.
-# Arguments: lower-case test name, upper-case test name, additional CFLAGS
+# Arguments: test file name, test var name, additional CFLAGS
 singletest() {
+	n=${1}${3}${4}
 	cat 1>&3 << __HEREDOC__
-${1}: testing...
-${COMP} ${3} -o test-${1} test-${1}.c
+testing ${n} ...
+${COMP} -o test-${1} test-${1}.c ${3} ${4}
 __HEREDOC__
 
-	if ${COMP} ${3} -o "test-${1}" "test-${1}.c" 1>&3 2>&3; then
-		echo "${1}: ${CC} succeeded" 1>&3
+	if ${COMP} -o "test-${1}" "${SOURCEDIR}/test-${1}.c" ${3} ${4} 1>&3 2>&3
+	then
+		echo "partial result of ${n}: ${CC} succeeded" 1>&3
 	else
-		echo "${1}: ${CC} failed with $?" 1>&3
+		echo "result of ${n}: ${CC} failed with exit status $?" 1>&3
+		echo "result of compiling ${n}: no" 1>&3
 		echo 1>&3
 		return 1
 	fi
 
 	if ./test-${1} 1>&3 2>&3; then
-		echo "${1}: yes" 1>&2
-		echo "${1}: yes" 1>&3
+		echo "tested ${n}: yes" 1>&2
+		echo "result of running ${n}: yes" 1>&3
 		echo 1>&3
 		eval HAVE_${2}=1
+		[ "X$3" = "X-D_GNU_SOURCE" ] && NEED_GNU_SOURCE=1
+		[ "X$3" = "X-D_OPENBSD_SOURCE" ] && NEED_OPENBSD_SOURCE=1
 		rm "test-${1}"
 		return 0
 	else
-		echo "${1}: execution failed with $?" 1>&3
+		echo "result of ${n}: execution failed with exit status $?" 1>&3
+		echo "result of running ${n}: no" 1>&3
 		echo 1>&3
 		rm "test-${1}"
 		return 1
@@ -152,182 +193,313 @@ __HEREDOC__
 
 # Run a complete autoconfiguration test, including the check for
 # a manual override and disabling the feature on failure.
-# Arguments: lower case name, upper case name, additional CFLAGS
+# Arguments: test file name, test var name, additional CFLAGS
 runtest() {
 	eval _manual=\${HAVE_${2}}
-	ismanual "${1}" "${_manual}" && return 0
-	singletest "${1}" "${2}" "${3}" && return 0
-	echo "${1}: no" 1>&2
+	ismanual "${1}" "${2}" "${_manual}" && return 0
+	singletest "${1}" "${2}" "${3}" "${4}" && return 0
+	echo "tested ${1}${3}${4}: no" 1>&2
 	eval HAVE_${2}=0
 	return 1
 }
 
+# Select a UTF-8 locale.
+get_locale() {
+	[ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0
+	ismanual UTF8_LOCALE UTF8_LOCALE "$UTF8_LOCALE" && return 0
+	echo "testing UTF8_LOCALE ..." 1>&3
+	UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1`
+	if [ -z "${UTF8_LOCALE}" ]; then
+		UTF8_LOCALE=`locale -a | grep -i '\.UTF-*8' | head -n 1`
+		[ -n "${UTF8_LOCALE}" ] || return 1
+	fi
+	echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&2
+	echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&3
+	echo 1>&3
+	return 0;
+}
+
+# --- compiler options -------------------------------------------------
+
+DEFCFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter"
+
+if [ -n "${CFLAGS}" ]; then
+	COMP="${CC} ${CFLAGS} -Wno-unused -Werror"
+else
+	COMP="${CC} ${DEFCFLAGS} -Wno-unused -Werror"
+fi
+echo -n "tested ${CC} -W: " 1>&2
+echo -n "testing ${CC} -W: " 1>&3
+runtest noop WFLAG || true
+
+if [ -n "${CFLAGS}" ]; then
+	echo "CFLAGS specified manually:" 1>&3
+elif [ ${HAVE_WFLAG} -eq 0 ]; then
+	CFLAGS="-g"
+else
+	CFLAGS="${DEFCFLAGS}"
+fi
+echo "selected CFLAGS=\"${CFLAGS}\"" 1>&2
+echo "selected CFLAGS=\"${CFLAGS}\"" 1>&3
+echo 1>&3
+
+COMP="${CC} ${CFLAGS}"
+[ ${HAVE_WFLAG} -eq 0 ] || COMP="${COMP} -Wno-unused -Werror"
+
+if [ -n "${STATIC}" ]; then
+	echo "selected STATIC=\"${STATIC}\" (manual)" 1>&2
+	echo "selected STATIC=\"${STATIC}\" (manual)" 1>&3
+	echo 1>&3
+else
+	runtest noop STATIC -static || true
+	[ ${HAVE_STATIC} -eq 0 ] || STATIC="-static"
+	echo "selected STATIC=\"${STATIC}\"" 1>&2
+	echo "selected STATIC=\"${STATIC}\"" 1>&3
+	echo 1>&3
+fi
+
+# --- tests for config.h  ----------------------------------------------
+
 # --- 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 be32toh		ENDIAN		|| true
+runtest be32toh		SYS_ENDIAN	-DSYS_ENDIAN || true
+runtest EFTYPE		EFTYPE		|| true
+runtest err		ERR		|| true
+runtest getline		GETLINE		|| true
+singletest getsubopt	GETSUBOPT	|| \
+   runtest getsubopt	GETSUBOPT	-D_GNU_SOURCE || true
+runtest isblank		ISBLANK		|| true
+runtest mkdtemp		MKDTEMP		|| true
+runtest ntohl		NTOHL		|| true
+runtest O_DIRECTORY	O_DIRECTORY	|| true
+runtest PATH_MAX	PATH_MAX	|| true
+runtest pledge		PLEDGE		|| true
+runtest sandbox_init	SANDBOX_INIT	|| true
+runtest progname	PROGNAME	|| true
+singletest reallocarray	REALLOCARRAY	|| \
+   runtest reallocarray	REALLOCARRAY	-D_OPENBSD_SOURCE || true
+singletest recallocarray RECALLOCARRAY	|| \
+   runtest recallocarray RECALLOCARRAY	-D_OPENBSD_SOURCE || true
+runtest rewb-bsd	REWB_BSD	|| true
+runtest rewb-sysv	REWB_SYSV	|| true
+singletest strcasestr	STRCASESTR	|| \
+   runtest strcasestr	STRCASESTR	-D_GNU_SOURCE || true
+runtest stringlist	STRINGLIST	|| true
 runtest strlcat		STRLCAT		|| true
 runtest strlcpy		STRLCPY		|| true
-runtest strptime	STRPTIME	|| true
+runtest strndup		STRNDUP		|| true
+singletest strptime	STRPTIME	|| \
+   runtest strptime	STRPTIME	-D_GNU_SOURCE || true
 runtest strsep		STRSEP		|| true
-runtest strtonum	STRTONUM	|| 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"
+singletest strtonum	STRTONUM	|| \
+   runtest strtonum	STRTONUM	-D_OPENBSD_SOURCE || true
+singletest vasprintf	VASPRINTF	|| \
+   runtest vasprintf	VASPRINTF	-D_GNU_SOURCE || true
+
+if [ ${HAVE_ENDIAN} -eq 0 -a \
+     ${HAVE_SYS_ENDIAN} -eq 0 -a \
+     ${HAVE_NTOHL} -eq 0 ]; then
+	echo "FATAL: no endian conversion functions found" 1>&2
+	echo "FATAL: no endian conversion functions found" 1>&3
+	exit 1
+fi
+
+if ismanual fts FTS ${HAVE_FTS}; then
+	HAVE_FTS_COMPARE_CONST=0
+elif runtest fts FTS_COMPARE_CONST -DFTS_COMPARE_CONST; then
+	HAVE_FTS=1
+else
+	runtest fts FTS || true
 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
+
+# --- wide character and locale support ---
+if get_locale; then
+	singletest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || \
+	runtest wchar WCHAR -D_GNU_SOURCE \
+			    -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true
+else
+	HAVE_WCHAR=0
+	echo "tested wchar: no (no UTF8_LOCALE)" 1>&2
+	echo "tested wchar: no (no UTF8_LOCALE)" 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
+# --- nanosleep ---
+if [ -n "${LD_NANOSLEEP}" ]; then
+	runtest nanosleep NANOSLEEP "${LD_NANOSLEEP}" || true
+elif singletest nanosleep NANOSLEEP; then
 	:
-elif [ -n "${DBLIB}" ]; then
-	runtest sqlite3_errstr SQLITE3_ERRSTR "${DBLIB}" || true
-else
-	runtest sqlite3_errstr SQLITE3_ERRSTR "${DETECTLIB}" || true
+elif runtest nanosleep NANOSLEEP "-lrt"; then
+	LD_NANOSLEEP="-lrt"
+fi
+if [ "${HAVE_NANOSLEEP}" -eq 0 ]; then
+	echo "FATAL: nanosleep: no" 1>&2
+	echo "FATAL: nanosleep: no" 1>&3
+	exit 1
+fi
+
+if [ ${BUILD_CATMAN} -gt 0 ]; then
+	# --- recvmsg ---
+	if [ -n "${LD_RECVMSG}" ]; then
+		runtest recvmsg RECVMSG "${LD_RECVMSG}" || true
+	elif singletest recvmsg RECVMSG; then
+		:
+	elif runtest recvmsg RECVMSG "-lsocket"; then
+		LD_RECVMSG="-lsocket"
+	fi
+	if [ "${HAVE_RECVMSG}" -eq 0 ]; then
+		echo "FATAL: recvmsg: no" 1>&2
+		echo "FATAL: recvmsg: no" 1>&3
+		echo "Without recvmsg(2), you cannot BUILD_CATMAN." 1>&2
+		exit 1
+	fi
+
+	# --- cmsg ---
+	if singletest cmsg CMSG; then
+		:
+	elif runtest cmsg CMSG "-D_XPG4_2"; then
+		HAVE_CMSG_XPG42=1
+	fi
+	if [ "${HAVE_CMSG}" -eq 0 ]; then
+		echo "FATAL: cmsg: no" 1>&2
+		echo "FATAL: cmsg: no" 1>&3
+		echo "Without CMSG_FIRSTHDR(3), you cannot BUILD_CATMAN." 1>&2
+		exit 1
+	fi
 fi
 
 # --- ohash ---
-if [ ${BUILD_DB} -eq 0 ]; then
-	HAVE_OHASH=1
-elif ismanual ohash "${HAVE_OHASH}"; then
+if ismanual ohash OHASH "${HAVE_OHASH}"; then
 	:
-elif [ -n "${DBLIB}" ]; then
-	runtest ohash OHASH "${DBLIB}" || true
+elif [ -n "${LD_OHASH}" ]; then
+	runtest ohash OHASH "${LD_OHASH}" || true
 elif singletest ohash OHASH; then
 	:
 elif runtest ohash OHASH "-lutil"; then
-	DETECTLIB="${DETECTLIB} -lutil"
+	LD_OHASH="-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
+if [ "${HAVE_OHASH}" -eq 0 ]; then
+	LD_OHASH=
 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
+# --- LDADD ---
+LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz"
+echo "selected LDADD=\"${LDADD}\"" 1>&2
+echo "selected LDADD=\"${LDADD}\"" 1>&3
+echo 1>&3
 
 # --- write config.h ---
 
 exec > config.h
 
 cat << __HEREDOC__
-#ifndef MANDOC_CONFIG_H
-#define MANDOC_CONFIG_H
+#ifdef __cplusplus
+#error "Do not use C++.  See the INSTALL file."
+#endif
 
-#if defined(__linux__) || defined(__MINT__)
-#define _GNU_SOURCE	/* See test-*.c what needs this. */
+#if !defined(__GNUC__) || (__GNUC__ < 4)
+#define __attribute__(x)
 #endif
 
 __HEREDOC__
 
-[ ${HAVE_FGETLN} -eq 0 -o ${HAVE_REALLOCARRAY} -eq 0 -o \
-  ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 ] \
+[ ${NEED_GNU_SOURCE} -eq 0 ] || echo "#define _GNU_SOURCE"
+[ ${NEED_OPENBSD_SOURCE} -eq 0 ] || echo "#define _OPENBSD_SOURCE"
+
+[ ${HAVE_GETLINE} -eq 0 -o \
+  ${HAVE_REALLOCARRAY} -eq 0 -o ${HAVE_RECALLOCARRAY} -eq 0 -o \
+  ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 -o \
+  ${HAVE_STRNDUP} -eq 0 ] \
 	&& echo "#include <sys/types.h>"
-[ ${HAVE_FGETLN} -eq 0 ] && echo "#include <stdio.h>"
+[ ${HAVE_VASPRINTF} -eq 0 ] && echo "#include <stdarg.h>"
+[ ${HAVE_GETLINE} -eq 0 ] && echo "#include <stdio.h>"
 
 echo
+echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
+echo "#define MANPATH_BASE \"${MANPATH_BASE}\""
+echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
 [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
 [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
+[ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
+[ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
+[ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096"
+if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then
+	echo "#define be32toh ntohl"
+	echo "#define htobe32 htonl"
+fi
 
 cat << __HEREDOC__
+#define HAVE_CMSG_XPG42 ${HAVE_CMSG_XPG42}
 #define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN}
-#define HAVE_FGETLN ${HAVE_FGETLN}
+#define HAVE_ENDIAN ${HAVE_ENDIAN}
+#define HAVE_ERR ${HAVE_ERR}
 #define HAVE_FTS ${HAVE_FTS}
+#define HAVE_FTS_COMPARE_CONST ${HAVE_FTS_COMPARE_CONST}
+#define HAVE_GETLINE ${HAVE_GETLINE}
 #define HAVE_GETSUBOPT ${HAVE_GETSUBOPT}
-#define HAVE_MMAP ${HAVE_MMAP}
+#define HAVE_ISBLANK ${HAVE_ISBLANK}
+#define HAVE_MKDTEMP ${HAVE_MKDTEMP}
+#define HAVE_NTOHL ${HAVE_NTOHL}
+#define HAVE_PLEDGE ${HAVE_PLEDGE}
+#define HAVE_PROGNAME ${HAVE_PROGNAME}
 #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
+#define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
+#define HAVE_REWB_BSD ${HAVE_REWB_BSD}
+#define HAVE_REWB_SYSV ${HAVE_REWB_SYSV}
+#define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
 #define HAVE_STRCASESTR ${HAVE_STRCASESTR}
+#define HAVE_STRINGLIST ${HAVE_STRINGLIST}
 #define HAVE_STRLCAT ${HAVE_STRLCAT}
 #define HAVE_STRLCPY ${HAVE_STRLCPY}
+#define HAVE_STRNDUP ${HAVE_STRNDUP}
 #define HAVE_STRPTIME ${HAVE_STRPTIME}
 #define HAVE_STRSEP ${HAVE_STRSEP}
 #define HAVE_STRTONUM ${HAVE_STRTONUM}
+#define HAVE_SYS_ENDIAN ${HAVE_SYS_ENDIAN}
+#define HAVE_VASPRINTF ${HAVE_VASPRINTF}
 #define HAVE_WCHAR ${HAVE_WCHAR}
-#define HAVE_SQLITE3 ${HAVE_SQLITE3}
-#define HAVE_SQLITE3_ERRSTR ${HAVE_SQLITE3_ERRSTR}
 #define HAVE_OHASH ${HAVE_OHASH}
-#define HAVE_MANPATH ${HAVE_MANPATH}
 
 #define BINM_APROPOS "${BINM_APROPOS}"
+#define BINM_CATMAN "${BINM_CATMAN}"
+#define BINM_MAKEWHATIS "${BINM_MAKEWHATIS}"
 #define BINM_MAN "${BINM_MAN}"
+#define BINM_SOELIM "${BINM_SOELIM}"
 #define BINM_WHATIS "${BINM_WHATIS}"
-#define BINM_MAKEWHATIS "${BINM_MAKEWHATIS}"
-
-#if !defined(__BEGIN_DECLS)
-#  ifdef __cplusplus
-#  define	__BEGIN_DECLS		extern "C" {
-#  else
-#  define	__BEGIN_DECLS
-#  endif
-#endif
-#if !defined(__END_DECLS)
-#  ifdef __cplusplus
-#  define	__END_DECLS		}
-#  else
-#  define	__END_DECLS
-#  endif
-#endif
 
 __HEREDOC__
 
-[ ${HAVE_FGETLN} -eq 0 ] && \
-	echo "extern	char	 *fgetln(FILE *, size_t *);"
+if [ ${HAVE_ERR} -eq 0 ]; then
+	echo "extern	void	  err(int, const char *, ...);"
+	echo "extern	void	  errx(int, const char *, ...);"
+	echo "extern	void	  warn(const char *, ...);"
+	echo "extern	void	  warnx(const char *, ...);"
+fi
+
+[ ${HAVE_GETLINE} -eq 0 ] && \
+	echo "extern	ssize_t	  getline(char **, size_t *, FILE *);"
 
 [ ${HAVE_GETSUBOPT} -eq 0 ] && \
 	echo "extern	int	  getsubopt(char **, char * const *, char **);"
 
+[ ${HAVE_ISBLANK} -eq 0 ] && \
+	echo "extern	int	  isblank(int);"
+
+[ ${HAVE_MKDTEMP} -eq 0 ] && \
+	echo "extern	char	 *mkdtemp(char *);"
+
+if [ ${HAVE_PROGNAME} -eq 0 ]; then
+	echo "extern 	const char *getprogname(void);"
+	echo "extern	void	  setprogname(const char *);"
+fi
+
 [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
 	echo "extern	void	 *reallocarray(void *, size_t, size_t);"
 
-[ ${BUILD_DB} -gt 0 -a ${HAVE_SQLITE3_ERRSTR} -eq 0 ] &&
-	echo "extern	const char *sqlite3_errstr(int);"
+[ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
+	echo "extern	void	 *recallocarray(void *, size_t, size_t, size_t);"
 
 [ ${HAVE_STRCASESTR} -eq 0 ] && \
 	echo "extern	char	 *strcasestr(const char *, const char *);"
@@ -338,70 +510,76 @@ __HEREDOC__
 [ ${HAVE_STRLCPY} -eq 0 ] && \
 	echo "extern	size_t	  strlcpy(char *, const char *, size_t);"
 
+[ ${HAVE_STRNDUP} -eq 0 ] && \
+	echo "extern	char	 *strndup(const char *, size_t);"
+
 [ ${HAVE_STRSEP} -eq 0 ] && \
 	echo "extern	char	 *strsep(char **, const char *);"
 
 [ ${HAVE_STRTONUM} -eq 0 ] && \
 	echo "extern	long long strtonum(const char *, long long, long long, const char **);"
 
-echo
-echo "#endif /* MANDOC_CONFIG_H */"
+[ ${HAVE_VASPRINTF} -eq 0 ] && \
+	echo "extern	int	  vasprintf(char **, const char *, va_list);"
 
-echo "config.h: written" 1>&2
-echo "config.h: written" 1>&3
+echo "file config.h: written" 1>&2
+echo "file config.h: written" 1>&3
 
 # --- tests for Makefile.local -----------------------------------------
 
 exec > Makefile.local
 
-[ -z "${BINDIR}"     ] && BINDIR="${PREFIX}/bin"
-[ -z "${SBINDIR}"    ] && SBINDIR="${PREFIX}/sbin"
-[ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include/mandoc"
-[ -z "${LIBDIR}"     ] && LIBDIR="${PREFIX}/lib/mandoc"
-[ -z "${MANDIR}"     ] && MANDIR="${PREFIX}/man"
-[ -z "${EXAMPLEDIR}" ] && EXAMPLEDIR="${PREFIX}/share/examples/mandoc"
+[ -z "${BINDIR}"          ] && BINDIR="${PREFIX}/bin"
+[ -z "${SBINDIR}"         ] && SBINDIR="${PREFIX}/sbin"
+[ -z "${BIN_FROM_SBIN}"   ] && BIN_FROM_SBIN="../bin"
+[ -z "${INCLUDEDIR}"      ] && INCLUDEDIR="${PREFIX}/include/mandoc"
+[ -z "${LIBDIR}"          ] && LIBDIR="${PREFIX}/lib/mandoc"
+[ -z "${MANDIR}"          ] && MANDIR="${PREFIX}/man"
 
-[ -z "${HTDOCDIR}"   ] && HTDOCDIR="${WWWPREFIX}/htdocs"
-[ -z "${CGIBINDIR}"  ] && CGIBINDIR="${WWWPREFIX}/cgi-bin"
+[ -z "${HTDOCDIR}"        ] && HTDOCDIR="${WWWPREFIX}/htdocs"
+[ -z "${CGIBINDIR}"       ] && CGIBINDIR="${WWWPREFIX}/cgi-bin"
 
 [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
 [ -z "${INSTALL_LIB}"     ] && INSTALL_LIB="${INSTALL} -m 0444"
 [ -z "${INSTALL_MAN}"     ] && INSTALL_MAN="${INSTALL} -m 0444"
 [ -z "${INSTALL_DATA}"    ] && INSTALL_DATA="${INSTALL} -m 0444"
 
-if [ ${BUILD_DB} -eq 0 -a ${BUILD_CGI} -gt 0 ]; then
-	echo "BUILD_CGI=0 (no BUILD_DB)" 1>&2
-	echo "BUILD_CGI=0 (no BUILD_DB)" 1>&3
-	BUILD_CGI=0
-fi
-
-BUILD_TARGETS="base-build"
-[ ${BUILD_CGI} -gt 0 ] && BUILD_TARGETS="${BUILD_TARGETS} cgi-build"
-INSTALL_TARGETS="base-install"
-[ ${BUILD_DB}  -gt 0 ] && INSTALL_TARGETS="${INSTALL_TARGETS} db-install"
+BUILD_TARGETS=
+[ ${BUILD_CGI} -gt 0 ] && BUILD_TARGETS="man.cgi"
+[ ${BUILD_CATMAN} -gt 0 ] && \
+	BUILD_TARGETS="${BUILD_TARGETS} mandocd catman"
+INSTALL_TARGETS=
+[ ${INSTALL_LIBMANDOC} -gt 0 ] && INSTALL_TARGETS="lib-install"
 [ ${BUILD_CGI} -gt 0 ] && INSTALL_TARGETS="${INSTALL_TARGETS} cgi-install"
+[ ${BUILD_CATMAN} -gt 0 ] && \
+	INSTALL_TARGETS="${INSTALL_TARGETS} catman-install"
 
 cat << __HEREDOC__
 BUILD_TARGETS	= ${BUILD_TARGETS}
 INSTALL_TARGETS	= ${INSTALL_TARGETS}
+CC		= ${CC}
 CFLAGS		= ${CFLAGS}
-DBLIB		= ${DBLIB}
+LDADD		= ${LDADD}
+LDFLAGS		= ${LDFLAGS}
 STATIC		= ${STATIC}
 PREFIX		= ${PREFIX}
 BINDIR		= ${BINDIR}
 SBINDIR		= ${SBINDIR}
+BIN_FROM_SBIN	= ${BIN_FROM_SBIN}
 INCLUDEDIR	= ${INCLUDEDIR}
 LIBDIR		= ${LIBDIR}
 MANDIR		= ${MANDIR}
-EXAMPLEDIR	= ${EXAMPLEDIR}
 WWWPREFIX	= ${WWWPREFIX}
 HTDOCDIR	= ${HTDOCDIR}
 CGIBINDIR	= ${CGIBINDIR}
 BINM_APROPOS	= ${BINM_APROPOS}
+BINM_CATMAN	= ${BINM_CATMAN}
+BINM_MAKEWHATIS	= ${BINM_MAKEWHATIS}
 BINM_MAN	= ${BINM_MAN}
+BINM_SOELIM	= ${BINM_SOELIM}
 BINM_WHATIS	= ${BINM_WHATIS}
-BINM_MAKEWHATIS	= ${BINM_MAKEWHATIS}
 MANM_MAN	= ${MANM_MAN}
+MANM_MANCONF	= ${MANM_MANCONF}
 MANM_MDOC	= ${MANM_MDOC}
 MANM_ROFF	= ${MANM_ROFF}
 MANM_EQN	= ${MANM_EQN}
@@ -411,12 +589,10 @@ INSTALL_PROGRAM	= ${INSTALL_PROGRAM}
 INSTALL_LIB	= ${INSTALL_LIB}
 INSTALL_MAN	= ${INSTALL_MAN}
 INSTALL_DATA	= ${INSTALL_DATA}
+LN		= ${LN}
 __HEREDOC__
 
-[ ${BUILD_DB} -gt 0 ] && \
-	echo "MAIN_OBJS	= \$(BASE_OBJS) \$(DB_OBJS)"
-
-echo "Makefile.local: written" 1>&2
-echo "Makefile.local: written" 1>&3
+echo "file Makefile.local: written" 1>&2
+echo "file Makefile.local: written" 1>&3
 
 exit 0