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])
25 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
26 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
27 # empty default.
28 : ${CFLAGS=""}
30 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
31 # AC_CHECK_HEADER doesn't give us any other way to update the include
32 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
33 SAVED_CFLAGS="$CFLAGS"
34 SAVED_CPPFLAGS="$CPPFLAGS"
35 SAVED_LDFLAGS="$LDFLAGS"
37 # YACC override
38 YACC_OVERRIDE="yes"
40 # Checks for programs.
41 AC_PROG_CC
42 AC_PROG_CPP
43 AC_PROG_INSTALL
44 AC_PROG_LN_S
45 AC_PROG_MAKE_SET
46 if test -z "$YACC"; then
47 YACC_OVERRIDE="no"
48 AC_PROG_YACC
49 fi
50 AM_PROG_AR
51 AC_PROG_RANLIB
52 PKG_PROG_PKG_CONFIG
54 if test "$YACC_OVERRIDE" = "yes"; then
55 AC_MSG_NOTICE("Using YACC set from environment: $YACC")
56 fi
58 # Checks for header files.
59 AC_CHECK_HEADERS([ \
60 fcntl.h \
61 getopt.h \
62 langinfo.h \
63 libutil.h \
64 limits.h \
65 linux/landlock.h \
66 locale.h \
67 netdb.h \
68 netinet/in.h \
69 paths.h \
70 poll.h \
71 sha.h \
72 sha1.h \
73 sha2.h \
74 sha256.h \
75 stddef.h \
76 stdint.h \
77 stdlib.h \
78 string.h \
79 sys/ioctl.h \
80 sys/param.h \
81 sys/poll.h \
82 sys/queue.h \
83 sys/select.h \
84 sys/socket.h \
85 sys/time.h \
86 sys/tree.h \
87 util.h \
88 unistd.h \
89 wchar.h \
90 ])
92 AC_HEADER_DIRENT
93 AC_CHECK_DECL([F_CLOSEM],
94 HAVE_FCNTL_CLOSEM
95 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
96 [Use F_CLOSEM fcntl for closefrom]),
97 [],
98 [#include <limits.h>
99 #include <fcntl.h>
103 AC_MSG_CHECKING([for /proc/pid/fd directory])
104 if test -d "/proc/$$/fd" ; then
105 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
106 AC_MSG_RESULT([yes])
107 else
108 AC_MSG_RESULT([no])
109 fi
111 AC_MSG_CHECKING([whether program_invocation_short_name is defined])
112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
113 #include <argp.h>
114 ]], [[
115 program_invocation_short_name = "test";
116 ]])], [
117 AC_MSG_RESULT([yes])
118 AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
119 [Define if program_invocation_short_name is defined])
120 ], [
121 AC_MSG_RESULT([no])
122 ])
124 # Look for prctl(PR_SET_NAME).
125 AC_CHECK_DECL(
126 [PR_SET_NAME],
127 [AC_DEFINE([HAVE_PR_SET_NAME], [1], [Define if PR_SET_NAME is defined])],
128 [],
129 [#include <sys/prctl.h>]
132 AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
134 AC_CACHE_CHECK([whether getopt has optreset support],
135 ac_cv_have_getopt_optreset, [
136 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
137 [[ extern int optreset; optreset = 0; ]])],
138 [ ac_cv_have_getopt_optreset="yes" ],
139 [ ac_cv_have_getopt_optreset="no"
140 ])
141 ])
143 AM_CONDITIONAL([HAVE_GETOPT], [test "x$ac_cv_have_getopt_optreset" = "xyes"])
144 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
145 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
146 [Define if your getopt(3) defines and uses optreset])
147 fi
149 AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[
150 #include <sys/types.h>
151 #ifdef HAVE_POLL_H
152 #include <poll.h>
153 #endif
154 #ifdef HAVE_SYS_POLL_H
155 #include <sys/poll.h>
156 #endif
157 ]])
159 # Checks for typ edefs, structures, and compiler characteristics.
160 AC_CHECK_HEADER_STDBOOL
161 AC_C_INLINE
162 AC_TYPE_INT64_T
163 AC_TYPE_MODE_T
164 AC_TYPE_OFF_T
165 AC_TYPE_PID_T
166 AC_TYPE_SIZE_T
167 AC_TYPE_SSIZE_T
168 AC_TYPE_UINT16_T
169 AC_TYPE_UINT32_T
170 AC_TYPE_UINT64_T
171 AC_TYPE_UINT8_T
173 # Check for ifgroupreq which is only available on BSD.
174 AC_CHECK_TYPES([struct ifgroupreq])
176 # Check for sockaddr_storage. On some systems, ss_len is filled out, although
177 # this is not mandated by POSIX, and hence systems such as linux, don't have
178 # it.
179 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
180 #include <sys/types.h>
181 #include <sys/socket.h>
182 ])
184 # Same thing as sockaddr_storage above, only now check if the member exists in
185 # the struct as well.
186 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
187 [ #include <netdb.h>
188 #include <netinet/in.h>
189 #include <sys/socket.h> ]
192 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
193 [ #include <netdb.h>
194 #include <netinet/in.h>
195 #include <sys/socket.h> ]
198 # Both checks above will result in:
200 # HAVE_STRUCT_SOCKADDR_AS_LEN
201 # SS_LEN
203 # Either being defined or not.
205 # Look for library needed for flock.
206 AC_SEARCH_LIBS(flock, bsd)
208 # Checks for library functions.
209 AC_FUNC_FORK
210 AC_FUNC_FSEEKO
211 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
212 AC_FUNC_MALLOC
213 AC_FUNC_MMAP
214 AC_FUNC_REALLOC
215 AC_FUNC_STRERROR_R
216 AC_FUNC_STRNLEN
217 AC_CHECK_FUNCS([ \
218 dup2 \
219 flock \
220 getcwd \
221 localtime_r \
222 memchr \
223 memmove \
224 memset \
225 mergesort \
226 mkdir \
227 munmap \
228 nl_langinfo \
229 realpath \
230 regcomp \
231 rmdir \
232 setlocale \
233 socket \
234 setresgid \
235 setresuid \
236 setproctitle \
237 strcasecmp \
238 strchr \
239 strcspn \
240 strdup \
241 strerror \
242 strncasecmp \
243 strndup \
244 strrchr \
245 strspn \
246 strstr \
247 strtol \
248 strtoul \
249 sysconf \
250 wcwidth \
251 ])
253 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
255 if test "x$ac_cv_func_sysconf" = xyes; then
256 AC_DEFINE([HAVE_SYSCONF], [1], [Define to 1 if sysconf() present])
257 fi
259 # Siphash support.
260 AC_CHECK_FUNCS([SipHash])
261 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
263 # Check for functions with a compatibility implementation.
264 AC_REPLACE_FUNCS([ \
265 asprintf \
266 closefrom \
267 explicit_bzero \
268 fmt_scaled \
269 freezero \
270 getdtablecount \
271 getline \
272 getprogname \
273 recallocarray \
274 reallocarray \
275 strlcat \
276 strlcpy \
277 strndup \
278 strnlen \
279 strsep \
280 strtonum \
281 ])
282 AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
284 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
285 # musl does not set optarg to NULL for flags without arguments (although it is
286 # not required to, but it is helpful) 3) there are probably other weird
287 # implementations.
288 AC_LIBOBJ(getopt)
290 # Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
291 AC_MSG_CHECKING(for b64_ntop)
292 AC_LINK_IFELSE([AC_LANG_PROGRAM(
294 #include <sys/types.h>
295 #include <netinet/in.h>
296 #include <resolv.h>
297 ],
299 b64_ntop(NULL, 0, NULL, 0);
300 ])],
301 found_b64_ntop=yes,
302 found_b64_ntop=no
304 AC_MSG_RESULT($found_b64_ntop)
305 libresolv_LIBS=""
306 if test "x$found_b64_ntop" = xno; then
307 AC_MSG_CHECKING(for b64_ntop with -lresolv)
308 LIBS="-lresolv"
309 AC_LINK_IFELSE([AC_LANG_PROGRAM(
311 #include <sys/types.h>
312 #include <netinet/in.h>
313 #include <resolv.h>
314 ],
316 b64_ntop(NULL, 0, NULL, 0);
317 ])],
318 found_b64_ntop=yes,
319 found_b64_ntop=no
321 AC_MSG_RESULT($found_b64_ntop)
322 libresolv_LIBS="$LIBS"
323 fi
324 if test "x$found_b64_ntop" = xno; then
325 AC_MSG_CHECKING(for b64_ntop with -lnetwork)
326 LIBS="-lresolv -lnetwork"
327 AC_LINK_IFELSE([AC_LANG_PROGRAM(
329 #include <sys/types.h>
330 #include <netinet/in.h>
331 #include <resolv.h>
332 ],
334 b64_ntop(NULL, 0, NULL, 0);
335 ])],
336 found_b64_ntop=yes,
337 found_b64_ntop=no
339 AC_MSG_RESULT($found_b64_ntop)
340 libresolv_LIBS="$LIBS"
341 fi
343 AM_CONDITIONAL([HAVE_B64], [test "x$found_b64_ntop" = xyes])
344 if test "x$found_b64_ntop" = xyes; then
345 AC_DEFINE([HAVE_B64_NTOP], [1], [define if b64_ntop is present])
346 AC_SUBST(libresolv_LIBS)
347 else
348 AC_LIBOBJ(base64)
349 fi
351 # Check the platform we're compiling on.
352 AC_MSG_CHECKING(platform)
353 case "$host_os" in
354 *linux*)
355 AC_MSG_RESULT(linux)
356 PLATFORM=linux
357 ;;
358 *freebsd*)
359 AC_MSG_RESULT(freebsd)
360 PLATFORM=freebsd
361 ;;
362 *darwin*)
363 AC_MSG_RESULT(darwin)
364 PLATFORM=darwin
365 ;;
366 *netbsd*)
367 AC_MSG_RESULT(netbsd)
368 PLATFORM=netbsd
369 ;;
370 *openbsd*)
371 AC_MSG_RESULT(openbsd)
372 PLATFORM=openbsd
373 ;;
374 *dragonfly*)
375 AC_MSG_RESULT(dragonfly)
376 PLATFORM=dragonflybsd
377 ;;
378 *)
379 AC_MSG_RESULT(unknown)
380 PLATFORM=unknown
381 ;;
382 esac
383 AC_SUBST(PLATFORM)
384 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
385 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
386 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
387 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
388 AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
389 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
391 # On OpenBSD, these functions are already defined, yet looking for them in
392 # this way on OpenBSD breaks <sha2.h> inclusion.
393 # FIXME: this needs addressing.
394 if test "x$PLATFORM" != "xopenbsd"; then
395 AC_CHECK_FUNCS([ \
396 SHA256Update \
397 SHA384Update \
398 SHA512Update \
399 ])
400 fi
402 # Look for yacc.
403 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
404 && ! command -v "$YACC" >/dev/null 2>&1; then
405 AC_MSG_ERROR("yacc not found: $YACC")
406 fi
408 if test x"$PLATFORM" = "xdarwin"; then
409 # Check for and/or set HOMEBREW_PREFIX. brew is a common way of
410 # installing applications. The other is MacPorts.
412 # Before Apple Silicon existed (M1 onward), the paths for applications
413 # installed via homebrew was typically /usr/local. However, with M1
414 # onward, this changed to a different path.
416 # Rather than hardcode this, check for HOMEBREW_PREFIX in the
417 # environment if it's already set, and use it. Otherwise, check for
418 # brew(1) and use that. If that fails, default to /usr/local
420 # This also means that MacPorts should continue to work.
422 # But with MacPorts, we should also check --prefix, and use that if it
423 # has been supplied.
425 # In both cases, the variable HOMEBREW_PREFIX is used for both.
426 HB_PREFIX=""
427 FOUND_BISON="no"
428 GNUBISON=""
429 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
430 # HOMEBREW_PREFIX not set, check for brew(1)
431 if command -v brew >/dev/null 2>&1; then
432 AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
433 export HOMEBREW_PREFIX="$(brew --prefix)"
434 fi
436 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
437 then
438 # Default.
439 if test -z "${prefix}" -o "${prefix}" = "NONE"; then
440 export HOMEBREW_PREFIX="/usr/local"
441 HB_PREFIX="/usr/local"
442 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
443 else
444 HB_PREFIX="$(eval echo ${prefix})"
445 if test "$HB_PREFIX" = "NONE"; then
446 HB_PREFIX="/opt/local"
447 else
448 AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
449 fi
450 export HOMEBREW_PREFIX="$HB_PREFIX"
451 fi
452 fi
453 fi
455 AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
457 if test "$YACC_OVERRIDE" = "no" && \
458 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
459 AC_MSG_WARN([
460 "***********************************************************
461 GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
462 ***********************************************************
464 Falling back to checking either /usr/local or \${prefix}"
465 ])
467 FOUND_BISON="no"
468 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
469 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
470 export HOMEBREW_PREFIX="/usr/local"
471 FOUND_BISON="yes"
472 GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
473 fi
475 if test "$FOUND_BISON" = "no"; then
476 HB_PREFIX="/opt/local"
477 AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
479 if test -x "${HB_PREFIX}/bin/bison"; then
480 export HOMEBREW_PREFIX="${HB_PREFIX}"
481 GNUBISON="${HB_PREFIX}/bin/bison"
482 FOUND_BISON="yes"
483 fi
484 fi
485 else
486 FOUND_BISON="yes"
487 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
488 fi
490 if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
491 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
492 fi
494 # Override YACC here to point to the GNU version of bison.
495 if test "$YACC_OVERRIDE" = "yes"; then
496 export YACC="$YACC -y"
497 else
498 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
499 export YACC="${GNUBISON} -y"
500 fi
501 export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
502 export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
503 export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
504 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
505 fi
507 # Landlock detection.
508 AC_MSG_CHECKING([for landlock])
509 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
510 [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
511 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
512 AC_MSG_RESULT(yes)
513 else
514 AC_MSG_RESULT(no)
515 fi
517 # Clang sanitizers wrap reallocarray even if it isn't available on the target
518 # system. When compiled it always returns NULL and crashes the program. To
519 # detect this we need a more complicated test.
520 AC_MSG_CHECKING([for working reallocarray])
521 AC_RUN_IFELSE([AC_LANG_PROGRAM(
522 [#include <stdlib.h>],
523 [return (reallocarray(NULL, 1, 1) == NULL);]
524 )],
525 AC_MSG_RESULT(yes),
526 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
527 [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
529 AC_MSG_CHECKING([for working recallocarray])
530 AC_RUN_IFELSE([AC_LANG_PROGRAM(
531 [#include <stdlib.h>],
532 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
533 )],
534 AC_MSG_RESULT(yes),
535 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
536 [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
539 # Look for imsg_init in libutil.
540 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
541 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
542 if test "x$found_imsg_init" = "xyes"; then
543 AC_DEFINE([HAVE_IMSG], [1], [Define to 1 if imsg is declared in libutil])
544 libutil_LIBS="$ac_cv_search_imsg_init"
545 AC_SUBST(libutil_LIBS)
546 fi
548 # libevent (for gotwebd). Lifted from tmux.
549 # Look for libevent. Try libevent_core or libevent with pkg-config first then
550 # look for the library.
551 found_libevent=no
552 PKG_CHECK_MODULES(
553 LIBEVENT_CORE,
554 [libevent_core >= 2],
556 libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
557 libevent_LIBS="$LIBEVENT_CORE_LIBS"
558 AC_SUBST(libevent_CFLAGS)
559 AC_SUBST(libevent_LIBS)
560 found_libevent=yes
561 ],
562 found_libevent=no
564 if test x$found_libevent = xno; then
565 PKG_CHECK_MODULES(
566 LIBEVENT,
567 [libevent >= 2],
569 libevent_CFLAGS="$LIBEVENT_CFLAGS"
570 libevent_LIBS="$LIBEVENT_LIBS"
571 AC_SUBST(libevent_CFLAGS)
572 AC_SUBST(libevent_LIBS)
573 found_libevent=yes
574 ],
575 found_libevent=no
577 fi
578 if test x$found_libevent = xno; then
579 AC_SEARCH_LIBS(
580 event_init,
581 [event_core event event-1.4],
582 found_libevent=yes,
583 found_libevent=no
586 if test "x$found_libevent" = "xyes"; then
587 libevent_LIBS="$ac_cv_search_event_init"
588 AC_SUBST(libevent_LIBS)
589 fi
590 fi
592 if test x$found_libevent = xno; then
593 AC_CHECK_HEADER(
594 event2/event.h,
595 AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
597 AC_CHECK_HEADER(
598 event.h,
599 AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
600 found_libevent=no
604 fi
606 if test "x$found_libevent" = xno; then
607 AC_MSG_ERROR("libevent not found")
608 fi
610 AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
612 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
613 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
614 # ossp
615 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
616 AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
617 else
618 PKG_CHECK_MODULES(
619 LIBUUID,
620 uuid,
622 libuuid_CFLAGS="$LIBUUID_CFLAGS"
623 libuuid_LIBS="$LIBUUID_LIBS"
624 AC_SUBST(libuuid_CFLAGS)
625 AC_SUBST(libuuid_LIBS)
626 found_libuuid=yes
627 ],
629 found_libuuid=no
633 if test "x$found_libuuid" = "xno"; then
634 AC_CHECK_HEADER(
635 uuid.h,
636 found_libuuid=yes,
637 found_libuuid=no)
638 fi
639 fi
641 if test "x$found_libuuid" = "xno"; then
642 AC_MSG_ERROR("*** couldn't find uuid ***")
643 fi
645 PKG_CHECK_MODULES(
646 ZLIB,
647 zlib,
649 zlib_CFLAGS="$ZLIB_CFLAGS"
650 zlib_LIBS="$ZLIB_LIBS"
651 AC_SUBST(zlib_CFLAGS)
652 AC_SUBST(zlib_LIBS)
653 found_zlib=yes
654 ],
656 found_zlib=no
660 if test "x$found_zlib" = "xno"; then
661 AC_CHECK_HEADER(
662 zlib.h,
664 found_zlib=no)
665 fi
667 if test "x$found_zlib" = "xno"; then
668 AC_MSG_ERROR("*** couldn't find zlib ***")
669 fi
671 if test "$PLATFORM" = "linux"; then
672 PKG_CHECK_MODULES(
673 LIBBSD,
674 libbsd-overlay,
676 libbsd_CFLAGS="$LIBBSD_CFLAGS"
677 libbsd_LIBS="$LIBBSD_LIBS"
678 AC_SUBST(libbsd_CFLAGS)
679 AC_SUBST(libbsd_LIBS)
680 AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
681 ],
683 AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
688 # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
689 # header files in a non-standard location, which means the overlay for
690 # <sys/tree.h> and <sys/queue.h> won't be found.
691 CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
692 LIBS="$LIBS $LIBBSD_LIBS"
694 PKG_CHECK_MODULES(
695 LIBMD,
696 libmd,
698 libmd_CFLAGS="$LIBMD_CFLAGS"
699 libmd_LIBS="$LIBMD_LIBS"
700 AC_SUBST(libmd_CFLAGS)
701 AC_SUBST(libmd_LIBS)
702 ], []
704 CFLAGS="$CFLAGS $LIBMD_CFLAGS"
705 LIBS="$LIBS $LIBMD_LIBS"
707 fi
709 # Look for a suitable queue.h. We hope libbsd is enough, but that is missing
710 # some declarations.
711 AC_CHECK_DECL(
712 TAILQ_CONCAT,
713 found_queue_h=yes,
714 found_queue_h=no,
715 [#include <sys/queue.h>]
717 AC_CHECK_DECL(
718 TAILQ_PREV,
720 found_queue_h=no,
721 [#include <sys/queue.h>]
723 AC_CHECK_DECL(
724 TAILQ_FOREACH_SAFE,
726 found_queue_h=no,
727 [#include <sys/queue.h>]
730 if test "x$found_queue_h" = xyes; then
731 AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
732 else
733 AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
734 fi
736 AC_CHECK_DECL(
737 RB_GENERATE_STATIC,
738 found_sys_tree_h=yes,
739 found_sys_tree_h=no,
740 [#include <sys/tree.h>]
743 if test "x$found_sys_tree_h" = xyes; then
744 AC_DEFINE([HAVE_TREE_H], [1], [sys/tree.h])
745 else
746 AC_MSG_NOTICE("Using compat/tree.h")
747 fi
749 # Look for __progname.
750 AC_MSG_CHECKING(for __progname)
751 AC_LINK_IFELSE([AC_LANG_SOURCE(
753 #include <stdio.h>
754 #include <stdlib.h>
755 extern char *__progname;
756 int main(void) {
757 const char *cp = __progname;
758 printf("%s\n", cp);
759 exit(0);
761 ])],
762 [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
763 [AC_MSG_RESULT(no)]
766 PKG_CHECK_MODULES(
767 LIBPANELW,
768 panelw,
769 LIBPANELW_LIBS="$LIBPANELW_LIBS"
770 found_panel=yes,
771 found_panel=no
774 if test "x$found_panel" = "xno"; then
775 PKG_CHECK_MODULES(
776 LIBPANELW,
777 gnupanelw,
779 LIBPANELW_LIBS="$LIBPANELW_LIBS"
780 found_panel=yes
781 ],
782 found_panel=no
784 fi
786 if test "x$found_panel" = "xno"; then
787 PKG_CHECK_MODULES(
788 LIBPANELW,
789 panel,
791 LIBPANELW_LIBS="$LIBPANELW_LIBS"
792 found_panel=yes
793 ],
794 found_panel=no
796 fi
798 if test "x$found_panel" = "xno"; then
799 AC_CHECK_LIB(panelw, update_panels, [],
800 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
801 [-lncurses]
804 fi
806 PKG_CHECK_MODULES(
807 LIBNCURSES,
808 ncursesw,
809 found_ncurses=yes,
810 found_ncurses=no
812 if test "x$found_ncurses" = xyes; then
813 libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
814 libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
815 AC_SUBST(libncurses_CFLAGS)
816 AC_SUBST(libncurses_LIBS)
817 else
818 AC_SEARCH_LIBS(
819 setupterm,
820 found_ncurses=yes,
821 found_ncurses=no
823 if test "x$found_ncurses" = xyes; then
824 AC_CHECK_HEADER(
825 ncurses.h,
826 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
827 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
828 AC_SUBST(libncurses_CFLAGS)
829 AC_SUBST(libncurses_LIBS)
831 fi
832 fi
833 if test "x$found_ncurses" = xyes; then
834 AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
835 else
836 # No ncurses, try curses.
837 AC_CHECK_FUNC(
838 setupterm,
839 found_curses=yes,
840 found_curses=no
842 AC_CHECK_HEADER(
843 curses.h,
844 found_curses=yes,
845 found_curses=no)
846 if test "x$found_curses" = xyes; then
847 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
848 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw -lpanelw"
849 AC_SUBST(libncurses_CFLAGS)
850 AC_SUBST(libncurses_LIBS)
851 AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
852 else
853 AC_MSG_ERROR("curses not found")
854 fi
855 fi
857 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
858 # variables.
859 AC_SUBST(AM_CPPFLAGS)
860 CPPFLAGS="$SAVED_CPPFLAGS"
861 AC_SUBST(AM_CFLAGS)
862 CFLAGS="$SAVED_CFLAGS"
863 AC_SUBST(AM_LDFLAGS)
864 LDFLAGS="$SAVED_LDFLAGS"
866 # LIBS is designed to accumulate library dependencies as checks for them are
867 # peformed, so that this can be included directly to ld(1).
869 # However, this hinders the splitting up of the library dependencies so that
870 # they're targetted just where they're needed. Flatting LIBS here ensures
871 # that this happens appropriately.
872 LIBS=""
874 AH_BOTTOM([#include "got_compat2.h"])
876 AC_CONFIG_FILES([Makefile
877 compat/Makefile
878 libexec/Makefile
879 libexec/got-read-tree/Makefile
880 libexec/got-fetch-pack/Makefile
881 libexec/got-index-pack/Makefile
882 libexec/got-read-blob/Makefile
883 libexec/got-read-commit/Makefile
884 libexec/got-read-gitconfig/Makefile
885 libexec/got-read-gotconfig/Makefile
886 libexec/got-read-object/Makefile
887 libexec/got-read-pack/Makefile
888 libexec/got-read-patch/Makefile
889 libexec/got-read-tag/Makefile
890 libexec/got-send-pack/Makefile
891 got/Makefile
892 gotadmin/Makefile
893 gotwebd/Makefile
894 tog/Makefile
895 Makefile.common:Makefile.common.in])
896 AC_OUTPUT
898 executables="$(eval echo ${exec_prefix}/bin)"
899 helpers="$(eval echo ${libexecdir})"
900 manpages="$(eval echo ${mandir})"
902 echo "
903 Configured got-portable with:
905 Version: $VERSION
907 Prefix: ${prefix}
908 Executables: ${executables}
909 Bison: $YACC
910 CFlags: $CFLAGS
911 Helpers: ${helpers}
912 Man pages: ${manpages}