portable: configure: split out dependencies
[got-portable.git] / configure.ac
blob9b8bcf405ff91d64b71e3904821a73c4085cb23f
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
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")
58 # Checks for header files.
59 AC_CHECK_HEADERS([ \
60         fcntl.h \
61         langinfo.h \
62         limits.h \
63         linux/landlock.h \
64         locale.h \
65         netdb.h \
66         netinet/in.h \
67         paths.h \
68         poll.h \
69         sha.h \
70         sha1.h \
71         sha2.h \
72         sha256.h \
73         stddef.h \
74         stdint.h \
75         stdlib.h \
76         string.h \
77         sys/ioctl.h \
78         sys/param.h \
79         sys/poll.h \
80         sys/queue.h \
81         sys/socket.h \
82         sys/time.h \
83         sys/tree.h \
84         util.h \
85         unistd.h \
86         wchar.h \
89 if test "x$ac_cv_header_sha256_h" = xyes; then
90         AC_DEFINE([HAVE_SHA256], [1], [SHA256 support])
93 AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
95 # Check for SHA1_DIGEST_LENGTH
96 AC_CHECK_DECL([SHA1_DIGEST_LENGTH],
97         [AC_DEFINE([HAVE_SHA1_AS_SHA1], [1], [SHA support is using SHA1])],
98         [
99                 dnl maybe sha.h is available
100                 AC_CHECK_DECL([SHA_DIGEST_LENGTH],
101                         [AC_DEFINE([HAVE_SHA_AS_SHA1], [1],
102                                    [SHA support is using SHA])],
103                         [],
104                         [#include <sha.h>])
105         ],
106         [
107         #include <sys/types.h>
108         #include <sha1.h>
109         ])
111 # Checks for typ edefs, structures, and compiler characteristics.
112 AC_CHECK_HEADER_STDBOOL
113 AC_C_INLINE
114 AC_TYPE_INT64_T
115 AC_TYPE_MODE_T
116 AC_TYPE_OFF_T
117 AC_TYPE_PID_T
118 AC_TYPE_SIZE_T
119 AC_TYPE_SSIZE_T
120 AC_TYPE_UINT16_T
121 AC_TYPE_UINT32_T
122 AC_TYPE_UINT64_T
123 AC_TYPE_UINT8_T
125 # Check for ifgroupreq which is only available on BSD.
126 AC_CHECK_TYPES([struct ifgroupreq])
128 # Check for sockaddr_storage.  On some systems, ss_len is filled out, although
129 # this is not mandated by POSIX, and hence systems such as linux, don't have
130 # it.
131 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
132 #include <sys/types.h>
133 #include <sys/socket.h>
136 # Same thing as sockaddr_storage above, only now check if the member exists in
137 # the struct as well.
138 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
139         [ #include <netdb.h>
140           #include <netinet/in.h>
141           #include <sys/socket.h> ]
144 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
145         [ #include <netdb.h>
146           #include <netinet/in.h>
147           #include <sys/socket.h> ]
150 # Both checks above will result in:
152 # HAVE_STRUCT_SOCKADDR_AS_LEN
153 # SS_LEN
155 # Either being defined or not.
157 # Look for library needed for flock.
158 AC_SEARCH_LIBS(flock, bsd)
160 # Checks for library functions.
161 AC_FUNC_FORK
162 AC_FUNC_FSEEKO
163 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
164 AC_FUNC_MALLOC
165 AC_FUNC_MMAP
166 AC_FUNC_REALLOC
167 AC_FUNC_STRERROR_R
168 AC_FUNC_STRNLEN
169 AC_CHECK_FUNCS([ \
170         dup2 \
171         flock \
172         getcwd \
173         localtime_r \
174         memchr \
175         memmove \
176         memset \
177         mergesort \
178         mkdir \
179         munmap \
180         nl_langinfo \
181         realpath \
182         regcomp \
183         rmdir \
184         setlocale \
185         socket \
186         setresgid \
187         setresuid \
188         setproctitle \
189         strcasecmp \
190         strchr \
191         strcspn \
192         strdup \
193         strerror \
194         strncasecmp \
195         strndup \
196         strrchr \
197         strspn \
198         strstr \
199         strtol \
200         strtoul \
201         wcwidth \
204 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
205 AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
206 AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
208 # Siphash support.
209 AC_CHECK_FUNCS([SipHash])
210 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
212 # Check for functions with a compatibility implementation.
213 AC_REPLACE_FUNCS([ \
214         asprintf \
215         closefrom \
216         explicit_bzero \
217         fmt_scaled \
218         freezero \
219         getdtablecount \
220         getline \
221         getprogname \
222         recallocarray \
223         reallocarray \
224         strlcat \
225         strlcpy \
226         strndup \
227         strsep \
228         strtonum \
230 AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
232 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
233 # musl does not set optarg to NULL for flags without arguments (although it is
234 # not required to, but it is helpful) 3) there are probably other weird
235 # implementations.
236 AC_LIBOBJ(getopt)
238 # Check the platform we're compiling on.
239 AC_MSG_CHECKING(platform)
240 case "$host_os" in
241         *linux*)
242                 AC_MSG_RESULT(linux)
243                 PLATFORM=linux
244                 ;;
245         *freebsd*)
246                 AC_MSG_RESULT(freebsd)
247                 PLATFORM=freebsd
248                 ;;
249         *darwin*)
250                 AC_MSG_RESULT(darwin)
251                 PLATFORM=darwin
252                 ;;
253         *netbsd*)
254                 AC_MSG_RESULT(netbsd)
255                 PLATFORM=netbsd
256                 ;;
257         *openbsd*)
258                 AC_MSG_RESULT(openbsd)
259                 PLATFORM=openbsd
260                 ;;
261         *dragonfly*)
262                 AC_MSG_RESULT(dragonfly)
263                 PLATFORM=dragonflybsd
264                 ;;
265         *)
266                 AC_MSG_RESULT(unknown)
267                 PLATFORM=unknown
268                 ;;
269 esac
270 AC_SUBST(PLATFORM)
271 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
272 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
273 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
274 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
275 AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
276 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
278 # Look for yacc.
279 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
280         && ! command -v "$YACC" >/dev/null 2>&1; then
281         AC_MSG_ERROR("yacc not found: $YACC")
284 if test x"$PLATFORM" = "xdarwin"; then
285         # Check for and/or set HOMEBREW_PREFIX.  brew is a common way of
286         # installing applications.  The other is MacPorts.
287         #
288         # Before Apple Silicon existed (M1 onward), the paths for applications
289         # installed via homebrew was typically /usr/local.  However, with M1
290         # onward, this changed to a different path.
291         #
292         # Rather than hardcode this, check for HOMEBREW_PREFIX in the
293         # environment if it's already set, and use it.  Otherwise, check for
294         # brew(1) and use that.  If that fails, default to /usr/local
295         #
296         # This also means that MacPorts should continue to work.
297         #
298         # But with MacPorts, we should also check --prefix, and use that if it
299         # has been supplied.
300         #
301         # In both cases, the variable HOMEBREW_PREFIX is used for both.
302         HB_PREFIX=""
303         FOUND_BISON="no"
304         GNUBISON=""
305         if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
306                 # HOMEBREW_PREFIX not set, check for brew(1)
307                 if command -v brew >/dev/null 2>&1; then
308                         AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
309                         export HOMEBREW_PREFIX="$(brew --prefix)"
310                 fi
312                 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
313                 then
314                         # Default.
315                         if test -z "${prefix}" -o "${prefix}" = "NONE"; then
316                                 export HOMEBREW_PREFIX="/usr/local"
317                                 HB_PREFIX="/usr/local"
318                                 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
319                         else
320                                 HB_PREFIX="$(eval echo ${prefix})"
321                                 if test "$HB_PREFIX" = "NONE"; then
322                                         HB_PREFIX="/opt/local"
323                                 else
324                                         AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
325                                 fi
326                                 export HOMEBREW_PREFIX="$HB_PREFIX"
327                         fi
328                 fi
329         fi
331         AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
333         if test "$YACC_OVERRIDE" = "no" && \
334                 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
335                 AC_MSG_WARN([
336                              "***********************************************************
337                              GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
338                              ***********************************************************
340                              Falling back to checking either /usr/local or \${prefix}"
341                 ])
343                 FOUND_BISON="no"
344                 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
345                 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
346                         export HOMEBREW_PREFIX="/usr/local"
347                         FOUND_BISON="yes"
348                         GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
349                 fi
351                 if test "$FOUND_BISON" = "no"; then
352                         HB_PREFIX="/opt/local"
353                         AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
355                         if test -x "${HB_PREFIX}/bin/bison"; then
356                                 export HOMEBREW_PREFIX="${HB_PREFIX}"
357                                 GNUBISON="${HB_PREFIX}/bin/bison"
358                                 FOUND_BISON="yes"
359                         fi
360                 fi
361         else
362                 FOUND_BISON="yes"
363                 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
364         fi
366         if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
367                 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
368         fi
370         # Override YACC here to point to the GNU version of bison.
371         if test "$YACC_OVERRIDE" = "yes"; then
372                 export YACC="$YACC -y"
373         else
374                 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
375                 export YACC="${GNUBISON} -y"
376         fi
377         export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
378         export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
379         export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
380         export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
383 # Landlock detection.
384 AC_MSG_CHECKING([for landlock])
385 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
386     [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
387 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
388         AC_MSG_RESULT(yes)
389 else
390         AC_MSG_RESULT(no)
393 # Clang sanitizers wrap reallocarray even if it isn't available on the target
394 # system. When compiled it always returns NULL and crashes the program. To
395 # detect this we need a more complicated test.
396 AC_MSG_CHECKING([for working reallocarray])
397 AC_RUN_IFELSE([AC_LANG_PROGRAM(
398                 [#include <stdlib.h>],
399                 [return (reallocarray(NULL, 1, 1) == NULL);]
400         )],
401         AC_MSG_RESULT(yes),
402         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
403         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
405 AC_MSG_CHECKING([for working recallocarray])
406 AC_RUN_IFELSE([AC_LANG_PROGRAM(
407                 [#include <stdlib.h>],
408                 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
409         )],
410         AC_MSG_RESULT(yes),
411         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
412         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
415 # Look for imsg_init in libutil.
416 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
417 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
418 if test "x$found_imsg_init" = "xyes"; then
419         libutil_LIBS="$ac_cv_search_imsg_init"
420         AC_SUBST(libutil_LIBS)
421 else
422         AC_LIBOBJ(imsg)
423         AC_LIBOBJ(imsg-buffer)
426 # libevent (for gotwebd).  Lifted from tmux.
427 # Look for libevent. Try libevent_core or libevent with pkg-config first then
428 # look for the library.
429 found_libevent=no
430 PKG_CHECK_MODULES(
431         LIBEVENT_CORE,
432         [libevent_core >= 2],
433         [
434                 libevent_CFLAGS="$LIBEVENT_CORE_CFLAGS"
435                 libevent_LIBS="$LIBEVENT_CORE_LIBS"
436                 AC_SUBST(libevent_CFLAGS)
437                 AC_SUBST(libevent_LIBS)
438                 found_libevent=yes
439         ],
440         found_libevent=no
442 if test x$found_libevent = xno; then
443         PKG_CHECK_MODULES(
444                 LIBEVENT,
445                 [libevent >= 2],
446                 [
447                         libevent_CFLAGS="$LIBEVENT_CFLAGS"
448                         libevent_LIBS="$LIBEVENT_LIBS"
449                         AC_SUBST(libevent_CFLAGS)
450                         AC_SUBST(libevent_LIBS)
451                         found_libevent=yes
452                 ],
453                 found_libevent=no
454         )
456 if test x$found_libevent = xno; then
457         AC_SEARCH_LIBS(
458                 event_init,
459                 [event_core event event-1.4],
460                 found_libevent=yes,
461                 found_libevent=no
462         )
464         if test "x$found_libevent" = "xyes"; then
465                 libevent_LIBS="$ac_cv_search_event_init"
466                 AC_SUBST(libevent_LIBS)
467         fi
470 if test x$found_libevent = xno; then
471 AC_CHECK_HEADER(
472         event2/event.h,
473         AC_DEFINE([HAVE_EVENT2_EVENT_H], [1], [libevent2 has event.h]),
474         [
475                 AC_CHECK_HEADER(
476                         event.h,
477                         AC_DEFINE([HAVE_EVENT_H], [0], [libevent]),
478                         found_libevent=no
479                 )
480         ]
484 if test "x$found_libevent" = xno; then
485         AC_MSG_ERROR("libevent not found")
488 # libcrypto (via libssl for SHA information)
489 PKG_CHECK_MODULES(
490         LIBCRYPTO,
491         libcrypto,
492         [
493                 libcrypto_CFLAGS="$LIBCRYPTO_CORE_CFLAGS"
494                 libcrypto_LIBS="$LIBCRYPTO_LIBS"
495                 AC_SUBST(libcrypto_CFLAGS)
496                 AC_SUBST(libcrypto_LIBS)
497                 found_libcrypto=yes
498         ],
499         [
500                 found_libcrypto=no
501         ]
504 if test "x$found_libcrypto" = "xyes"; then
505         AC_DEFINE([HAVE_LIBCRYPTO], [1], [libcrypto])
508 AC_CHECK_FUNC([uuid_create], [found_uuid=yes], [found_uuid=no])
510 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
511 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
512 # ossp
513 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
514         AC_DEFINE([HAVE_BSD_UUID], [1], [BSD UUID])
515 else
516         PKG_CHECK_MODULES(
517                 LIBUUID,
518                 uuid,
519                 [
520                         libuuid_CFLAGS="$LIBUUID_CFLAGS"
521                         libuuid_LIBS="$LIBUUID_LIBS"
522                         AC_SUBST(libuuid_CFLAGS)
523                         AC_SUBST(libuuid_LIBS)
524                         found_libuuid=yes
525                 ],
526                 [
527                         found_libuuid=no
528                 ]
529         )
531         if test "x$found_libuuid" = "xno"; then
532                 AC_CHECK_HEADER(
533                         uuid.h,
534                         found_libuuid=yes,
535                         found_libuuid=no)
536         fi
539 if test "x$found_libuuid" = "xno"; then
540         AC_MSG_ERROR("*** couldn't find uuid ***")
543 PKG_CHECK_MODULES(
544         ZLIB,
545         zlib,
546         [
547                 zlib_CFLAGS="$ZLIB_CFLAGS"
548                 zlib_LIBS="$ZLIB_LIBS"
549                 AC_SUBST(zlib_CFLAGS)
550                 AC_SUBST(zlib_LIBS)
551                 found_zlib=yes
552         ],
553         [
554                 found_zlib=no
555         ]
558 if test "x$found_zlib" = "xno"; then
559         AC_CHECK_HEADER(
560                 zlib.h,
561                 ,
562                 found_zlib=no)
565 if test "x$found_zlib" = "xno"; then
566         AC_MSG_ERROR("*** couldn't find zlib ***")
569 if test "$PLATFORM" = "linux"; then
570         PKG_CHECK_MODULES(
571                 LIBMD,
572                 libmd,
573                 [
574                         libmd_CFLAGS="$LIBMD_CFLAGS"
575                         libmd_LIBS="$LIBMD_LIBS"
576                         AC_SUBST(libmd_CFLAGS)
577                         AC_SUBST(libmd_LIBS)
578                 ],
579                 [
580                         AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
581                 ]
582         )
583         PKG_CHECK_MODULES(
584                 LIBBSD,
585                 libbsd-overlay,
586                 [
587                         libbsd_CFLAGS="$LIBBSD_CFLAGS"
588                         libbsd_LIBS="$LIBBSD_LIBS"
589                         AC_SUBST(libbsd_CFLAGS)
590                         AC_SUBST(libbsd_LIBS)
591                         AC_DEFINE([HAVE_LIBBSD], [1], [BSD UUID])
592                 ],
593                 [
594                         AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
595                 ]
597         )
599         # Add LIBBSD_{CFLAGS,LIBS} to the environment here, as libbsd puts its
600         # header files in a non-standard location, which means the overlay for
601         # <sys/tree.h> and <sys/queue.h> won't be found.
602         CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
603         LIBS="$LIBS $LIBBSD_LIBS"
606 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
607 # some declarations.
608 AC_CHECK_DECL(
609         TAILQ_CONCAT,
610         found_queue_h=yes,
611         found_queue_h=no,
612         [#include <sys/queue.h>]
614 AC_CHECK_DECL(
615         TAILQ_PREV,
616         ,
617         found_queue_h=no,
618         [#include <sys/queue.h>]
620 AC_CHECK_DECL(
621         TAILQ_FOREACH_SAFE,
622         ,
623         found_queue_h=no,
624         [#include <sys/queue.h>]
627 if test "x$found_queue_h" = xyes; then
628         AC_DEFINE([HAVE_QUEUE_H], [1], [sys/queue.h])
629 else
630         AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
633 AC_CHECK_DECL(
634         RB_GENERATE_STATIC,
635         found_sys_tree_h=yes,
636         found_sys_tree_h=no,
637         [#include <sys/tree.h>]
640 if test "x$found_sys_tree_h" = xyes; then
641         AC_DEFINE([HAVE_TREE_H], [1], [sys/tree.h])
642 else
643         AC_MSG_NOTICE("Using compat/tree.h")
646 # Look for __progname.
647 AC_MSG_CHECKING(for __progname)
648 AC_LINK_IFELSE([AC_LANG_SOURCE(
649         [
650                 #include <stdio.h>
651                 #include <stdlib.h>
652                 extern char *__progname;
653                 int main(void) {
654                         const char *cp = __progname;
655                         printf("%s\n", cp);
656                         exit(0);
657                 }
658         ])],
659         [AC_DEFINE([HAVE___PROGNAME], [1], [___progname]) AC_MSG_RESULT(yes)],
660         [AC_MSG_RESULT(no)]
663 PKG_CHECK_MODULES(
664         LIBPANELW,
665         panelw,
666         found_panel=yes,
667         found_panel=no
670 PKG_CHECK_MODULES(
671         LIBPANELW,
672         gnupanelw,
673         found_panel=yes,
674         found_panel=no
677 PKG_CHECK_MODULES(
678         LIBPANELW,
679         panel,
680         found_panel=yes,
681         found_panel=no
683 if test "x$found_panel" = "xno"; then
684         AC_CHECK_LIB(panelw, update_panels, [],
685                 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
686                 [-lncurses]
687         )
689         LIBPANELW_LIBS="-lpanelw"
692 PKG_CHECK_MODULES(
693         LIBNCURSES,
694         ncursesw,
695         found_ncurses=yes,
696         found_ncurses=no
698 if test "x$found_ncurses" = xyes; then
699         libncurses_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS"
700         libncurses_LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS"
701         AC_SUBST(libncurses_CFLAGS)
702         AC_SUBST(libncurses_LIBS)
703 else
704         AC_SEARCH_LIBS(
705                 setupterm,
706                 found_ncurses=yes,
707                 found_ncurses=no
708         )
709         if test "x$found_ncurses" = xyes; then
710                 AC_CHECK_HEADER(
711                         ncurses.h,
712                         libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
713                         libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
714                         AC_SUBST(libncurses_CFLAGS)
715                         AC_SUBST(libncurses_LIBS)
716                 )
717         fi
719 if test "x$found_ncurses" = xyes; then
720         AC_DEFINE([HAVE_NCURSES_H], [1], [NCurses])
721 else
722         # No ncurses, try curses.
723         AC_CHECK_FUNC(
724                 setupterm,
725                 found_curses=yes,
726                 found_curses=no
727         )
728         AC_CHECK_HEADER(
729                 curses.h,
730                 found_curses=yes,
731                 found_curses=no)
732         if test "x$found_curses" = xyes; then
733                 libncurses_CFLAGS="$LIBPANELW_CFLAGS $LIBPANEL_CFLAGS"
734                 libncurses_LIBS="$LIBPANELW_LIBS -lncursesw"
735                 AC_SUBST(libncurses_CFLAGS)
736                 AC_SUBST(libncurses_LIBS)
737                 AC_DEFINE([HAVE_CURSES_H], [1], [Curses_h])
738         else
739                 AC_MSG_ERROR("curses not found")
740         fi
743 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
744 # variables.
745 AC_SUBST(AM_CPPFLAGS)
746 CPPFLAGS="$SAVED_CPPFLAGS"
747 AC_SUBST(AM_CFLAGS)
748 CFLAGS="$SAVED_CFLAGS"
749 AC_SUBST(AM_LDFLAGS)
750 LDFLAGS="$SAVED_LDFLAGS"
752 if test x"$PLATFORM" = "xopenbsd"; then
753         LIBS=""
756 AH_BOTTOM([#include "got_compat2.h"])
758 AC_CONFIG_FILES([Makefile
759                  compat/Makefile
760                  libexec/Makefile
761                  libexec/got-read-tree/Makefile
762                  libexec/got-fetch-pack/Makefile
763                  libexec/got-index-pack/Makefile
764                  libexec/got-read-blob/Makefile
765                  libexec/got-read-commit/Makefile
766                  libexec/got-read-gitconfig/Makefile
767                  libexec/got-read-gotconfig/Makefile
768                  libexec/got-read-object/Makefile
769                  libexec/got-read-pack/Makefile
770                  libexec/got-read-patch/Makefile
771                  libexec/got-read-tag/Makefile
772                  libexec/got-send-pack/Makefile
773                  got/Makefile
774                  gotadmin/Makefile
775                  gotwebd/Makefile
776                  tog/Makefile
777                  Makefile.common:Makefile.common.in])
778 AC_OUTPUT
780 executables="$(eval echo ${exec_prefix}/bin)"
781 helpers="$(eval echo ${libexecdir})"
782 manpages="$(eval echo ${mandir})"
784 echo "
785 Configured got-portable with:
787  Version:      $VERSION
789  Prefix:       ${prefix}
790  Executables:  ${executables}
791  Bison:        $YACC
792  CFlags:       $CFLAGS
793  Helpers:      ${helpers}
794  Man pages:    ${manpages}