1 # Process this file with autoconf to produce a configure script.
4 AC_INIT([got-portable], [0.47], [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 # Clang sanitizers wrap reallocarray even if it isn't available on the target
147 # system. When compiled it always returns NULL and crashes the program. To
148 # detect this we need a more complicated test.
149 AC_MSG_CHECKING([for working reallocarray])
150 AC_RUN_IFELSE([AC_LANG_PROGRAM(
151 [#include <stdlib.h>],
152 [return (reallocarray(NULL, 1, 1) == NULL);]
155 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
157 AC_MSG_CHECKING([for working recallocarray])
158 AC_RUN_IFELSE([AC_LANG_PROGRAM(
159 [#include <stdlib.h>],
160 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
163 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
166 # Look for imsg_init in libutil.
167 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
168 if test "x$found_imsg_init" = xyes; then
172 AC_LIBOBJ(imsg-buffer)
175 # libcrypto (via libssl for SHA information)
180 AM_CFLAGS="$LIBCRYTPO_CFLAGS $AM_CFLAGS"
181 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
182 LIBS="$LIBCRYPTO_LIBS $LIBS"
186 AC_MSG_ERROR("*** couldn't find libcrypto via pkg-config")
190 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
191 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
197 AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
198 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
199 LIBS="$LIBUUID_LIBS $LIBS"
203 AC_MSG_ERROR("*** couldn't find libuuid via pkg-config")
212 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
213 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
214 LIBS="$ZLIB_LIBS $LIBS"
218 AC_MSG_ERROR("*** couldn't find zlib via pkg-config")
226 AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
227 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
228 LIBS="$LIBMD_LIBS $LIBS"
231 AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
236 # libbsd (some portability gloop)
242 # Check if libbsd is installed -- if we can use that version of sys/tree.h or
248 AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
249 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
250 LIBS="$LIBBSD_LIBS $LIBS"
252 AC_DEFINE(HAVE_LIBBSD)
257 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
263 [#include <sys/queue.h>]
269 [#include <sys/queue.h>]
275 [#include <sys/queue.h>]
281 [#include <sys/queue.h>]
287 [#include <sys/queue.h>]
293 [#include <sys/queue.h>]
295 if test "x$found_queue_h" = xyes; then
296 AC_DEFINE(HAVE_QUEUE_H)
299 # Look for __progname.
300 AC_MSG_CHECKING(for __progname)
301 AC_LINK_IFELSE([AC_LANG_SOURCE(
305 extern char *__progname;
307 const char *cp = __progname;
312 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
320 AC_MSG_ERROR("*** couldn't find -lpanel from ncurses")
329 if test "x$found_ncurses" = xyes; then
330 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
331 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
332 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
340 if test "x$found_ncurses" = xyes; then
343 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
344 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
345 LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
350 if test "x$found_ncurses" = xyes; then
351 AC_DEFINE(HAVE_NCURSES_H)
353 # No ncurses, try curses.
364 if test "x$found_curses" = xyes; then
365 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
366 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
367 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
368 AC_DEFINE(HAVE_CURSES_H)
370 AC_MSG_ERROR("curses not found")
374 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
376 AC_SUBST(AM_CPPFLAGS)
377 CPPFLAGS="$SAVED_CPPFLAGS"
379 CFLAGS="$SAVED_CFLAGS"
381 LDFLAGS="$SAVED_LDFLAGS"
383 AC_CONFIG_FILES([Makefile
386 libexec/got-read-tree/Makefile
387 libexec/got-fetch-pack/Makefile
388 libexec/got-index-pack/Makefile
389 libexec/got-read-blob/Makefile
390 libexec/got-read-commit/Makefile
391 libexec/got-read-gitconfig/Makefile
392 libexec/got-read-gotconfig/Makefile
393 libexec/got-read-object/Makefile
394 libexec/got-read-pack/Makefile
395 libexec/got-read-tag/Makefile
396 libexec/got-send-pack/Makefile
403 # regress/GNUMakefile
404 # regress/cmdline/GNUMakefile
405 # regress/delta/GNUMakefile
406 # regress/fetch/GNUMakefile
407 # regress/idset/GNUMakefile
408 # regress/path/GNUMakefile
410 # gotweb/libexec/GNUMakefile
411 # gotweb/libexec/got-read-blob/GNUMakefile
412 # gotweb/libexec/got-read-commit/GNUMakefile
413 # gotweb/libexec/got-read-gitconfig/GNUMakefile
414 # gotweb/libexec/got-read-gotconfig/GNUMakefile
415 # gotweb/libexec/got-read-object/GNUMakefile
416 # gotweb/libexec/got-read-pack/GNUMakefile
417 # gotweb/libexec/got-read-tag/GNUMakefile
418 # gotweb/libexec/got-read-tree/GNUMakefile