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