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.
66 # Checks for typ edefs, structures, and compiler characteristics.
67 AC_CHECK_HEADER_STDBOOL
80 # Look for library needed for flock.
81 AC_SEARCH_LIBS(flock, bsd)
83 # Checks for library functions.
86 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
124 # Check for functions with a compatibility implementation.
143 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
144 # musl does not set optarg to NULL for flags without arguments (although it is
145 # not required to, but it is helpful) 3) there are probably other weird
149 # Check the platform we're compiling on.
150 AC_MSG_CHECKING(platform)
157 AC_MSG_RESULT(freebsd)
161 AC_MSG_RESULT(darwin)
165 AC_MSG_RESULT(netbsd)
169 AC_MSG_RESULT(unknown)
174 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
175 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
176 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
177 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
179 # Landlock detection.
180 AC_MSG_CHECKING([for landlock])
181 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
182 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
183 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
189 # Clang sanitizers wrap reallocarray even if it isn't available on the target
190 # system. When compiled it always returns NULL and crashes the program. To
191 # detect this we need a more complicated test.
192 AC_MSG_CHECKING([for working reallocarray])
193 AC_RUN_IFELSE([AC_LANG_PROGRAM(
194 [#include <stdlib.h>],
195 [return (reallocarray(NULL, 1, 1) == NULL);]
198 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
200 AC_MSG_CHECKING([for working recallocarray])
201 AC_RUN_IFELSE([AC_LANG_PROGRAM(
202 [#include <stdlib.h>],
203 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
206 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
209 # Look for imsg_init in libutil.
210 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
211 if test "x$found_imsg_init" = xyes; then
215 AC_LIBOBJ(imsg-buffer)
218 # libcrypto (via libssl for SHA information)
223 AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
224 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
225 LIBS="$LIBCRYPTO_LIBS $LIBS"
233 if test "x$found_libcrypto" = "xyes"; then
234 AC_DEFINE(HAVE_LIBCRYPTO)
237 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
238 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
239 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
241 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
242 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
244 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
245 AC_DEFINE(HAVE_BSD_UUID)
251 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
252 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
253 LIBS="$LIBUUID_LIBS $LIBS"
261 if test "x$found_libuuid" = "xno"; then
269 if test "x$found_libuuid" = "xno"; then
270 AC_MSG_ERROR("*** couldn't find uuid ***")
277 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
278 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
279 LIBS="$ZLIB_LIBS $LIBS"
287 if test "x$found_zlib" = "xno"; then
294 if test "x$found_zlib" = "xno"; then
295 AC_MSG_ERROR("*** couldn't find zlib ***")
298 if test "$PLATFORM" = "linux"; then
303 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
304 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
305 LIBS="$LIBMD_LIBS $LIBS"
308 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
315 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
316 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
317 LIBS="$LIBBSD_LIBS $LIBS"
319 AC_DEFINE(HAVE_LIBBSD)
325 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
331 [#include <sys/queue.h>]
337 [#include <sys/queue.h>]
343 [#include <sys/queue.h>]
349 [#include <sys/queue.h>]
355 [#include <sys/queue.h>]
361 [#include <sys/queue.h>]
363 if test "x$found_queue_h" = xyes; then
364 AC_DEFINE(HAVE_QUEUE_H)
367 # Look for __progname.
368 AC_MSG_CHECKING(for __progname)
369 AC_LINK_IFELSE([AC_LANG_SOURCE(
373 extern char *__progname;
375 const char *cp = __progname;
380 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
398 if test "x$found_panel" = "xno"; then
399 AC_CHECK_LIB(panelw, update_panels,,
400 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
403 LIBPANELW_LIBS="-lpanelw"
412 if test "x$found_ncurses" = xyes; then
413 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
414 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
415 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
423 if test "x$found_ncurses" = xyes; then
426 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
427 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
428 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
433 if test "x$found_ncurses" = xyes; then
434 AC_DEFINE(HAVE_NCURSES_H)
436 # No ncurses, try curses.
447 if test "x$found_curses" = xyes; then
448 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
449 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
450 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
451 AC_DEFINE(HAVE_CURSES_H)
453 AC_MSG_ERROR("curses not found")
457 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
459 AC_SUBST(AM_CPPFLAGS)
460 CPPFLAGS="$SAVED_CPPFLAGS"
462 CFLAGS="$SAVED_CFLAGS"
464 LDFLAGS="$SAVED_LDFLAGS"
466 AC_CONFIG_FILES([Makefile
469 libexec/got-read-tree/Makefile
470 libexec/got-fetch-pack/Makefile
471 libexec/got-index-pack/Makefile
472 libexec/got-read-blob/Makefile
473 libexec/got-read-commit/Makefile
474 libexec/got-read-gitconfig/Makefile
475 libexec/got-read-gotconfig/Makefile
476 libexec/got-read-object/Makefile
477 libexec/got-read-pack/Makefile
478 libexec/got-read-tag/Makefile
479 libexec/got-send-pack/Makefile
483 Makefile.common:Makefile.common.in])
487 # regress/GNUMakefile
488 # regress/cmdline/GNUMakefile
489 # regress/delta/GNUMakefile
490 # regress/fetch/GNUMakefile
491 # regress/idset/GNUMakefile
492 # regress/path/GNUMakefile
494 # gotweb/libexec/GNUMakefile
495 # gotweb/libexec/got-read-blob/GNUMakefile
496 # gotweb/libexec/got-read-commit/GNUMakefile
497 # gotweb/libexec/got-read-gitconfig/GNUMakefile
498 # gotweb/libexec/got-read-gotconfig/GNUMakefile
499 # gotweb/libexec/got-read-object/GNUMakefile
500 # gotweb/libexec/got-read-pack/GNUMakefile
501 # gotweb/libexec/got-read-tag/GNUMakefile
502 # gotweb/libexec/got-read-tree/GNUMakefile