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