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])
156 AC_CACHE_CHECK([whether getopt has optreset support],
157 ac_cv_have_getopt_optreset, [
158 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
159 [[ extern int optreset; optreset = 0; ]])],
160 [ ac_cv_have_getopt_optreset="yes" ],
161 [ ac_cv_have_getopt_optreset="no"
162 ])
163 ])
165 AM_CONDITIONAL([HAVE_GETOPT], [test "x$ac_cv_have_getopt_optreset" = "xyes"])
166 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
167 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
168 [Define if your getopt(3) defines and uses optreset])
169 fi
171 AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[
172 #include <sys/types.h>
173 #ifdef HAVE_POLL_H
174 #include <poll.h>
175 #endif
176 #ifdef HAVE_SYS_POLL_H
177 #include <sys/poll.h>
178 #endif
179 ]])
181 # Checks for typ edefs, structures, and compiler characteristics.
182 AC_CHECK_HEADER_STDBOOL
183 AC_C_INLINE
184 AC_TYPE_INT64_T
185 AC_TYPE_MODE_T
186 AC_TYPE_OFF_T
187 AC_TYPE_PID_T
188 AC_TYPE_SIZE_T
189 AC_TYPE_SSIZE_T
190 AC_TYPE_UINT16_T
191 AC_TYPE_UINT32_T
192 AC_TYPE_UINT64_T
193 AC_TYPE_UINT8_T
195 # Check for ifgroupreq which is only available on BSD.
196 AC_CHECK_TYPES([struct ifgroupreq])
198 # Check for sockaddr_storage. On some systems, ss_len is filled out, although
199 # this is not mandated by POSIX, and hence systems such as linux, don't have
200 # it.
201 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
202 #include <sys/types.h>
203 #include <sys/socket.h>
204 ])
206 # Same thing as sockaddr_storage above, only now check if the member exists in
207 # the struct as well.
208 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
209 [ #include <netdb.h>
210 #include <netinet/in.h>
211 #include <sys/socket.h> ]
214 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
215 [ #include <netdb.h>
216 #include <netinet/in.h>
217 #include <sys/socket.h> ]
220 # Both checks above will result in:
222 # HAVE_STRUCT_SOCKADDR_AS_LEN
223 # SS_LEN
225 # Either being defined or not.
227 # Look for library needed for flock.
228 AC_SEARCH_LIBS(flock, bsd)
230 # Checks for library functions.
231 AC_FUNC_FORK
232 AC_FUNC_FSEEKO
233 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
234 AC_FUNC_MALLOC
235 AC_FUNC_MMAP
236 AC_FUNC_REALLOC
237 AC_FUNC_STRERROR_R
238 AC_FUNC_STRNLEN
239 AC_CHECK_FUNCS([ \
240 dup2 \
241 flock \
242 getcwd \
243 localtime_r \
244 memchr \
245 memmove \
246 memset \
247 mergesort \
248 mkdir \
249 munmap \
250 nl_langinfo \
251 realpath \
252 regcomp \
253 rmdir \
254 setlocale \
255 socket \
256 setresgid \
257 setresuid \
258 setproctitle \
259 strcasecmp \
260 strchr \
261 strcspn \
262 strdup \
263 strerror \
264 strncasecmp \
265 strndup \
266 strrchr \
267 strspn \
268 strstr \
269 strtol \
270 strtoul \
271 sysconf \
272 wcwidth \
273 ])
275 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
277 if test "x$ac_cv_func_sysconf" = xyes; then
278 AC_DEFINE([HAVE_SYSCONF], [1], [Define to 1 if sysconf() present])
279 fi
281 # Siphash support.
282 AC_CHECK_FUNCS([SipHash])
283 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
285 # Check for functions with a compatibility implementation.
286 AC_REPLACE_FUNCS([ \
287 asprintf \
288 closefrom \
289 explicit_bzero \
290 fmt_scaled \
291 freezero \
292 getdtablecount \
293 getline \
294 getprogname \
295 recallocarray \
296 reallocarray \
297 strlcat \
298 strlcpy \
299 strndup \
300 strnlen \
301 strsep \
302 strtonum \
303 ])
304 AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
306 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
307 # musl does not set optarg to NULL for flags without arguments (although it is
308 # not required to, but it is helpful) 3) there are probably other weird
309 # implementations.
310 AC_LIBOBJ(getopt)
312 # Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
313 AC_MSG_CHECKING(for b64_ntop)
314 AC_LINK_IFELSE([AC_LANG_PROGRAM(
316 #include <sys/types.h>
317 #include <netinet/in.h>
318 #include <resolv.h>
319 ],
321 b64_ntop(NULL, 0, NULL, 0);
322 ])],
323 found_b64_ntop=yes,
324 found_b64_ntop=no
326 AC_MSG_RESULT($found_b64_ntop)
327 libresolv_LIBS=""
328 if test "x$found_b64_ntop" = xno; then
329 AC_MSG_CHECKING(for b64_ntop with -lresolv)
330 LIBS="-lresolv"
331 AC_LINK_IFELSE([AC_LANG_PROGRAM(
333 #include <sys/types.h>
334 #include <netinet/in.h>
335 #include <resolv.h>
336 ],
338 b64_ntop(NULL, 0, NULL, 0);
339 ])],
340 found_b64_ntop=yes,
341 found_b64_ntop=no
343 AC_MSG_RESULT($found_b64_ntop)
344 libresolv_LIBS="$LIBS"
345 fi
346 if test "x$found_b64_ntop" = xno; then
347 AC_MSG_CHECKING(for b64_ntop with -lnetwork)
348 LIBS="-lresolv -lnetwork"
349 AC_LINK_IFELSE([AC_LANG_PROGRAM(
351 #include <sys/types.h>
352 #include <netinet/in.h>
353 #include <resolv.h>
354 ],
356 b64_ntop(NULL, 0, NULL, 0);
357 ])],
358 found_b64_ntop=yes,
359 found_b64_ntop=no
361 AC_MSG_RESULT($found_b64_ntop)
362 libresolv_LIBS="$LIBS"
363 fi
365 AM_CONDITIONAL([HAVE_B64], [test "x$found_b64_ntop" = xyes])
366 if test "x$found_b64_ntop" = xyes; then
367 AC_DEFINE([HAVE_B64_NTOP], [1], [define if b64_ntop is present])
368 AC_SUBST(libresolv_LIBS)
369 else
370 AC_LIBOBJ(base64)
371 fi
373 # Check the platform we're compiling on.
374 AC_MSG_CHECKING(platform)
375 case "$host_os" in
376 *linux*)
377 AC_MSG_RESULT(linux)
378 PLATFORM=linux
379 ;;
380 *freebsd*)
381 AC_MSG_RESULT(freebsd)
382 PLATFORM=freebsd
383 ;;
384 *darwin*)
385 AC_MSG_RESULT(darwin)
386 PLATFORM=darwin
387 ;;
388 *netbsd*)
389 AC_MSG_RESULT(netbsd)
390 PLATFORM=netbsd
391 ;;
392 *openbsd*)
393 AC_MSG_RESULT(openbsd)
394 PLATFORM=openbsd
395 ;;
396 *dragonfly*)
397 AC_MSG_RESULT(dragonfly)
398 PLATFORM=dragonflybsd
399 ;;
400 *)
401 AC_MSG_RESULT(unknown)
402 PLATFORM=unknown
403 ;;
404 esac
405 AC_SUBST(PLATFORM)
406 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
407 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
408 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
409 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
410 AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
411 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
413 # On OpenBSD, these functions are already defined, yet looking for them in
414 # this way on OpenBSD breaks <sha2.h> inclusion.
415 # FIXME: this needs addressing.
416 if test "x$PLATFORM" != "xopenbsd"; then
417 AC_CHECK_FUNCS([ \
418 SHA256Update \
419 SHA384Update \
420 SHA512Update \
421 ])
422 fi
424 # Look for yacc.
425 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
426 && ! command -v "$YACC" >/dev/null 2>&1; then
427 AC_MSG_ERROR("yacc not found: $YACC")
428 fi
430 if test x"$PLATFORM" = "xdarwin"; then
431 # Check for and/or set HOMEBREW_PREFIX. brew is a common way of
432 # installing applications. The other is MacPorts.
434 # Before Apple Silicon existed (M1 onward), the paths for applications
435 # installed via homebrew was typically /usr/local. However, with M1
436 # onward, this changed to a different path.
438 # Rather than hardcode this, check for HOMEBREW_PREFIX in the
439 # environment if it's already set, and use it. Otherwise, check for
440 # brew(1) and use that. If that fails, default to /usr/local
442 # This also means that MacPorts should continue to work.
444 # But with MacPorts, we should also check --prefix, and use that if it
445 # has been supplied.
447 # In both cases, the variable HOMEBREW_PREFIX is used for both.
448 HB_PREFIX=""
449 FOUND_BISON="no"
450 GNUBISON=""
451 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
452 # HOMEBREW_PREFIX not set, check for brew(1)
453 if command -v brew >/dev/null 2>&1; then
454 AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
455 export HOMEBREW_PREFIX="$(brew --prefix)"
456 fi
458 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
459 then
460 # Default.
461 if test -z "${prefix}" -o "${prefix}" = "NONE"; then
462 export HOMEBREW_PREFIX="/usr/local"
463 HB_PREFIX="/usr/local"
464 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
465 else
466 HB_PREFIX="$(eval echo ${prefix})"
467 if test "$HB_PREFIX" = "NONE"; then
468 HB_PREFIX="/opt/local"
469 else
470 AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
471 fi
472 export HOMEBREW_PREFIX="$HB_PREFIX"
473 fi
474 fi
475 fi
477 AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
479 if test "$YACC_OVERRIDE" = "no" && \
480 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
481 AC_MSG_WARN([
482 "***********************************************************
483 GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
484 ***********************************************************
486 Falling back to checking either /usr/local or \${prefix}"
487 ])
489 FOUND_BISON="no"
490 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
491 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
492 export HOMEBREW_PREFIX="/usr/local"
493 FOUND_BISON="yes"
494 GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
495 fi
497 if test "$FOUND_BISON" = "no"; then
498 HB_PREFIX="/opt/local"
499 AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
501 if test -x "${HB_PREFIX}/bin/bison"; then
502 export HOMEBREW_PREFIX="${HB_PREFIX}"
503 GNUBISON="${HB_PREFIX}/bin/bison"
504 FOUND_BISON="yes"
505 fi
506 fi
507 else
508 FOUND_BISON="yes"
509 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
510 fi
512 if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
513 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
514 fi
516 # Override YACC here to point to the GNU version of bison.
517 if test "$YACC_OVERRIDE" = "yes"; then
518 export YACC="$YACC -y"
519 else
520 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
521 export YACC="${GNUBISON} -y"
522 fi
523 export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
524 export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
525 export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
526 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
527 fi
529 # Landlock detection.
530 AC_MSG_CHECKING([for landlock])
531 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
532 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
533 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
534 AC_MSG_RESULT(yes)
535 else
536 AC_MSG_RESULT(no)
537 fi
539 # Clang sanitizers wrap reallocarray even if it isn't available on the target
540 # system. When compiled it always returns NULL and crashes the program. To
541 # detect this we need a more complicated test.
542 AC_MSG_CHECKING([for working reallocarray])
543 AC_RUN_IFELSE([AC_LANG_PROGRAM(
544 [#include <stdlib.h>],
545 [return (reallocarray(NULL, 1, 1) == NULL);]
546 )],
547 AC_MSG_RESULT(yes),
548 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
549 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
551 AC_MSG_CHECKING([for working recallocarray])
552 AC_RUN_IFELSE([AC_LANG_PROGRAM(
553 [#include <stdlib.h>],
554 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
555 )],
556 AC_MSG_RESULT(yes),
557 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
558 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
561 # Look for imsg_init in libutil.
562 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
563 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
564 if test "x$found_imsg_init" = "xyes"; then
565 AC_DEFINE([HAVE_IMSG], [1], [Define to 1 if imsg is declared in libutil])
566 libutil_LIBS="$ac_cv_search_imsg_init"
567 AC_SUBST(libutil_LIBS)
568 fi
570 # libevent (for gotwebd). Lifted from tmux.
571 # Look for libevent. Try libevent_core or libevent with pkg-config first then
572 # look for the library.
573 found_libevent=no
574 PKG_CHECK_MODULES(
575 LIBEVENT_CORE,
576 [libevent_core >= 2],
578 libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
579 libevent_LIBS="$LIBEVENT_CORE_LIBS"
580 AC_SUBST(libevent_CFLAGS)
581 AC_SUBST(libevent_LIBS)
582 found_libevent=yes
583 ],
584 found_libevent=no
586 if test x$found_libevent = xno; then
587 PKG_CHECK_MODULES(
588 LIBEVENT,
589 [libevent >= 2],
591 libevent_CFLAGS="$LIBEVENT_CFLAGS"
592 libevent_LIBS="$LIBEVENT_LIBS"
593 AC_SUBST(libevent_CFLAGS)
594 AC_SUBST(libevent_LIBS)
595 found_libevent=yes
596 ],
597 found_libevent=no
599 fi
600 if test x$found_libevent = xno; then
601 AC_SEARCH_LIBS(
602 event_init,
603 [event_core event event-1.4],
604 found_libevent=yes,
605 found_libevent=no
608 if test "x$found_libevent" = "xyes"; then
609 libevent_LIBS="$ac_cv_search_event_init"
610 AC_SUBST(libevent_LIBS)
611 fi
612 fi
614 if test x$found_libevent = xno; then
615 AC_CHECK_HEADER(
616 event2/event.h,
617 AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
619 AC_CHECK_HEADER(
620 event.h,
621 AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
622 found_libevent=no
626 fi
628 if test "x$found_libevent" = xno; then
629 AC_MSG_ERROR("libevent not found")
630 fi
632 AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
634 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
635 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
636 # ossp
637 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
638 AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
639 else
640 PKG_CHECK_MODULES(
641 LIBUUID,
642 uuid,
644 libuuid_CFLAGS="$LIBUUID_CFLAGS"
645 libuuid_LIBS="$LIBUUID_LIBS"
646 AC_SUBST(libuuid_CFLAGS)
647 AC_SUBST(libuuid_LIBS)
648 found_libuuid=yes
649 ],
651 found_libuuid=no
655 if test "x$found_libuuid" = "xno"; then
656 AC_CHECK_HEADER(
657 uuid.h,
658 found_libuuid=yes,
659 found_libuuid=no)
660 fi
661 fi
663 if test "x$found_libuuid" = "xno"; then
664 AC_MSG_ERROR("*** couldn't find uuid ***")
665 fi
667 PKG_CHECK_MODULES(
668 ZLIB,
669 zlib,
671 zlib_CFLAGS="$ZLIB_CFLAGS"
672 zlib_LIBS="$ZLIB_LIBS"
673 AC_SUBST(zlib_CFLAGS)
674 AC_SUBST(zlib_LIBS)
675 found_zlib=yes
676 ],
678 found_zlib=no
682 if test "x$found_zlib" = "xno"; then
683 AC_CHECK_HEADER(
684 zlib.h,
686 found_zlib=no)
687 fi
689 if test "x$found_zlib" = "xno"; then
690 AC_MSG_ERROR("*** couldn't find zlib ***")
691 fi
693 if test "$PLATFORM" = "linux"; then
694 PKG_CHECK_MODULES(
695 LIBBSD,
696 libbsd-overlay,
698 libbsd_CFLAGS="$LIBBSD_CFLAGS"
699 libbsd_LIBS="$LIBBSD_LIBS"
700 AC_SUBST(libbsd_CFLAGS)
701 AC_SUBST(libbsd_LIBS)
702 AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
703 ],
705 AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
710 # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
711 # header files in a non-standard location, which means the overlay for
712 # <sys/tree.h> and <sys/queue.h> won't be found.
713 CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
714 LIBS="$LIBS $LIBBSD_LIBS"
716 PKG_CHECK_MODULES(
717 LIBMD,
718 libmd,
720 libmd_CFLAGS="$LIBMD_CFLAGS"
721 libmd_LIBS="$LIBMD_LIBS"
722 AC_SUBST(libmd_CFLAGS)
723 AC_SUBST(libmd_LIBS)
724 ], []
726 CFLAGS="$CFLAGS $LIBMD_CFLAGS"
727 LIBS="$LIBS $LIBMD_LIBS"
729 fi
731 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
732 # some declarations.
733 AC_CHECK_DECL(
734 TAILQ_CONCAT,
735 found_queue_h=yes,
736 found_queue_h=no,
737 [#include <sys/queue.h>]
739 AC_CHECK_DECL(
740 TAILQ_PREV,
742 found_queue_h=no,
743 [#include <sys/queue.h>]
745 AC_CHECK_DECL(
746 TAILQ_FOREACH_SAFE,
748 found_queue_h=no,
749 [#include <sys/queue.h>]
752 if test "x$found_queue_h" = xyes; then
753 AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
754 else
755 AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
756 fi
758 AC_CHECK_DECL(
759 RB_GENERATE_STATIC,
760 found_sys_tree_h=yes,
761 found_sys_tree_h=no,
762 [#include <sys/tree.h>]
765 #FIXME: May need OS-wrapping.
766 PKG_CHECK_MODULES(
767 LIBTLS,
768 [libtls],
770 libtls_CFLAGS="$LIBTLS_CFLAGS"
771 libtls_LIBS="$LIBTLS_LIBS"
772 AC_SUBST(libtls_CFLAGS)
773 AC_SUBST(libtls_LIBS)
774 ],
775 AC_MSG_ERROR(["*** Couldn't find libtls ***"])
778 # Look for __progname.
779 AC_MSG_CHECKING(for __progname)
780 AC_LINK_IFELSE([AC_LANG_SOURCE(
782 #include <stdio.h>
783 #include <stdlib.h>
784 extern char *__progname;
785 int main(void) {
786 const char *cp = __progname;
787 printf("%s\n", cp);
788 exit(0);
790 ])],
791 [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
792 [AC_MSG_RESULT(no)]
795 PKG_CHECK_MODULES(
796 LIBPANELW,
797 panelw,
798 LIBPANELW_LIBS="$LIBPANELW_LIBS"
799 found_panel=yes,
800 found_panel=no
803 if test "x$found_panel" = "xno"; then
804 PKG_CHECK_MODULES(
805 LIBPANELW,
806 gnupanelw,
808 LIBPANELW_LIBS="$LIBPANELW_LIBS"
809 found_panel=yes
810 ],
811 found_panel=no
813 fi
815 if test "x$found_panel" = "xno"; then
816 PKG_CHECK_MODULES(
817 LIBPANELW,
818 panel,
820 LIBPANELW_LIBS="$LIBPANELW_LIBS"
821 found_panel=yes
822 ],
823 found_panel=no
825 fi
827 if test "x$found_panel" = "xno"; then
828 AC_CHECK_LIB(panelw, update_panels, [],
829 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
830 [-lncurses]
833 fi
835 PKG_CHECK_MODULES(
836 LIBNCURSES,
837 ncursesw,
838 found_ncurses=yes,
839 found_ncurses=no
841 if test "x$found_ncurses" = xyes; then
842 libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
843 libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
844 AC_SUBST(libncurses_CFLAGS)
845 AC_SUBST(libncurses_LIBS)
846 else
847 AC_SEARCH_LIBS(
848 setupterm,
849 found_ncurses=yes,
850 found_ncurses=no
852 if test "x$found_ncurses" = xyes; then
853 AC_CHECK_HEADER(
854 ncurses.h,
855 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
856 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
857 AC_SUBST(libncurses_CFLAGS)
858 AC_SUBST(libncurses_LIBS)
860 fi
861 fi
862 if test "x$found_ncurses" = xyes; then
863 AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
864 else
865 # No ncurses, try curses.
866 AC_CHECK_FUNC(
867 setupterm,
868 found_curses=yes,
869 found_curses=no
871 AC_CHECK_HEADER(
872 curses.h,
873 found_curses=yes,
874 found_curses=no)
875 if test "x$found_curses" = xyes; then
876 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
877 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw -lpanelw"
878 AC_SUBST(libncurses_CFLAGS)
879 AC_SUBST(libncurses_LIBS)
880 AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
881 else
882 AC_MSG_ERROR("curses not found")
883 fi
884 fi
886 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
887 # variables.
888 AC_SUBST(AM_CPPFLAGS)
889 CPPFLAGS="$SAVED_CPPFLAGS"
890 AC_SUBST(AM_CFLAGS)
891 CFLAGS="$SAVED_CFLAGS"
892 AC_SUBST(AM_LDFLAGS)
893 LDFLAGS="$SAVED_LDFLAGS"
895 # LIBS is designed to accumulate library dependencies as checks for them are
896 # peformed, so that this can be included directly to ld(1).
898 # However, this hinders the splitting up of the library dependencies so that
899 # they're targetted just where they're needed. Flatting LIBS here ensures
900 # that this happens appropriately.
901 LIBS=""
903 AH_BOTTOM([#include "got_compat2.h"])
905 AM_CONDITIONAL([CVG_ENABLED], [test "x$enable_cvg" = xyes])
907 AC_CONFIG_FILES([Makefile
908 compat/Makefile
909 gitwrapper/Makefile
910 got/Makefile
911 gotadmin/Makefile
912 gotctl/Makefile
913 gotd/Makefile
914 gotd/libexec/Makefile
915 gotd/libexec/got-notify-email/Makefile
916 gotd/libexec/got-notify-http/Makefile
917 gotsh/Makefile
918 gotwebd/Makefile
919 libexec/Makefile
920 libexec/got-fetch-http/Makefile
921 libexec/got-fetch-pack/Makefile
922 libexec/got-index-pack/Makefile
923 libexec/got-read-blob/Makefile
924 libexec/got-read-commit/Makefile
925 libexec/got-read-gitconfig/Makefile
926 libexec/got-read-gotconfig/Makefile
927 libexec/got-read-object/Makefile
928 libexec/got-read-pack/Makefile
929 libexec/got-read-patch/Makefile
930 libexec/got-read-tag/Makefile
931 libexec/got-read-tree/Makefile
932 libexec/got-send-pack/Makefile
933 tog/Makefile
934 Makefile.common:Makefile.common.in])
936 if test "x$enable_cvg" = "xyes"; then
937 AC_CONFIG_FILES([cvg/Makefile])
938 fi
940 AC_OUTPUT
942 executables="$(eval echo ${exec_prefix}/bin)"
943 helpers="$(eval echo ${libexecdir})"
944 manpages="$(eval echo ${mandir})"
945 gotdep="$GOTD_EMPTY_PATHC"
946 gotgwlep="$GITWRAPPER_LIBEXEC_PATHC"
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:
971 Empty Path: ${gotdep}
972 Gitwrapper: ${gotgwlep}
973 Helpers: ${helpers}
974 Man pages: ${manpages}