Blame


1 dd038bc6 2021-09-21 thomas.ad # Process this file with autoconf to produce a configure script.
2 dd038bc6 2021-09-21 thomas.ad
3 dd038bc6 2021-09-21 thomas.ad AC_PREREQ([2.69])
4 598139dd 2022-07-22 thomas AC_INIT([got-portable],
5 4b553fec 2022-08-20 thomas m4_esyscmd_s(util/got-portable-ver.sh),
6 598139dd 2022-07-22 thomas [thomas@xteddy.org])
7 dd038bc6 2021-09-21 thomas.ad AC_CONFIG_AUX_DIR(etc)
8 dd038bc6 2021-09-21 thomas.ad AC_CONFIG_SRCDIR([lib/rcsutil.h])
9 dd038bc6 2021-09-21 thomas.ad AM_INIT_AUTOMAKE([foreign subdir-objects])
10 dd038bc6 2021-09-21 thomas.ad
11 47dc83f5 2023-03-08 thomas AC_CONFIG_HEADERS([include/got_compat.h])
12 47dc83f5 2023-03-08 thomas
13 4fccd2fe 2023-03-08 thomas AC_DEFINE_UNQUOTED(VERSION, $VERSION)
14 dd038bc6 2021-09-21 thomas.ad AC_SUBST(VERSION)
15 dd038bc6 2021-09-21 thomas.ad AC_SUBST(GOT_RELEASE)
16 dd038bc6 2021-09-21 thomas.ad
17 4fccd2fe 2023-03-08 thomas AC_DEFINE_UNQUOTED([GOT_VERSION], VERSION, [GoT version string])
18 4fccd2fe 2023-03-08 thomas AC_DEFINE_UNQUOTED([GOT_VERSION_NUMBER], VERSION, [Got version number])
19 47dc83f5 2023-03-08 thomas
20 4859aafd 2022-11-05 thomas AC_USE_SYSTEM_EXTENSIONS
21 dd038bc6 2021-09-21 thomas.ad AC_CANONICAL_HOST
22 dd038bc6 2021-09-21 thomas.ad
23 9981e8e3 2023-01-19 thomas AC_CONFIG_SUBDIRS([template])
24 9981e8e3 2023-01-19 thomas
25 dd038bc6 2021-09-21 thomas.ad # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
26 dd038bc6 2021-09-21 thomas.ad # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
27 dd038bc6 2021-09-21 thomas.ad # empty default.
28 dd038bc6 2021-09-21 thomas.ad : ${CFLAGS=""}
29 dd038bc6 2021-09-21 thomas.ad
30 dd038bc6 2021-09-21 thomas.ad # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
31 dd038bc6 2021-09-21 thomas.ad # AC_CHECK_HEADER doesn't give us any other way to update the include
32 dd038bc6 2021-09-21 thomas.ad # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
33 dd038bc6 2021-09-21 thomas.ad SAVED_CFLAGS="$CFLAGS"
34 dd038bc6 2021-09-21 thomas.ad SAVED_CPPFLAGS="$CPPFLAGS"
35 dd038bc6 2021-09-21 thomas.ad SAVED_LDFLAGS="$LDFLAGS"
36 dd038bc6 2021-09-21 thomas.ad
37 b29d689b 2023-02-11 thomas # YACC override
38 b29d689b 2023-02-11 thomas YACC_OVERRIDE="yes"
39 b29d689b 2023-02-11 thomas
40 dd038bc6 2021-09-21 thomas.ad # Checks for programs.
41 dd038bc6 2021-09-21 thomas.ad AC_PROG_CC
42 dd038bc6 2021-09-21 thomas.ad AC_PROG_CPP
43 dd038bc6 2021-09-21 thomas.ad AC_PROG_INSTALL
44 dd038bc6 2021-09-21 thomas.ad AC_PROG_LN_S
45 dd038bc6 2021-09-21 thomas.ad AC_PROG_MAKE_SET
46 b29d689b 2023-02-11 thomas if test -z "$YACC"; then
47 b29d689b 2023-02-11 thomas YACC_OVERRIDE="no"
48 dd038bc6 2021-09-21 thomas.ad AC_PROG_YACC
49 b29d689b 2023-02-11 thomas fi
50 47e5cb11 2022-11-05 thomas AM_PROG_AR
51 dd038bc6 2021-09-21 thomas.ad AC_PROG_RANLIB
52 dd038bc6 2021-09-21 thomas.ad PKG_PROG_PKG_CONFIG
53 dd038bc6 2021-09-21 thomas.ad
54 b29d689b 2023-02-11 thomas if test "$YACC_OVERRIDE" = "yes"; then
55 b29d689b 2023-02-11 thomas AC_MSG_NOTICE("Using YACC set from environment: $YACC")
56 b29d689b 2023-02-11 thomas fi
57 b29d689b 2023-02-11 thomas
58 dd038bc6 2021-09-21 thomas.ad # Checks for header files.
59 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADERS([ \
60 dd038bc6 2021-09-21 thomas.ad fcntl.h \
61 dd038bc6 2021-09-21 thomas.ad langinfo.h \
62 d9b944c7 2023-03-08 thomas libutil.h \
63 dd038bc6 2021-09-21 thomas.ad limits.h \
64 97799ccd 2022-02-06 thomas linux/landlock.h \
65 dd038bc6 2021-09-21 thomas.ad locale.h \
66 dd038bc6 2021-09-21 thomas.ad netdb.h \
67 dd038bc6 2021-09-21 thomas.ad netinet/in.h \
68 dd038bc6 2021-09-21 thomas.ad paths.h \
69 d24ddaa6 2022-02-26 thomas poll.h \
70 98670ba7 2023-02-23 thomas sha.h \
71 98670ba7 2023-02-23 thomas sha1.h \
72 98670ba7 2023-02-23 thomas sha2.h \
73 98670ba7 2023-02-23 thomas sha256.h \
74 dd038bc6 2021-09-21 thomas.ad stddef.h \
75 dd038bc6 2021-09-21 thomas.ad stdint.h \
76 dd038bc6 2021-09-21 thomas.ad stdlib.h \
77 dd038bc6 2021-09-21 thomas.ad string.h \
78 dd038bc6 2021-09-21 thomas.ad sys/ioctl.h \
79 dd038bc6 2021-09-21 thomas.ad sys/param.h \
80 d24ddaa6 2022-02-26 thomas sys/poll.h \
81 19467d59 2022-07-16 thomas sys/queue.h \
82 d9b944c7 2023-03-08 thomas sys/select.h \
83 dd038bc6 2021-09-21 thomas.ad sys/socket.h \
84 dd038bc6 2021-09-21 thomas.ad sys/time.h \
85 dd038bc6 2021-09-21 thomas.ad sys/tree.h \
86 dd038bc6 2021-09-21 thomas.ad util.h \
87 dd038bc6 2021-09-21 thomas.ad unistd.h \
88 dd038bc6 2021-09-21 thomas.ad wchar.h \
89 dd038bc6 2021-09-21 thomas.ad ])
90 b1ec8cee 2023-02-25 thomas
91 d9b944c7 2023-03-08 thomas AC_HEADER_DIRENT
92 d9b944c7 2023-03-08 thomas AC_CHECK_DECL([F_CLOSEM],
93 d9b944c7 2023-03-08 thomas HAVE_FCNTL_CLOSEM
94 d9b944c7 2023-03-08 thomas AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
95 d9b944c7 2023-03-08 thomas [Use F_CLOSEM fcntl for closefrom]),
96 d9b944c7 2023-03-08 thomas [],
97 d9b944c7 2023-03-08 thomas [#include <limits.h>
98 d9b944c7 2023-03-08 thomas #include <fcntl.h>
99 d9b944c7 2023-03-08 thomas ]
100 d9b944c7 2023-03-08 thomas )
101 d9b944c7 2023-03-08 thomas
102 d9b944c7 2023-03-08 thomas AC_MSG_CHECKING([for /proc/pid/fd directory])
103 d9b944c7 2023-03-08 thomas if test -d "/proc/$$/fd" ; then
104 d9b944c7 2023-03-08 thomas AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
105 d9b944c7 2023-03-08 thomas AC_MSG_RESULT([yes])
106 d9b944c7 2023-03-08 thomas else
107 d9b944c7 2023-03-08 thomas AC_MSG_RESULT([no])
108 d9b944c7 2023-03-08 thomas fi
109 d9b944c7 2023-03-08 thomas
110 d9b944c7 2023-03-08 thomas AC_MSG_CHECKING([whether program_invocation_short_name is defined])
111 d9b944c7 2023-03-08 thomas AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
112 d9b944c7 2023-03-08 thomas #include <argp.h>
113 d9b944c7 2023-03-08 thomas ]], [[
114 d9b944c7 2023-03-08 thomas program_invocation_short_name = "test";
115 d9b944c7 2023-03-08 thomas ]])], [
116 d9b944c7 2023-03-08 thomas AC_MSG_RESULT([yes])
117 d9b944c7 2023-03-08 thomas AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
118 d9b944c7 2023-03-08 thomas [Define if program_invocation_short_name is defined])
119 d9b944c7 2023-03-08 thomas ], [
120 d9b944c7 2023-03-08 thomas AC_MSG_RESULT([no])
121 d9b944c7 2023-03-08 thomas ])
122 d9b944c7 2023-03-08 thomas
123 d9b944c7 2023-03-08 thomas # Look for prctl(PR_SET_NAME).
124 d9b944c7 2023-03-08 thomas AC_CHECK_DECL(
125 d9b944c7 2023-03-08 thomas [PR_SET_NAME],
126 d9b944c7 2023-03-08 thomas [AC_DEFINE([HAVE_PR_SET_NAME], [1], [Define if PR_SET_NAME is defined])],
127 d9b944c7 2023-03-08 thomas [],
128 d9b944c7 2023-03-08 thomas [#include <sys/prctl.h>]
129 d9b944c7 2023-03-08 thomas )
130 d9b944c7 2023-03-08 thomas
131 b1ec8cee 2023-02-25 thomas AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
132 9445abba 2023-02-24 thomas
133 d9b944c7 2023-03-08 thomas AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[
134 d9b944c7 2023-03-08 thomas #include <sys/types.h>
135 d9b944c7 2023-03-08 thomas #ifdef HAVE_POLL_H
136 d9b944c7 2023-03-08 thomas #include <poll.h>
137 d9b944c7 2023-03-08 thomas #endif
138 d9b944c7 2023-03-08 thomas #ifdef HAVE_SYS_POLL_H
139 d9b944c7 2023-03-08 thomas #include <sys/poll.h>
140 d9b944c7 2023-03-08 thomas #endif
141 d9b944c7 2023-03-08 thomas ]])
142 98670ba7 2023-02-23 thomas
143 dd038bc6 2021-09-21 thomas.ad # Checks for typ edefs, structures, and compiler characteristics.
144 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER_STDBOOL
145 dd038bc6 2021-09-21 thomas.ad AC_C_INLINE
146 dd038bc6 2021-09-21 thomas.ad AC_TYPE_INT64_T
147 dd038bc6 2021-09-21 thomas.ad AC_TYPE_MODE_T
148 dd038bc6 2021-09-21 thomas.ad AC_TYPE_OFF_T
149 dd038bc6 2021-09-21 thomas.ad AC_TYPE_PID_T
150 dd038bc6 2021-09-21 thomas.ad AC_TYPE_SIZE_T
151 dd038bc6 2021-09-21 thomas.ad AC_TYPE_SSIZE_T
152 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT16_T
153 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT32_T
154 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT64_T
155 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT8_T
156 dd038bc6 2021-09-21 thomas.ad
157 ff36aeea 2022-07-16 thomas # Check for ifgroupreq which is only available on BSD.
158 ff36aeea 2022-07-16 thomas AC_CHECK_TYPES([struct ifgroupreq])
159 ff36aeea 2022-07-16 thomas
160 75716fd6 2022-08-27 thomas # Check for sockaddr_storage. On some systems, ss_len is filled out, although
161 75716fd6 2022-08-27 thomas # this is not mandated by POSIX, and hence systems such as linux, don't have
162 75716fd6 2022-08-27 thomas # it.
163 75716fd6 2022-08-27 thomas AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
164 75716fd6 2022-08-27 thomas #include <sys/types.h>
165 75716fd6 2022-08-27 thomas #include <sys/socket.h>
166 75716fd6 2022-08-27 thomas ])
167 75716fd6 2022-08-27 thomas
168 75716fd6 2022-08-27 thomas # Same thing as sockaddr_storage above, only now check if the member exists in
169 75716fd6 2022-08-27 thomas # the struct as well.
170 75716fd6 2022-08-27 thomas AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
171 75716fd6 2022-08-27 thomas [ #include <netdb.h>
172 75716fd6 2022-08-27 thomas #include <netinet/in.h>
173 75716fd6 2022-08-27 thomas #include <sys/socket.h> ]
174 75716fd6 2022-08-27 thomas )
175 75716fd6 2022-08-27 thomas
176 75716fd6 2022-08-27 thomas AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
177 75716fd6 2022-08-27 thomas [ #include <netdb.h>
178 75716fd6 2022-08-27 thomas #include <netinet/in.h>
179 75716fd6 2022-08-27 thomas #include <sys/socket.h> ]
180 75716fd6 2022-08-27 thomas )
181 75716fd6 2022-08-27 thomas
182 75716fd6 2022-08-27 thomas # Both checks above will result in:
183 75716fd6 2022-08-27 thomas #
184 75716fd6 2022-08-27 thomas # HAVE_STRUCT_SOCKADDR_AS_LEN
185 75716fd6 2022-08-27 thomas # SS_LEN
186 75716fd6 2022-08-27 thomas #
187 75716fd6 2022-08-27 thomas # Either being defined or not.
188 75716fd6 2022-08-27 thomas
189 dd038bc6 2021-09-21 thomas.ad # Look for library needed for flock.
190 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(flock, bsd)
191 dd038bc6 2021-09-21 thomas.ad
192 dd038bc6 2021-09-21 thomas.ad # Checks for library functions.
193 dd038bc6 2021-09-21 thomas.ad AC_FUNC_FORK
194 dd038bc6 2021-09-21 thomas.ad AC_FUNC_FSEEKO
195 dd038bc6 2021-09-21 thomas.ad AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
196 dd038bc6 2021-09-21 thomas.ad AC_FUNC_MALLOC
197 dd038bc6 2021-09-21 thomas.ad AC_FUNC_MMAP
198 dd038bc6 2021-09-21 thomas.ad AC_FUNC_REALLOC
199 dd038bc6 2021-09-21 thomas.ad AC_FUNC_STRERROR_R
200 dd038bc6 2021-09-21 thomas.ad AC_FUNC_STRNLEN
201 dd038bc6 2021-09-21 thomas.ad AC_CHECK_FUNCS([ \
202 dd038bc6 2021-09-21 thomas.ad dup2 \
203 dd038bc6 2021-09-21 thomas.ad flock \
204 dd038bc6 2021-09-21 thomas.ad getcwd \
205 dd038bc6 2021-09-21 thomas.ad localtime_r \
206 dd038bc6 2021-09-21 thomas.ad memchr \
207 dd038bc6 2021-09-21 thomas.ad memmove \
208 dd038bc6 2021-09-21 thomas.ad memset \
209 4fccd2fe 2023-03-08 thomas mergesort \
210 dd038bc6 2021-09-21 thomas.ad mkdir \
211 dd038bc6 2021-09-21 thomas.ad munmap \
212 dd038bc6 2021-09-21 thomas.ad nl_langinfo \
213 dd038bc6 2021-09-21 thomas.ad realpath \
214 dd038bc6 2021-09-21 thomas.ad regcomp \
215 dd038bc6 2021-09-21 thomas.ad rmdir \
216 dd038bc6 2021-09-21 thomas.ad setlocale \
217 dd038bc6 2021-09-21 thomas.ad socket \
218 683ec58e 2022-07-16 thomas setresgid \
219 683ec58e 2022-07-16 thomas setresuid \
220 c4e2e0d0 2022-07-16 thomas setproctitle \
221 dd038bc6 2021-09-21 thomas.ad strcasecmp \
222 dd038bc6 2021-09-21 thomas.ad strchr \
223 dd038bc6 2021-09-21 thomas.ad strcspn \
224 dd038bc6 2021-09-21 thomas.ad strdup \
225 dd038bc6 2021-09-21 thomas.ad strerror \
226 dd038bc6 2021-09-21 thomas.ad strncasecmp \
227 dd038bc6 2021-09-21 thomas.ad strndup \
228 dd038bc6 2021-09-21 thomas.ad strrchr \
229 dd038bc6 2021-09-21 thomas.ad strspn \
230 dd038bc6 2021-09-21 thomas.ad strstr \
231 dd038bc6 2021-09-21 thomas.ad strtol \
232 dd038bc6 2021-09-21 thomas.ad strtoul \
233 d9b944c7 2023-03-08 thomas sysconf \
234 dd038bc6 2021-09-21 thomas.ad wcwidth \
235 dd038bc6 2021-09-21 thomas.ad ])
236 ddd12270 2022-04-22 thomas
237 c4e2e0d0 2022-07-16 thomas AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
238 d9b944c7 2023-03-08 thomas
239 d9b944c7 2023-03-08 thomas if test "x$ac_cv_func_sysconf" = xyes; then
240 d9b944c7 2023-03-08 thomas AC_DEFINE([HAVE_SYSCONF], [1], [Define to 1 if sysconf() present])
241 d9b944c7 2023-03-08 thomas fi
242 c4e2e0d0 2022-07-16 thomas
243 ddd12270 2022-04-22 thomas # Siphash support.
244 ddd12270 2022-04-22 thomas AC_CHECK_FUNCS([SipHash])
245 ddd12270 2022-04-22 thomas AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
246 dd038bc6 2021-09-21 thomas.ad
247 dd038bc6 2021-09-21 thomas.ad # Check for functions with a compatibility implementation.
248 dd038bc6 2021-09-21 thomas.ad AC_REPLACE_FUNCS([ \
249 dd038bc6 2021-09-21 thomas.ad asprintf \
250 dd038bc6 2021-09-21 thomas.ad closefrom \
251 dd038bc6 2021-09-21 thomas.ad explicit_bzero \
252 dd038bc6 2021-09-21 thomas.ad fmt_scaled \
253 dd038bc6 2021-09-21 thomas.ad freezero \
254 dd038bc6 2021-09-21 thomas.ad getdtablecount \
255 dd038bc6 2021-09-21 thomas.ad getline \
256 dd038bc6 2021-09-21 thomas.ad getprogname \
257 dd038bc6 2021-09-21 thomas.ad recallocarray \
258 dd038bc6 2021-09-21 thomas.ad reallocarray \
259 dd038bc6 2021-09-21 thomas.ad strlcat \
260 dd038bc6 2021-09-21 thomas.ad strlcpy \
261 dd038bc6 2021-09-21 thomas.ad strndup \
262 d9b944c7 2023-03-08 thomas strnlen \
263 dd038bc6 2021-09-21 thomas.ad strsep \
264 dd038bc6 2021-09-21 thomas.ad strtonum \
265 dd038bc6 2021-09-21 thomas.ad ])
266 4fccd2fe 2023-03-08 thomas AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
267 dd038bc6 2021-09-21 thomas.ad
268 dd038bc6 2021-09-21 thomas.ad # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
269 dd038bc6 2021-09-21 thomas.ad # musl does not set optarg to NULL for flags without arguments (although it is
270 dd038bc6 2021-09-21 thomas.ad # not required to, but it is helpful) 3) there are probably other weird
271 dd038bc6 2021-09-21 thomas.ad # implementations.
272 dd038bc6 2021-09-21 thomas.ad AC_LIBOBJ(getopt)
273 dd038bc6 2021-09-21 thomas.ad
274 206be139 2023-03-08 thomas # Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
275 206be139 2023-03-08 thomas AC_MSG_CHECKING(for b64_ntop)
276 206be139 2023-03-08 thomas AC_LINK_IFELSE([AC_LANG_PROGRAM(
277 206be139 2023-03-08 thomas [
278 206be139 2023-03-08 thomas #include <sys/types.h>
279 206be139 2023-03-08 thomas #include <netinet/in.h>
280 206be139 2023-03-08 thomas #include <resolv.h>
281 206be139 2023-03-08 thomas ],
282 206be139 2023-03-08 thomas [
283 206be139 2023-03-08 thomas b64_ntop(NULL, 0, NULL, 0);
284 206be139 2023-03-08 thomas ])],
285 206be139 2023-03-08 thomas found_b64_ntop=yes,
286 206be139 2023-03-08 thomas found_b64_ntop=no
287 206be139 2023-03-08 thomas )
288 206be139 2023-03-08 thomas AC_MSG_RESULT($found_b64_ntop)
289 206be139 2023-03-08 thomas libresolv_LIBS=""
290 206be139 2023-03-08 thomas if test "x$found_b64_ntop" = xno; then
291 206be139 2023-03-08 thomas AC_MSG_CHECKING(for b64_ntop with -lresolv)
292 206be139 2023-03-08 thomas LIBS="-lresolv"
293 206be139 2023-03-08 thomas AC_LINK_IFELSE([AC_LANG_PROGRAM(
294 206be139 2023-03-08 thomas [
295 206be139 2023-03-08 thomas #include <sys/types.h>
296 206be139 2023-03-08 thomas #include <netinet/in.h>
297 206be139 2023-03-08 thomas #include <resolv.h>
298 206be139 2023-03-08 thomas ],
299 206be139 2023-03-08 thomas [
300 206be139 2023-03-08 thomas b64_ntop(NULL, 0, NULL, 0);
301 206be139 2023-03-08 thomas ])],
302 206be139 2023-03-08 thomas found_b64_ntop=yes,
303 206be139 2023-03-08 thomas found_b64_ntop=no
304 206be139 2023-03-08 thomas )
305 206be139 2023-03-08 thomas AC_MSG_RESULT($found_b64_ntop)
306 206be139 2023-03-08 thomas libresolv_LIBS="$LIBS"
307 206be139 2023-03-08 thomas fi
308 206be139 2023-03-08 thomas if test "x$found_b64_ntop" = xno; then
309 206be139 2023-03-08 thomas AC_MSG_CHECKING(for b64_ntop with -lnetwork)
310 206be139 2023-03-08 thomas LIBS="-lresolv -lnetwork"
311 206be139 2023-03-08 thomas AC_LINK_IFELSE([AC_LANG_PROGRAM(
312 206be139 2023-03-08 thomas [
313 206be139 2023-03-08 thomas #include <sys/types.h>
314 206be139 2023-03-08 thomas #include <netinet/in.h>
315 206be139 2023-03-08 thomas #include <resolv.h>
316 206be139 2023-03-08 thomas ],
317 206be139 2023-03-08 thomas [
318 206be139 2023-03-08 thomas b64_ntop(NULL, 0, NULL, 0);
319 206be139 2023-03-08 thomas ])],
320 206be139 2023-03-08 thomas found_b64_ntop=yes,
321 206be139 2023-03-08 thomas found_b64_ntop=no
322 206be139 2023-03-08 thomas )
323 206be139 2023-03-08 thomas AC_MSG_RESULT($found_b64_ntop)
324 206be139 2023-03-08 thomas libresolv_LIBS="$LIBS"
325 206be139 2023-03-08 thomas fi
326 206be139 2023-03-08 thomas
327 206be139 2023-03-08 thomas AM_CONDITIONAL([HAVE_B64], [test "x$found_b64_ntop" = xyes])
328 206be139 2023-03-08 thomas if test "x$found_b64_ntop" = xyes; then
329 206be139 2023-03-08 thomas AC_DEFINE([HAVE_B64_NTOP], [1], [define if b64_ntop is present])
330 206be139 2023-03-08 thomas AC_SUBST(libresolv_LIBS)
331 206be139 2023-03-08 thomas else
332 206be139 2023-03-08 thomas AC_LIBOBJ(base64)
333 206be139 2023-03-08 thomas fi
334 206be139 2023-03-08 thomas
335 92a9e85d 2021-09-24 thomas # Check the platform we're compiling on.
336 92a9e85d 2021-09-24 thomas AC_MSG_CHECKING(platform)
337 92a9e85d 2021-09-24 thomas case "$host_os" in
338 92a9e85d 2021-09-24 thomas *linux*)
339 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(linux)
340 92a9e85d 2021-09-24 thomas PLATFORM=linux
341 92a9e85d 2021-09-24 thomas ;;
342 92a9e85d 2021-09-24 thomas *freebsd*)
343 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(freebsd)
344 92a9e85d 2021-09-24 thomas PLATFORM=freebsd
345 d24ddaa6 2022-02-26 thomas ;;
346 d24ddaa6 2022-02-26 thomas *darwin*)
347 d24ddaa6 2022-02-26 thomas AC_MSG_RESULT(darwin)
348 d24ddaa6 2022-02-26 thomas PLATFORM=darwin
349 a3732bb6 2022-02-26 thomas ;;
350 a3732bb6 2022-02-26 thomas *netbsd*)
351 a3732bb6 2022-02-26 thomas AC_MSG_RESULT(netbsd)
352 a3732bb6 2022-02-26 thomas PLATFORM=netbsd
353 92a9e85d 2021-09-24 thomas ;;
354 01a22331 2023-02-26 thomas *openbsd*)
355 398ba35f 2023-02-26 thomas AC_MSG_RESULT(openbsd)
356 01a22331 2023-02-26 thomas PLATFORM=openbsd
357 01a22331 2023-02-26 thomas ;;
358 b26177ad 2022-03-03 thomas *dragonfly*)
359 b26177ad 2022-03-03 thomas AC_MSG_RESULT(dragonfly)
360 b26177ad 2022-03-03 thomas PLATFORM=dragonflybsd
361 b26177ad 2022-03-03 thomas ;;
362 92a9e85d 2021-09-24 thomas *)
363 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(unknown)
364 92a9e85d 2021-09-24 thomas PLATFORM=unknown
365 92a9e85d 2021-09-24 thomas ;;
366 92a9e85d 2021-09-24 thomas esac
367 92a9e85d 2021-09-24 thomas AC_SUBST(PLATFORM)
368 92a9e85d 2021-09-24 thomas AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
369 92a9e85d 2021-09-24 thomas AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
370 d24ddaa6 2022-02-26 thomas AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
371 a3732bb6 2022-02-26 thomas AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
372 01a22331 2023-02-26 thomas AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
373 b26177ad 2022-03-03 thomas AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
374 8cff5e95 2023-03-08 thomas
375 8cff5e95 2023-03-08 thomas # On OpenBSD, these functions are already defined, yet looking for them in
376 8cff5e95 2023-03-08 thomas # this way on OpenBSD breaks <sha2.h> inclusion.
377 8cff5e95 2023-03-08 thomas # FIXME: this needs addressing.
378 8cff5e95 2023-03-08 thomas if test "x$PLATFORM" != "xopenbsd"; then
379 8cff5e95 2023-03-08 thomas AC_CHECK_FUNCS([ \
380 8cff5e95 2023-03-08 thomas SHA256Update \
381 8cff5e95 2023-03-08 thomas SHA384Update \
382 8cff5e95 2023-03-08 thomas SHA512Update \
383 8cff5e95 2023-03-08 thomas ])
384 8cff5e95 2023-03-08 thomas fi
385 92a9e85d 2021-09-24 thomas
386 b29d689b 2023-02-11 thomas # Look for yacc.
387 b29d689b 2023-02-11 thomas if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
388 b29d689b 2023-02-11 thomas && ! command -v "$YACC" >/dev/null 2>&1; then
389 b29d689b 2023-02-11 thomas AC_MSG_ERROR("yacc not found: $YACC")
390 b29d689b 2023-02-11 thomas fi
391 b29d689b 2023-02-11 thomas
392 51207398 2022-07-21 thomas if test x"$PLATFORM" = "xdarwin"; then
393 5baa5fe2 2022-09-05 thomas # Check for and/or set HOMEBREW_PREFIX. brew is a common way of
394 5baa5fe2 2022-09-05 thomas # installing applications. The other is MacPorts.
395 5baa5fe2 2022-09-05 thomas #
396 5baa5fe2 2022-09-05 thomas # Before Apple Silicon existed (M1 onward), the paths for applications
397 5baa5fe2 2022-09-05 thomas # installed via homebrew was typically /usr/local. However, with M1
398 5baa5fe2 2022-09-05 thomas # onward, this changed to a different path.
399 5baa5fe2 2022-09-05 thomas #
400 5baa5fe2 2022-09-05 thomas # Rather than hardcode this, check for HOMEBREW_PREFIX in the
401 8e396e19 2022-09-12 thomas # environment if it's already set, and use it. Otherwise, check for
402 5baa5fe2 2022-09-05 thomas # brew(1) and use that. If that fails, default to /usr/local
403 5baa5fe2 2022-09-05 thomas #
404 5baa5fe2 2022-09-05 thomas # This also means that MacPorts should continue to work.
405 8e396e19 2022-09-12 thomas #
406 8e396e19 2022-09-12 thomas # But with MacPorts, we should also check --prefix, and use that if it
407 8e396e19 2022-09-12 thomas # has been supplied.
408 8e396e19 2022-09-12 thomas #
409 8e396e19 2022-09-12 thomas # In both cases, the variable HOMEBREW_PREFIX is used for both.
410 8e396e19 2022-09-12 thomas HB_PREFIX=""
411 8e396e19 2022-09-12 thomas FOUND_BISON="no"
412 8e396e19 2022-09-12 thomas GNUBISON=""
413 8e396e19 2022-09-12 thomas if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
414 5baa5fe2 2022-09-05 thomas # HOMEBREW_PREFIX not set, check for brew(1)
415 8e396e19 2022-09-12 thomas if command -v brew >/dev/null 2>&1; then
416 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
417 5baa5fe2 2022-09-05 thomas export HOMEBREW_PREFIX="$(brew --prefix)"
418 8e396e19 2022-09-12 thomas fi
419 8e396e19 2022-09-12 thomas
420 8e396e19 2022-09-12 thomas if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
421 8e396e19 2022-09-12 thomas then
422 5baa5fe2 2022-09-05 thomas # Default.
423 8e396e19 2022-09-12 thomas if test -z "${prefix}" -o "${prefix}" = "NONE"; then
424 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="/usr/local"
425 8e396e19 2022-09-12 thomas HB_PREFIX="/usr/local"
426 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
427 8e396e19 2022-09-12 thomas else
428 8e396e19 2022-09-12 thomas HB_PREFIX="$(eval echo ${prefix})"
429 8e396e19 2022-09-12 thomas if test "$HB_PREFIX" = "NONE"; then
430 8e396e19 2022-09-12 thomas HB_PREFIX="/opt/local"
431 8e396e19 2022-09-12 thomas else
432 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
433 8e396e19 2022-09-12 thomas fi
434 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="$HB_PREFIX"
435 8e396e19 2022-09-12 thomas fi
436 5baa5fe2 2022-09-05 thomas fi
437 5baa5fe2 2022-09-05 thomas fi
438 5baa5fe2 2022-09-05 thomas
439 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
440 8e396e19 2022-09-12 thomas
441 b29d689b 2023-02-11 thomas if test "$YACC_OVERRIDE" = "no" && \
442 b29d689b 2023-02-11 thomas ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
443 8e396e19 2022-09-12 thomas AC_MSG_WARN([
444 8e396e19 2022-09-12 thomas "***********************************************************
445 8e396e19 2022-09-12 thomas GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
446 8e396e19 2022-09-12 thomas ***********************************************************
447 8e396e19 2022-09-12 thomas
448 8e396e19 2022-09-12 thomas Falling back to checking either /usr/local or \${prefix}"
449 8e396e19 2022-09-12 thomas ])
450 8e396e19 2022-09-12 thomas
451 8e396e19 2022-09-12 thomas FOUND_BISON="no"
452 8e396e19 2022-09-12 thomas AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
453 8e396e19 2022-09-12 thomas if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
454 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="/usr/local"
455 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
456 8e396e19 2022-09-12 thomas GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
457 8e396e19 2022-09-12 thomas fi
458 8e396e19 2022-09-12 thomas
459 8e396e19 2022-09-12 thomas if test "$FOUND_BISON" = "no"; then
460 8e396e19 2022-09-12 thomas HB_PREFIX="/opt/local"
461 8e396e19 2022-09-12 thomas AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
462 8e396e19 2022-09-12 thomas
463 8e396e19 2022-09-12 thomas if test -x "${HB_PREFIX}/bin/bison"; then
464 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="${HB_PREFIX}"
465 8e396e19 2022-09-12 thomas GNUBISON="${HB_PREFIX}/bin/bison"
466 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
467 8e396e19 2022-09-12 thomas fi
468 8e396e19 2022-09-12 thomas fi
469 8e396e19 2022-09-12 thomas else
470 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
471 8e396e19 2022-09-12 thomas GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
472 8e396e19 2022-09-12 thomas fi
473 8e396e19 2022-09-12 thomas
474 b29d689b 2023-02-11 thomas if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
475 8e396e19 2022-09-12 thomas AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
476 51207398 2022-07-21 thomas fi
477 8e396e19 2022-09-12 thomas
478 51207398 2022-07-21 thomas # Override YACC here to point to the GNU version of bison.
479 b29d689b 2023-02-11 thomas if test "$YACC_OVERRIDE" = "yes"; then
480 b29d689b 2023-02-11 thomas export YACC="$YACC -y"
481 b29d689b 2023-02-11 thomas else
482 b29d689b 2023-02-11 thomas AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
483 b29d689b 2023-02-11 thomas export YACC="${GNUBISON} -y"
484 b29d689b 2023-02-11 thomas fi
485 8e396e19 2022-09-12 thomas export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
486 5baa5fe2 2022-09-05 thomas export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
487 5baa5fe2 2022-09-05 thomas export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
488 5baa5fe2 2022-09-05 thomas export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
489 51207398 2022-07-21 thomas fi
490 51207398 2022-07-21 thomas
491 97799ccd 2022-02-06 thomas # Landlock detection.
492 97799ccd 2022-02-06 thomas AC_MSG_CHECKING([for landlock])
493 97799ccd 2022-02-06 thomas AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
494 97799ccd 2022-02-06 thomas [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
495 97799ccd 2022-02-06 thomas if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
496 97799ccd 2022-02-06 thomas AC_MSG_RESULT(yes)
497 97799ccd 2022-02-06 thomas else
498 97799ccd 2022-02-06 thomas AC_MSG_RESULT(no)
499 97799ccd 2022-02-06 thomas fi
500 97799ccd 2022-02-06 thomas
501 dd038bc6 2021-09-21 thomas.ad # Clang sanitizers wrap reallocarray even if it isn't available on the target
502 dd038bc6 2021-09-21 thomas.ad # system. When compiled it always returns NULL and crashes the program. To
503 dd038bc6 2021-09-21 thomas.ad # detect this we need a more complicated test.
504 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING([for working reallocarray])
505 dd038bc6 2021-09-21 thomas.ad AC_RUN_IFELSE([AC_LANG_PROGRAM(
506 dd038bc6 2021-09-21 thomas.ad [#include <stdlib.h>],
507 dd038bc6 2021-09-21 thomas.ad [return (reallocarray(NULL, 1, 1) == NULL);]
508 dd038bc6 2021-09-21 thomas.ad )],
509 dd038bc6 2021-09-21 thomas.ad AC_MSG_RESULT(yes),
510 7f20c2a8 2022-05-13 op [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
511 dd038bc6 2021-09-21 thomas.ad [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
512 dd038bc6 2021-09-21 thomas.ad )
513 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING([for working recallocarray])
514 dd038bc6 2021-09-21 thomas.ad AC_RUN_IFELSE([AC_LANG_PROGRAM(
515 dd038bc6 2021-09-21 thomas.ad [#include <stdlib.h>],
516 dd038bc6 2021-09-21 thomas.ad [return (recallocarray(NULL, 1, 1, 1) == NULL);]
517 dd038bc6 2021-09-21 thomas.ad )],
518 dd038bc6 2021-09-21 thomas.ad AC_MSG_RESULT(yes),
519 7f20c2a8 2022-05-13 op [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
520 dd038bc6 2021-09-21 thomas.ad [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
521 dd038bc6 2021-09-21 thomas.ad )
522 dd038bc6 2021-09-21 thomas.ad
523 dd038bc6 2021-09-21 thomas.ad # Look for imsg_init in libutil.
524 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
525 f600ad76 2023-01-06 thomas AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
526 4fccd2fe 2023-03-08 thomas if test "x$found_imsg_init" = "xyes"; then
527 d9b944c7 2023-03-08 thomas AC_DEFINE([HAVE_IMSG], [1], [Define to 1 if imsg is declared in libutil])
528 4fccd2fe 2023-03-08 thomas libutil_LIBS="$ac_cv_search_imsg_init"
529 4fccd2fe 2023-03-08 thomas AC_SUBST(libutil_LIBS)
530 ff36aeea 2022-07-16 thomas fi
531 ff36aeea 2022-07-16 thomas
532 ff36aeea 2022-07-16 thomas # libevent (for gotwebd). Lifted from tmux.
533 ff36aeea 2022-07-16 thomas # Look for libevent. Try libevent_core or libevent with pkg-config first then
534 ff36aeea 2022-07-16 thomas # look for the library.
535 4fccd2fe 2023-03-08 thomas found_libevent=no
536 ff36aeea 2022-07-16 thomas PKG_CHECK_MODULES(
537 ff36aeea 2022-07-16 thomas LIBEVENT_CORE,
538 ff36aeea 2022-07-16 thomas [libevent_core >= 2],
539 ff36aeea 2022-07-16 thomas [
540 4fccd2fe 2023-03-08 thomas libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
541 4fccd2fe 2023-03-08 thomas libevent_LIBS="$LIBEVENT_CORE_LIBS"
542 4fccd2fe 2023-03-08 thomas AC_SUBST(libevent_CFLAGS)
543 4fccd2fe 2023-03-08 thomas AC_SUBST(libevent_LIBS)
544 ff36aeea 2022-07-16 thomas found_libevent=yes
545 ff36aeea 2022-07-16 thomas ],
546 ff36aeea 2022-07-16 thomas found_libevent=no
547 ff36aeea 2022-07-16 thomas )
548 ff36aeea 2022-07-16 thomas if test x$found_libevent = xno; then
549 ff36aeea 2022-07-16 thomas PKG_CHECK_MODULES(
550 ff36aeea 2022-07-16 thomas LIBEVENT,
551 ff36aeea 2022-07-16 thomas [libevent >= 2],
552 ff36aeea 2022-07-16 thomas [
553 4fccd2fe 2023-03-08 thomas libevent_CFLAGS="$LIBEVENT_CFLAGS"
554 4fccd2fe 2023-03-08 thomas libevent_LIBS="$LIBEVENT_LIBS"
555 4fccd2fe 2023-03-08 thomas AC_SUBST(libevent_CFLAGS)
556 4fccd2fe 2023-03-08 thomas AC_SUBST(libevent_LIBS)
557 ff36aeea 2022-07-16 thomas found_libevent=yes
558 ff36aeea 2022-07-16 thomas ],
559 ff36aeea 2022-07-16 thomas found_libevent=no
560 ff36aeea 2022-07-16 thomas )
561 ff36aeea 2022-07-16 thomas fi
562 ff36aeea 2022-07-16 thomas if test x$found_libevent = xno; then
563 ff36aeea 2022-07-16 thomas AC_SEARCH_LIBS(
564 ff36aeea 2022-07-16 thomas event_init,
565 ff36aeea 2022-07-16 thomas [event_core event event-1.4],
566 ff36aeea 2022-07-16 thomas found_libevent=yes,
567 ff36aeea 2022-07-16 thomas found_libevent=no
568 ff36aeea 2022-07-16 thomas )
569 4fccd2fe 2023-03-08 thomas
570 4fccd2fe 2023-03-08 thomas if test "x$found_libevent" = "xyes"; then
571 4fccd2fe 2023-03-08 thomas libevent_LIBS="$ac_cv_search_event_init"
572 4fccd2fe 2023-03-08 thomas AC_SUBST(libevent_LIBS)
573 4fccd2fe 2023-03-08 thomas fi
574 ff36aeea 2022-07-16 thomas fi
575 4fccd2fe 2023-03-08 thomas
576 4fccd2fe 2023-03-08 thomas if test x$found_libevent = xno; then
577 ff36aeea 2022-07-16 thomas AC_CHECK_HEADER(
578 ff36aeea 2022-07-16 thomas event2/event.h,
579 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
580 ff36aeea 2022-07-16 thomas [
581 ff36aeea 2022-07-16 thomas AC_CHECK_HEADER(
582 ff36aeea 2022-07-16 thomas event.h,
583 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
584 ff36aeea 2022-07-16 thomas found_libevent=no
585 ff36aeea 2022-07-16 thomas )
586 ff36aeea 2022-07-16 thomas ]
587 ff36aeea 2022-07-16 thomas )
588 4fccd2fe 2023-03-08 thomas fi
589 4fccd2fe 2023-03-08 thomas
590 ff36aeea 2022-07-16 thomas if test "x$found_libevent" = xno; then
591 ff36aeea 2022-07-16 thomas AC_MSG_ERROR("libevent not found")
592 92a9e85d 2021-09-24 thomas fi
593 92a9e85d 2021-09-24 thomas
594 4fccd2fe 2023-03-08 thomas AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
595 dd038bc6 2021-09-21 thomas.ad
596 d24ddaa6 2022-02-26 thomas # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
597 d24ddaa6 2022-02-26 thomas # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
598 d24ddaa6 2022-02-26 thomas # ossp
599 d24ddaa6 2022-02-26 thomas if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
600 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
601 326237a6 2021-09-25 thomas else
602 326237a6 2021-09-25 thomas PKG_CHECK_MODULES(
603 326237a6 2021-09-25 thomas LIBUUID,
604 326237a6 2021-09-25 thomas uuid,
605 326237a6 2021-09-25 thomas [
606 4fccd2fe 2023-03-08 thomas libuuid_CFLAGS="$LIBUUID_CFLAGS"
607 4fccd2fe 2023-03-08 thomas libuuid_LIBS="$LIBUUID_LIBS"
608 4fccd2fe 2023-03-08 thomas AC_SUBST(libuuid_CFLAGS)
609 4fccd2fe 2023-03-08 thomas AC_SUBST(libuuid_LIBS)
610 326237a6 2021-09-25 thomas found_libuuid=yes
611 326237a6 2021-09-25 thomas ],
612 326237a6 2021-09-25 thomas [
613 326237a6 2021-09-25 thomas found_libuuid=no
614 326237a6 2021-09-25 thomas ]
615 326237a6 2021-09-25 thomas )
616 dd038bc6 2021-09-21 thomas.ad
617 326237a6 2021-09-25 thomas if test "x$found_libuuid" = "xno"; then
618 326237a6 2021-09-25 thomas AC_CHECK_HEADER(
619 326237a6 2021-09-25 thomas uuid.h,
620 326237a6 2021-09-25 thomas found_libuuid=yes,
621 326237a6 2021-09-25 thomas found_libuuid=no)
622 326237a6 2021-09-25 thomas fi
623 92a9e85d 2021-09-24 thomas fi
624 dd038bc6 2021-09-21 thomas.ad
625 92a9e85d 2021-09-24 thomas if test "x$found_libuuid" = "xno"; then
626 92a9e85d 2021-09-24 thomas AC_MSG_ERROR("*** couldn't find uuid ***")
627 92a9e85d 2021-09-24 thomas fi
628 92a9e85d 2021-09-24 thomas
629 dd038bc6 2021-09-21 thomas.ad PKG_CHECK_MODULES(
630 dd038bc6 2021-09-21 thomas.ad ZLIB,
631 dd038bc6 2021-09-21 thomas.ad zlib,
632 dd038bc6 2021-09-21 thomas.ad [
633 4fccd2fe 2023-03-08 thomas zlib_CFLAGS="$ZLIB_CFLAGS"
634 4fccd2fe 2023-03-08 thomas zlib_LIBS="$ZLIB_LIBS"
635 4fccd2fe 2023-03-08 thomas AC_SUBST(zlib_CFLAGS)
636 4fccd2fe 2023-03-08 thomas AC_SUBST(zlib_LIBS)
637 dd038bc6 2021-09-21 thomas.ad found_zlib=yes
638 dd038bc6 2021-09-21 thomas.ad ],
639 dd038bc6 2021-09-21 thomas.ad [
640 92a9e85d 2021-09-24 thomas found_zlib=no
641 dd038bc6 2021-09-21 thomas.ad ]
642 dd038bc6 2021-09-21 thomas.ad )
643 dd038bc6 2021-09-21 thomas.ad
644 92a9e85d 2021-09-24 thomas if test "x$found_zlib" = "xno"; then
645 92a9e85d 2021-09-24 thomas AC_CHECK_HEADER(
646 92a9e85d 2021-09-24 thomas zlib.h,
647 92a9e85d 2021-09-24 thomas ,
648 92a9e85d 2021-09-24 thomas found_zlib=no)
649 92a9e85d 2021-09-24 thomas fi
650 dd038bc6 2021-09-21 thomas.ad
651 92a9e85d 2021-09-24 thomas if test "x$found_zlib" = "xno"; then
652 92a9e85d 2021-09-24 thomas AC_MSG_ERROR("*** couldn't find zlib ***")
653 92a9e85d 2021-09-24 thomas fi
654 dd038bc6 2021-09-21 thomas.ad
655 92a9e85d 2021-09-24 thomas if test "$PLATFORM" = "linux"; then
656 92a9e85d 2021-09-24 thomas PKG_CHECK_MODULES(
657 92a9e85d 2021-09-24 thomas LIBBSD,
658 92a9e85d 2021-09-24 thomas libbsd-overlay,
659 92a9e85d 2021-09-24 thomas [
660 4fccd2fe 2023-03-08 thomas libbsd_CFLAGS="$LIBBSD_CFLAGS"
661 4fccd2fe 2023-03-08 thomas libbsd_LIBS="$LIBBSD_LIBS"
662 4fccd2fe 2023-03-08 thomas AC_SUBST(libbsd_CFLAGS)
663 4fccd2fe 2023-03-08 thomas AC_SUBST(libbsd_LIBS)
664 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
665 92a9e85d 2021-09-24 thomas ],
666 46384c6e 2022-09-13 thomas [
667 46384c6e 2022-09-13 thomas AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
668 46384c6e 2022-09-13 thomas ]
669 46384c6e 2022-09-13 thomas
670 92a9e85d 2021-09-24 thomas )
671 4fccd2fe 2023-03-08 thomas
672 4fccd2fe 2023-03-08 thomas # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
673 4fccd2fe 2023-03-08 thomas # header files in a non-standard location, which means the overlay for
674 4fccd2fe 2023-03-08 thomas # <sys/tree.h> and <sys/queue.h> won't be found.
675 4fccd2fe 2023-03-08 thomas CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
676 4fccd2fe 2023-03-08 thomas LIBS="$LIBS $LIBBSD_LIBS"
677 92a9e85d 2021-09-24 thomas fi
678 92a9e85d 2021-09-24 thomas
679 dd038bc6 2021-09-21 thomas.ad # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
680 8dbd2d50 2022-08-12 thomas # some declarations.
681 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
682 dd038bc6 2021-09-21 thomas.ad TAILQ_CONCAT,
683 dd038bc6 2021-09-21 thomas.ad found_queue_h=yes,
684 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
685 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
686 dd038bc6 2021-09-21 thomas.ad )
687 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
688 dd038bc6 2021-09-21 thomas.ad TAILQ_PREV,
689 19467d59 2022-07-16 thomas ,
690 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
691 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
692 dd038bc6 2021-09-21 thomas.ad )
693 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
694 dd038bc6 2021-09-21 thomas.ad TAILQ_FOREACH_SAFE,
695 dd038bc6 2021-09-21 thomas.ad ,
696 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
697 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
698 dd038bc6 2021-09-21 thomas.ad )
699 19467d59 2022-07-16 thomas
700 8dbd2d50 2022-08-12 thomas if test "x$found_queue_h" = xyes; then
701 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
702 46384c6e 2022-09-13 thomas else
703 46384c6e 2022-09-13 thomas AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
704 dd038bc6 2021-09-21 thomas.ad fi
705 c59427c5 2022-10-13 thomas
706 c59427c5 2022-10-13 thomas AC_CHECK_DECL(
707 c59427c5 2022-10-13 thomas RB_GENERATE_STATIC,
708 c59427c5 2022-10-13 thomas found_sys_tree_h=yes,
709 c59427c5 2022-10-13 thomas found_sys_tree_h=no,
710 c59427c5 2022-10-13 thomas [#include <sys/tree.h>]
711 c59427c5 2022-10-13 thomas )
712 dd038bc6 2021-09-21 thomas.ad
713 c59427c5 2022-10-13 thomas if test "x$found_sys_tree_h" = xyes; then
714 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_TREE_H], [1], [sys/tree.h])
715 c59427c5 2022-10-13 thomas else
716 c59427c5 2022-10-13 thomas AC_MSG_NOTICE("Using compat/tree.h")
717 c59427c5 2022-10-13 thomas fi
718 46384c6e 2022-09-13 thomas
719 dd038bc6 2021-09-21 thomas.ad # Look for __progname.
720 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING(for __progname)
721 dd038bc6 2021-09-21 thomas.ad AC_LINK_IFELSE([AC_LANG_SOURCE(
722 dd038bc6 2021-09-21 thomas.ad [
723 dd038bc6 2021-09-21 thomas.ad #include <stdio.h>
724 dd038bc6 2021-09-21 thomas.ad #include <stdlib.h>
725 dd038bc6 2021-09-21 thomas.ad extern char *__progname;
726 dd038bc6 2021-09-21 thomas.ad int main(void) {
727 dd038bc6 2021-09-21 thomas.ad const char *cp = __progname;
728 dd038bc6 2021-09-21 thomas.ad printf("%s\n", cp);
729 dd038bc6 2021-09-21 thomas.ad exit(0);
730 dd038bc6 2021-09-21 thomas.ad }
731 dd038bc6 2021-09-21 thomas.ad ])],
732 47dc83f5 2023-03-08 thomas [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
733 47dc83f5 2023-03-08 thomas [AC_MSG_RESULT(no)]
734 dd038bc6 2021-09-21 thomas.ad )
735 dd038bc6 2021-09-21 thomas.ad
736 d9e4d43f 2022-03-03 thomas PKG_CHECK_MODULES(
737 d9e4d43f 2022-03-03 thomas LIBPANELW,
738 d9e4d43f 2022-03-03 thomas panelw,
739 d3f1e38b 2023-03-08 thomas LIBPANELW_LIBS="$LIBPANELW_LIBS"
740 d9e4d43f 2022-03-03 thomas found_panel=yes,
741 d9e4d43f 2022-03-03 thomas found_panel=no
742 d9e4d43f 2022-03-03 thomas )
743 d9e4d43f 2022-03-03 thomas
744 d3f1e38b 2023-03-08 thomas if test "x$found_panel" = "xno"; then
745 d9e4d43f 2022-03-03 thomas PKG_CHECK_MODULES(
746 d9e4d43f 2022-03-03 thomas LIBPANELW,
747 d9e4d43f 2022-03-03 thomas gnupanelw,
748 d3f1e38b 2023-03-08 thomas [
749 d3f1e38b 2023-03-08 thomas LIBPANELW_LIBS="$LIBPANELW_LIBS"
750 d3f1e38b 2023-03-08 thomas found_panel=yes
751 d3f1e38b 2023-03-08 thomas ],
752 d9e4d43f 2022-03-03 thomas found_panel=no
753 d9e4d43f 2022-03-03 thomas )
754 d3f1e38b 2023-03-08 thomas fi
755 d9e4d43f 2022-03-03 thomas
756 d3f1e38b 2023-03-08 thomas if test "x$found_panel" = "xno"; then
757 b26177ad 2022-03-03 thomas PKG_CHECK_MODULES(
758 b26177ad 2022-03-03 thomas LIBPANELW,
759 b26177ad 2022-03-03 thomas panel,
760 d3f1e38b 2023-03-08 thomas [
761 d3f1e38b 2023-03-08 thomas LIBPANELW_LIBS="$LIBPANELW_LIBS"
762 d3f1e38b 2023-03-08 thomas found_panel=yes
763 d3f1e38b 2023-03-08 thomas ],
764 b26177ad 2022-03-03 thomas found_panel=no
765 b26177ad 2022-03-03 thomas )
766 d3f1e38b 2023-03-08 thomas fi
767 d3f1e38b 2023-03-08 thomas
768 d9e4d43f 2022-03-03 thomas if test "x$found_panel" = "xno"; then
769 947fe78c 2023-01-06 thomas AC_CHECK_LIB(panelw, update_panels, [],
770 947fe78c 2023-01-06 thomas AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
771 947fe78c 2023-01-06 thomas [-lncurses]
772 92a9e85d 2021-09-24 thomas )
773 acf52a76 2021-09-21 thomas.ad
774 92a9e85d 2021-09-24 thomas fi
775 92a9e85d 2021-09-24 thomas
776 acf52a76 2021-09-21 thomas.ad PKG_CHECK_MODULES(
777 acf52a76 2021-09-21 thomas.ad LIBNCURSES,
778 acf52a76 2021-09-21 thomas.ad ncursesw,
779 dd038bc6 2021-09-21 thomas.ad found_ncurses=yes,
780 dd038bc6 2021-09-21 thomas.ad found_ncurses=no
781 dd038bc6 2021-09-21 thomas.ad )
782 acf52a76 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
783 4fccd2fe 2023-03-08 thomas libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
784 4fccd2fe 2023-03-08 thomas libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
785 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_CFLAGS)
786 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_LIBS)
787 dd038bc6 2021-09-21 thomas.ad else
788 4fccd2fe 2023-03-08 thomas AC_SEARCH_LIBS(
789 dd038bc6 2021-09-21 thomas.ad setupterm,
790 dd038bc6 2021-09-21 thomas.ad found_ncurses=yes,
791 dd038bc6 2021-09-21 thomas.ad found_ncurses=no
792 dd038bc6 2021-09-21 thomas.ad )
793 dd038bc6 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
794 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER(
795 dd038bc6 2021-09-21 thomas.ad ncurses.h,
796 4fccd2fe 2023-03-08 thomas libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
797 4fccd2fe 2023-03-08 thomas libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
798 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_CFLAGS)
799 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_LIBS)
800 acf52a76 2021-09-21 thomas.ad )
801 92a9e85d 2021-09-24 thomas fi
802 dd038bc6 2021-09-21 thomas.ad fi
803 dd038bc6 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
804 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
805 dd038bc6 2021-09-21 thomas.ad else
806 dd038bc6 2021-09-21 thomas.ad # No ncurses, try curses.
807 4fccd2fe 2023-03-08 thomas AC_CHECK_FUNC(
808 dd038bc6 2021-09-21 thomas.ad setupterm,
809 dd038bc6 2021-09-21 thomas.ad found_curses=yes,
810 dd038bc6 2021-09-21 thomas.ad found_curses=no
811 dd038bc6 2021-09-21 thomas.ad )
812 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER(
813 dd038bc6 2021-09-21 thomas.ad curses.h,
814 4fccd2fe 2023-03-08 thomas found_curses=yes,
815 dd038bc6 2021-09-21 thomas.ad found_curses=no)
816 dd038bc6 2021-09-21 thomas.ad if test "x$found_curses" = xyes; then
817 4fccd2fe 2023-03-08 thomas libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
818 d3f1e38b 2023-03-08 thomas libncurses_LIBS="$LIBPANELW_LIBS -lncursesw -lpanelw"
819 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_CFLAGS)
820 4fccd2fe 2023-03-08 thomas AC_SUBST(libncurses_LIBS)
821 47dc83f5 2023-03-08 thomas AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
822 dd038bc6 2021-09-21 thomas.ad else
823 dd038bc6 2021-09-21 thomas.ad AC_MSG_ERROR("curses not found")
824 dd038bc6 2021-09-21 thomas.ad fi
825 dd038bc6 2021-09-21 thomas.ad fi
826 dd038bc6 2021-09-21 thomas.ad
827 dd038bc6 2021-09-21 thomas.ad # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
828 dd038bc6 2021-09-21 thomas.ad # variables.
829 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_CPPFLAGS)
830 dd038bc6 2021-09-21 thomas.ad CPPFLAGS="$SAVED_CPPFLAGS"
831 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_CFLAGS)
832 dd038bc6 2021-09-21 thomas.ad CFLAGS="$SAVED_CFLAGS"
833 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_LDFLAGS)
834 dd038bc6 2021-09-21 thomas.ad LDFLAGS="$SAVED_LDFLAGS"
835 dd038bc6 2021-09-21 thomas.ad
836 943e9ed2 2023-03-08 thomas # LIBS is designed to accumulate library dependencies as checks for them are
837 943e9ed2 2023-03-08 thomas # peformed, so that this can be included directly to ld(1).
838 943e9ed2 2023-03-08 thomas #
839 943e9ed2 2023-03-08 thomas # However, this hinders the splitting up of the library dependencies so that
840 943e9ed2 2023-03-08 thomas # they're targetted just where they're needed. Flatting LIBS here ensures
841 943e9ed2 2023-03-08 thomas # that this happens appropriately.
842 943e9ed2 2023-03-08 thomas LIBS=""
843 4fccd2fe 2023-03-08 thomas
844 47dc83f5 2023-03-08 thomas AH_BOTTOM([#include "got_compat2.h"])
845 47dc83f5 2023-03-08 thomas
846 dd038bc6 2021-09-21 thomas.ad AC_CONFIG_FILES([Makefile
847 dd038bc6 2021-09-21 thomas.ad compat/Makefile
848 dd038bc6 2021-09-21 thomas.ad libexec/Makefile
849 dd038bc6 2021-09-21 thomas.ad libexec/got-read-tree/Makefile
850 dd038bc6 2021-09-21 thomas.ad libexec/got-fetch-pack/Makefile
851 dd038bc6 2021-09-21 thomas.ad libexec/got-index-pack/Makefile
852 dd038bc6 2021-09-21 thomas.ad libexec/got-read-blob/Makefile
853 dd038bc6 2021-09-21 thomas.ad libexec/got-read-commit/Makefile
854 dd038bc6 2021-09-21 thomas.ad libexec/got-read-gitconfig/Makefile
855 dd038bc6 2021-09-21 thomas.ad libexec/got-read-gotconfig/Makefile
856 dd038bc6 2021-09-21 thomas.ad libexec/got-read-object/Makefile
857 dd038bc6 2021-09-21 thomas.ad libexec/got-read-pack/Makefile
858 973f3f6e 2022-03-07 thomas libexec/got-read-patch/Makefile
859 dd038bc6 2021-09-21 thomas.ad libexec/got-read-tag/Makefile
860 dd038bc6 2021-09-21 thomas.ad libexec/got-send-pack/Makefile
861 dd038bc6 2021-09-21 thomas.ad got/Makefile
862 2b0eee35 2021-09-21 thomas.ad gotadmin/Makefile
863 ff36aeea 2022-07-16 thomas gotwebd/Makefile
864 d3f2ad5e 2021-09-21 thomas.ad tog/Makefile
865 5a7ef102 2021-10-09 thomas Makefile.common:Makefile.common.in])
866 dd038bc6 2021-09-21 thomas.ad AC_OUTPUT
867 dd038bc6 2021-09-21 thomas.ad
868 9ffe20fd 2022-09-10 thomas executables="$(eval echo ${exec_prefix}/bin)"
869 9ffe20fd 2022-09-10 thomas helpers="$(eval echo ${libexecdir})"
870 9ffe20fd 2022-09-10 thomas manpages="$(eval echo ${mandir})"
871 9ffe20fd 2022-09-10 thomas
872 9ffe20fd 2022-09-10 thomas echo "
873 9ffe20fd 2022-09-10 thomas Configured got-portable with:
874 9ffe20fd 2022-09-10 thomas
875 9ffe20fd 2022-09-10 thomas Version: $VERSION
876 9ffe20fd 2022-09-10 thomas
877 9ffe20fd 2022-09-10 thomas Prefix: ${prefix}
878 9ffe20fd 2022-09-10 thomas Executables: ${executables}
879 b29d689b 2023-02-11 thomas Bison: $YACC
880 4fccd2fe 2023-03-08 thomas CFlags: $CFLAGS
881 9ffe20fd 2022-09-10 thomas Helpers: ${helpers}
882 9ffe20fd 2022-09-10 thomas Man pages: ${manpages}
883 9ffe20fd 2022-09-10 thomas "