xref: /freebsd/contrib/mandoc/configure (revision dc318a4ffabcbfa23bb56a33403aad36e6de30af)
1#!/bin/sh
2#
3# $Id: configure,v 1.71 2019/07/01 22:56:24 schwarze Exp $
4#
5# Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
6#
7# Permission to use, copy, modify, and distribute this software for any
8# purpose with or without fee is hereby granted, provided that the above
9# copyright notice and this permission notice appear in all copies.
10#
11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19set -e
20
21[ -w config.log ] && mv config.log config.log.old
22[ -w config.h   ] && mv config.h config.h.old
23
24# Output file descriptor usage:
25# 1 (stdout): config.h, Makefile.local
26# 2 (stderr): original stderr, usually to the console
27# 3: config.log
28
29exec 3> config.log
30echo "file config.log: writing..."
31
32# --- default settings -------------------------------------------------
33# Initialize all variables here,
34# such that nothing can leak in from the environment.
35
36SOURCEDIR=`dirname "$0"`
37
38MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
39MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
40OSENUM=
41OSNAME=
42UTF8_LOCALE=
43
44CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -`
45CFLAGS=
46LDADD=
47LDFLAGS=
48LD_NANOSLEEP=
49LD_OHASH=
50LD_RECVMSG=
51STATIC=
52
53BUILD_CGI=0
54BUILD_CATMAN=0
55INSTALL_LIBMANDOC=0
56
57HAVE_CMSG=
58HAVE_CMSG_XPG42=0
59HAVE_DIRENT_NAMLEN=
60HAVE_EFTYPE=
61HAVE_ENDIAN=
62HAVE_ERR=
63HAVE_FTS=
64HAVE_FTS_COMPARE_CONST=
65HAVE_GETLINE=
66HAVE_GETSUBOPT=
67HAVE_ISBLANK=
68HAVE_LESS_T=
69HAVE_MKDTEMP=
70HAVE_NANOSLEEP=
71HAVE_NTOHL=
72HAVE_O_DIRECTORY=
73HAVE_OHASH=
74HAVE_PATH_MAX=
75HAVE_PLEDGE=
76HAVE_PROGNAME=
77HAVE_REALLOCARRAY=
78HAVE_RECALLOCARRAY=
79HAVE_RECVMSG=
80HAVE_REWB_BSD=
81HAVE_REWB_SYSV=
82HAVE_SANDBOX_INIT=
83HAVE_STRCASESTR=
84HAVE_STRINGLIST=
85HAVE_STRLCAT=
86HAVE_STRLCPY=
87HAVE_STRNDUP=
88HAVE_STRPTIME=
89HAVE_STRSEP=
90HAVE_STRTONUM=
91HAVE_SYS_ENDIAN=
92HAVE_VASPRINTF=
93HAVE_WCHAR=
94
95NEED_GNU_SOURCE=0
96NEED_OPENBSD_SOURCE=0
97
98PREFIX="/usr/local"
99BINDIR=
100SBINDIR=
101BIN_FROM_SBIN=
102INCLUDEDIR=
103LIBDIR=
104MANDIR=
105HOMEBREWDIR=
106
107WWWPREFIX="/var/www"
108HTDOCDIR=
109CGIBINDIR=
110
111BINM_APROPOS="apropos"
112BINM_CATMAN="catman"
113BINM_MAKEWHATIS="makewhatis"
114BINM_MAN="man"
115BINM_SOELIM="soelim"
116BINM_WHATIS="whatis"
117MANM_MAN="man"
118MANM_MANCONF="man.conf"
119MANM_MDOC="mdoc"
120MANM_ROFF="roff"
121MANM_EQN="eqn"
122MANM_TBL="tbl"
123
124INSTALL="install"
125INSTALL_PROGRAM=
126INSTALL_LIB=
127INSTALL_MAN=
128INSTALL_DATA=
129LN="ln -f"
130
131# --- manual settings from configure.local -----------------------------
132
133if [ -r ./configure.local ]; then
134	echo "file configure.local: reading..." 1>&2
135	echo "file configure.local: reading..." 1>&3
136	cat ./configure.local 1>&3
137	. ./configure.local
138else
139	echo "file configure.local: no (fully automatic configuration)" 1>&2
140	echo "file configure.local: no (fully automatic configuration)" 1>&3
141fi
142echo 1>&3
143
144# --- tests functions --------------------------------------------------
145
146# Check whether this HAVE_ setting is manually overridden.
147# If yes, use the override, if no, do not decide anything yet.
148# Arguments: test file name, test var name, manual value
149ismanual() {
150	[ -z "${3}" ] && return 1
151	echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&2
152	echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&3
153	echo 1>&3
154	return 0
155}
156
157# Run a single autoconfiguration test.
158# In case of success, enable the feature.
159# In case of failure, do not decide anything yet.
160# Arguments: test file name, test var name, additional CFLAGS
161singletest() {
162	n=${1}${3}${4}
163	cat 1>&3 << __HEREDOC__
164testing ${n} ...
165${COMP} -o test-${1} test-${1}.c ${3} ${4}
166__HEREDOC__
167
168	if ${COMP} -o "test-${1}" "${SOURCEDIR}/test-${1}.c" ${3} ${4} 1>&3 2>&3
169	then
170		echo "partial result of ${n}: ${CC} succeeded" 1>&3
171	else
172		echo "result of ${n}: ${CC} failed with exit status $?" 1>&3
173		echo "result of compiling ${n}: no" 1>&3
174		echo 1>&3
175		return 1
176	fi
177
178	if ./test-${1} 1>&3 2>&3; then
179		echo "tested ${n}: yes" 1>&2
180		echo "result of running ${n}: yes" 1>&3
181		echo 1>&3
182		eval HAVE_${2}=1
183		[ "X$3" = "X-D_GNU_SOURCE" ] && NEED_GNU_SOURCE=1
184		[ "X$3" = "X-D_OPENBSD_SOURCE" ] && NEED_OPENBSD_SOURCE=1
185		rm "test-${1}"
186		return 0
187	else
188		echo "result of ${n}: execution failed with exit status $?" 1>&3
189		echo "result of running ${n}: no" 1>&3
190		echo 1>&3
191		rm "test-${1}"
192		return 1
193	fi
194}
195
196# Run a complete autoconfiguration test, including the check for
197# a manual override and disabling the feature on failure.
198# Arguments: test file name, test var name, additional CFLAGS
199runtest() {
200	eval _manual=\${HAVE_${2}}
201	ismanual "${1}" "${2}" "${_manual}" && return 0
202	singletest "${1}" "${2}" "${3}" "${4}" && return 0
203	echo "tested ${1}${3}${4}: no" 1>&2
204	eval HAVE_${2}=0
205	return 1
206}
207
208# Select a UTF-8 locale.
209get_locale() {
210	[ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0
211	ismanual UTF8_LOCALE UTF8_LOCALE "$UTF8_LOCALE" && return 0
212	echo "testing UTF8_LOCALE ..." 1>&3
213	UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1`
214	if [ -z "${UTF8_LOCALE}" ]; then
215		UTF8_LOCALE=`locale -a | grep -i '\.UTF-*8' | head -n 1`
216		[ -n "${UTF8_LOCALE}" ] || return 1
217	fi
218	echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&2
219	echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&3
220	echo 1>&3
221	return 0;
222}
223
224# --- operating system -------------------------------------------------
225
226if [ -n "${OSENUM}" ]; then
227	echo "OSENUM specified manually: ${OSENUM}" 1>&2
228	echo "OSENUM specified manually: ${OSENUM}" 1>&3
229else
230	OSDETECT=`uname`
231	if [ "X${OSDETECT}" = "XNetBSD" ]; then
232		OSENUM=MANDOC_OS_NETBSD
233	elif [ "X${OSDETECT}" = "XOpenBSD" ]; then
234		OSENUM=MANDOC_OS_OPENBSD
235	else
236		OSENUM=MANDOC_OS_OTHER
237	fi
238	echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&2
239	echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&3
240	unset OSDETECT
241fi
242echo 1>&3
243
244# --- compiler options -------------------------------------------------
245
246DEFCFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter"
247
248if [ -n "${CFLAGS}" ]; then
249	COMP="${CC} ${CFLAGS} -Wno-unused -Werror"
250else
251	COMP="${CC} ${DEFCFLAGS} -Wno-unused -Werror"
252fi
253echo -n "tested ${CC} -W: " 1>&2
254echo -n "testing ${CC} -W: " 1>&3
255runtest noop WFLAG || true
256
257if [ -n "${CFLAGS}" ]; then
258	echo "CFLAGS specified manually:" 1>&3
259elif [ ${HAVE_WFLAG} -eq 0 ]; then
260	CFLAGS="-g"
261else
262	CFLAGS="${DEFCFLAGS}"
263fi
264echo "selected CFLAGS=\"${CFLAGS}\"" 1>&2
265echo "selected CFLAGS=\"${CFLAGS}\"" 1>&3
266echo 1>&3
267
268COMP="${CC} ${CFLAGS}"
269[ ${HAVE_WFLAG} -eq 0 ] || COMP="${COMP} -Wno-unused -Werror"
270
271if [ -n "${STATIC}" ]; then
272	echo "selected STATIC=\"${STATIC}\" (manual)" 1>&2
273	echo "selected STATIC=\"${STATIC}\" (manual)" 1>&3
274	echo 1>&3
275else
276	runtest noop STATIC -static || true
277	[ ${HAVE_STATIC} -eq 0 ] || STATIC="-static"
278	echo "selected STATIC=\"${STATIC}\"" 1>&2
279	echo "selected STATIC=\"${STATIC}\"" 1>&3
280	echo 1>&3
281fi
282
283# --- tests for config.h  ----------------------------------------------
284
285# --- library functions ---
286runtest dirent-namlen	DIRENT_NAMLEN	|| true
287runtest be32toh		ENDIAN		|| true
288runtest be32toh		SYS_ENDIAN	-DSYS_ENDIAN || true
289runtest EFTYPE		EFTYPE		|| true
290runtest err		ERR		|| true
291runtest getline		GETLINE		|| true
292singletest getsubopt	GETSUBOPT	|| \
293   runtest getsubopt	GETSUBOPT	-D_GNU_SOURCE || true
294runtest isblank		ISBLANK		|| true
295runtest mkdtemp		MKDTEMP		|| true
296runtest ntohl		NTOHL		|| true
297runtest O_DIRECTORY	O_DIRECTORY	|| true
298runtest PATH_MAX	PATH_MAX	|| true
299runtest pledge		PLEDGE		|| true
300runtest sandbox_init	SANDBOX_INIT	|| true
301runtest progname	PROGNAME	|| true
302singletest reallocarray	REALLOCARRAY	|| \
303   runtest reallocarray	REALLOCARRAY	-D_OPENBSD_SOURCE || true
304singletest recallocarray RECALLOCARRAY	|| \
305   runtest recallocarray RECALLOCARRAY	-D_OPENBSD_SOURCE || true
306runtest rewb-bsd	REWB_BSD	|| true
307runtest rewb-sysv	REWB_SYSV	|| true
308singletest strcasestr	STRCASESTR	|| \
309   runtest strcasestr	STRCASESTR	-D_GNU_SOURCE || true
310runtest stringlist	STRINGLIST	|| true
311runtest strlcat		STRLCAT		|| true
312runtest strlcpy		STRLCPY		|| true
313runtest strndup		STRNDUP		|| true
314singletest strptime	STRPTIME	|| \
315   runtest strptime	STRPTIME	-D_GNU_SOURCE || true
316runtest strsep		STRSEP		|| true
317singletest strtonum	STRTONUM	|| \
318   runtest strtonum	STRTONUM	-D_OPENBSD_SOURCE || true
319singletest vasprintf	VASPRINTF	|| \
320   runtest vasprintf	VASPRINTF	-D_GNU_SOURCE || true
321
322if [ ${HAVE_ENDIAN} -eq 0 -a \
323     ${HAVE_SYS_ENDIAN} -eq 0 -a \
324     ${HAVE_NTOHL} -eq 0 ]; then
325	echo "FATAL: no endian conversion functions found" 1>&2
326	echo "FATAL: no endian conversion functions found" 1>&3
327	exit 1
328fi
329
330if ismanual fts FTS ${HAVE_FTS}; then
331	HAVE_FTS_COMPARE_CONST=0
332elif runtest fts FTS_COMPARE_CONST -DFTS_COMPARE_CONST; then
333	HAVE_FTS=1
334else
335	runtest fts FTS || true
336fi
337
338if ismanual "less -T" LESS_T ${HAVE_LESS_T}; then
339	:
340elif less -ET /dev/null test-noop.c 1>/dev/null 2>&3; then
341	HAVE_LESS_T=1
342	echo "tested less -T: yes" 1>&2
343	echo "tested less -T: yes" 1>&3
344	echo 1>&3
345else
346	HAVE_LESS_T=0
347	echo "tested less -T: no" 1>&2
348	echo "tested less -T: no" 1>&3
349	echo 1>&3
350fi
351
352# --- wide character and locale support ---
353if get_locale; then
354	singletest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || \
355	runtest wchar WCHAR -D_GNU_SOURCE \
356			    -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true
357else
358	HAVE_WCHAR=0
359	echo "tested wchar: no (no UTF8_LOCALE)" 1>&2
360	echo "tested wchar: no (no UTF8_LOCALE)" 1>&3
361	echo 1>&3
362fi
363
364# --- nanosleep ---
365if [ -n "${LD_NANOSLEEP}" ]; then
366	runtest nanosleep NANOSLEEP "${LD_NANOSLEEP}" || true
367elif singletest nanosleep NANOSLEEP; then
368	:
369elif runtest nanosleep NANOSLEEP "-lrt"; then
370	LD_NANOSLEEP="-lrt"
371fi
372if [ "${HAVE_NANOSLEEP}" -eq 0 ]; then
373	echo "FATAL: nanosleep: no" 1>&2
374	echo "FATAL: nanosleep: no" 1>&3
375	exit 1
376fi
377
378if [ ${BUILD_CATMAN} -gt 0 ]; then
379	# --- recvmsg ---
380	if [ -n "${LD_RECVMSG}" ]; then
381		runtest recvmsg RECVMSG "${LD_RECVMSG}" || true
382	elif singletest recvmsg RECVMSG; then
383		:
384	elif runtest recvmsg RECVMSG "-lsocket"; then
385		LD_RECVMSG="-lsocket"
386	fi
387	if [ "${HAVE_RECVMSG}" -eq 0 ]; then
388		echo "FATAL: recvmsg: no" 1>&2
389		echo "FATAL: recvmsg: no" 1>&3
390		echo "Without recvmsg(2), you cannot BUILD_CATMAN." 1>&2
391		exit 1
392	fi
393
394	# --- cmsg ---
395	if singletest cmsg CMSG; then
396		:
397	elif runtest cmsg CMSG "-D_XPG4_2"; then
398		HAVE_CMSG_XPG42=1
399	fi
400	if [ "${HAVE_CMSG}" -eq 0 ]; then
401		echo "FATAL: cmsg: no" 1>&2
402		echo "FATAL: cmsg: no" 1>&3
403		echo "Without CMSG_FIRSTHDR(3), you cannot BUILD_CATMAN." 1>&2
404		exit 1
405	fi
406fi
407
408# --- ohash ---
409if ismanual ohash OHASH "${HAVE_OHASH}"; then
410	:
411elif [ -n "${LD_OHASH}" ]; then
412	runtest ohash OHASH "${LD_OHASH}" || true
413elif singletest ohash OHASH; then
414	:
415elif runtest ohash OHASH "-lutil"; then
416	LD_OHASH="-lutil"
417fi
418if [ "${HAVE_OHASH}" -eq 0 ]; then
419	LD_OHASH=
420fi
421
422# --- LDADD ---
423LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz"
424echo "selected LDADD=\"${LDADD}\"" 1>&2
425echo "selected LDADD=\"${LDADD}\"" 1>&3
426echo 1>&3
427
428# --- write config.h ---
429
430exec > config.h
431
432cat << __HEREDOC__
433#ifdef __cplusplus
434#error "Do not use C++.  See the INSTALL file."
435#endif
436
437#if !defined(__GNUC__) || (__GNUC__ < 4)
438#define __attribute__(x)
439#endif
440
441__HEREDOC__
442
443[ ${NEED_GNU_SOURCE} -eq 0 ] || echo "#define _GNU_SOURCE"
444[ ${NEED_OPENBSD_SOURCE} -eq 0 ] || echo "#define _OPENBSD_SOURCE"
445
446[ ${HAVE_GETLINE} -eq 0 -o \
447  ${HAVE_REALLOCARRAY} -eq 0 -o ${HAVE_RECALLOCARRAY} -eq 0 -o \
448  ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 -o \
449  ${HAVE_STRNDUP} -eq 0 ] \
450	&& echo "#include <sys/types.h>"
451[ ${HAVE_VASPRINTF} -eq 0 ] && echo "#include <stdarg.h>"
452[ ${HAVE_GETLINE} -eq 0 ] && echo "#include <stdio.h>"
453
454echo
455echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
456echo "#define MANPATH_BASE \"${MANPATH_BASE}\""
457echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
458echo "#define OSENUM ${OSENUM}"
459[ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
460[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
461[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
462[ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
463[ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
464[ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096"
465if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then
466	echo "#define be32toh ntohl"
467	echo "#define htobe32 htonl"
468fi
469
470cat << __HEREDOC__
471#define HAVE_CMSG_XPG42 ${HAVE_CMSG_XPG42}
472#define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN}
473#define HAVE_ENDIAN ${HAVE_ENDIAN}
474#define HAVE_ERR ${HAVE_ERR}
475#define HAVE_FTS ${HAVE_FTS}
476#define HAVE_FTS_COMPARE_CONST ${HAVE_FTS_COMPARE_CONST}
477#define HAVE_GETLINE ${HAVE_GETLINE}
478#define HAVE_GETSUBOPT ${HAVE_GETSUBOPT}
479#define HAVE_ISBLANK ${HAVE_ISBLANK}
480#define HAVE_LESS_T ${HAVE_LESS_T}
481#define HAVE_MKDTEMP ${HAVE_MKDTEMP}
482#define HAVE_NTOHL ${HAVE_NTOHL}
483#define HAVE_PLEDGE ${HAVE_PLEDGE}
484#define HAVE_PROGNAME ${HAVE_PROGNAME}
485#define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
486#define HAVE_RECALLOCARRAY ${HAVE_RECALLOCARRAY}
487#define HAVE_REWB_BSD ${HAVE_REWB_BSD}
488#define HAVE_REWB_SYSV ${HAVE_REWB_SYSV}
489#define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
490#define HAVE_STRCASESTR ${HAVE_STRCASESTR}
491#define HAVE_STRINGLIST ${HAVE_STRINGLIST}
492#define HAVE_STRLCAT ${HAVE_STRLCAT}
493#define HAVE_STRLCPY ${HAVE_STRLCPY}
494#define HAVE_STRNDUP ${HAVE_STRNDUP}
495#define HAVE_STRPTIME ${HAVE_STRPTIME}
496#define HAVE_STRSEP ${HAVE_STRSEP}
497#define HAVE_STRTONUM ${HAVE_STRTONUM}
498#define HAVE_SYS_ENDIAN ${HAVE_SYS_ENDIAN}
499#define HAVE_VASPRINTF ${HAVE_VASPRINTF}
500#define HAVE_WCHAR ${HAVE_WCHAR}
501#define HAVE_OHASH ${HAVE_OHASH}
502
503#define BINM_APROPOS "${BINM_APROPOS}"
504#define BINM_CATMAN "${BINM_CATMAN}"
505#define BINM_MAKEWHATIS "${BINM_MAKEWHATIS}"
506#define BINM_MAN "${BINM_MAN}"
507#define BINM_SOELIM "${BINM_SOELIM}"
508#define BINM_WHATIS "${BINM_WHATIS}"
509
510__HEREDOC__
511
512if [ ${HAVE_ERR} -eq 0 ]; then
513	echo "extern	void	  err(int, const char *, ...);"
514	echo "extern	void	  errx(int, const char *, ...);"
515	echo "extern	void	  warn(const char *, ...);"
516	echo "extern	void	  warnx(const char *, ...);"
517fi
518
519[ ${HAVE_GETLINE} -eq 0 ] && \
520	echo "extern	ssize_t	  getline(char **, size_t *, FILE *);"
521
522[ ${HAVE_GETSUBOPT} -eq 0 ] && \
523	echo "extern	int	  getsubopt(char **, char * const *, char **);"
524
525[ ${HAVE_ISBLANK} -eq 0 ] && \
526	echo "extern	int	  isblank(int);"
527
528[ ${HAVE_MKDTEMP} -eq 0 ] && \
529	echo "extern	char	 *mkdtemp(char *);"
530
531if [ ${HAVE_PROGNAME} -eq 0 ]; then
532	echo "extern	const char *getprogname(void);"
533	echo "extern	void	  setprogname(const char *);"
534fi
535
536[ ${HAVE_REALLOCARRAY} -eq 0 ] && \
537	echo "extern	void	 *reallocarray(void *, size_t, size_t);"
538
539[ ${HAVE_RECALLOCARRAY} -eq 0 ] && \
540	echo "extern	void	 *recallocarray(void *, size_t, size_t, size_t);"
541
542[ ${HAVE_STRCASESTR} -eq 0 ] && \
543	echo "extern	char	 *strcasestr(const char *, const char *);"
544
545[ ${HAVE_STRLCAT} -eq 0 ] && \
546	echo "extern	size_t	  strlcat(char *, const char *, size_t);"
547
548[ ${HAVE_STRLCPY} -eq 0 ] && \
549	echo "extern	size_t	  strlcpy(char *, const char *, size_t);"
550
551[ ${HAVE_STRNDUP} -eq 0 ] && \
552	echo "extern	char	 *strndup(const char *, size_t);"
553
554[ ${HAVE_STRSEP} -eq 0 ] && \
555	echo "extern	char	 *strsep(char **, const char *);"
556
557[ ${HAVE_STRTONUM} -eq 0 ] && \
558	echo "extern	long long strtonum(const char *, long long, long long, const char **);"
559
560[ ${HAVE_VASPRINTF} -eq 0 ] && \
561	echo "extern	int	  vasprintf(char **, const char *, va_list);"
562
563echo "file config.h: written" 1>&2
564echo "file config.h: written" 1>&3
565
566# --- tests for Makefile.local -----------------------------------------
567
568exec > Makefile.local
569
570[ -z "${BINDIR}"          ] && BINDIR="${PREFIX}/bin"
571[ -z "${SBINDIR}"         ] && SBINDIR="${PREFIX}/sbin"
572[ -z "${BIN_FROM_SBIN}"   ] && BIN_FROM_SBIN="../bin"
573[ -z "${INCLUDEDIR}"      ] && INCLUDEDIR="${PREFIX}/include/mandoc"
574[ -z "${LIBDIR}"          ] && LIBDIR="${PREFIX}/lib/mandoc"
575[ -z "${MANDIR}"          ] && MANDIR="${PREFIX}/man"
576
577[ -z "${HTDOCDIR}"        ] && HTDOCDIR="${WWWPREFIX}/htdocs"
578[ -z "${CGIBINDIR}"       ] && CGIBINDIR="${WWWPREFIX}/cgi-bin"
579
580[ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
581[ -z "${INSTALL_LIB}"     ] && INSTALL_LIB="${INSTALL} -m 0444"
582[ -z "${INSTALL_MAN}"     ] && INSTALL_MAN="${INSTALL} -m 0444"
583[ -z "${INSTALL_DATA}"    ] && INSTALL_DATA="${INSTALL} -m 0444"
584
585BUILD_TARGETS=
586[ ${BUILD_CGI} -gt 0 ] && BUILD_TARGETS="man.cgi"
587[ ${BUILD_CATMAN} -gt 0 ] && \
588	BUILD_TARGETS="${BUILD_TARGETS} mandocd catman"
589INSTALL_TARGETS=
590[ ${INSTALL_LIBMANDOC} -gt 0 ] && INSTALL_TARGETS="lib-install"
591[ ${BUILD_CGI} -gt 0 ] && INSTALL_TARGETS="${INSTALL_TARGETS} cgi-install"
592[ ${BUILD_CATMAN} -gt 0 ] && \
593	INSTALL_TARGETS="${INSTALL_TARGETS} catman-install"
594
595cat << __HEREDOC__
596BUILD_TARGETS	= ${BUILD_TARGETS}
597INSTALL_TARGETS	= ${INSTALL_TARGETS}
598CC		= ${CC}
599CFLAGS		= ${CFLAGS}
600LDADD		= ${LDADD}
601LDFLAGS		= ${LDFLAGS}
602STATIC		= ${STATIC}
603PREFIX		= ${PREFIX}
604BINDIR		= ${BINDIR}
605SBINDIR		= ${SBINDIR}
606BIN_FROM_SBIN	= ${BIN_FROM_SBIN}
607INCLUDEDIR	= ${INCLUDEDIR}
608LIBDIR		= ${LIBDIR}
609MANDIR		= ${MANDIR}
610WWWPREFIX	= ${WWWPREFIX}
611HTDOCDIR	= ${HTDOCDIR}
612CGIBINDIR	= ${CGIBINDIR}
613BINM_APROPOS	= ${BINM_APROPOS}
614BINM_CATMAN	= ${BINM_CATMAN}
615BINM_MAKEWHATIS	= ${BINM_MAKEWHATIS}
616BINM_MAN	= ${BINM_MAN}
617BINM_SOELIM	= ${BINM_SOELIM}
618BINM_WHATIS	= ${BINM_WHATIS}
619MANM_MAN	= ${MANM_MAN}
620MANM_MANCONF	= ${MANM_MANCONF}
621MANM_MDOC	= ${MANM_MDOC}
622MANM_ROFF	= ${MANM_ROFF}
623MANM_EQN	= ${MANM_EQN}
624MANM_TBL	= ${MANM_TBL}
625INSTALL		= ${INSTALL}
626INSTALL_PROGRAM	= ${INSTALL_PROGRAM}
627INSTALL_LIB	= ${INSTALL_LIB}
628INSTALL_MAN	= ${INSTALL_MAN}
629INSTALL_DATA	= ${INSTALL_DATA}
630LN		= ${LN}
631__HEREDOC__
632
633echo "file Makefile.local: written" 1>&2
634echo "file Makefile.local: written" 1>&3
635
636exit 0
637