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([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
72 fi
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")
79 fi
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 util.h \
111 unistd.h \
112 wchar.h \
113 ])
115 AC_HEADER_DIRENT
116 AC_CHECK_DECL([F_CLOSEM],
117 HAVE_FCNTL_CLOSEM
118 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
119 [Use F_CLOSEM fcntl for closefrom]),
120 [],
121 [#include <limits.h>
122 #include <fcntl.h>
126 AC_MSG_CHECKING([for /proc/pid/fd directory])
127 if test -d "/proc/$$/fd" ; then
128 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
129 AC_MSG_RESULT([yes])
130 else
131 AC_MSG_RESULT([no])
132 fi
134 AC_MSG_CHECKING([whether program_invocation_short_name is defined])
135 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
136 #include <argp.h>
137 ]], [[
138 program_invocation_short_name = "test";
139 ]])], [
140 AC_MSG_RESULT([yes])
141 AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
142 [Define if program_invocation_short_name is defined])
143 ], [
144 AC_MSG_RESULT([no])
145 ])
147 # Look for prctl(PR_SET_NAME).
148 AC_CHECK_DECL(
149 [PR_SET_NAME],
150 [AC_DEFINE([HAVE_PR_SET_NAME], [1], [Define if PR_SET_NAME is defined])],
151 [],
152 [#include <sys/prctl.h>]
155 AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_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([ \
419 SHA256Update \
420 SHA384Update \
421 SHA512Update \
422 ])
423 fi
425 # Look for yacc.
426 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
427 && ! command -v "$YACC" >/dev/null 2>&1; then
428 AC_MSG_ERROR("yacc not found: $YACC")
429 fi
431 if test x"$PLATFORM" = "xdarwin"; then
432 # Check for and/or set HOMEBREW_PREFIX. brew is a common way of
433 # installing applications. The other is MacPorts.
435 # Before Apple Silicon existed (M1 onward), the paths for applications
436 # installed via homebrew was typically /usr/local. However, with M1
437 # onward, this changed to a different path.
439 # Rather than hardcode this, check for HOMEBREW_PREFIX in the
440 # environment if it's already set, and use it. Otherwise, check for
441 # brew(1) and use that. If that fails, default to /usr/local
443 # This also means that MacPorts should continue to work.
445 # But with MacPorts, we should also check --prefix, and use that if it
446 # has been supplied.
448 # In both cases, the variable HOMEBREW_PREFIX is used for both.
449 HB_PREFIX=""
450 FOUND_BISON="no"
451 GNUBISON=""
452 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
453 # HOMEBREW_PREFIX not set, check for brew(1)
454 if command -v brew >/dev/null 2>&1; then
455 AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
456 export HOMEBREW_PREFIX="$(brew --prefix)"
457 fi
459 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
460 then
461 # Default.
462 if test -z "${prefix}" -o "${prefix}" = "NONE"; then
463 export HOMEBREW_PREFIX="/usr/local"
464 HB_PREFIX="/usr/local"
465 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
466 else
467 HB_PREFIX="$(eval echo ${prefix})"
468 if test "$HB_PREFIX" = "NONE"; then
469 HB_PREFIX="/opt/local"
470 else
471 AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
472 fi
473 export HOMEBREW_PREFIX="$HB_PREFIX"
474 fi
475 fi
476 fi
478 AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
480 if test "$YACC_OVERRIDE" = "no" && \
481 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
482 AC_MSG_WARN([
483 "***********************************************************
484 GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
485 ***********************************************************
487 Falling back to checking either /usr/local or \${prefix}"
488 ])
490 FOUND_BISON="no"
491 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
492 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
493 export HOMEBREW_PREFIX="/usr/local"
494 FOUND_BISON="yes"
495 GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
496 fi
498 if test "$FOUND_BISON" = "no"; then
499 HB_PREFIX="/opt/local"
500 AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
502 if test -x "${HB_PREFIX}/bin/bison"; then
503 export HOMEBREW_PREFIX="${HB_PREFIX}"
504 GNUBISON="${HB_PREFIX}/bin/bison"
505 FOUND_BISON="yes"
506 fi
507 fi
508 else
509 FOUND_BISON="yes"
510 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
511 fi
513 if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
514 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
515 fi
517 # Override YACC here to point to the GNU version of bison.
518 if test "$YACC_OVERRIDE" = "yes"; then
519 export YACC="$YACC -y"
520 else
521 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
522 export YACC="${GNUBISON} -y"
523 fi
524 export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
525 export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
526 export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
527 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
528 fi
530 # Landlock detection.
531 AC_MSG_CHECKING([for landlock])
532 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
533 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
534 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
535 AC_MSG_RESULT(yes)
536 else
537 AC_MSG_RESULT(no)
538 fi
540 # Clang sanitizers wrap reallocarray even if it isn't available on the target
541 # system. When compiled it always returns NULL and crashes the program. To
542 # detect this we need a more complicated test.
543 AC_MSG_CHECKING([for working reallocarray])
544 AC_RUN_IFELSE([AC_LANG_PROGRAM(
545 [#include <stdlib.h>],
546 [return (reallocarray(NULL, 1, 1) == NULL);]
547 )],
548 AC_MSG_RESULT(yes),
549 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
550 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
552 AC_MSG_CHECKING([for working recallocarray])
553 AC_RUN_IFELSE([AC_LANG_PROGRAM(
554 [#include <stdlib.h>],
555 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
556 )],
557 AC_MSG_RESULT(yes),
558 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
559 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
562 # Look for imsg_init in libutil.
563 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
564 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
565 if test "x$found_imsg_init" = "xyes"; then
566 AC_DEFINE([HAVE_IMSG], [1], [Define to 1 if imsg is declared in libutil])
567 libutil_LIBS="$ac_cv_search_imsg_init"
568 AC_SUBST(libutil_LIBS)
569 fi
571 # libevent (for gotwebd). Lifted from tmux.
572 # Look for libevent. Try libevent_core or libevent with pkg-config first then
573 # look for the library.
574 found_libevent=no
575 PKG_CHECK_MODULES(
576 LIBEVENT_CORE,
577 [libevent_core >= 2],
579 libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
580 libevent_LIBS="$LIBEVENT_CORE_LIBS"
581 AC_SUBST(libevent_CFLAGS)
582 AC_SUBST(libevent_LIBS)
583 found_libevent=yes
584 ],
585 found_libevent=no
587 if test x$found_libevent = xno; then
588 PKG_CHECK_MODULES(
589 LIBEVENT,
590 [libevent >= 2],
592 libevent_CFLAGS="$LIBEVENT_CFLAGS"
593 libevent_LIBS="$LIBEVENT_LIBS"
594 AC_SUBST(libevent_CFLAGS)
595 AC_SUBST(libevent_LIBS)
596 found_libevent=yes
597 ],
598 found_libevent=no
600 fi
601 if test x$found_libevent = xno; then
602 AC_SEARCH_LIBS(
603 event_init,
604 [event_core event event-1.4],
605 found_libevent=yes,
606 found_libevent=no
609 if test "x$found_libevent" = "xyes"; then
610 libevent_LIBS="$ac_cv_search_event_init"
611 AC_SUBST(libevent_LIBS)
612 fi
613 fi
615 if test x$found_libevent = xno; then
616 AC_CHECK_HEADER(
617 event2/event.h,
618 AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
620 AC_CHECK_HEADER(
621 event.h,
622 AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
623 found_libevent=no
627 fi
629 if test "x$found_libevent" = xno; then
630 AC_MSG_ERROR("libevent not found")
631 fi
633 AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
635 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
636 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
637 # ossp
638 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
639 AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
640 else
641 PKG_CHECK_MODULES(
642 LIBUUID,
643 uuid,
645 libuuid_CFLAGS="$LIBUUID_CFLAGS"
646 libuuid_LIBS="$LIBUUID_LIBS"
647 AC_SUBST(libuuid_CFLAGS)
648 AC_SUBST(libuuid_LIBS)
649 found_libuuid=yes
650 ],
652 found_libuuid=no
656 if test "x$found_libuuid" = "xno"; then
657 AC_CHECK_HEADER(
658 uuid.h,
659 found_libuuid=yes,
660 found_libuuid=no)
661 fi
662 fi
664 if test "x$found_libuuid" = "xno"; then
665 AC_MSG_ERROR("*** couldn't find uuid ***")
666 fi
668 PKG_CHECK_MODULES(
669 ZLIB,
670 zlib,
672 zlib_CFLAGS="$ZLIB_CFLAGS"
673 zlib_LIBS="$ZLIB_LIBS"
674 AC_SUBST(zlib_CFLAGS)
675 AC_SUBST(zlib_LIBS)
676 found_zlib=yes
677 ],
679 found_zlib=no
683 if test "x$found_zlib" = "xno"; then
684 AC_CHECK_HEADER(
685 zlib.h,
687 found_zlib=no)
688 fi
690 if test "x$found_zlib" = "xno"; then
691 AC_MSG_ERROR("*** couldn't find zlib ***")
692 fi
694 if test "$PLATFORM" = "linux"; then
695 PKG_CHECK_MODULES(
696 LIBBSD,
697 libbsd-overlay,
699 libbsd_CFLAGS="$LIBBSD_CFLAGS"
700 libbsd_LIBS="$LIBBSD_LIBS"
701 AC_SUBST(libbsd_CFLAGS)
702 AC_SUBST(libbsd_LIBS)
703 AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
704 ],
706 AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
711 # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
712 # header files in a non-standard location, which means the overlay for
713 # <sys/tree.h> and <sys/queue.h> won't be found.
714 CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
715 LIBS="$LIBS $LIBBSD_LIBS"
717 PKG_CHECK_MODULES(
718 LIBMD,
719 libmd,
721 libmd_CFLAGS="$LIBMD_CFLAGS"
722 libmd_LIBS="$LIBMD_LIBS"
723 AC_SUBST(libmd_CFLAGS)
724 AC_SUBST(libmd_LIBS)
725 ], []
727 CFLAGS="$CFLAGS $LIBMD_CFLAGS"
728 LIBS="$LIBS $LIBMD_LIBS"
730 fi
732 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
733 # some declarations.
734 AC_CHECK_DECL(
735 TAILQ_CONCAT,
736 found_queue_h=yes,
737 found_queue_h=no,
738 [#include <sys/queue.h>]
740 AC_CHECK_DECL(
741 TAILQ_PREV,
743 found_queue_h=no,
744 [#include <sys/queue.h>]
746 AC_CHECK_DECL(
747 TAILQ_FOREACH_SAFE,
749 found_queue_h=no,
750 [#include <sys/queue.h>]
753 if test "x$found_queue_h" = xyes; then
754 AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
755 else
756 AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
757 fi
759 AC_CHECK_DECL(
760 RB_GENERATE_STATIC,
761 found_sys_tree_h=yes,
762 found_sys_tree_h=no,
763 [#include <sys/tree.h>]
766 if test "x$found_sys_tree_h" = xyes; then
767 AC_DEFINE([HAVE_TREE_H], [1], [sys/tree.h])
768 else
769 AC_MSG_NOTICE("Using compat/tree.h")
770 fi
772 # Look for __progname.
773 AC_MSG_CHECKING(for __progname)
774 AC_LINK_IFELSE([AC_LANG_SOURCE(
776 #include <stdio.h>
777 #include <stdlib.h>
778 extern char *__progname;
779 int main(void) {
780 const char *cp = __progname;
781 printf("%s\n", cp);
782 exit(0);
784 ])],
785 [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
786 [AC_MSG_RESULT(no)]
789 PKG_CHECK_MODULES(
790 LIBPANELW,
791 panelw,
792 LIBPANELW_LIBS="$LIBPANELW_LIBS"
793 found_panel=yes,
794 found_panel=no
797 if test "x$found_panel" = "xno"; then
798 PKG_CHECK_MODULES(
799 LIBPANELW,
800 gnupanelw,
802 LIBPANELW_LIBS="$LIBPANELW_LIBS"
803 found_panel=yes
804 ],
805 found_panel=no
807 fi
809 if test "x$found_panel" = "xno"; then
810 PKG_CHECK_MODULES(
811 LIBPANELW,
812 panel,
814 LIBPANELW_LIBS="$LIBPANELW_LIBS"
815 found_panel=yes
816 ],
817 found_panel=no
819 fi
821 if test "x$found_panel" = "xno"; then
822 AC_CHECK_LIB(panelw, update_panels, [],
823 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
824 [-lncurses]
827 fi
829 PKG_CHECK_MODULES(
830 LIBNCURSES,
831 ncursesw,
832 found_ncurses=yes,
833 found_ncurses=no
835 if test "x$found_ncurses" = xyes; then
836 libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
837 libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
838 AC_SUBST(libncurses_CFLAGS)
839 AC_SUBST(libncurses_LIBS)
840 else
841 AC_SEARCH_LIBS(
842 setupterm,
843 found_ncurses=yes,
844 found_ncurses=no
846 if test "x$found_ncurses" = xyes; then
847 AC_CHECK_HEADER(
848 ncurses.h,
849 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
850 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
851 AC_SUBST(libncurses_CFLAGS)
852 AC_SUBST(libncurses_LIBS)
854 fi
855 fi
856 if test "x$found_ncurses" = xyes; then
857 AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
858 else
859 # No ncurses, try curses.
860 AC_CHECK_FUNC(
861 setupterm,
862 found_curses=yes,
863 found_curses=no
865 AC_CHECK_HEADER(
866 curses.h,
867 found_curses=yes,
868 found_curses=no)
869 if test "x$found_curses" = xyes; then
870 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
871 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw -lpanelw"
872 AC_SUBST(libncurses_CFLAGS)
873 AC_SUBST(libncurses_LIBS)
874 AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
875 else
876 AC_MSG_ERROR("curses not found")
877 fi
878 fi
880 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
881 # variables.
882 AC_SUBST(AM_CPPFLAGS)
883 CPPFLAGS="$SAVED_CPPFLAGS"
884 AC_SUBST(AM_CFLAGS)
885 CFLAGS="$SAVED_CFLAGS"
886 AC_SUBST(AM_LDFLAGS)
887 LDFLAGS="$SAVED_LDFLAGS"
889 # LIBS is designed to accumulate library dependencies as checks for them are
890 # peformed, so that this can be included directly to ld(1).
892 # However, this hinders the splitting up of the library dependencies so that
893 # they're targetted just where they're needed. Flatting LIBS here ensures
894 # that this happens appropriately.
895 LIBS=""
897 AH_BOTTOM([#include "got_compat2.h"])
899 AM_CONDITIONAL([GOTD_ENABLED], [test "x$enable_gotd" = xyes])
900 AM_CONDITIONAL([CVG_ENABLED], [test "x$enable_cvg" = xyes])
902 AC_CONFIG_FILES([Makefile
903 compat/Makefile
904 libexec/Makefile
905 libexec/got-read-tree/Makefile
906 libexec/got-fetch-pack/Makefile
907 libexec/got-index-pack/Makefile
908 libexec/got-read-blob/Makefile
909 libexec/got-read-commit/Makefile
910 libexec/got-read-gitconfig/Makefile
911 libexec/got-read-gotconfig/Makefile
912 libexec/got-read-object/Makefile
913 libexec/got-read-pack/Makefile
914 libexec/got-read-patch/Makefile
915 libexec/got-read-tag/Makefile
916 libexec/got-send-pack/Makefile
917 got/Makefile
918 gotadmin/Makefile
919 gotwebd/Makefile
920 tog/Makefile
921 Makefile.common:Makefile.common.in])
923 if test "x$enable_gotd" = "xyes"; then
924 AC_CONFIG_FILES([gitwrapper/Makefile])
925 AC_CONFIG_FILES([gotd/Makefile])
926 AC_CONFIG_FILES([gotsh/Makefile])
927 AC_CONFIG_FILES([gotctl/Makefile])
928 fi
930 if test "x$enable_cvg" = "xyes"; then
931 AC_CONFIG_FILES([cvg/Makefile])
932 fi
934 AC_OUTPUT
936 executables="$(eval echo ${exec_prefix}/bin)"
937 helpers="$(eval echo ${libexecdir})"
938 manpages="$(eval echo ${mandir})"
939 gotdep="$GOTD_EMPTY_PATHC"
940 gotgwlep="$GITWRAPPER_LIBEXEC_PATHC"
942 if test -z "$enable_gotd"; then
943 enable_gotd="no"
944 gotdep="N/A"
945 gotgwlep="N/A"
946 fi
948 if test -z "$enable_cvg"; then
949 enable_cvg="no"
950 fi
952 if test -z "$gotdep"; then
953 gotdep="N/A"
954 fi
956 if test -z "$gotgwlep"; then
957 gotgwlep="N/A"
958 fi
960 echo "
961 Configured got-portable with:
963 Version: $VERSION
965 Prefix: ${prefix}
966 Executables: ${executables}
967 Bison: $YACC
968 CFlags: $CFLAGS
969 cvg: ${enable_cvg}
970 Gotd: ${enable_gotd}
971 Empty Path: ${gotdep}
972 Gitwrapper: ${gotgwlep}
973 Helpers: ${helpers}
974 Man pages: ${manpages}