1 # Process this file with autoconf to produce a configure script.
4 AC_INIT([got-portable], [0.60], [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.
64 # Checks for typ edefs, structures, and compiler characteristics.
65 AC_CHECK_HEADER_STDBOOL
78 # Look for library needed for flock.
79 AC_SEARCH_LIBS(flock, bsd)
81 # Checks for library functions.
84 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
122 # Check for functions with a compatibility implementation.
141 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
142 # musl does not set optarg to NULL for flags without arguments (although it is
143 # not required to, but it is helpful) 3) there are probably other weird
147 # Check the platform we're compiling on.
148 AC_MSG_CHECKING(platform)
155 AC_MSG_RESULT(freebsd)
159 AC_MSG_RESULT(unknown)
164 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
165 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
167 # Landlock detection.
168 AC_MSG_CHECKING([for landlock])
169 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
170 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
171 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
177 # Clang sanitizers wrap reallocarray even if it isn't available on the target
178 # system. When compiled it always returns NULL and crashes the program. To
179 # detect this we need a more complicated test.
180 AC_MSG_CHECKING([for working reallocarray])
181 AC_RUN_IFELSE([AC_LANG_PROGRAM(
182 [#include <stdlib.h>],
183 [return (reallocarray(NULL, 1, 1) == NULL);]
186 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
188 AC_MSG_CHECKING([for working recallocarray])
189 AC_RUN_IFELSE([AC_LANG_PROGRAM(
190 [#include <stdlib.h>],
191 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
194 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
197 # Look for imsg_init in libutil.
198 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
199 if test "x$found_imsg_init" = xyes; then
203 AC_LIBOBJ(imsg-buffer)
206 # libcrypto (via libssl for SHA information)
211 AM_CFLAGS="$LIBCRYTPO_CFLAGS $AM_CFLAGS"
212 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
213 LIBS="$LIBCRYPTO_LIBS $LIBS"
221 if test "x$found_libcrypto" = "xyes"; then
222 AC_DEFINE(HAVE_LIBCRYPTO)
225 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
226 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
232 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
233 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
234 LIBS="$LIBUUID_LIBS $LIBS"
242 if test "x$found_libuuid" = "xno"; then
249 if test "x$found_libuuid" = "xno"; then
250 AC_MSG_ERROR("*** couldn't find uuid ***")
257 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
258 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
259 LIBS="$ZLIB_LIBS $LIBS"
267 if test "x$found_zlib" = "xno"; then
274 if test "x$found_zlib" = "xno"; then
275 AC_MSG_ERROR("*** couldn't find zlib ***")
278 if test "$PLATFORM" = "linux"; then
283 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
284 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
285 LIBS="$LIBMD_LIBS $LIBS"
288 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
295 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
296 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
297 LIBS="$LIBBSD_LIBS $LIBS"
299 AC_DEFINE(HAVE_LIBBSD)
305 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
311 [#include <sys/queue.h>]
317 [#include <sys/queue.h>]
323 [#include <sys/queue.h>]
329 [#include <sys/queue.h>]
335 [#include <sys/queue.h>]
341 [#include <sys/queue.h>]
343 if test "x$found_queue_h" = xyes; then
344 AC_DEFINE(HAVE_QUEUE_H)
347 # Look for __progname.
348 AC_MSG_CHECKING(for __progname)
349 AC_LINK_IFELSE([AC_LANG_SOURCE(
353 extern char *__progname;
355 const char *cp = __progname;
360 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
364 if test "$PLATFORM" = "linux"; then
369 AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
372 AC_CHECK_LIB(panelw, update_panels,,
373 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
376 LIBPANELW_LIBS="-lpanelw"
385 if test "x$found_ncurses" = xyes; then
386 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
387 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
388 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
396 if test "x$found_ncurses" = xyes; then
399 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
400 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
401 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
406 if test "x$found_ncurses" = xyes; then
407 AC_DEFINE(HAVE_NCURSES_H)
409 # No ncurses, try curses.
420 if test "x$found_curses" = xyes; then
421 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
422 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
423 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
424 AC_DEFINE(HAVE_CURSES_H)
426 AC_MSG_ERROR("curses not found")
430 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
432 AC_SUBST(AM_CPPFLAGS)
433 CPPFLAGS="$SAVED_CPPFLAGS"
435 CFLAGS="$SAVED_CFLAGS"
437 LDFLAGS="$SAVED_LDFLAGS"
439 AC_CONFIG_FILES([Makefile
442 libexec/got-read-tree/Makefile
443 libexec/got-fetch-pack/Makefile
444 libexec/got-index-pack/Makefile
445 libexec/got-read-blob/Makefile
446 libexec/got-read-commit/Makefile
447 libexec/got-read-gitconfig/Makefile
448 libexec/got-read-gotconfig/Makefile
449 libexec/got-read-object/Makefile
450 libexec/got-read-pack/Makefile
451 libexec/got-read-tag/Makefile
452 libexec/got-send-pack/Makefile
456 regress/cmdline/Makefile.linux:regress/cmdline/Makefile.am])
460 # regress/GNUMakefile
461 # regress/cmdline/GNUMakefile
462 # regress/delta/GNUMakefile
463 # regress/fetch/GNUMakefile
464 # regress/idset/GNUMakefile
465 # regress/path/GNUMakefile
467 # gotweb/libexec/GNUMakefile
468 # gotweb/libexec/got-read-blob/GNUMakefile
469 # gotweb/libexec/got-read-commit/GNUMakefile
470 # gotweb/libexec/got-read-gitconfig/GNUMakefile
471 # gotweb/libexec/got-read-gotconfig/GNUMakefile
472 # gotweb/libexec/got-read-object/GNUMakefile
473 # gotweb/libexec/got-read-pack/GNUMakefile
474 # gotweb/libexec/got-read-tag/GNUMakefile
475 # gotweb/libexec/got-read-tree/GNUMakefile