portable: gotd: enable got-notify-http
[got-portable.git] / configure.ac
blob055c7f00a6fe4fb9cb88a4bedb1f8beb0e3ec875
1 # Process this file with autoconf to produce a configure script.
3 AC_PREREQ([2.69])
4 AC_INIT([got-portable],
5         m4_esyscmd_s(util/got-portable-ver.sh),
6         [thomas@xteddy.org])
7 AC_CONFIG_AUX_DIR(etc)
8 AC_CONFIG_SRCDIR([lib/rcsutil.h])
9 AM_INIT_AUTOMAKE([foreign subdir-objects])
11 AC_CONFIG_HEADERS([include/got_compat.h])
13 AC_DEFINE_UNQUOTED(VERSION, $VERSION)
14 AC_SUBST(VERSION)
15 AC_SUBST(GOT_RELEASE)
17 AC_DEFINE_UNQUOTED([GOT_VERSION], VERSION, [GoT version string])
18 AC_DEFINE_UNQUOTED([GOT_VERSION_NUMBER], VERSION, [Got version number])
20 AC_USE_SYSTEM_EXTENSIONS
21 AC_CANONICAL_HOST
23 AC_CONFIG_SUBDIRS([template])
24 AC_ARG_ENABLE([gotd],
25         AS_HELP_STRING([--enable gotd], [build gotd and gotsh]))
26 AC_ARG_ENABLE([cvg],
27                AS_HELP_STRING([--enable cvg],
28                               [EXPERIMENTAL: cvg - cvs-like-git]))
30 # Override gotd's empty_path location.
31 AC_ARG_WITH([gotd-empty-path],
32             [AS_HELP_STRING([--with-gotd-empty-path],
33                             [gotd empty path])
34             ],
35             [GOTD_EMPTY_PATHC=$withval]
36             [])
37 AC_SUBST(GOTD_EMPTY_PATHC)
39 # Override where git's libexec helpers are located for gitwrapper.
40 AC_ARG_WITH([gitwrapper-git-libexec-path],
41             [AS_HELP_STRING([--with-gitwrapper-git-libexec-path],
42                             [git libexec path for gitwrapper])
43             ],
44             [GITWRAPPER_LIBEXEC_PATHC=$withval]
45             [])
46 AC_SUBST(GITWRAPPER_LIBEXEC_PATHC)
48 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
49 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
50 # empty default.
51 : ${CFLAGS=""}
53 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
54 # AC_CHECK_HEADER doesn't give us any other way to update the include
55 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
56 SAVED_CFLAGS="$CFLAGS"
57 SAVED_CPPFLAGS="$CPPFLAGS"
58 SAVED_LDFLAGS="$LDFLAGS"
60 # YACC override
61 YACC_OVERRIDE="yes"
63 # Checks for programs.
64 AC_PROG_CC
65 AC_PROG_CPP
66 AC_PROG_INSTALL
67 AC_PROG_LN_S
68 AC_PROG_MAKE_SET
69 if test -z "$YACC"; then
70 YACC_OVERRIDE="no"
71 AC_PROG_YACC
73 AM_PROG_AR
74 AC_PROG_RANLIB
75 PKG_PROG_PKG_CONFIG
77 if test "$YACC_OVERRIDE" = "yes"; then
78         AC_MSG_NOTICE("Using YACC set from environment: $YACC")
81 # Checks for header files.
82 AC_CHECK_HEADERS([ \
83         fcntl.h \
84         getopt.h \
85         langinfo.h \
86         libutil.h \
87         limits.h \
88         linux/landlock.h \
89         locale.h \
90         netdb.h \
91         netinet/in.h \
92         paths.h \
93         poll.h \
94         sha.h \
95         sha1.h \
96         sha2.h \
97         sha256.h \
98         stddef.h \
99         stdint.h \
100         stdlib.h \
101         string.h \
102         sys/ioctl.h \
103         sys/param.h \
104         sys/poll.h \
105         sys/queue.h \
106         sys/select.h \
107         sys/socket.h \
108         sys/time.h \
109         sys/tree.h \
110         tls.h \
111         util.h \
112         unistd.h \
113         wchar.h \
116 AC_HEADER_DIRENT
117 AC_CHECK_DECL([F_CLOSEM],
118               HAVE_FCNTL_CLOSEM
119               AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
120                         [Use F_CLOSEM fcntl for closefrom]),
121                         [],
122                         [#include <limits.h>
123                          #include <fcntl.h>
124                         ]
127 AC_MSG_CHECKING([for /proc/pid/fd directory])
128 if test -d "/proc/$$/fd" ; then
129         AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
130         AC_MSG_RESULT([yes])
131 else
132         AC_MSG_RESULT([no])
135 AC_MSG_CHECKING([whether program_invocation_short_name is defined])
136 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
137         #include <argp.h>
138 ]], [[
139         program_invocation_short_name = "test";
140 ]])], [
141         AC_MSG_RESULT([yes])
142         AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
143                 [Define if program_invocation_short_name is defined])
144 ], [
145         AC_MSG_RESULT([no])
148 # Look for prctl(PR_SET_NAME).
149 AC_CHECK_DECL(
150         [PR_SET_NAME],
151         [AC_DEFINE([HAVE_PR_SET_NAME], [1], [Define if PR_SET_NAME is defined])],
152         [],
153         [#include <sys/prctl.h>]
156 AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
158 AC_CACHE_CHECK([whether getopt has optreset support],
159                 ac_cv_have_getopt_optreset, [
160         AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
161                 [[ extern int optreset; optreset = 0; ]])],
162         [ ac_cv_have_getopt_optreset="yes" ],
163         [ ac_cv_have_getopt_optreset="no"
164         ])
167 AM_CONDITIONAL([HAVE_GETOPT], [test "x$ac_cv_have_getopt_optreset" = "xyes"])
168 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
169         AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
170                 [Define if your getopt(3) defines and uses optreset])
173 AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[
174 #include <sys/types.h>
175 #ifdef HAVE_POLL_H
176 #include <poll.h>
177 #endif
178 #ifdef HAVE_SYS_POLL_H
179 #include <sys/poll.h>
180 #endif
183 # Checks for typ edefs, structures, and compiler characteristics.
184 AC_CHECK_HEADER_STDBOOL
185 AC_C_INLINE
186 AC_TYPE_INT64_T
187 AC_TYPE_MODE_T
188 AC_TYPE_OFF_T
189 AC_TYPE_PID_T
190 AC_TYPE_SIZE_T
191 AC_TYPE_SSIZE_T
192 AC_TYPE_UINT16_T
193 AC_TYPE_UINT32_T
194 AC_TYPE_UINT64_T
195 AC_TYPE_UINT8_T
197 # Check for ifgroupreq which is only available on BSD.
198 AC_CHECK_TYPES([struct ifgroupreq])
200 # Check for sockaddr_storage.  On some systems, ss_len is filled out, although
201 # this is not mandated by POSIX, and hence systems such as linux, don't have
202 # it.
203 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
204 #include <sys/types.h>
205 #include <sys/socket.h>
208 # Same thing as sockaddr_storage above, only now check if the member exists in
209 # the struct as well.
210 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
211         [ #include <netdb.h>
212           #include <netinet/in.h>
213           #include <sys/socket.h> ]
216 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
217         [ #include <netdb.h>
218           #include <netinet/in.h>
219           #include <sys/socket.h> ]
222 # Both checks above will result in:
224 # HAVE_STRUCT_SOCKADDR_AS_LEN
225 # SS_LEN
227 # Either being defined or not.
229 # Look for library needed for flock.
230 AC_SEARCH_LIBS(flock, bsd)
232 # Checks for library functions.
233 AC_FUNC_FORK
234 AC_FUNC_FSEEKO
235 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
236 AC_FUNC_MALLOC
237 AC_FUNC_MMAP
238 AC_FUNC_REALLOC
239 AC_FUNC_STRERROR_R
240 AC_FUNC_STRNLEN
241 AC_CHECK_FUNCS([ \
242         dup2 \
243         flock \
244         getcwd \
245         localtime_r \
246         memchr \
247         memmove \
248         memset \
249         mergesort \
250         mkdir \
251         munmap \
252         nl_langinfo \
253         realpath \
254         regcomp \
255         rmdir \
256         setlocale \
257         socket \
258         setresgid \
259         setresuid \
260         setproctitle \
261         strcasecmp \
262         strchr \
263         strcspn \
264         strdup \
265         strerror \
266         strncasecmp \
267         strndup \
268         strrchr \
269         strspn \
270         strstr \
271         strtol \
272         strtoul \
273         sysconf \
274         wcwidth \
277 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
279 if test "x$ac_cv_func_sysconf" = xyes; then
280         AC_DEFINE([HAVE_SYSCONF], [1], [Define to 1 if sysconf() present])
283 # Siphash support.
284 AC_CHECK_FUNCS([SipHash])
285 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
287 # Check for functions with a compatibility implementation.
288 AC_REPLACE_FUNCS([ \
289         asprintf \
290         closefrom \
291         explicit_bzero \
292         fmt_scaled \
293         freezero \
294         getdtablecount \
295         getline \
296         getprogname \
297         recallocarray \
298         reallocarray \
299         strlcat \
300         strlcpy \
301         strndup \
302         strnlen \
303         strsep \
304         strtonum \
306 AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
308 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
309 # musl does not set optarg to NULL for flags without arguments (although it is
310 # not required to, but it is helpful) 3) there are probably other weird
311 # implementations.
312 AC_LIBOBJ(getopt)
314 # Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
315 AC_MSG_CHECKING(for b64_ntop)
316         AC_LINK_IFELSE([AC_LANG_PROGRAM(
317         [
318                 #include <sys/types.h>
319                 #include <netinet/in.h>
320                 #include <resolv.h>
321         ],
322         [
323                 b64_ntop(NULL, 0, NULL, 0);
324         ])],
325         found_b64_ntop=yes,
326         found_b64_ntop=no
328 AC_MSG_RESULT($found_b64_ntop)
329 libresolv_LIBS=""
330 if test "x$found_b64_ntop" = xno; then
331         AC_MSG_CHECKING(for b64_ntop with -lresolv)
332         LIBS="-lresolv"
333         AC_LINK_IFELSE([AC_LANG_PROGRAM(
334                 [
335                         #include <sys/types.h>
336                         #include <netinet/in.h>
337                         #include <resolv.h>
338                 ],
339                 [
340                         b64_ntop(NULL, 0, NULL, 0);
341                 ])],
342                 found_b64_ntop=yes,
343                 found_b64_ntop=no
344         )
345         AC_MSG_RESULT($found_b64_ntop)
346         libresolv_LIBS="$LIBS"
348 if test "x$found_b64_ntop" = xno; then
349         AC_MSG_CHECKING(for b64_ntop with -lnetwork)
350         LIBS="-lresolv -lnetwork"
351         AC_LINK_IFELSE([AC_LANG_PROGRAM(
352                 [
353                         #include <sys/types.h>
354                         #include <netinet/in.h>
355                         #include <resolv.h>
356                 ],
357                 [
358                         b64_ntop(NULL, 0, NULL, 0);
359                 ])],
360                 found_b64_ntop=yes,
361                 found_b64_ntop=no
362         )
363         AC_MSG_RESULT($found_b64_ntop)
364         libresolv_LIBS="$LIBS"
367 AM_CONDITIONAL([HAVE_B64], [test "x$found_b64_ntop" = xyes])
368 if test "x$found_b64_ntop" = xyes; then
369         AC_DEFINE([HAVE_B64_NTOP], [1], [define if b64_ntop is present])
370         AC_SUBST(libresolv_LIBS)
371 else
372         AC_LIBOBJ(base64)
375 # Check the platform we're compiling on.
376 AC_MSG_CHECKING(platform)
377 case "$host_os" in
378         *linux*)
379                 AC_MSG_RESULT(linux)
380                 PLATFORM=linux
381                 ;;
382         *freebsd*)
383                 AC_MSG_RESULT(freebsd)
384                 PLATFORM=freebsd
385                 ;;
386         *darwin*)
387                 AC_MSG_RESULT(darwin)
388                 PLATFORM=darwin
389                 ;;
390         *netbsd*)
391                 AC_MSG_RESULT(netbsd)
392                 PLATFORM=netbsd
393                 ;;
394         *openbsd*)
395                 AC_MSG_RESULT(openbsd)
396                 PLATFORM=openbsd
397                 ;;
398         *dragonfly*)
399                 AC_MSG_RESULT(dragonfly)
400                 PLATFORM=dragonflybsd
401                 ;;
402         *)
403                 AC_MSG_RESULT(unknown)
404                 PLATFORM=unknown
405                 ;;
406 esac
407 AC_SUBST(PLATFORM)
408 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
409 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
410 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
411 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
412 AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
413 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
415 # On OpenBSD, these functions are already defined, yet looking for them in
416 # this way on OpenBSD breaks <sha2.h> inclusion.
417 # FIXME: this needs addressing.
418 if test "x$PLATFORM" != "xopenbsd"; then
419         AC_CHECK_FUNCS([ \
420                 SHA256Update \
421                 SHA384Update \
422                 SHA512Update \
423         ])
426 # Look for yacc.
427 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
428         && ! command -v "$YACC" >/dev/null 2>&1; then
429         AC_MSG_ERROR("yacc not found: $YACC")
432 if test x"$PLATFORM" = "xdarwin"; then
433         # Check for and/or set HOMEBREW_PREFIX.  brew is a common way of
434         # installing applications.  The other is MacPorts.
435         #
436         # Before Apple Silicon existed (M1 onward), the paths for applications
437         # installed via homebrew was typically /usr/local.  However, with M1
438         # onward, this changed to a different path.
439         #
440         # Rather than hardcode this, check for HOMEBREW_PREFIX in the
441         # environment if it's already set, and use it.  Otherwise, check for
442         # brew(1) and use that.  If that fails, default to /usr/local
443         #
444         # This also means that MacPorts should continue to work.
445         #
446         # But with MacPorts, we should also check --prefix, and use that if it
447         # has been supplied.
448         #
449         # In both cases, the variable HOMEBREW_PREFIX is used for both.
450         HB_PREFIX=""
451         FOUND_BISON="no"
452         GNUBISON=""
453         if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
454                 # HOMEBREW_PREFIX not set, check for brew(1)
455                 if command -v brew >/dev/null 2>&1; then
456                         AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
457                         export HOMEBREW_PREFIX="$(brew --prefix)"
458                 fi
460                 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
461                 then
462                         # Default.
463                         if test -z "${prefix}" -o "${prefix}" = "NONE"; then
464                                 export HOMEBREW_PREFIX="/usr/local"
465                                 HB_PREFIX="/usr/local"
466                                 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
467                         else
468                                 HB_PREFIX="$(eval echo ${prefix})"
469                                 if test "$HB_PREFIX" = "NONE"; then
470                                         HB_PREFIX="/opt/local"
471                                 else
472                                         AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
473                                 fi
474                                 export HOMEBREW_PREFIX="$HB_PREFIX"
475                         fi
476                 fi
477         fi
479         AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
481         if test "$YACC_OVERRIDE" = "no" && \
482                 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
483                 AC_MSG_WARN([
484                              "***********************************************************
485                              GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
486                              ***********************************************************
488                              Falling back to checking either /usr/local or \${prefix}"
489                 ])
491                 FOUND_BISON="no"
492                 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
493                 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
494                         export HOMEBREW_PREFIX="/usr/local"
495                         FOUND_BISON="yes"
496                         GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
497                 fi
499                 if test "$FOUND_BISON" = "no"; then
500                         HB_PREFIX="/opt/local"
501                         AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
503                         if test -x "${HB_PREFIX}/bin/bison"; then
504                                 export HOMEBREW_PREFIX="${HB_PREFIX}"
505                                 GNUBISON="${HB_PREFIX}/bin/bison"
506                                 FOUND_BISON="yes"
507                         fi
508                 fi
509         else
510                 FOUND_BISON="yes"
511                 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
512         fi
514         if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
515                 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
516         fi
518         # Override YACC here to point to the GNU version of bison.
519         if test "$YACC_OVERRIDE" = "yes"; then
520                 export YACC="$YACC -y"
521         else
522                 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
523                 export YACC="${GNUBISON} -y"
524         fi
525         export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
526         export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
527         export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
528         export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
531 # Landlock detection.
532 AC_MSG_CHECKING([for landlock])
533 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
534     [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
535 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
536         AC_MSG_RESULT(yes)
537 else
538         AC_MSG_RESULT(no)
541 # Clang sanitizers wrap reallocarray even if it isn't available on the target
542 # system. When compiled it always returns NULL and crashes the program. To
543 # detect this we need a more complicated test.
544 AC_MSG_CHECKING([for working reallocarray])
545 AC_RUN_IFELSE([AC_LANG_PROGRAM(
546                 [#include <stdlib.h>],
547                 [return (reallocarray(NULL, 1, 1) == NULL);]
548         )],
549         AC_MSG_RESULT(yes),
550         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
551         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
553 AC_MSG_CHECKING([for working recallocarray])
554 AC_RUN_IFELSE([AC_LANG_PROGRAM(
555                 [#include <stdlib.h>],
556                 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
557         )],
558         AC_MSG_RESULT(yes),
559         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
560         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
563 # Look for imsg_init in libutil.
564 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
565 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
566 if test "x$found_imsg_init" = "xyes"; then
567         AC_DEFINE([HAVE_IMSG], [1], [Define to 1 if imsg is declared in libutil])
568         libutil_LIBS="$ac_cv_search_imsg_init"
569         AC_SUBST(libutil_LIBS)
572 # libevent (for gotwebd).  Lifted from tmux.
573 # Look for libevent. Try libevent_core or libevent with pkg-config first then
574 # look for the library.
575 found_libevent=no
576 PKG_CHECK_MODULES(
577         LIBEVENT_CORE,
578         [libevent_core >= 2],
579         [
580                 libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
581                 libevent_LIBS="$LIBEVENT_CORE_LIBS"
582                 AC_SUBST(libevent_CFLAGS)
583                 AC_SUBST(libevent_LIBS)
584                 found_libevent=yes
585         ],
586         found_libevent=no
588 if test x$found_libevent = xno; then
589         PKG_CHECK_MODULES(
590                 LIBEVENT,
591                 [libevent >= 2],
592                 [
593                         libevent_CFLAGS="$LIBEVENT_CFLAGS"
594                         libevent_LIBS="$LIBEVENT_LIBS"
595                         AC_SUBST(libevent_CFLAGS)
596                         AC_SUBST(libevent_LIBS)
597                         found_libevent=yes
598                 ],
599                 found_libevent=no
600         )
602 if test x$found_libevent = xno; then
603         AC_SEARCH_LIBS(
604                 event_init,
605                 [event_core event event-1.4],
606                 found_libevent=yes,
607                 found_libevent=no
608         )
610         if test "x$found_libevent" = "xyes"; then
611                 libevent_LIBS="$ac_cv_search_event_init"
612                 AC_SUBST(libevent_LIBS)
613         fi
616 if test x$found_libevent = xno; then
617 AC_CHECK_HEADER(
618         event2/event.h,
619         AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
620         [
621                 AC_CHECK_HEADER(
622                         event.h,
623                         AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
624                         found_libevent=no
625                 )
626         ]
630 if test "x$found_libevent" = xno; then
631         AC_MSG_ERROR("libevent not found")
634 AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
636 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
637 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
638 # ossp
639 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
640         AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
641 else
642         PKG_CHECK_MODULES(
643                 LIBUUID,
644                 uuid,
645                 [
646                         libuuid_CFLAGS="$LIBUUID_CFLAGS"
647                         libuuid_LIBS="$LIBUUID_LIBS"
648                         AC_SUBST(libuuid_CFLAGS)
649                         AC_SUBST(libuuid_LIBS)
650                         found_libuuid=yes
651                 ],
652                 [
653                         found_libuuid=no
654                 ]
655         )
657         if test "x$found_libuuid" = "xno"; then
658                 AC_CHECK_HEADER(
659                         uuid.h,
660                         found_libuuid=yes,
661                         found_libuuid=no)
662         fi
665 if test "x$found_libuuid" = "xno"; then
666         AC_MSG_ERROR("*** couldn't find uuid ***")
669 PKG_CHECK_MODULES(
670         ZLIB,
671         zlib,
672         [
673                 zlib_CFLAGS="$ZLIB_CFLAGS"
674                 zlib_LIBS="$ZLIB_LIBS"
675                 AC_SUBST(zlib_CFLAGS)
676                 AC_SUBST(zlib_LIBS)
677                 found_zlib=yes
678         ],
679         [
680                 found_zlib=no
681         ]
684 if test "x$found_zlib" = "xno"; then
685         AC_CHECK_HEADER(
686                 zlib.h,
687                 ,
688                 found_zlib=no)
691 if test "x$found_zlib" = "xno"; then
692         AC_MSG_ERROR("*** couldn't find zlib ***")
695 if test "$PLATFORM" = "linux"; then
696         PKG_CHECK_MODULES(
697                 LIBBSD,
698                 libbsd-overlay,
699                 [
700                         libbsd_CFLAGS="$LIBBSD_CFLAGS"
701                         libbsd_LIBS="$LIBBSD_LIBS"
702                         AC_SUBST(libbsd_CFLAGS)
703                         AC_SUBST(libbsd_LIBS)
704                         AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
705                 ],
706                 [
707                         AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
708                 ]
710         )
712         # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
713         # header files in a non-standard location, which means the overlay for
714         # <sys/tree.h> and <sys/queue.h> won't be found.
715         CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
716         LIBS="$LIBS $LIBBSD_LIBS"
718         PKG_CHECK_MODULES(
719                 LIBMD,
720                 libmd,
721                 [
722                      libmd_CFLAGS="$LIBMD_CFLAGS"
723                      libmd_LIBS="$LIBMD_LIBS"
724                      AC_SUBST(libmd_CFLAGS)
725                      AC_SUBST(libmd_LIBS)
726                 ], []
727         )
728         CFLAGS="$CFLAGS $LIBMD_CFLAGS"
729         LIBS="$LIBS $LIBMD_LIBS"
733 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
734 # some declarations.
735 AC_CHECK_DECL(
736         TAILQ_CONCAT,
737         found_queue_h=yes,
738         found_queue_h=no,
739         [#include <sys/queue.h>]
741 AC_CHECK_DECL(
742         TAILQ_PREV,
743         ,
744         found_queue_h=no,
745         [#include <sys/queue.h>]
747 AC_CHECK_DECL(
748         TAILQ_FOREACH_SAFE,
749         ,
750         found_queue_h=no,
751         [#include <sys/queue.h>]
754 if test "x$found_queue_h" = xyes; then
755         AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
756 else
757         AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
760 AC_CHECK_DECL(
761         RB_GENERATE_STATIC,
762         found_sys_tree_h=yes,
763         found_sys_tree_h=no,
764         [#include <sys/tree.h>]
767 #FIXME: May need OS-wrapping.
768 PKG_CHECK_MODULES(
769         LIBTLS,
770         [libtls],
771         [
772                 libtls_CFLAGS="$LIBTLS_CFLAGS"
773                 libtls_LIBS="$LIBTLS_LIBS"
774                 AC_SUBST(libtls_CFLAGS)
775                 AC_SUBST(libtls_LIBS)
776         ],
777         AC_MSG_ERROR(["*** Couldn't find libtls ***"])
780 # Look for __progname.
781 AC_MSG_CHECKING(for __progname)
782 AC_LINK_IFELSE([AC_LANG_SOURCE(
783         [
784                 #include <stdio.h>
785                 #include <stdlib.h>
786                 extern char *__progname;
787                 int main(void) {
788                         const char *cp = __progname;
789                         printf("%s\n", cp);
790                         exit(0);
791                 }
792         ])],
793         [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
794         [AC_MSG_RESULT(no)]
797 PKG_CHECK_MODULES(
798         LIBPANELW,
799         panelw,
800         LIBPANELW_LIBS="$LIBPANELW_LIBS"
801         found_panel=yes,
802         found_panel=no
805 if test "x$found_panel" = "xno"; then
806 PKG_CHECK_MODULES(
807         LIBPANELW,
808         gnupanelw,
809         [
810                 LIBPANELW_LIBS="$LIBPANELW_LIBS"
811                 found_panel=yes
812         ],
813         found_panel=no
817 if test "x$found_panel" = "xno"; then
818 PKG_CHECK_MODULES(
819         LIBPANELW,
820         panel,
821         [
822                 LIBPANELW_LIBS="$LIBPANELW_LIBS"
823                 found_panel=yes
824         ],
825         found_panel=no
829 if test "x$found_panel" = "xno"; then
830         AC_CHECK_LIB(panelw, update_panels, [],
831                 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
832                 [-lncurses]
833         )
837 PKG_CHECK_MODULES(
838         LIBNCURSES,
839         ncursesw,
840         found_ncurses=yes,
841         found_ncurses=no
843 if test "x$found_ncurses" = xyes; then
844         libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
845         libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
846         AC_SUBST(libncurses_CFLAGS)
847         AC_SUBST(libncurses_LIBS)
848 else
849         AC_SEARCH_LIBS(
850                 setupterm,
851                 found_ncurses=yes,
852                 found_ncurses=no
853         )
854         if test "x$found_ncurses" = xyes; then
855                 AC_CHECK_HEADER(
856                         ncurses.h,
857                         libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
858                         libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
859                         AC_SUBST(libncurses_CFLAGS)
860                         AC_SUBST(libncurses_LIBS)
861                 )
862         fi
864 if test "x$found_ncurses" = xyes; then
865         AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
866 else
867         # No ncurses, try curses.
868         AC_CHECK_FUNC(
869                 setupterm,
870                 found_curses=yes,
871                 found_curses=no
872         )
873         AC_CHECK_HEADER(
874                 curses.h,
875                 found_curses=yes,
876                 found_curses=no)
877         if test "x$found_curses" = xyes; then
878                 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
879                 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw -lpanelw"
880                 AC_SUBST(libncurses_CFLAGS)
881                 AC_SUBST(libncurses_LIBS)
882                 AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
883         else
884                 AC_MSG_ERROR("curses not found")
885         fi
888 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
889 # variables.
890 AC_SUBST(AM_CPPFLAGS)
891 CPPFLAGS="$SAVED_CPPFLAGS"
892 AC_SUBST(AM_CFLAGS)
893 CFLAGS="$SAVED_CFLAGS"
894 AC_SUBST(AM_LDFLAGS)
895 LDFLAGS="$SAVED_LDFLAGS"
897 # LIBS is designed to accumulate library dependencies as checks for them are
898 # peformed, so that this can be included directly to ld(1).
900 # However, this hinders the splitting up of the library dependencies so that
901 # they're targetted just where they're needed.  Flatting LIBS here ensures
902 # that this happens appropriately.
903 LIBS=""
905 AH_BOTTOM([#include "got_compat2.h"])
907 AM_CONDITIONAL([GOTD_ENABLED], [test "x$enable_gotd" = xyes])
908 AM_CONDITIONAL([CVG_ENABLED], [test "x$enable_cvg" = xyes])
910 AC_CONFIG_FILES([Makefile
911                  compat/Makefile
912                  libexec/Makefile
913                  libexec/got-read-tree/Makefile
914                  libexec/got-fetch-pack/Makefile
915                  libexec/got-index-pack/Makefile
916                  libexec/got-read-blob/Makefile
917                  libexec/got-read-commit/Makefile
918                  libexec/got-read-gitconfig/Makefile
919                  libexec/got-read-gotconfig/Makefile
920                  libexec/got-read-object/Makefile
921                  libexec/got-read-pack/Makefile
922                  libexec/got-read-patch/Makefile
923                  libexec/got-read-tag/Makefile
924                  libexec/got-send-pack/Makefile
925                  got/Makefile
926                  gotadmin/Makefile
927                  gotwebd/Makefile
928                  tog/Makefile
929                  Makefile.common:Makefile.common.in])
931 if test "x$enable_gotd" = "xyes"; then
932         AC_CONFIG_FILES([gitwrapper/Makefile])
933         AC_CONFIG_FILES([gotd/Makefile])
934         AC_CONFIG_FILES([gotd/libexec/Makefile])
935         AC_CONFIG_FILES([gotd/libexec/got-notify-email/Makefile])
936         AC_CONFIG_FILES([gotd/libexec/got-notify-http/Makefile])
937         AC_CONFIG_FILES([gotsh/Makefile])
938         AC_CONFIG_FILES([gotctl/Makefile])
941 if test "x$enable_cvg" = "xyes"; then
942         AC_CONFIG_FILES([cvg/Makefile])
945 AC_OUTPUT
947 executables="$(eval echo ${exec_prefix}/bin)"
948 helpers="$(eval echo ${libexecdir})"
949 manpages="$(eval echo ${mandir})"
950 gotdep="$GOTD_EMPTY_PATHC"
951 gotgwlep="$GITWRAPPER_LIBEXEC_PATHC"
953 if test -z "$enable_gotd"; then
954         enable_gotd="no"
955         gotdep="N/A"
956         gotgwlep="N/A"
959 if test -z "$enable_cvg"; then
960         enable_cvg="no"
963 if test -z "$gotdep"; then
964         gotdep="N/A"
967 if test -z "$gotgwlep"; then
968         gotgwlep="N/A"
971 echo "
972 Configured got-portable with:
974  Version:      $VERSION
976  Prefix:           ${prefix}
977  Executables:      ${executables}
978  Bison:            $YACC
979  CFlags:           $CFLAGS
980  cvg:              ${enable_cvg}
981  Gotd:             ${enable_gotd}
982    Empty Path:     ${gotdep}
983    Gitwrapper:     ${gotgwlep}
984  Helpers:          ${helpers}
985  Man pages:        ${manpages}