1 # Process this file with autoconf to produce a configure script.
4 AC_INIT([got-portable],
5 m4_esyscmd([util/got-portable-ver.sh]),
8 AC_CONFIG_SRCDIR([lib/rcsutil.h])
9 AM_INIT_AUTOMAKE([foreign subdir-objects])
13 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
19 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
20 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
24 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
25 # AC_CHECK_HEADER doesn't give us any other way to update the include
26 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
27 SAVED_CFLAGS="$CFLAGS"
28 SAVED_CPPFLAGS="$CPPFLAGS"
29 SAVED_LDFLAGS="$LDFLAGS"
31 # Checks for programs.
40 AC_USE_SYSTEM_EXTENSIONS
42 # Checks for header files.
69 # Checks for typ edefs, structures, and compiler characteristics.
70 AC_CHECK_HEADER_STDBOOL
83 # Check for ifgroupreq which is only available on BSD.
84 AC_CHECK_TYPES([struct ifgroupreq])
86 # Look for library needed for flock.
87 AC_SEARCH_LIBS(flock, bsd)
89 # Checks for library functions.
92 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
133 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
134 AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
135 AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
138 AC_CHECK_FUNCS([SipHash])
139 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
141 # Check for functions with a compatibility implementation.
160 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
161 # musl does not set optarg to NULL for flags without arguments (although it is
162 # not required to, but it is helpful) 3) there are probably other weird
166 # Check the platform we're compiling on.
167 AC_MSG_CHECKING(platform)
174 AC_MSG_RESULT(freebsd)
178 AC_MSG_RESULT(darwin)
182 AC_MSG_RESULT(netbsd)
186 AC_MSG_RESULT(dragonfly)
187 PLATFORM=dragonflybsd
190 AC_MSG_RESULT(unknown)
195 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
196 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
197 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
198 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
199 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
201 if test x"$PLATFORM" = "xdarwin"; then
202 if ! test -x "/usr/local/opt/bison/bin/bison"; then
203 AC_MSG_ERROR("GNU Bison not found")
206 # Override YACC here to point to the GNU version of bison.
207 export YACC="/usr/local/opt/bison/bin/bison -y"
208 export LDFLAGS="-L/usr/local/opt/ncurses/lib -L/usr/local/opt/openssl@3/lib $LDFLAGS"
209 export CPPFLAGS="-I/usr/local/opt/ncurses/include -I/usr/local/opt/openssl@3/include $CPPFLAGS"
210 export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"
211 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/openssl@3/lib/pkgconfig"
214 # Landlock detection.
215 AC_MSG_CHECKING([for landlock])
216 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
217 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
218 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
224 # Clang sanitizers wrap reallocarray even if it isn't available on the target
225 # system. When compiled it always returns NULL and crashes the program. To
226 # detect this we need a more complicated test.
227 AC_MSG_CHECKING([for working reallocarray])
228 AC_RUN_IFELSE([AC_LANG_PROGRAM(
229 [#include <stdlib.h>],
230 [return (reallocarray(NULL, 1, 1) == NULL);]
233 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
234 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
236 AC_MSG_CHECKING([for working recallocarray])
237 AC_RUN_IFELSE([AC_LANG_PROGRAM(
238 [#include <stdlib.h>],
239 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
242 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
243 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
246 # Look for imsg_init in libutil.
247 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
248 if test "x$found_imsg_init" = xyes; then
252 AC_LIBOBJ(imsg-buffer)
255 # libevent (for gotwebd). Lifted from tmux.
256 # Look for libevent. Try libevent_core or libevent with pkg-config first then
257 # look for the library.
260 [libevent_core >= 2],
262 AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
263 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
264 LIBS="$LIBEVENT_CORE_LIBS $LIBS"
269 if test x$found_libevent = xno; then
274 AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
275 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
276 LIBS="$LIBEVENT_LIBS $LIBS"
282 if test x$found_libevent = xno; then
285 [event_core event event-1.4],
292 AC_DEFINE(HAVE_EVENT2_EVENT_H),
296 AC_DEFINE(HAVE_EVENT_H),
301 if test "x$found_libevent" = xno; then
302 AC_MSG_ERROR("libevent not found")
305 # libcrypto (via libssl for SHA information)
310 AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
311 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
312 LIBS="$LIBCRYPTO_LIBS $LIBS"
320 if test "x$found_libcrypto" = "xyes"; then
321 AC_DEFINE(HAVE_LIBCRYPTO)
324 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
325 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
326 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
328 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
329 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
331 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
332 AC_DEFINE(HAVE_BSD_UUID)
338 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
339 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
340 LIBS="$LIBUUID_LIBS $LIBS"
348 if test "x$found_libuuid" = "xno"; then
356 if test "x$found_libuuid" = "xno"; then
357 AC_MSG_ERROR("*** couldn't find uuid ***")
364 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
365 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
366 LIBS="$ZLIB_LIBS $LIBS"
374 if test "x$found_zlib" = "xno"; then
381 if test "x$found_zlib" = "xno"; then
382 AC_MSG_ERROR("*** couldn't find zlib ***")
385 if test "$PLATFORM" = "linux"; then
390 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
391 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
392 LIBS="$LIBMD_LIBS $LIBS"
395 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
402 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
403 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
404 LIBS="$LIBBSD_LIBS $LIBS"
406 AC_DEFINE(HAVE_LIBBSD)
412 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
445 if test "x$found_queue_h" = xyes -o "x$ac_cv_header_sys_queue_h" = xyes; then
446 AC_DEFINE(HAVE_QUEUE_H)
449 # Look for __progname.
450 AC_MSG_CHECKING(for __progname)
451 AC_LINK_IFELSE([AC_LANG_SOURCE(
455 extern char *__progname;
457 const char *cp = __progname;
462 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
486 if test "x$found_panel" = "xno"; then
487 AC_CHECK_LIB(panelw, update_panels,,
488 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
491 LIBPANELW_LIBS="-lpanelw"
500 if test "x$found_ncurses" = xyes; then
501 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
502 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
503 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
511 if test "x$found_ncurses" = xyes; then
514 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
515 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
516 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
521 if test "x$found_ncurses" = xyes; then
522 AC_DEFINE(HAVE_NCURSES_H)
524 # No ncurses, try curses.
535 if test "x$found_curses" = xyes; then
536 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
537 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
538 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
539 AC_DEFINE(HAVE_CURSES_H)
541 AC_MSG_ERROR("curses not found")
545 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
547 AC_SUBST(AM_CPPFLAGS)
548 CPPFLAGS="$SAVED_CPPFLAGS"
550 CFLAGS="$SAVED_CFLAGS"
552 LDFLAGS="$SAVED_LDFLAGS"
554 AC_CONFIG_FILES([Makefile
557 libexec/got-read-tree/Makefile
558 libexec/got-fetch-pack/Makefile
559 libexec/got-index-pack/Makefile
560 libexec/got-read-blob/Makefile
561 libexec/got-read-commit/Makefile
562 libexec/got-read-gitconfig/Makefile
563 libexec/got-read-gotconfig/Makefile
564 libexec/got-read-object/Makefile
565 libexec/got-read-pack/Makefile
566 libexec/got-read-patch/Makefile
567 libexec/got-read-tag/Makefile
568 libexec/got-send-pack/Makefile
573 Makefile.common:Makefile.common.in])
577 # regress/GNUMakefile
578 # regress/cmdline/GNUMakefile
579 # regress/delta/GNUMakefile
580 # regress/fetch/GNUMakefile
581 # regress/idset/GNUMakefile
582 # regress/path/GNUMakefile
584 # gotweb/libexec/GNUMakefile
585 # gotweb/libexec/got-read-blob/GNUMakefile
586 # gotweb/libexec/got-read-commit/GNUMakefile
587 # gotweb/libexec/got-read-gitconfig/GNUMakefile
588 # gotweb/libexec/got-read-gotconfig/GNUMakefile
589 # gotweb/libexec/got-read-object/GNUMakefile
590 # gotweb/libexec/got-read-pack/GNUMakefile
591 # gotweb/libexec/got-read-tag/GNUMakefile
592 # gotweb/libexec/got-read-tree/GNUMakefile