Blob


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