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