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