1 dd038bc6 2021-09-21 thomas.ad # Process this file with autoconf to produce a configure script.
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])
11 dd038bc6 2021-09-21 thomas.ad AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
12 dd038bc6 2021-09-21 thomas.ad AC_SUBST(VERSION)
13 dd038bc6 2021-09-21 thomas.ad AC_SUBST(GOT_RELEASE)
15 dd038bc6 2021-09-21 thomas.ad AC_CANONICAL_HOST
17 dd038bc6 2021-09-21 thomas.ad # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
18 dd038bc6 2021-09-21 thomas.ad # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
19 dd038bc6 2021-09-21 thomas.ad # empty default.
20 dd038bc6 2021-09-21 thomas.ad : ${CFLAGS=""}
22 dd038bc6 2021-09-21 thomas.ad # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
23 dd038bc6 2021-09-21 thomas.ad # AC_CHECK_HEADER doesn't give us any other way to update the include
24 dd038bc6 2021-09-21 thomas.ad # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
25 dd038bc6 2021-09-21 thomas.ad SAVED_CFLAGS="$CFLAGS"
26 dd038bc6 2021-09-21 thomas.ad SAVED_CPPFLAGS="$CPPFLAGS"
27 dd038bc6 2021-09-21 thomas.ad SAVED_LDFLAGS="$LDFLAGS"
29 dd038bc6 2021-09-21 thomas.ad # Checks for programs.
30 dd038bc6 2021-09-21 thomas.ad AC_PROG_CC
31 dd038bc6 2021-09-21 thomas.ad AC_PROG_CPP
32 dd038bc6 2021-09-21 thomas.ad AC_PROG_INSTALL
33 dd038bc6 2021-09-21 thomas.ad AC_PROG_LN_S
34 dd038bc6 2021-09-21 thomas.ad AC_PROG_MAKE_SET
35 dd038bc6 2021-09-21 thomas.ad AC_PROG_YACC
36 dd038bc6 2021-09-21 thomas.ad AC_PROG_RANLIB
37 dd038bc6 2021-09-21 thomas.ad PKG_PROG_PKG_CONFIG
38 dd038bc6 2021-09-21 thomas.ad AC_USE_SYSTEM_EXTENSIONS
40 dd038bc6 2021-09-21 thomas.ad # Checks for header files.
41 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADERS([ \
42 dd038bc6 2021-09-21 thomas.ad fcntl.h \
43 dd038bc6 2021-09-21 thomas.ad langinfo.h \
44 dd038bc6 2021-09-21 thomas.ad limits.h \
45 97799ccd 2022-02-06 thomas linux/landlock.h \
46 dd038bc6 2021-09-21 thomas.ad locale.h \
47 dd038bc6 2021-09-21 thomas.ad netdb.h \
48 dd038bc6 2021-09-21 thomas.ad netinet/in.h \
49 dd038bc6 2021-09-21 thomas.ad paths.h \
51 dd038bc6 2021-09-21 thomas.ad stddef.h \
52 dd038bc6 2021-09-21 thomas.ad stdint.h \
53 dd038bc6 2021-09-21 thomas.ad stdlib.h \
54 dd038bc6 2021-09-21 thomas.ad string.h \
55 dd038bc6 2021-09-21 thomas.ad sys/ioctl.h \
56 dd038bc6 2021-09-21 thomas.ad sys/param.h \
57 d24ddaa6 2022-02-26 thomas sys/poll.h \
58 19467d59 2022-07-16 thomas sys/queue.h \
59 dd038bc6 2021-09-21 thomas.ad sys/socket.h \
60 dd038bc6 2021-09-21 thomas.ad sys/time.h \
61 dd038bc6 2021-09-21 thomas.ad sys/tree.h \
62 dd038bc6 2021-09-21 thomas.ad util.h \
63 dd038bc6 2021-09-21 thomas.ad unistd.h \
64 dd038bc6 2021-09-21 thomas.ad wchar.h \
67 dd038bc6 2021-09-21 thomas.ad # Checks for typ edefs, structures, and compiler characteristics.
68 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER_STDBOOL
69 dd038bc6 2021-09-21 thomas.ad AC_C_INLINE
70 dd038bc6 2021-09-21 thomas.ad AC_TYPE_INT64_T
71 dd038bc6 2021-09-21 thomas.ad AC_TYPE_MODE_T
72 dd038bc6 2021-09-21 thomas.ad AC_TYPE_OFF_T
73 dd038bc6 2021-09-21 thomas.ad AC_TYPE_PID_T
74 dd038bc6 2021-09-21 thomas.ad AC_TYPE_SIZE_T
75 dd038bc6 2021-09-21 thomas.ad AC_TYPE_SSIZE_T
76 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT16_T
77 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT32_T
78 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT64_T
79 dd038bc6 2021-09-21 thomas.ad AC_TYPE_UINT8_T
81 ff36aeea 2022-07-16 thomas # Check for ifgroupreq which is only available on BSD.
82 ff36aeea 2022-07-16 thomas AC_CHECK_TYPES([struct ifgroupreq])
84 75716fd6 2022-08-27 thomas # Check for sockaddr_storage. On some systems, ss_len is filled out, although
85 75716fd6 2022-08-27 thomas # this is not mandated by POSIX, and hence systems such as linux, don't have
87 75716fd6 2022-08-27 thomas AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
88 75716fd6 2022-08-27 thomas #include <sys/types.h>
89 75716fd6 2022-08-27 thomas #include <sys/socket.h>
92 75716fd6 2022-08-27 thomas # Same thing as sockaddr_storage above, only now check if the member exists in
93 75716fd6 2022-08-27 thomas # the struct as well.
94 75716fd6 2022-08-27 thomas AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
95 75716fd6 2022-08-27 thomas [ #include <netdb.h>
96 75716fd6 2022-08-27 thomas #include <netinet/in.h>
97 75716fd6 2022-08-27 thomas #include <sys/socket.h> ]
100 75716fd6 2022-08-27 thomas AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
101 75716fd6 2022-08-27 thomas [ #include <netdb.h>
102 75716fd6 2022-08-27 thomas #include <netinet/in.h>
103 75716fd6 2022-08-27 thomas #include <sys/socket.h> ]
106 75716fd6 2022-08-27 thomas # Both checks above will result in:
108 75716fd6 2022-08-27 thomas # HAVE_STRUCT_SOCKADDR_AS_LEN
111 75716fd6 2022-08-27 thomas # Either being defined or not.
113 dd038bc6 2021-09-21 thomas.ad # Look for library needed for flock.
114 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(flock, bsd)
116 dd038bc6 2021-09-21 thomas.ad # Checks for library functions.
117 dd038bc6 2021-09-21 thomas.ad AC_FUNC_FORK
118 dd038bc6 2021-09-21 thomas.ad AC_FUNC_FSEEKO
119 dd038bc6 2021-09-21 thomas.ad AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
120 dd038bc6 2021-09-21 thomas.ad AC_FUNC_MALLOC
121 dd038bc6 2021-09-21 thomas.ad AC_FUNC_MMAP
122 dd038bc6 2021-09-21 thomas.ad AC_FUNC_REALLOC
123 dd038bc6 2021-09-21 thomas.ad AC_FUNC_STRERROR_R
124 dd038bc6 2021-09-21 thomas.ad AC_FUNC_STRNLEN
125 dd038bc6 2021-09-21 thomas.ad AC_CHECK_FUNCS([ \
126 dd038bc6 2021-09-21 thomas.ad dup2 \
127 dd038bc6 2021-09-21 thomas.ad flock \
128 dd038bc6 2021-09-21 thomas.ad getcwd \
129 dd038bc6 2021-09-21 thomas.ad localtime_r \
130 dd038bc6 2021-09-21 thomas.ad memchr \
131 dd038bc6 2021-09-21 thomas.ad memmove \
132 dd038bc6 2021-09-21 thomas.ad memset \
133 dd038bc6 2021-09-21 thomas.ad mkdir \
134 dd038bc6 2021-09-21 thomas.ad munmap \
135 dd038bc6 2021-09-21 thomas.ad nl_langinfo \
136 dd038bc6 2021-09-21 thomas.ad realpath \
137 dd038bc6 2021-09-21 thomas.ad regcomp \
138 dd038bc6 2021-09-21 thomas.ad rmdir \
139 dd038bc6 2021-09-21 thomas.ad setlocale \
140 dd038bc6 2021-09-21 thomas.ad socket \
141 683ec58e 2022-07-16 thomas setresgid \
142 683ec58e 2022-07-16 thomas setresuid \
143 c4e2e0d0 2022-07-16 thomas setproctitle \
144 dd038bc6 2021-09-21 thomas.ad strcasecmp \
145 dd038bc6 2021-09-21 thomas.ad strchr \
146 dd038bc6 2021-09-21 thomas.ad strcspn \
147 dd038bc6 2021-09-21 thomas.ad strdup \
148 dd038bc6 2021-09-21 thomas.ad strerror \
149 dd038bc6 2021-09-21 thomas.ad strlcpy \
150 dd038bc6 2021-09-21 thomas.ad strncasecmp \
151 dd038bc6 2021-09-21 thomas.ad strndup \
152 dd038bc6 2021-09-21 thomas.ad strrchr \
153 dd038bc6 2021-09-21 thomas.ad strspn \
154 dd038bc6 2021-09-21 thomas.ad strstr \
155 dd038bc6 2021-09-21 thomas.ad strtol \
156 dd038bc6 2021-09-21 thomas.ad strtoul \
157 dd038bc6 2021-09-21 thomas.ad wcwidth \
160 c4e2e0d0 2022-07-16 thomas AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
161 683ec58e 2022-07-16 thomas AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
162 683ec58e 2022-07-16 thomas AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
164 ddd12270 2022-04-22 thomas # Siphash support.
165 ddd12270 2022-04-22 thomas AC_CHECK_FUNCS([SipHash])
166 ddd12270 2022-04-22 thomas AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
168 dd038bc6 2021-09-21 thomas.ad # Check for functions with a compatibility implementation.
169 dd038bc6 2021-09-21 thomas.ad AC_REPLACE_FUNCS([ \
170 dd038bc6 2021-09-21 thomas.ad asprintf \
171 dd038bc6 2021-09-21 thomas.ad closefrom \
172 dd038bc6 2021-09-21 thomas.ad explicit_bzero \
173 dd038bc6 2021-09-21 thomas.ad fmt_scaled \
174 dd038bc6 2021-09-21 thomas.ad freezero \
175 dd038bc6 2021-09-21 thomas.ad getdtablecount \
176 dd038bc6 2021-09-21 thomas.ad getline \
177 dd038bc6 2021-09-21 thomas.ad getprogname \
178 dd038bc6 2021-09-21 thomas.ad recallocarray \
179 dd038bc6 2021-09-21 thomas.ad reallocarray \
180 dd038bc6 2021-09-21 thomas.ad strlcat \
181 dd038bc6 2021-09-21 thomas.ad strlcpy \
182 dd038bc6 2021-09-21 thomas.ad strndup \
183 dd038bc6 2021-09-21 thomas.ad strsep \
184 dd038bc6 2021-09-21 thomas.ad strtonum \
187 dd038bc6 2021-09-21 thomas.ad # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
188 dd038bc6 2021-09-21 thomas.ad # musl does not set optarg to NULL for flags without arguments (although it is
189 dd038bc6 2021-09-21 thomas.ad # not required to, but it is helpful) 3) there are probably other weird
190 dd038bc6 2021-09-21 thomas.ad # implementations.
191 dd038bc6 2021-09-21 thomas.ad AC_LIBOBJ(getopt)
193 92a9e85d 2021-09-24 thomas # Check the platform we're compiling on.
194 92a9e85d 2021-09-24 thomas AC_MSG_CHECKING(platform)
195 92a9e85d 2021-09-24 thomas case "$host_os" in
197 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(linux)
198 92a9e85d 2021-09-24 thomas PLATFORM=linux
200 92a9e85d 2021-09-24 thomas *freebsd*)
201 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(freebsd)
202 92a9e85d 2021-09-24 thomas PLATFORM=freebsd
204 d24ddaa6 2022-02-26 thomas *darwin*)
205 d24ddaa6 2022-02-26 thomas AC_MSG_RESULT(darwin)
206 d24ddaa6 2022-02-26 thomas PLATFORM=darwin
208 a3732bb6 2022-02-26 thomas *netbsd*)
209 a3732bb6 2022-02-26 thomas AC_MSG_RESULT(netbsd)
210 a3732bb6 2022-02-26 thomas PLATFORM=netbsd
212 b26177ad 2022-03-03 thomas *dragonfly*)
213 b26177ad 2022-03-03 thomas AC_MSG_RESULT(dragonfly)
214 b26177ad 2022-03-03 thomas PLATFORM=dragonflybsd
217 92a9e85d 2021-09-24 thomas AC_MSG_RESULT(unknown)
218 92a9e85d 2021-09-24 thomas PLATFORM=unknown
221 92a9e85d 2021-09-24 thomas AC_SUBST(PLATFORM)
222 92a9e85d 2021-09-24 thomas AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
223 92a9e85d 2021-09-24 thomas AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
224 d24ddaa6 2022-02-26 thomas AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
225 a3732bb6 2022-02-26 thomas AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
226 b26177ad 2022-03-03 thomas AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
228 51207398 2022-07-21 thomas if test x"$PLATFORM" = "xdarwin"; then
229 5baa5fe2 2022-09-05 thomas # Check for and/or set HOMEBREW_PREFIX. brew is a common way of
230 5baa5fe2 2022-09-05 thomas # installing applications. The other is MacPorts.
232 5baa5fe2 2022-09-05 thomas # Before Apple Silicon existed (M1 onward), the paths for applications
233 5baa5fe2 2022-09-05 thomas # installed via homebrew was typically /usr/local. However, with M1
234 5baa5fe2 2022-09-05 thomas # onward, this changed to a different path.
236 5baa5fe2 2022-09-05 thomas # Rather than hardcode this, check for HOMEBREW_PREFIX in the
237 8e396e19 2022-09-12 thomas # environment if it's already set, and use it. Otherwise, check for
238 5baa5fe2 2022-09-05 thomas # brew(1) and use that. If that fails, default to /usr/local
240 5baa5fe2 2022-09-05 thomas # This also means that MacPorts should continue to work.
242 8e396e19 2022-09-12 thomas # But with MacPorts, we should also check --prefix, and use that if it
243 8e396e19 2022-09-12 thomas # has been supplied.
245 8e396e19 2022-09-12 thomas # In both cases, the variable HOMEBREW_PREFIX is used for both.
246 8e396e19 2022-09-12 thomas HB_PREFIX=""
247 8e396e19 2022-09-12 thomas FOUND_BISON="no"
248 8e396e19 2022-09-12 thomas GNUBISON=""
249 8e396e19 2022-09-12 thomas if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
250 5baa5fe2 2022-09-05 thomas # HOMEBREW_PREFIX not set, check for brew(1)
251 8e396e19 2022-09-12 thomas if command -v brew >/dev/null 2>&1; then
252 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
253 5baa5fe2 2022-09-05 thomas export HOMEBREW_PREFIX="$(brew --prefix)"
256 8e396e19 2022-09-12 thomas if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
258 5baa5fe2 2022-09-05 thomas # Default.
259 8e396e19 2022-09-12 thomas if test -z "${prefix}" -o "${prefix}" = "NONE"; then
260 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="/usr/local"
261 8e396e19 2022-09-12 thomas HB_PREFIX="/usr/local"
262 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
264 8e396e19 2022-09-12 thomas HB_PREFIX="$(eval echo ${prefix})"
265 8e396e19 2022-09-12 thomas if test "$HB_PREFIX" = "NONE"; then
266 8e396e19 2022-09-12 thomas HB_PREFIX="/opt/local"
268 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
270 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="$HB_PREFIX"
275 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
277 5baa5fe2 2022-09-05 thomas if ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
278 8e396e19 2022-09-12 thomas AC_MSG_WARN([
279 8e396e19 2022-09-12 thomas "***********************************************************
280 8e396e19 2022-09-12 thomas GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
281 8e396e19 2022-09-12 thomas ***********************************************************
283 8e396e19 2022-09-12 thomas Falling back to checking either /usr/local or \${prefix}"
286 8e396e19 2022-09-12 thomas FOUND_BISON="no"
287 8e396e19 2022-09-12 thomas AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
288 8e396e19 2022-09-12 thomas if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
289 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="/usr/local"
290 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
291 8e396e19 2022-09-12 thomas GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
294 8e396e19 2022-09-12 thomas if test "$FOUND_BISON" = "no"; then
295 8e396e19 2022-09-12 thomas HB_PREFIX="/opt/local"
296 8e396e19 2022-09-12 thomas AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
298 8e396e19 2022-09-12 thomas if test -x "${HB_PREFIX}/bin/bison"; then
299 8e396e19 2022-09-12 thomas export HOMEBREW_PREFIX="${HB_PREFIX}"
300 8e396e19 2022-09-12 thomas GNUBISON="${HB_PREFIX}/bin/bison"
301 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
305 8e396e19 2022-09-12 thomas FOUND_BISON="yes"
306 8e396e19 2022-09-12 thomas GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
309 8e396e19 2022-09-12 thomas if test "$FOUND_BISON" = "no"; then
310 8e396e19 2022-09-12 thomas AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
313 8e396e19 2022-09-12 thomas AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
315 51207398 2022-07-21 thomas # Override YACC here to point to the GNU version of bison.
316 8e396e19 2022-09-12 thomas export YACC="${GNUBISON} -y"
317 8e396e19 2022-09-12 thomas export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
318 5baa5fe2 2022-09-05 thomas export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
319 5baa5fe2 2022-09-05 thomas export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
320 5baa5fe2 2022-09-05 thomas export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
323 97799ccd 2022-02-06 thomas # Landlock detection.
324 97799ccd 2022-02-06 thomas AC_MSG_CHECKING([for landlock])
325 97799ccd 2022-02-06 thomas AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
326 97799ccd 2022-02-06 thomas [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
327 97799ccd 2022-02-06 thomas if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
328 97799ccd 2022-02-06 thomas AC_MSG_RESULT(yes)
330 97799ccd 2022-02-06 thomas AC_MSG_RESULT(no)
333 dd038bc6 2021-09-21 thomas.ad # Clang sanitizers wrap reallocarray even if it isn't available on the target
334 dd038bc6 2021-09-21 thomas.ad # system. When compiled it always returns NULL and crashes the program. To
335 dd038bc6 2021-09-21 thomas.ad # detect this we need a more complicated test.
336 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING([for working reallocarray])
337 dd038bc6 2021-09-21 thomas.ad AC_RUN_IFELSE([AC_LANG_PROGRAM(
338 dd038bc6 2021-09-21 thomas.ad [#include <stdlib.h>],
339 dd038bc6 2021-09-21 thomas.ad [return (reallocarray(NULL, 1, 1) == NULL);]
341 dd038bc6 2021-09-21 thomas.ad AC_MSG_RESULT(yes),
342 7f20c2a8 2022-05-13 op [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
343 dd038bc6 2021-09-21 thomas.ad [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
345 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING([for working recallocarray])
346 dd038bc6 2021-09-21 thomas.ad AC_RUN_IFELSE([AC_LANG_PROGRAM(
347 dd038bc6 2021-09-21 thomas.ad [#include <stdlib.h>],
348 dd038bc6 2021-09-21 thomas.ad [return (recallocarray(NULL, 1, 1, 1) == NULL);]
350 dd038bc6 2021-09-21 thomas.ad AC_MSG_RESULT(yes),
351 7f20c2a8 2022-05-13 op [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
352 dd038bc6 2021-09-21 thomas.ad [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
355 dd038bc6 2021-09-21 thomas.ad # Look for imsg_init in libutil.
356 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
357 dd038bc6 2021-09-21 thomas.ad if test "x$found_imsg_init" = xyes; then
358 dd038bc6 2021-09-21 thomas.ad AC_DEFINE(HAVE_IMSG)
360 dd038bc6 2021-09-21 thomas.ad AC_LIBOBJ(imsg)
361 dd038bc6 2021-09-21 thomas.ad AC_LIBOBJ(imsg-buffer)
364 ff36aeea 2022-07-16 thomas # libevent (for gotwebd). Lifted from tmux.
365 ff36aeea 2022-07-16 thomas # Look for libevent. Try libevent_core or libevent with pkg-config first then
366 ff36aeea 2022-07-16 thomas # look for the library.
367 ff36aeea 2022-07-16 thomas PKG_CHECK_MODULES(
368 ff36aeea 2022-07-16 thomas LIBEVENT_CORE,
369 ff36aeea 2022-07-16 thomas [libevent_core >= 2],
371 ff36aeea 2022-07-16 thomas AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
372 ff36aeea 2022-07-16 thomas CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
373 ff36aeea 2022-07-16 thomas LIBS="$LIBEVENT_CORE_LIBS $LIBS"
374 ff36aeea 2022-07-16 thomas found_libevent=yes
376 ff36aeea 2022-07-16 thomas found_libevent=no
378 ff36aeea 2022-07-16 thomas if test x$found_libevent = xno; then
379 ff36aeea 2022-07-16 thomas PKG_CHECK_MODULES(
380 ff36aeea 2022-07-16 thomas LIBEVENT,
381 ff36aeea 2022-07-16 thomas [libevent >= 2],
383 ff36aeea 2022-07-16 thomas AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
384 ff36aeea 2022-07-16 thomas CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
385 ff36aeea 2022-07-16 thomas LIBS="$LIBEVENT_LIBS $LIBS"
386 ff36aeea 2022-07-16 thomas found_libevent=yes
388 ff36aeea 2022-07-16 thomas found_libevent=no
391 ff36aeea 2022-07-16 thomas if test x$found_libevent = xno; then
392 ff36aeea 2022-07-16 thomas AC_SEARCH_LIBS(
393 ff36aeea 2022-07-16 thomas event_init,
394 ff36aeea 2022-07-16 thomas [event_core event event-1.4],
395 ff36aeea 2022-07-16 thomas found_libevent=yes,
396 ff36aeea 2022-07-16 thomas found_libevent=no
399 ff36aeea 2022-07-16 thomas AC_CHECK_HEADER(
400 ff36aeea 2022-07-16 thomas event2/event.h,
401 ff36aeea 2022-07-16 thomas AC_DEFINE(HAVE_EVENT2_EVENT_H),
403 ff36aeea 2022-07-16 thomas AC_CHECK_HEADER(
405 ff36aeea 2022-07-16 thomas AC_DEFINE(HAVE_EVENT_H),
406 ff36aeea 2022-07-16 thomas found_libevent=no
410 ff36aeea 2022-07-16 thomas if test "x$found_libevent" = xno; then
411 ff36aeea 2022-07-16 thomas AC_MSG_ERROR("libevent not found")
414 dd038bc6 2021-09-21 thomas.ad # libcrypto (via libssl for SHA information)
415 dd038bc6 2021-09-21 thomas.ad PKG_CHECK_MODULES(
416 dd038bc6 2021-09-21 thomas.ad LIBCRYPTO,
417 dd038bc6 2021-09-21 thomas.ad libcrypto,
419 839511b2 2021-10-01 stsp AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
420 dd038bc6 2021-09-21 thomas.ad CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
421 dd038bc6 2021-09-21 thomas.ad LIBS="$LIBCRYPTO_LIBS $LIBS"
422 dd038bc6 2021-09-21 thomas.ad found_libcrypto=yes
425 92a9e85d 2021-09-24 thomas found_libcrypto=no
429 92a9e85d 2021-09-24 thomas if test "x$found_libcrypto" = "xyes"; then
430 92a9e85d 2021-09-24 thomas AC_DEFINE(HAVE_LIBCRYPTO)
433 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
434 326237a6 2021-09-25 thomas AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
435 dd038bc6 2021-09-21 thomas.ad AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
437 d24ddaa6 2022-02-26 thomas # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
438 d24ddaa6 2022-02-26 thomas # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
440 d24ddaa6 2022-02-26 thomas if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
441 326237a6 2021-09-25 thomas AC_DEFINE(HAVE_BSD_UUID)
443 326237a6 2021-09-25 thomas PKG_CHECK_MODULES(
447 326237a6 2021-09-25 thomas AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
448 326237a6 2021-09-25 thomas CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
449 326237a6 2021-09-25 thomas LIBS="$LIBUUID_LIBS $LIBS"
450 326237a6 2021-09-25 thomas found_libuuid=yes
453 326237a6 2021-09-25 thomas found_libuuid=no
457 326237a6 2021-09-25 thomas if test "x$found_libuuid" = "xno"; then
458 326237a6 2021-09-25 thomas AC_CHECK_HEADER(
460 326237a6 2021-09-25 thomas found_libuuid=yes,
461 326237a6 2021-09-25 thomas found_libuuid=no)
465 92a9e85d 2021-09-24 thomas if test "x$found_libuuid" = "xno"; then
466 92a9e85d 2021-09-24 thomas AC_MSG_ERROR("*** couldn't find uuid ***")
469 dd038bc6 2021-09-21 thomas.ad PKG_CHECK_MODULES(
473 dd038bc6 2021-09-21 thomas.ad AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
474 dd038bc6 2021-09-21 thomas.ad CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
475 dd038bc6 2021-09-21 thomas.ad LIBS="$ZLIB_LIBS $LIBS"
476 dd038bc6 2021-09-21 thomas.ad found_zlib=yes
479 92a9e85d 2021-09-24 thomas found_zlib=no
483 92a9e85d 2021-09-24 thomas if test "x$found_zlib" = "xno"; then
484 92a9e85d 2021-09-24 thomas AC_CHECK_HEADER(
487 92a9e85d 2021-09-24 thomas found_zlib=no)
490 92a9e85d 2021-09-24 thomas if test "x$found_zlib" = "xno"; then
491 92a9e85d 2021-09-24 thomas AC_MSG_ERROR("*** couldn't find zlib ***")
494 92a9e85d 2021-09-24 thomas if test "$PLATFORM" = "linux"; then
495 92a9e85d 2021-09-24 thomas PKG_CHECK_MODULES(
499 92a9e85d 2021-09-24 thomas AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
500 92a9e85d 2021-09-24 thomas CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
501 92a9e85d 2021-09-24 thomas LIBS="$LIBMD_LIBS $LIBS"
504 92a9e85d 2021-09-24 thomas AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
507 92a9e85d 2021-09-24 thomas PKG_CHECK_MODULES(
509 92a9e85d 2021-09-24 thomas libbsd-overlay,
511 92a9e85d 2021-09-24 thomas AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
512 92a9e85d 2021-09-24 thomas CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
513 92a9e85d 2021-09-24 thomas LIBS="$LIBBSD_LIBS $LIBS"
514 92a9e85d 2021-09-24 thomas found_libbsd=yes
515 92a9e85d 2021-09-24 thomas AC_DEFINE(HAVE_LIBBSD)
518 46384c6e 2022-09-13 thomas AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
524 dd038bc6 2021-09-21 thomas.ad # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
525 8dbd2d50 2022-08-12 thomas # some declarations.
526 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
527 dd038bc6 2021-09-21 thomas.ad TAILQ_CONCAT,
528 dd038bc6 2021-09-21 thomas.ad found_queue_h=yes,
529 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
530 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
532 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
533 dd038bc6 2021-09-21 thomas.ad TAILQ_PREV,
535 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
536 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
538 dd038bc6 2021-09-21 thomas.ad AC_CHECK_DECL(
539 dd038bc6 2021-09-21 thomas.ad TAILQ_FOREACH_SAFE,
541 dd038bc6 2021-09-21 thomas.ad found_queue_h=no,
542 8dbd2d50 2022-08-12 thomas [#include <sys/queue.h>]
545 8dbd2d50 2022-08-12 thomas if test "x$found_queue_h" = xyes; then
546 dd038bc6 2021-09-21 thomas.ad AC_DEFINE(HAVE_QUEUE_H)
548 46384c6e 2022-09-13 thomas AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
552 dd038bc6 2021-09-21 thomas.ad # Look for __progname.
553 dd038bc6 2021-09-21 thomas.ad AC_MSG_CHECKING(for __progname)
554 dd038bc6 2021-09-21 thomas.ad AC_LINK_IFELSE([AC_LANG_SOURCE(
556 dd038bc6 2021-09-21 thomas.ad #include <stdio.h>
557 dd038bc6 2021-09-21 thomas.ad #include <stdlib.h>
558 dd038bc6 2021-09-21 thomas.ad extern char *__progname;
559 dd038bc6 2021-09-21 thomas.ad int main(void) {
560 dd038bc6 2021-09-21 thomas.ad const char *cp = __progname;
561 dd038bc6 2021-09-21 thomas.ad printf("%s\n", cp);
562 dd038bc6 2021-09-21 thomas.ad exit(0);
565 dd038bc6 2021-09-21 thomas.ad [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
566 dd038bc6 2021-09-21 thomas.ad AC_MSG_RESULT(no)
569 d9e4d43f 2022-03-03 thomas PKG_CHECK_MODULES(
570 d9e4d43f 2022-03-03 thomas LIBPANELW,
572 d9e4d43f 2022-03-03 thomas found_panel=yes,
573 d9e4d43f 2022-03-03 thomas found_panel=no
576 d9e4d43f 2022-03-03 thomas PKG_CHECK_MODULES(
577 d9e4d43f 2022-03-03 thomas LIBPANELW,
578 d9e4d43f 2022-03-03 thomas gnupanelw,
579 d9e4d43f 2022-03-03 thomas found_panel=yes,
580 d9e4d43f 2022-03-03 thomas found_panel=no
583 b26177ad 2022-03-03 thomas PKG_CHECK_MODULES(
584 b26177ad 2022-03-03 thomas LIBPANELW,
586 b26177ad 2022-03-03 thomas found_panel=yes,
587 b26177ad 2022-03-03 thomas found_panel=no
589 d9e4d43f 2022-03-03 thomas if test "x$found_panel" = "xno"; then
590 92a9e85d 2021-09-24 thomas AC_CHECK_LIB(panelw, update_panels,,
591 92a9e85d 2021-09-24 thomas AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
594 92a9e85d 2021-09-24 thomas LIBPANELW_LIBS="-lpanelw"
597 acf52a76 2021-09-21 thomas.ad PKG_CHECK_MODULES(
598 acf52a76 2021-09-21 thomas.ad LIBNCURSES,
599 acf52a76 2021-09-21 thomas.ad ncursesw,
600 dd038bc6 2021-09-21 thomas.ad found_ncurses=yes,
601 dd038bc6 2021-09-21 thomas.ad found_ncurses=no
603 acf52a76 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
604 acf52a76 2021-09-21 thomas.ad AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
605 acf52a76 2021-09-21 thomas.ad CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
606 acf52a76 2021-09-21 thomas.ad LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
608 dd038bc6 2021-09-21 thomas.ad AC_CHECK_LIB(
609 acf52a76 2021-09-21 thomas.ad ncursesw,
610 dd038bc6 2021-09-21 thomas.ad setupterm,
611 dd038bc6 2021-09-21 thomas.ad found_ncurses=yes,
612 dd038bc6 2021-09-21 thomas.ad found_ncurses=no
614 dd038bc6 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
615 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER(
616 dd038bc6 2021-09-21 thomas.ad ncurses.h,
617 acf52a76 2021-09-21 thomas.ad AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
618 acf52a76 2021-09-21 thomas.ad CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
619 acf52a76 2021-09-21 thomas.ad LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
620 acf52a76 2021-09-21 thomas.ad found_ncurses=no
624 dd038bc6 2021-09-21 thomas.ad if test "x$found_ncurses" = xyes; then
625 dd038bc6 2021-09-21 thomas.ad AC_DEFINE(HAVE_NCURSES_H)
627 dd038bc6 2021-09-21 thomas.ad # No ncurses, try curses.
628 dd038bc6 2021-09-21 thomas.ad AC_CHECK_LIB(
629 acf52a76 2021-09-21 thomas.ad cursesw,
630 dd038bc6 2021-09-21 thomas.ad setupterm,
631 dd038bc6 2021-09-21 thomas.ad found_curses=yes,
632 dd038bc6 2021-09-21 thomas.ad found_curses=no
634 dd038bc6 2021-09-21 thomas.ad AC_CHECK_HEADER(
635 dd038bc6 2021-09-21 thomas.ad curses.h,
637 dd038bc6 2021-09-21 thomas.ad found_curses=no)
638 dd038bc6 2021-09-21 thomas.ad if test "x$found_curses" = xyes; then
639 acf52a76 2021-09-21 thomas.ad AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
640 acf52a76 2021-09-21 thomas.ad CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
641 acf52a76 2021-09-21 thomas.ad LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
642 dd038bc6 2021-09-21 thomas.ad AC_DEFINE(HAVE_CURSES_H)
644 dd038bc6 2021-09-21 thomas.ad AC_MSG_ERROR("curses not found")
648 dd038bc6 2021-09-21 thomas.ad # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
649 dd038bc6 2021-09-21 thomas.ad # variables.
650 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_CPPFLAGS)
651 dd038bc6 2021-09-21 thomas.ad CPPFLAGS="$SAVED_CPPFLAGS"
652 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_CFLAGS)
653 dd038bc6 2021-09-21 thomas.ad CFLAGS="$SAVED_CFLAGS"
654 dd038bc6 2021-09-21 thomas.ad AC_SUBST(AM_LDFLAGS)
655 dd038bc6 2021-09-21 thomas.ad LDFLAGS="$SAVED_LDFLAGS"
657 dd038bc6 2021-09-21 thomas.ad AC_CONFIG_FILES([Makefile
658 dd038bc6 2021-09-21 thomas.ad compat/Makefile
659 dd038bc6 2021-09-21 thomas.ad libexec/Makefile
660 dd038bc6 2021-09-21 thomas.ad libexec/got-read-tree/Makefile
661 dd038bc6 2021-09-21 thomas.ad libexec/got-fetch-pack/Makefile
662 dd038bc6 2021-09-21 thomas.ad libexec/got-index-pack/Makefile
663 dd038bc6 2021-09-21 thomas.ad libexec/got-read-blob/Makefile
664 dd038bc6 2021-09-21 thomas.ad libexec/got-read-commit/Makefile
665 dd038bc6 2021-09-21 thomas.ad libexec/got-read-gitconfig/Makefile
666 dd038bc6 2021-09-21 thomas.ad libexec/got-read-gotconfig/Makefile
667 dd038bc6 2021-09-21 thomas.ad libexec/got-read-object/Makefile
668 dd038bc6 2021-09-21 thomas.ad libexec/got-read-pack/Makefile
669 973f3f6e 2022-03-07 thomas libexec/got-read-patch/Makefile
670 dd038bc6 2021-09-21 thomas.ad libexec/got-read-tag/Makefile
671 dd038bc6 2021-09-21 thomas.ad libexec/got-send-pack/Makefile
672 dd038bc6 2021-09-21 thomas.ad got/Makefile
673 2b0eee35 2021-09-21 thomas.ad gotadmin/Makefile
674 ff36aeea 2022-07-16 thomas gotwebd/Makefile
675 d3f2ad5e 2021-09-21 thomas.ad tog/Makefile
676 5a7ef102 2021-10-09 thomas Makefile.common:Makefile.common.in])
677 dd038bc6 2021-09-21 thomas.ad AC_OUTPUT
679 9ffe20fd 2022-09-10 thomas executables="$(eval echo ${exec_prefix}/bin)"
680 9ffe20fd 2022-09-10 thomas helpers="$(eval echo ${libexecdir})"
681 9ffe20fd 2022-09-10 thomas manpages="$(eval echo ${mandir})"
684 9ffe20fd 2022-09-10 thomas Configured got-portable with:
686 9ffe20fd 2022-09-10 thomas Version: $VERSION
688 9ffe20fd 2022-09-10 thomas Prefix: ${prefix}
689 9ffe20fd 2022-09-10 thomas Executables: ${executables}
690 9ffe20fd 2022-09-10 thomas Helpers: ${helpers}
691 9ffe20fd 2022-09-10 thomas Man pages: ${manpages}