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.
63 # Checks for typ edefs, structures, and compiler characteristics.
64 AC_CHECK_HEADER_STDBOOL
77 # Look for library needed for flock.
78 AC_SEARCH_LIBS(flock, bsd)
80 # Checks for library functions.
83 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
121 # Check for functions with a compatibility implementation.
140 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
141 # musl does not set optarg to NULL for flags without arguments (although it is
142 # not required to, but it is helpful) 3) there are probably other weird
146 # Check the platform we're compiling on.
147 AC_MSG_CHECKING(platform)
154 AC_MSG_RESULT(freebsd)
158 AC_MSG_RESULT(unknown)
163 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
164 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
166 # Clang sanitizers wrap reallocarray even if it isn't available on the target
167 # system. When compiled it always returns NULL and crashes the program. To
168 # detect this we need a more complicated test.
169 AC_MSG_CHECKING([for working reallocarray])
170 AC_RUN_IFELSE([AC_LANG_PROGRAM(
171 [#include <stdlib.h>],
172 [return (reallocarray(NULL, 1, 1) == NULL);]
175 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
177 AC_MSG_CHECKING([for working recallocarray])
178 AC_RUN_IFELSE([AC_LANG_PROGRAM(
179 [#include <stdlib.h>],
180 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
183 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
186 # Look for imsg_init in libutil.
187 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
188 if test "x$found_imsg_init" = xyes; then
192 AC_LIBOBJ(imsg-buffer)
195 # libcrypto (via libssl for SHA information)
200 AM_CFLAGS="$LIBCRYTPO_CFLAGS $AM_CFLAGS"
201 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
202 LIBS="$LIBCRYPTO_LIBS $LIBS"
210 if test "x$found_libcrypto" = "xyes"; then
211 AC_DEFINE(HAVE_LIBCRYPTO)
214 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
215 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
216 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
218 if test "x$found_uuid" = "xyes"; then
219 AC_DEFINE(HAVE_BSD_UUID)
225 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
226 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
227 LIBS="$LIBUUID_LIBS $LIBS"
235 if test "x$found_libuuid" = "xno"; then
243 if test "x$found_libuuid" = "xno"; then
244 AC_MSG_ERROR("*** couldn't find uuid ***")
251 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
252 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
253 LIBS="$ZLIB_LIBS $LIBS"
261 if test "x$found_zlib" = "xno"; then
268 if test "x$found_zlib" = "xno"; then
269 AC_MSG_ERROR("*** couldn't find zlib ***")
272 if test "$PLATFORM" = "linux"; then
277 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
278 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
279 LIBS="$LIBMD_LIBS $LIBS"
282 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
289 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
290 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
291 LIBS="$LIBBSD_LIBS $LIBS"
293 AC_DEFINE(HAVE_LIBBSD)
299 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
305 [#include <sys/queue.h>]
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>]
337 if test "x$found_queue_h" = xyes; then
338 AC_DEFINE(HAVE_QUEUE_H)
341 # Look for __progname.
342 AC_MSG_CHECKING(for __progname)
343 AC_LINK_IFELSE([AC_LANG_SOURCE(
347 extern char *__progname;
349 const char *cp = __progname;
354 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
358 if test "$PLATFORM" = "linux"; then
363 AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
366 AC_CHECK_LIB(panelw, update_panels,,
367 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"])
370 LIBPANELW_LIBS="-lpanelw"
379 if test "x$found_ncurses" = xyes; then
380 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
381 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
382 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
390 if test "x$found_ncurses" = xyes; then
393 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
394 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
395 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
400 if test "x$found_ncurses" = xyes; then
401 AC_DEFINE(HAVE_NCURSES_H)
403 # No ncurses, try curses.
414 if test "x$found_curses" = xyes; then
415 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
416 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
417 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
418 AC_DEFINE(HAVE_CURSES_H)
420 AC_MSG_ERROR("curses not found")
424 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
426 AC_SUBST(AM_CPPFLAGS)
427 CPPFLAGS="$SAVED_CPPFLAGS"
429 CFLAGS="$SAVED_CFLAGS"
431 LDFLAGS="$SAVED_LDFLAGS"
433 AC_CONFIG_FILES([Makefile
436 libexec/got-read-tree/Makefile
437 libexec/got-fetch-pack/Makefile
438 libexec/got-index-pack/Makefile
439 libexec/got-read-blob/Makefile
440 libexec/got-read-commit/Makefile
441 libexec/got-read-gitconfig/Makefile
442 libexec/got-read-gotconfig/Makefile
443 libexec/got-read-object/Makefile
444 libexec/got-read-pack/Makefile
445 libexec/got-read-tag/Makefile
446 libexec/got-send-pack/Makefile
450 regress/cmdline/Makefile.linux:regress/cmdline/Makefile.am])
454 # regress/GNUMakefile
455 # regress/cmdline/GNUMakefile
456 # regress/delta/GNUMakefile
457 # regress/fetch/GNUMakefile
458 # regress/idset/GNUMakefile
459 # regress/path/GNUMakefile
461 # gotweb/libexec/GNUMakefile
462 # gotweb/libexec/got-read-blob/GNUMakefile
463 # gotweb/libexec/got-read-commit/GNUMakefile
464 # gotweb/libexec/got-read-gitconfig/GNUMakefile
465 # gotweb/libexec/got-read-gotconfig/GNUMakefile
466 # gotweb/libexec/got-read-object/GNUMakefile
467 # gotweb/libexec/got-read-pack/GNUMakefile
468 # gotweb/libexec/got-read-tag/GNUMakefile
469 # gotweb/libexec/got-read-tree/GNUMakefile