1 # Process this file with autoconf to produce a configure script.
4 AC_INIT([got-portable], [0.75], [thomas@xteddy.org])
6 AC_CONFIG_SRCDIR([lib/rcsutil.h])
7 AM_INIT_AUTOMAKE([foreign subdir-objects])
11 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
17 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
18 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
22 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
23 # AC_CHECK_HEADER doesn't give us any other way to update the include
24 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
25 SAVED_CFLAGS="$CFLAGS"
26 SAVED_CPPFLAGS="$CPPFLAGS"
27 SAVED_LDFLAGS="$LDFLAGS"
29 # Checks for programs.
38 AC_USE_SYSTEM_EXTENSIONS
40 # Checks for header files.
67 # Checks for typ edefs, structures, and compiler characteristics.
68 AC_CHECK_HEADER_STDBOOL
81 # Check for ifgroupreq which is only available on BSD.
82 AC_CHECK_TYPES([struct ifgroupreq])
84 # Look for library needed for flock.
85 AC_SEARCH_LIBS(flock, bsd)
87 # Checks for library functions.
90 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
131 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
132 AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
133 AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
136 AC_CHECK_FUNCS([SipHash])
137 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
139 # Check for functions with a compatibility implementation.
158 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
159 # musl does not set optarg to NULL for flags without arguments (although it is
160 # not required to, but it is helpful) 3) there are probably other weird
164 # Check the platform we're compiling on.
165 AC_MSG_CHECKING(platform)
172 AC_MSG_RESULT(freebsd)
176 AC_MSG_RESULT(darwin)
180 AC_MSG_RESULT(netbsd)
184 AC_MSG_RESULT(dragonfly)
185 PLATFORM=dragonflybsd
188 AC_MSG_RESULT(unknown)
193 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
194 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
195 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
196 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
197 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
199 # Landlock detection.
200 AC_MSG_CHECKING([for landlock])
201 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
202 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
203 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
209 # Clang sanitizers wrap reallocarray even if it isn't available on the target
210 # system. When compiled it always returns NULL and crashes the program. To
211 # detect this we need a more complicated test.
212 AC_MSG_CHECKING([for working reallocarray])
213 AC_RUN_IFELSE([AC_LANG_PROGRAM(
214 [#include <stdlib.h>],
215 [return (reallocarray(NULL, 1, 1) == NULL);]
218 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
219 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
221 AC_MSG_CHECKING([for working recallocarray])
222 AC_RUN_IFELSE([AC_LANG_PROGRAM(
223 [#include <stdlib.h>],
224 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
227 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
228 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
231 # Look for imsg_init in libutil.
232 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
233 if test "x$found_imsg_init" = xyes; then
237 AC_LIBOBJ(imsg-buffer)
240 # libevent (for gotwebd). Lifted from tmux.
241 # Look for libevent. Try libevent_core or libevent with pkg-config first then
242 # look for the library.
245 [libevent_core >= 2],
247 AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
248 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
249 LIBS="$LIBEVENT_CORE_LIBS $LIBS"
254 if test x$found_libevent = xno; then
259 AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
260 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
261 LIBS="$LIBEVENT_LIBS $LIBS"
267 if test x$found_libevent = xno; then
270 [event_core event event-1.4],
277 AC_DEFINE(HAVE_EVENT2_EVENT_H),
281 AC_DEFINE(HAVE_EVENT_H),
286 if test "x$found_libevent" = xno; then
287 AC_MSG_ERROR("libevent not found")
290 # libcrypto (via libssl for SHA information)
295 AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
296 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
297 LIBS="$LIBCRYPTO_LIBS $LIBS"
305 if test "x$found_libcrypto" = "xyes"; then
306 AC_DEFINE(HAVE_LIBCRYPTO)
309 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
310 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
311 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
313 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
314 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
316 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
317 AC_DEFINE(HAVE_BSD_UUID)
323 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
324 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
325 LIBS="$LIBUUID_LIBS $LIBS"
333 if test "x$found_libuuid" = "xno"; then
341 if test "x$found_libuuid" = "xno"; then
342 AC_MSG_ERROR("*** couldn't find uuid ***")
349 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
350 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
351 LIBS="$ZLIB_LIBS $LIBS"
359 if test "x$found_zlib" = "xno"; then
366 if test "x$found_zlib" = "xno"; then
367 AC_MSG_ERROR("*** couldn't find zlib ***")
370 if test "$PLATFORM" = "linux"; then
375 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
376 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
377 LIBS="$LIBMD_LIBS $LIBS"
380 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
387 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
388 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
389 LIBS="$LIBBSD_LIBS $LIBS"
391 AC_DEFINE(HAVE_LIBBSD)
397 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
403 [#include <sys/queue.h>]
409 [#include <sys/queue.h>]
415 [#include <sys/queue.h>]
421 [#include <sys/queue.h>]
427 [#include <sys/queue.h>]
433 [#include <sys/queue.h>]
435 if test "x$found_queue_h" = xyes; then
436 AC_DEFINE(HAVE_QUEUE_H)
439 # Look for __progname.
440 AC_MSG_CHECKING(for __progname)
441 AC_LINK_IFELSE([AC_LANG_SOURCE(
445 extern char *__progname;
447 const char *cp = __progname;
452 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
476 if test "x$found_panel" = "xno"; then
477 AC_CHECK_LIB(panelw, update_panels,,
478 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
481 LIBPANELW_LIBS="-lpanelw"
490 if test "x$found_ncurses" = xyes; then
491 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
492 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
493 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
501 if test "x$found_ncurses" = xyes; then
504 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
505 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
506 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
511 if test "x$found_ncurses" = xyes; then
512 AC_DEFINE(HAVE_NCURSES_H)
514 # No ncurses, try curses.
525 if test "x$found_curses" = xyes; then
526 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
527 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
528 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
529 AC_DEFINE(HAVE_CURSES_H)
531 AC_MSG_ERROR("curses not found")
535 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
537 AC_SUBST(AM_CPPFLAGS)
538 CPPFLAGS="$SAVED_CPPFLAGS"
540 CFLAGS="$SAVED_CFLAGS"
542 LDFLAGS="$SAVED_LDFLAGS"
544 AC_CONFIG_FILES([Makefile
547 libexec/got-read-tree/Makefile
548 libexec/got-fetch-pack/Makefile
549 libexec/got-index-pack/Makefile
550 libexec/got-read-blob/Makefile
551 libexec/got-read-commit/Makefile
552 libexec/got-read-gitconfig/Makefile
553 libexec/got-read-gotconfig/Makefile
554 libexec/got-read-object/Makefile
555 libexec/got-read-pack/Makefile
556 libexec/got-read-patch/Makefile
557 libexec/got-read-tag/Makefile
558 libexec/got-send-pack/Makefile
563 Makefile.common:Makefile.common.in])
567 # regress/GNUMakefile
568 # regress/cmdline/GNUMakefile
569 # regress/delta/GNUMakefile
570 # regress/fetch/GNUMakefile
571 # regress/idset/GNUMakefile
572 # regress/path/GNUMakefile
574 # gotweb/libexec/GNUMakefile
575 # gotweb/libexec/got-read-blob/GNUMakefile
576 # gotweb/libexec/got-read-commit/GNUMakefile
577 # gotweb/libexec/got-read-gitconfig/GNUMakefile
578 # gotweb/libexec/got-read-gotconfig/GNUMakefile
579 # gotweb/libexec/got-read-object/GNUMakefile
580 # gotweb/libexec/got-read-pack/GNUMakefile
581 # gotweb/libexec/got-read-tag/GNUMakefile
582 # gotweb/libexec/got-read-tree/GNUMakefile