Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2021, 2022, 2023 Omar Polo <op@omarpolo.com>
4 # Copyright (c) 2011, 2013-2022 Ingo Schwarze <schwarze@openbsd.org>
5 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
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.
19 set -e
21 RELEASE=no
22 VERSION=2.0.5-current
24 usage()
25 {
26 echo "usage: $0 [--help] [--prefix=prefix] [OPTION=VALUE...]" >&2
27 exit 1
28 }
30 if command -v yacc 2>/dev/null >&2; then
31 YACC=yacc
32 elif command -v bison 2>/dev/null >&2; then
33 YACC=bison
34 else
35 # assume yacc by default. Make will fail building parse.y if
36 # not from a release tarball, but at least it'll have a decent
37 # error message.
38 YACC=yacc
39 fi
41 pkgconfig=
43 CC=${CC:-cc}
45 if [ "$RELEASE" = no ]; then
46 CFLAGS=${CFLAGS:--O0 -g3}
47 else
48 CFLAGS=${CFLAGS:--O2 -pipe}
49 fi
51 INSTALL=${INSTALL-install}
52 PREFIX=${PREFIX-/usr/local}
53 SYSCONFDIR=${SYSCONFDIR-/etc}
55 CDIAGFLAGS=
56 CDIAGFLAGS="${CDIAGFLAGS} -W -Wall -Wextra -Wpointer-arith -Wuninitialized"
57 CDIAGFLAGS="${CDIAGFLAGS} -Wstrict-prototypes -Wmissing-prototypes -Wunused"
58 CDIAGFLAGS="${CDIAGFLAGS} -Wsign-compare -Wno-unused-parameter" # -Wshadow
59 CDIAGFLAGS="${CDIAGFLAGS} -Wno-missing-field-initializers"
60 CDIAGFLAGS="${CDIAGFLAGS} -Wno-pointer-sign"
62 # On all OSes except OpenBSD use the bundled one. It may crash at
63 # runtime otherwise since we depend on the libtls internals for the
64 # privsep crypto engine.
65 # See <https://codeberg.org/op/gmid/issues/2>.
66 LIBTLS=bundled # or system
67 if [ "$(uname || true)" = OpenBSD ]; then
68 LIBTLS=system
69 fi
71 while [ $# -gt 0 ]; do
72 key="${1%%=*}"
73 val="${1#*=}"
75 if [ "$key" = --help ]; then
76 usage
77 fi
79 if [ "$key" = -Werror ]; then
80 CDIAGFLAGS="$CDIAGFLAGS -Werror"
81 shift
82 continue
83 fi
85 if [ "$key" = --enable-sandbox ]; then
86 key=DISABLE_SANDBOX
87 val=0
88 fi
90 if [ "$key" = --disable-sandbox ]; then
91 key=DISABLE_SANDBOX
92 val=1
93 fi
95 if [ "$key" = "$1" ]; then
96 # if no --xy=, look at the next arg
97 if ! shift 2>/dev/null; then
98 echo "$0: missing value for $key" >&2
99 exit 1
100 fi
101 val="$1"
102 fi
104 case "$key" in
105 --bindir) key=BINDIR ;;
106 --mandir) key=MANDIR ;;
107 --prefix) key=PREFIX ;;
108 --sysconfdir) key=SYSCONFDIR ;;
109 --with-libtls) key=LIBTLS ;;
110 esac
112 case "$key" in
113 LIBTLS)
114 case "$val" in
115 bundled) LIBTLS=bundled ;;
116 system) LIBTLS=system ;;
117 *) usage ;;
118 esac
119 ;;
120 BINDIR) BINDIR="$val" ;;
121 CC) CC="$val" ;;
122 CFLAGS) CFLAGS="$val" ;;
123 CDIAGFLAGS) CDIAGFLAGS="$val" ;;
124 DISABLE_SANDBOX) DISABLE_SANDBOX="$val" ;;
125 INSTALL) INSTALL="$val" ;;
126 LDFLAGS) LDFLAGS="$val" ;;
127 MANDIR) MANDIR="$val" ;;
128 PKG_CONFIG) PKG_CONFIG="$val" ;;
129 PREFIX) PREFIX="$val" ;;
130 SYSCONFDIR) SYSCONFDIR="$val" ;;
131 YACC) YACC="$val" ;;
132 *) usage
133 esac
135 shift
136 done
138 [ -w config.log ] && mv config.log config.log.old
139 [ -w config.h ] && mv config.h config.h.old
141 exec 3> config.log
142 echo "file config.log: writing..."
144 echo "running as ./configure $@" >&3
145 echo "on $(uname -a)" >&3
146 echo "" >&3
148 NEED_GNU_SOURCE=0
149 NEED_OPENBSD_SOURCE=0
151 COMPATS=
152 COMP="${CC} ${CFLAGS} -Werror=implicit-function-declaration"
154 # singletest name var extra-cflags extra-libs msg
155 singletest() {
156 msg="$5"
157 if [ -z "$msg" ]; then
158 if [ -n "$3" ]; then
159 msg=" ($3)"
160 elif [ -n "$4" ]; then
161 msg=" ($4)"
162 fi
163 elif [ "$msg" = no ]; then
164 msg=""
165 fi
167 cat >&3 <<EOF
168 ${1}: testing...
169 $COMP have/${1}.c $3 -o test-$1 $LDFLAGS $4
170 EOF
171 if $COMP have/${1}.c $3 -o test-$1 $LDFLAGS $4 >&3 2>&3; then
172 rm -f test-${1} test-${1}.d
174 echo "${1}: $CC$msg succeeded" >&3
175 echo "${1}$msg: yes"
176 echo >&3
178 return 0
179 fi
181 echo "${1}: $CC$msg failed $?" >&3
182 echo "${1}$msg: no"
183 echo >&3
185 return 1
188 # deptest name var
189 deptest() {
190 if singletest "$1" "$2" "${CFLAGS}" "${LIBS}" no; then
191 eval HAVE_${2}=1
192 return 0
193 fi
195 if [ -f compat/${1}.c ]; then
196 COMPATS="compat/$1.c $COMPATS"
197 fi
199 eval HAVE_${2}=0
200 return 1
203 # runtest name var extra-cflags extra-libs pkgconfig-name
204 runtest() {
205 if singletest "$1" "$2" "" ""; then
206 eval HAVE_${2}=1
207 return 0
208 fi
210 if [ -n "$3" -o -n "$4" ]; then
211 echo "retrying with ${3+$3 }$4" >&3
212 if singletest "$1" "$2" "$3" "$4"; then
213 eval HAVE_${2}=1
214 if [ "$3" = -D_GNU_SOURCE ]; then
215 NEED_GNU_SOURCE=1
216 return 0
217 fi
218 if [ "$4" = -D_OPENBSD_SOURCE ]; then
219 NEED_OPENBSD_SOURCE=1
220 return 0
221 fi
222 if [ -n "$3" ]; then
223 CFLAGS="$CFLAGS $3"
224 fi
225 if [ -n "$4" ]; then
226 LIBS="$LIBS $4"
227 fi
228 return 0
229 fi
230 fi
232 if [ -n "$5" -a -n "$pkgconfig" ]; then
233 if $pkgconfig $5; then
234 cflags="$($pkgconfig --cflags $5)"
235 ldflags="$($pkgconfig --libs $5)"
236 echo "retrying with pkg-config" >&3
237 if singletest "$1" "$2" "$cflags" "$ldflags"; then
238 CFLAGS="$CFLAGS $cflags"
239 LIBS="$LIBS $ldflags"
240 eval HAVE_$2=1
241 return 0
242 fi
243 fi
244 fi
246 if [ -f compat/$1.c ]; then
247 COMPATS="compat/$1.c $COMPATS"
248 fi
250 eval HAVE_$2=0
251 return 1
254 if [ "$PKG_CONFIG" = no ]; then
255 echo "pkg-config: disabled"
256 elif [ -n "$PKG_CONFIG" ]; then
257 pkgconfig="$PKG_CONFIG"
258 echo "pkg-config: (manual) $PKG_CONFIG"
259 elif command -v pkg-config 2>/dev/null >&2; then
260 pkgconfig="pkg-config"
261 echo "pkg-config: (auto) pkg-config"
262 else
263 echo "pkg-config: not found"
264 fi
266 if singletest noop MMD -MMD; then
267 CFLAGS="${CFLAGS} -MMD"
268 fi
270 if ! runtest wait_any WAIT_ANY; then
271 CFLAGS="${CFLAGS} -DWAIT_ANY=-1"
272 fi
274 HAVE_ENDIAN_H=0
275 HAVE_SYS_ENDIAN_H=0
276 HAVE_MACHINE_ENDIAN=0
278 runtest endian_h ENDIAN_H || \
279 runtest sys_endian_h SYS_ENDIAN_H || \
280 runtest machine_endian MACHINE_ENDIAN || true
282 if [ ${HAVE_ENDIAN_H} -eq 0 -a \
283 ${HAVE_SYS_ENDIAN_H} -eq 0 -a \
284 ${HAVE_MACHINE_ENDIAN} -eq 0 ]; then
285 echo "FATAL: no endian header found" 1>&2
286 echo "FATAL: no endian header found" 1>&3
287 exit 1
288 fi
290 runtest arc4random ARC4RANDOM || true
291 runtest arc4random_buf ARC4RANDOM_BUF || true
292 runtest err ERR || true
293 runtest explicit_bzero EXPLICIT_BZERO || true
294 runtest freezero FREEZERO || true
295 runtest getdtablecount GETDTABLECOUNT || true
296 runtest getdtablesize GETDTABLESIZE || true
297 runtest getprogname GETPROGNAME || true
298 runtest imsg IMSG "" -lutil libimsg || true
299 runtest landlock LANDLOCK || true
300 runtest libevent LIBEVENT "" -levent libevent_core|| true
301 runtest memmem MEMMEM -D_GNU_SOURCE || true
302 runtest openssl OPENSSL "" '-lcrypto -lssl' 'libcrypto libssl' || true
303 runtest pr_set_name PR_SET_NAME || true
304 runtest program_invocation_short_name PROGRAM_INVOCATION_SHORT_NAME -D_GNU_SOURCE || true
305 runtest queue_h QUEUE_H || true
306 runtest reallocarray REALLOCARRAY -D_OPENBSD_SOURCE || true
307 runtest recallocarray RECALLOCARRAY || true
308 runtest setproctitle SETPROCTITLE || true
309 runtest setresgid SETRESGID -D_GNU_SOURCE || true
310 runtest setresuid SETRESUID -D_GNU_SOURCE || true
311 runtest strlcat STRLCAT || true
312 runtest strlcpy STRLCPY || true
313 runtest strtonum STRTONUM -D_OPENBSD_SOURCE || true
314 runtest timingsafe_memcmp TIMINGSAFE_MEMCMP || true
315 runtest tree_h TREE_H || true
316 runtest vasprintf VASPRINTF -D_GNU_SOURCE || true
318 # strnvis is a bit special since NetBSD, FreeBSD and MacOS have
319 # the broken version with the wrong semantics and arguments.
320 # Hence the -Wall -Werror check.
321 if ! singletest strnvis STRNVIS "-Wall -Werror"; then
322 CFLAGS="-I ${PWD}/compat/vis ${CFLAGS} ${CFLAGS}"
323 COMPATS="compat/vis.c ${COMPATS}"
324 fi
326 if [ ${HAVE_ARC4RANDOM} -eq 1 -a ${HAVE_ARC4RANDOM_BUF} -eq 0 ]; then
327 COMPATS="compat/arc4random.c ${COMPATS}"
328 fi
330 if [ ${HAVE_ARC4RANDOM} -eq 0 ]; then
331 runtest getentropy GETENTROPY || true
332 else
333 # fake it
334 HAVE_GETENTROPY=1
335 fi
337 if [ ${HAVE_ARC4RANDOM} -eq 0 -a ${HAVE_GETENTROPY} -eq 1 ]; then
338 COMPATS="compat/getentropy.c ${COMPATS}"
339 fi
341 if [ "${LIBTLS}" = system ]; then
342 runtest libtls LIBTLS "" -ltls libtls || true
344 # not actually needed
345 HAVE_ASN1_TIME_TM_CMP=1
346 HAVE_ASN1_TIME_TM_CLAMP_NOTAFTER=1
347 HAVE_ASN1_TIME_PARSE=1
348 HAVE_SSL_CTX_UCCM=1
349 HAVE_SSL_CTX_LVM=1
350 HAVE_X509_LOOKUP_MEM=1
351 else
352 # use bundled one
353 HAVE_LIBTLS=1
354 for f in compat/libtls/*.c; do
355 COMPATS="$f ${COMPATS}"
356 done
358 CFLAGS="-Icompat/libtls -I../compat/libtls ${CFLAGS}"
360 deptest ASN1_time_tm_cmp ASN1_TIME_TM_CMP || true
361 deptest ASN1_time_tm_clamp_notafter ASN1_TIME_TM_CLAMP_NOTAFTER || true
362 deptest ASN1_time_parse ASN1_TIME_PARSE || true
363 deptest SSL_CTX_use_certificate_chain_mem SSL_CTX_UCCM || true
364 deptest SSL_CTX_load_verify_mem SSL_CTX_LVM || true
365 deptest X509_LOOKUP_mem X509_LOOKUP_MEM || true
366 fi
368 deptest libevent2 LIBEVENT2 || true
370 if [ ${HAVE_LIBTLS} -eq 0 ]; then
371 echo "FATAL: openssl not found" 1>&2
372 echo "FATAL: openssl not found" 1>&3
373 exit 1
374 fi
376 if [ ${HAVE_OPENSSL} -eq 0 ]; then
377 echo "FATAL: openssl not found" 1>&2
378 echo "FATAL: openssl not found" 1>&3
379 exit 1
380 fi
382 if [ ${HAVE_LIBEVENT} -eq 0 ]; then
383 echo "FATAL: libevent not found" 1>&2
384 echo "FATAL: libevent not found" 1>&3
385 exit 1
386 fi
388 if [ ${HAVE_IMSG} -eq 0 ]; then
389 # compat/imsg.c is implicitly added
390 COMPATS="$COMPATS compat/imsg-buffer.c"
391 fi
393 if [ ${HAVE_QUEUE_H} -eq 0 -o ${HAVE_IMSG} -eq 0 -o ${HAVE_TREE_H} -eq 0 ]; then
394 CFLAGS="${CFLAGS} -I ${PWD}/compat"
395 fi
397 if [ $HAVE_LIBEVENT2 -eq 1 ]; then
398 CFLAGS="$CFLAGS -DHAVE_LIBEVENT2=1"
399 fi
401 if [ $NEED_GNU_SOURCE = 1 ]; then
402 CFLAGS="$CFLAGS -D_GNU_SOURCE"
403 fi
404 if [ $NEED_OPENBSD_SOURCE = 1 ]; then
405 CFLAGS="$CFLAGS -D_OPENBSD_SOURCE"
406 fi
408 CFLAGS="-I. ${CFLAGS} ${CDIAGFLAGS}"
410 exec > config.h
411 echo "config.h: writing.." >&2
413 cat <<__HEREDOC__
414 #ifdef __cplusplus
415 #error "Do not use C++."
416 #endif
417 __HEREDOC__
419 [ ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 -o ${HAVE_IMSG} -eq 0 ] \
420 && echo "#include <sys/types.h>"
421 [ ${HAVE_VASPRINTF} -eq 0 ] && echo "#include <stdarg.h>"
423 if [ ${HAVE_QUEUE_H} -eq 1 ]; then
424 echo "#include <sys/queue.h>"
425 else
426 echo "#include <queue.h>"
427 fi
429 if [ ${HAVE_TREE_H} -eq 1 ]; then
430 echo "#include <sys/tree.h>"
431 else
432 echo "#include <tree.h>"
433 fi
435 echo "#include <sys/types.h>"
436 echo "#include <sys/uio.h>"
437 echo "#include <stdint.h>"
438 echo "#include <imsg.h>"
439 echo "#include <limits.h>"
441 cat <<__HEREDOC__
443 #define VERSION "${VERSION}"
444 #define DISABLE_SANDBOX ${DISABLE_SANDBOX}
445 #define HAVE_LANDLOCK ${HAVE_LANDLOCK}
447 #ifndef SYSCONFDIR
448 # define SYSCONFDIR "${SYSCONFDIR}"
449 #endif
451 __HEREDOC__
453 if [ ${HAVE_ENDIAN_H} -eq 1 ]; then
454 echo "#include <endian.h>"
455 elif [ ${HAVE_SYS_ENDIAN_H} -eq 1 ]; then
456 echo "#include <sys/endian.h>"
457 elif [ ${HAVE_MACHINE_ENDIAN} -eq 1 ]; then
458 cat <<__HEREDOC__
459 #include <machine/endian.h>
460 #include <libkern/OSByteOrder.h>
462 # define htobe16(x) OSSwapHostToBigInt16(x)
463 # define htole16(x) OSSwapHostToLittleInt16(x)
464 # define be16toh(x) OSSwapBigToHostInt16(x)
465 # define le16toh(x) OSSwapLittleToHostInt16(x)
467 # define htobe32(x) OSSwapHostToBigInt32(x)
468 # define htole32(x) OSSwapHostToLittleInt32(x)
469 # define be32toh(x) OSSwapBigToHostInt32(x)
470 # define le32toh(x) OSSwapLittleToHostInt32(x)
472 # define htobe64(x) OSSwapHostToBigInt64(x)
473 # define htole64(x) OSSwapHostToLittleInt64(x)
474 # define be64toh(x) OSSwapBigToHostInt64(x)
475 # define le64toh(x) OSSwapLittleToHostInt64(x)
476 __HEREDOC__
477 fi
479 [ ${HAVE_ARC4RANDOM_BUF} -eq 0 -o \
480 ${HAVE_ASN1_TIME_PARSE} -eq 0 -o \
481 ${HAVE_EXPLICIT_BZERO} -eq 0 -o \
482 ${HAVE_FREEZERO} -eq 0 -o \
483 ${HAVE_GETENTROPY} -eq 0 -o \
484 ${HAVE_REALLOCARRAY} -eq 0 -o \
485 ${HAVE_RECALLOCARRAY} -eq 0 -o \
486 ${HAVE_STRLCAT} -eq 0 -o \
487 ${HAVE_STRLCPY} -eq 0 -o \
488 ${HAVE_STRTONUM} -eq 0 -o \
489 ${HAVE_TIMINGSAFE_MEMCMP} -eq 0 ] && echo "#include <stddef.h>"
491 [ ${HAVE_ARC4RANDOM} -eq 0 ] && echo "#include <stdint.h>"
493 [ ${HAVE_SETRESGID} -eq 0 -o \
494 ${HAVE_SETRESUID} -eq 0 ] && echo "#include <unistd.h>"
496 if [ ${HAVE_GETENTROPY} -eq 1 ]; then
497 echo "#define HAVE_GETENTROPY 1"
498 else
499 echo "#define WITH_OPENSSL 1"
500 echo "#define OPENSSL_PRNG_ONLY 1"
501 fi
503 if [ ${HAVE_ARC4RANDOM} -eq 0 ]; then
504 echo "extern uint32_t arc4random(void);"
505 else
506 echo "#define HAVE_ARC4RANDOM 1"
507 fi
508 if [ ${HAVE_ARC4RANDOM_BUF} -eq 0 ]; then
509 echo "extern void arc4random_buf(void *, size_t);"
510 else
511 echo "#define HAVE_ARC4RANDOM_BUF 1"
512 fi
514 if [ ${HAVE_ASN1_TIME_TM_CMP} -eq 0 ]; then
515 echo "struct tm;"
516 echo "extern int ASN1_time_tm_cmp(struct tm *, struct tm *);"
517 else
518 echo "#define HAVE_ASN1_TIME_TM_CMP 1"
519 fi
521 if [ ${HAVE_ASN1_TIME_TM_CLAMP_NOTAFTER} -eq 0 ]; then
522 echo "struct tm;"
523 echo "extern int ASN1_time_tm_clamp_notafter(struct tm *);"
524 else
525 echo "#define HAVE_ASN1_TIME_TM_CLAMP_NOTAFTER 1"
526 fi
528 if [ ${HAVE_ASN1_TIME_PARSE} -eq 0 ]; then
529 echo "struct tm;"
530 echo "extern int ASN1_time_parse(const char *, size_t, struct tm *, int);"
531 else
532 echo "#define HAVE_ASN1_TIME_PARSE 1"
533 fi
535 if [ ${HAVE_ERR} -eq 0 ]; then
536 echo "extern void err(int, const char*, ...);"
537 echo "extern void errx(int, const char*, ...);"
538 echo "extern void warn(const char*, ...);"
539 echo "extern void warnx(const char*, ...);"
540 else
541 echo "#include <err.h>"
542 fi
543 if [ ${HAVE_EXPLICIT_BZERO} -eq 0 ]; then
544 echo "extern void explicit_bzero(void*, size_t);"
545 fi
546 if [ ${HAVE_FREEZERO} -eq 0 ]; then
547 echo "extern void freezero(void*, size_t);"
548 fi
549 if [ ${HAVE_GETDTABLECOUNT} -eq 0 ]; then
550 echo "extern int getdtablecount(void);"
551 fi
552 if [ ${HAVE_GETDTABLESIZE} -eq 0 ]; then
553 echo "extern int getdtablesize(void);"
554 fi
555 if [ ${HAVE_GETENTROPY} -eq 0 ]; then
556 echo "extern int getentropy(void *, size_t);"
557 fi
558 if [ ${HAVE_GETPROGNAME} -eq 0 ]; then
559 echo "extern const char *getprogname(void);"
560 fi
561 if [ ${HAVE_MEMMEM} -eq 0 ]; then
562 echo "extern void *memmem(const void *, size_t, const void *, size_t);"
563 fi
564 if [ ${HAVE_REALLOCARRAY} -eq 0 ]; then
565 echo "extern void *reallocarray(void*, size_t, size_t);"
566 fi
567 if [ ${HAVE_RECALLOCARRAY} -eq 0 ]; then
568 echo "extern void *recallocarray(void*, size_t, size_t, size_t);"
569 fi
570 if [ ${HAVE_SETPROCTITLE} -eq 0 ]; then
571 echo "extern void setproctitle(const char *fmt, ...);"
572 fi
573 if [ ${HAVE_SETRESGID} -eq 0 ]; then
574 echo "extern int setresgid(gid_t, gid_t, gid_t);"
575 fi
576 if [ ${HAVE_SETRESUID} -eq 0 ]; then
577 echo "extern int setresuid(uid_t, uid_t, uid_t);"
578 fi
579 if [ ${HAVE_STRLCAT} -eq 0 ]; then
580 echo "extern size_t strlcat(char*, const char*, size_t);"
581 fi
582 if [ ${HAVE_STRLCPY} -eq 0 ]; then
583 echo "extern size_t strlcpy(char*, const char*, size_t);"
584 fi
585 if [ ${HAVE_STRTONUM} -eq 0 ]; then
586 echo "extern long long strtonum(const char*, long long, long long, const char**);"
587 fi
588 if [ ${HAVE_TIMINGSAFE_MEMCMP} -eq 0 ]; then
589 echo "extern int timingsafe_memcmp(const void *, const void *, size_t);"
590 fi
591 if [ ${HAVE_VASPRINTF} -eq 0 ]; then
592 echo "extern int vasprintf(char**, const char*, va_list);"
593 fi
595 if [ ${HAVE_ASN1_TIME_TM_CMP} -eq 0 ]; then
596 echo "#include <openssl/asn1.h>"
597 echo "struct tm;"
598 echo "int ASN1_time_tm_cmp(struct tm *, struct tm *);"
599 else
600 echo "#define HAVE_ASN1_TIME_TM_CMP 1"
601 fi
603 if [ ${HAVE_SSL_CTX_UCCM} -eq 0 -o ${HAVE_SSL_CTX_LVM} -eq 0 ]; then
604 echo "#include <openssl/ssl.h>"
605 fi
607 if [ ${HAVE_SSL_CTX_UCCM} -eq 0 ]; then
608 echo "int SSL_CTX_use_certificate_chain_mem(SSL_CTX *, void *, int);"
609 else
610 echo "#define HAVE_SSL_CTX_USE_CERTIFICATE_CHAIN_MEM 1"
611 fi
613 if [ ${HAVE_SSL_CTX_LVM} -eq 0 ]; then
614 echo "int SSL_CTX_load_verify_mem(SSL_CTX *, void *, int);"
615 else
616 echo "#define HAVE_SSL_CTX_LOAD_VERIFY_MEM 1"
617 fi
619 if [ ${HAVE_X509_LOOKUP_MEM} -eq 0 ]; then
620 echo "#include <openssl/x509_vfy.h>"
621 echo "X509_LOOKUP_METHOD *X509_LOOKUP_mem(void);"
622 else
623 echo "#define HAVE_X509_LOOKUP_MEM 1"
624 fi
626 cat <<__HEREDOC__
628 #ifndef __dead
629 #define __dead __attribute__((noreturn))
630 #endif
632 /* Linux and OpenBSD have LOGIN_NAME_MAX, FreeBSD MAXLOGNAME. */
633 #ifndef LOGIN_NAME_MAX
634 # if defined(MAXLOGNAME)
635 # define LOGIN_NAME_MAX MAXLOGNAME
636 # elif defined(_POSIX_LOGIN_NAME_MAX)
637 # define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX
638 # else
639 # define LOGIN_NAME_MAX 32
640 # endif
641 #endif
643 #ifndef HOST_NAME_MAX
644 # if defined(_POSIX_HOST_NAME_MAX)
645 # define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
646 # else
647 # define HOST_NAME_MAX 255
648 # endif
649 #endif
650 __HEREDOC__
652 echo "file config.h: written" 1>&2
653 echo "file config.h: written" 1>&3
655 exec > config.mk
657 [ -z "${BINDIR}" ] && BINDIR="\${PREFIX}/bin"
658 [ -z "${MANDIR}" ] && MANDIR="\${PREFIX}/man"
660 cat << __HEREDOC__
661 CC = ${CC}
662 CFLAGS = ${CFLAGS}
663 LDFLAGS = ${LDFLAGS}
664 LIBS = ${LIBS}
665 YACC = ${YACC}
666 STATIC = ${STATIC}
667 PREFIX = ${PREFIX}
668 BINDIR = ${BINDIR}
669 MANDIR = ${MANDIR}
671 INSTALL = ${INSTALL}
672 INSTALL_PROGRAM = \${INSTALL} -m 0555
673 INSTALL_LIB = \${INSTALL} -m 0444
674 INSTALL_MAN = \${INSTALL} -m 0444
675 INSTALL_DATA = \${INSTALL} -m 0444
677 COMPATS= ${COMPATS}
679 VERSION = ${VERSION}
681 __HEREDOC__
683 echo "file config.mk: written" 1>&2
684 echo "file config.mk: written" 1>&3
686 echo >&2
687 echo "Now run \`make' to compile." >&2
688 echo >&2
690 exit 0