Blame


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