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