1 # Process this file with autoconf to produce a configure script.
4 AC_INIT([got-portable], [0.67], [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="$LIBCRYPTO_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(uuid_create, found_uuid=no, found_uuid=yes)
227 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
229 if test "x$found_uuid" = "xyes"; then
230 AC_DEFINE(HAVE_BSD_UUID)
236 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
237 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
238 LIBS="$LIBUUID_LIBS $LIBS"
246 if test "x$found_libuuid" = "xno"; then
254 if test "x$found_libuuid" = "xno"; then
255 AC_MSG_ERROR("*** couldn't find uuid ***")
262 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
263 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
264 LIBS="$ZLIB_LIBS $LIBS"
272 if test "x$found_zlib" = "xno"; then
279 if test "x$found_zlib" = "xno"; then
280 AC_MSG_ERROR("*** couldn't find zlib ***")
283 if test "$PLATFORM" = "linux"; then
288 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
289 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
290 LIBS="$LIBMD_LIBS $LIBS"
293 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
300 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
301 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
302 LIBS="$LIBBSD_LIBS $LIBS"
304 AC_DEFINE(HAVE_LIBBSD)
310 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
316 [#include <sys/queue.h>]
322 [#include <sys/queue.h>]
328 [#include <sys/queue.h>]
334 [#include <sys/queue.h>]
340 [#include <sys/queue.h>]
346 [#include <sys/queue.h>]
348 if test "x$found_queue_h" = xyes; then
349 AC_DEFINE(HAVE_QUEUE_H)
352 # Look for __progname.
353 AC_MSG_CHECKING(for __progname)
354 AC_LINK_IFELSE([AC_LANG_SOURCE(
358 extern char *__progname;
360 const char *cp = __progname;
365 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
369 if test "$PLATFORM" = "linux"; then
374 AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
377 AC_CHECK_LIB(panelw, update_panels,,
378 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
381 LIBPANELW_LIBS="-lpanelw"
390 if test "x$found_ncurses" = xyes; then
391 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
392 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
393 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
401 if test "x$found_ncurses" = xyes; then
404 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
405 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
406 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
411 if test "x$found_ncurses" = xyes; then
412 AC_DEFINE(HAVE_NCURSES_H)
414 # No ncurses, try curses.
425 if test "x$found_curses" = xyes; then
426 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
427 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
428 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
429 AC_DEFINE(HAVE_CURSES_H)
431 AC_MSG_ERROR("curses not found")
435 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
437 AC_SUBST(AM_CPPFLAGS)
438 CPPFLAGS="$SAVED_CPPFLAGS"
440 CFLAGS="$SAVED_CFLAGS"
442 LDFLAGS="$SAVED_LDFLAGS"
444 AC_CONFIG_FILES([Makefile
447 libexec/got-read-tree/Makefile
448 libexec/got-fetch-pack/Makefile
449 libexec/got-index-pack/Makefile
450 libexec/got-read-blob/Makefile
451 libexec/got-read-commit/Makefile
452 libexec/got-read-gitconfig/Makefile
453 libexec/got-read-gotconfig/Makefile
454 libexec/got-read-object/Makefile
455 libexec/got-read-pack/Makefile
456 libexec/got-read-tag/Makefile
457 libexec/got-send-pack/Makefile
461 Makefile.common:Makefile.common.in])
465 # regress/GNUMakefile
466 # regress/cmdline/GNUMakefile
467 # regress/delta/GNUMakefile
468 # regress/fetch/GNUMakefile
469 # regress/idset/GNUMakefile
470 # regress/path/GNUMakefile
472 # gotweb/libexec/GNUMakefile
473 # gotweb/libexec/got-read-blob/GNUMakefile
474 # gotweb/libexec/got-read-commit/GNUMakefile
475 # gotweb/libexec/got-read-gitconfig/GNUMakefile
476 # gotweb/libexec/got-read-gotconfig/GNUMakefile
477 # gotweb/libexec/got-read-object/GNUMakefile
478 # gotweb/libexec/got-read-pack/GNUMakefile
479 # gotweb/libexec/got-read-tag/GNUMakefile
480 # gotweb/libexec/got-read-tree/GNUMakefile