portable: release 0.84.1
[got-portable.git] / configure.ac
blob9307922a9c5eff0a9735dfc2b42ab58f130a5bbc
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_DEFINE_UNQUOTED(VERSION, "$VERSION")
12 AC_SUBST(VERSION)
13 AC_SUBST(GOT_RELEASE)
15 AC_USE_SYSTEM_EXTENSIONS
16 AC_CANONICAL_HOST
18 AC_CONFIG_SUBDIRS([template])
20 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
21 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
22 # empty default.
23 : ${CFLAGS=""}
25 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
26 # AC_CHECK_HEADER doesn't give us any other way to update the include
27 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
28 SAVED_CFLAGS="$CFLAGS"
29 SAVED_CPPFLAGS="$CPPFLAGS"
30 SAVED_LDFLAGS="$LDFLAGS"
32 # YACC override
33 YACC_OVERRIDE="yes"
35 # Checks for programs.
36 AC_PROG_CC
37 AC_PROG_CPP
38 AC_PROG_INSTALL
39 AC_PROG_LN_S
40 AC_PROG_MAKE_SET
41 if test -z "$YACC"; then
42 YACC_OVERRIDE="no"
43 AC_PROG_YACC
45 AM_PROG_AR
46 AC_PROG_RANLIB
47 PKG_PROG_PKG_CONFIG
49 if test "$YACC_OVERRIDE" = "yes"; then
50         AC_MSG_NOTICE("Using YACC set from environment: $YACC")
53 # Checks for header files.
54 AC_CHECK_HEADERS([ \
55         fcntl.h \
56         langinfo.h \
57         limits.h \
58         linux/landlock.h \
59         locale.h \
60         netdb.h \
61         netinet/in.h \
62         paths.h \
63         poll.h \
64         sha.h \
65         sha1.h \
66         sha2.h \
67         sha256.h \
68         stddef.h \
69         stdint.h \
70         stdlib.h \
71         string.h \
72         sys/ioctl.h \
73         sys/param.h \
74         sys/poll.h \
75         sys/queue.h \
76         sys/socket.h \
77         sys/time.h \
78         sys/tree.h \
79         util.h \
80         unistd.h \
81         wchar.h \
84 if test "x$ac_cv_header_sha2_h" = xyes; then
85         AC_DEFINE(HAVE_SHA2)
88 if test "x$ac_cv_header_sha256_h" = xyes; then
89         AC_DEFINE(HAVE_SHA256)
92 # Check for SHA1_DIGEST_LENGTH
93 if test "x$ac_cv_header_sha_h" = xyes; then
94 AC_CHECK_DECL([SHA_DIGEST_LENGTH],
95               [AC_DEFINE(HAVE_SHA_AS_SHA1)],
96               [AC_DEFINE(NEEDS_SHA1_DEFS)],
97               [#include <sha.h>])
100 if test "x$ac_cv_header_sha1_h" = xyes; then
101 AC_CHECK_DECL([SHA_DIGEST_LENGTH],
102               [AC_DEFINE(HAVE_SHA1_AS_SHA1)],
103               [AC_DEFINE(NEEDS_SHA1_DEFS)],
104               [#include <sha1.h>])
107 if test "x$ac_cv_header_sha_h" = xno || test "x$ac_cv_header_sha1_h" = xno
108 then
109         AC_DEFINE(NEEDS_SHA1_DEFS)
112 # Checks for typ edefs, structures, and compiler characteristics.
113 AC_CHECK_HEADER_STDBOOL
114 AC_C_INLINE
115 AC_TYPE_INT64_T
116 AC_TYPE_MODE_T
117 AC_TYPE_OFF_T
118 AC_TYPE_PID_T
119 AC_TYPE_SIZE_T
120 AC_TYPE_SSIZE_T
121 AC_TYPE_UINT16_T
122 AC_TYPE_UINT32_T
123 AC_TYPE_UINT64_T
124 AC_TYPE_UINT8_T
126 # Check for ifgroupreq which is only available on BSD.
127 AC_CHECK_TYPES([struct ifgroupreq])
129 # Check for sockaddr_storage.  On some systems, ss_len is filled out, although
130 # this is not mandated by POSIX, and hence systems such as linux, don't have
131 # it.
132 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
133 #include <sys/types.h>
134 #include <sys/socket.h>
137 # Same thing as sockaddr_storage above, only now check if the member exists in
138 # the struct as well.
139 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
140         [ #include <netdb.h>
141           #include <netinet/in.h>
142           #include <sys/socket.h> ]
145 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
146         [ #include <netdb.h>
147           #include <netinet/in.h>
148           #include <sys/socket.h> ]
151 # Both checks above will result in:
153 # HAVE_STRUCT_SOCKADDR_AS_LEN
154 # SS_LEN
156 # Either being defined or not.
158 # Look for library needed for flock.
159 AC_SEARCH_LIBS(flock, bsd)
161 # Checks for library functions.
162 AC_FUNC_FORK
163 AC_FUNC_FSEEKO
164 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
165 AC_FUNC_MALLOC
166 AC_FUNC_MMAP
167 AC_FUNC_REALLOC
168 AC_FUNC_STRERROR_R
169 AC_FUNC_STRNLEN
170 AC_CHECK_FUNCS([ \
171         dup2 \
172         flock \
173         getcwd \
174         localtime_r \
175         memchr \
176         memmove \
177         memset \
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         strlcpy \
195         strncasecmp \
196         strndup \
197         strrchr \
198         strspn \
199         strstr \
200         strtol \
201         strtoul \
202         wcwidth \
205 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
206 AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
207 AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
209 # Siphash support.
210 AC_CHECK_FUNCS([SipHash])
211 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
213 # Check for functions with a compatibility implementation.
214 AC_REPLACE_FUNCS([ \
215         asprintf \
216         closefrom \
217         explicit_bzero \
218         fmt_scaled \
219         freezero \
220         getdtablecount \
221         getline \
222         getprogname \
223         recallocarray \
224         reallocarray \
225         strlcat \
226         strlcpy \
227         strndup \
228         strsep \
229         strtonum \
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         *dragonfly*)
258                 AC_MSG_RESULT(dragonfly)
259                 PLATFORM=dragonflybsd
260                 ;;
261         *)
262                 AC_MSG_RESULT(unknown)
263                 PLATFORM=unknown
264                 ;;
265 esac
266 AC_SUBST(PLATFORM)
267 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
268 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
269 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
270 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
271 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
273 # Look for yacc.
274 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
275         && ! command -v "$YACC" >/dev/null 2>&1; then
276         AC_MSG_ERROR("yacc not found: $YACC")
279 if test x"$PLATFORM" = "xdarwin"; then
280         # Check for and/or set HOMEBREW_PREFIX.  brew is a common way of
281         # installing applications.  The other is MacPorts.
282         #
283         # Before Apple Silicon existed (M1 onward), the paths for applications
284         # installed via homebrew was typically /usr/local.  However, with M1
285         # onward, this changed to a different path.
286         #
287         # Rather than hardcode this, check for HOMEBREW_PREFIX in the
288         # environment if it's already set, and use it.  Otherwise, check for
289         # brew(1) and use that.  If that fails, default to /usr/local
290         #
291         # This also means that MacPorts should continue to work.
292         #
293         # But with MacPorts, we should also check --prefix, and use that if it
294         # has been supplied.
295         #
296         # In both cases, the variable HOMEBREW_PREFIX is used for both.
297         HB_PREFIX=""
298         FOUND_BISON="no"
299         GNUBISON=""
300         if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
301                 # HOMEBREW_PREFIX not set, check for brew(1)
302                 if command -v brew >/dev/null 2>&1; then
303                         AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
304                         export HOMEBREW_PREFIX="$(brew --prefix)"
305                 fi
307                 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
308                 then
309                         # Default.
310                         if test -z "${prefix}" -o "${prefix}" = "NONE"; then
311                                 export HOMEBREW_PREFIX="/usr/local"
312                                 HB_PREFIX="/usr/local"
313                                 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
314                         else
315                                 HB_PREFIX="$(eval echo ${prefix})"
316                                 if test "$HB_PREFIX" = "NONE"; then
317                                         HB_PREFIX="/opt/local"
318                                 else
319                                         AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
320                                 fi
321                                 export HOMEBREW_PREFIX="$HB_PREFIX"
322                         fi
323                 fi
324         fi
326         AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
328         if test "$YACC_OVERRIDE" = "no" && \
329                 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
330                 AC_MSG_WARN([
331                              "***********************************************************
332                              GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
333                              ***********************************************************
335                              Falling back to checking either /usr/local or \${prefix}"
336                 ])
338                 FOUND_BISON="no"
339                 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
340                 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
341                         export HOMEBREW_PREFIX="/usr/local"
342                         FOUND_BISON="yes"
343                         GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
344                 fi
346                 if test "$FOUND_BISON" = "no"; then
347                         HB_PREFIX="/opt/local"
348                         AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
350                         if test -x "${HB_PREFIX}/bin/bison"; then
351                                 export HOMEBREW_PREFIX="${HB_PREFIX}"
352                                 GNUBISON="${HB_PREFIX}/bin/bison"
353                                 FOUND_BISON="yes"
354                         fi
355                 fi
356         else
357                 FOUND_BISON="yes"
358                 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
359         fi
361         if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
362                 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
363         fi
365         # Override YACC here to point to the GNU version of bison.
366         if test "$YACC_OVERRIDE" = "yes"; then
367                 export YACC="$YACC -y"
368         else
369                 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
370                 export YACC="${GNUBISON} -y"
371         fi
372         export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
373         export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
374         export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
375         export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
378 # Landlock detection.
379 AC_MSG_CHECKING([for landlock])
380 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
381     [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
382 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
383         AC_MSG_RESULT(yes)
384 else
385         AC_MSG_RESULT(no)
388 # Clang sanitizers wrap reallocarray even if it isn't available on the target
389 # system. When compiled it always returns NULL and crashes the program. To
390 # detect this we need a more complicated test.
391 AC_MSG_CHECKING([for working reallocarray])
392 AC_RUN_IFELSE([AC_LANG_PROGRAM(
393                 [#include <stdlib.h>],
394                 [return (reallocarray(NULL, 1, 1) == NULL);]
395         )],
396         AC_MSG_RESULT(yes),
397         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
398         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
400 AC_MSG_CHECKING([for working recallocarray])
401 AC_RUN_IFELSE([AC_LANG_PROGRAM(
402                 [#include <stdlib.h>],
403                 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
404         )],
405         AC_MSG_RESULT(yes),
406         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
407         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
410 # Look for imsg_init in libutil.
411 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
412 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
413 if test "x$found_imsg_init" = xno; then
414         AC_LIBOBJ(imsg)
415         AC_LIBOBJ(imsg-buffer)
418 # libevent (for gotwebd).  Lifted from tmux.
419 # Look for libevent. Try libevent_core or libevent with pkg-config first then
420 # look for the library.
421 PKG_CHECK_MODULES(
422         LIBEVENT_CORE,
423         [libevent_core >= 2],
424         [
425                 AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
426                 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
427                 LIBS="$LIBEVENT_CORE_LIBS $LIBS"
428                 found_libevent=yes
429         ],
430         found_libevent=no
432 if test x$found_libevent = xno; then
433         PKG_CHECK_MODULES(
434                 LIBEVENT,
435                 [libevent >= 2],
436                 [
437                         AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
438                         CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
439                         LIBS="$LIBEVENT_LIBS $LIBS"
440                         found_libevent=yes
441                 ],
442                 found_libevent=no
443         )
445 if test x$found_libevent = xno; then
446         AC_SEARCH_LIBS(
447                 event_init,
448                 [event_core event event-1.4],
449                 found_libevent=yes,
450                 found_libevent=no
451         )
453 AC_CHECK_HEADER(
454         event2/event.h,
455         AC_DEFINE(HAVE_EVENT2_EVENT_H),
456         [
457                 AC_CHECK_HEADER(
458                         event.h,
459                         AC_DEFINE(HAVE_EVENT_H),
460                         found_libevent=no
461                 )
462         ]
464 if test "x$found_libevent" = xno; then
465         AC_MSG_ERROR("libevent not found")
468 # libcrypto (via libssl for SHA information)
469 PKG_CHECK_MODULES(
470         LIBCRYPTO,
471         libcrypto,
472         [
473                 AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
474                 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
475                 LIBS="$LIBCRYPTO_LIBS $LIBS"
476                 found_libcrypto=yes
477         ],
478         [
479                 found_libcrypto=no
480         ]
483 if test "x$found_libcrypto" = "xyes"; then
484         AC_DEFINE(HAVE_LIBCRYPTO)
487 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
488 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
489 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
491 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
492 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
493 # ossp
494 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
495         AC_DEFINE(HAVE_BSD_UUID)
496 else
497         PKG_CHECK_MODULES(
498                 LIBUUID,
499                 uuid,
500                 [
501                         AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
502                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
503                         LIBS="$LIBUUID_LIBS $LIBS"
504                         found_libuuid=yes
505                 ],
506                 [
507                         found_libuuid=no
508                 ]
509         )
511         if test "x$found_libuuid" = "xno"; then
512                 AC_CHECK_HEADER(
513                         uuid.h,
514                         found_libuuid=yes,
515                         found_libuuid=no)
516         fi
519 if test "x$found_libuuid" = "xno"; then
520         AC_MSG_ERROR("*** couldn't find uuid ***")
523 PKG_CHECK_MODULES(
524         ZLIB,
525         zlib,
526         [
527                 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
528                 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
529                 LIBS="$ZLIB_LIBS $LIBS"
530                 found_zlib=yes
531         ],
532         [
533                 found_zlib=no
534         ]
537 if test "x$found_zlib" = "xno"; then
538         AC_CHECK_HEADER(
539                 zlib.h,
540                 ,
541                 found_zlib=no)
544 if test "x$found_zlib" = "xno"; then
545         AC_MSG_ERROR("*** couldn't find zlib ***")
548 if test "$PLATFORM" = "linux"; then
549         PKG_CHECK_MODULES(
550                 LIBMD,
551                 libmd,
552                 [
553                         AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
554                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
555                         LIBS="$LIBMD_LIBS $LIBS"
556                 ],
557                 [
558                         AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
559                 ]
560         )
561         PKG_CHECK_MODULES(
562                 LIBBSD,
563                 libbsd-overlay,
564                 [
565                         AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
566                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
567                         LIBS="$LIBBSD_LIBS $LIBS"
568                         found_libbsd=yes
569                         AC_DEFINE(HAVE_LIBBSD)
570                 ],
571                 [
572                         AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
573                 ]
575         )
578 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
579 # some declarations.
580 AC_CHECK_DECL(
581         TAILQ_CONCAT,
582         found_queue_h=yes,
583         found_queue_h=no,
584         [#include <sys/queue.h>]
586 AC_CHECK_DECL(
587         TAILQ_PREV,
588         ,
589         found_queue_h=no,
590         [#include <sys/queue.h>]
592 AC_CHECK_DECL(
593         TAILQ_FOREACH_SAFE,
594         ,
595         found_queue_h=no,
596         [#include <sys/queue.h>]
599 if test "x$found_queue_h" = xyes; then
600         AC_DEFINE(HAVE_QUEUE_H)
601 else
602         AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
605 AC_CHECK_DECL(
606         RB_GENERATE_STATIC,
607         found_sys_tree_h=yes,
608         found_sys_tree_h=no,
609         [#include <sys/tree.h>]
612 if test "x$found_sys_tree_h" = xyes; then
613         AC_DEFINE(HAVE_TREE_H)
614 else
615         AC_MSG_NOTICE("Using compat/tree.h")
618 # Look for __progname.
619 AC_MSG_CHECKING(for __progname)
620 AC_LINK_IFELSE([AC_LANG_SOURCE(
621         [
622                 #include <stdio.h>
623                 #include <stdlib.h>
624                 extern char *__progname;
625                 int main(void) {
626                         const char *cp = __progname;
627                         printf("%s\n", cp);
628                         exit(0);
629                 }
630         ])],
631         [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
632         AC_MSG_RESULT(no)
635 PKG_CHECK_MODULES(
636         LIBPANELW,
637         panelw,
638         found_panel=yes,
639         found_panel=no
642 PKG_CHECK_MODULES(
643         LIBPANELW,
644         gnupanelw,
645         found_panel=yes,
646         found_panel=no
649 PKG_CHECK_MODULES(
650         LIBPANELW,
651         panel,
652         found_panel=yes,
653         found_panel=no
655 if test "x$found_panel" = "xno"; then
656         AC_CHECK_LIB(panelw, update_panels, [],
657                 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
658                 [-lncurses]
659         )
661         LIBPANELW_LIBS="-lpanelw"
664 PKG_CHECK_MODULES(
665         LIBNCURSES,
666         ncursesw,
667         found_ncurses=yes,
668         found_ncurses=no
670 if test "x$found_ncurses" = xyes; then
671         AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
672         CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
673         LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
674 else
675         AC_CHECK_LIB(
676                 ncursesw,
677                 setupterm,
678                 found_ncurses=yes,
679                 found_ncurses=no
680         )
681         if test "x$found_ncurses" = xyes; then
682                 AC_CHECK_HEADER(
683                         ncurses.h,
684                         AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
685                         CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
686                         LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
687                         found_ncurses=no
688                 )
689         fi
691 if test "x$found_ncurses" = xyes; then
692         AC_DEFINE(HAVE_NCURSES_H)
693 else
694         # No ncurses, try curses.
695         AC_CHECK_LIB(
696                 cursesw,
697                 setupterm,
698                 found_curses=yes,
699                 found_curses=no
700         )
701         AC_CHECK_HEADER(
702                 curses.h,
703                 ,
704                 found_curses=no)
705         if test "x$found_curses" = xyes; then
706                 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
707                 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
708                 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
709                 AC_DEFINE(HAVE_CURSES_H)
710         else
711                 AC_MSG_ERROR("curses not found")
712         fi
715 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
716 # variables.
717 AC_SUBST(AM_CPPFLAGS)
718 CPPFLAGS="$SAVED_CPPFLAGS"
719 AC_SUBST(AM_CFLAGS)
720 CFLAGS="$SAVED_CFLAGS"
721 AC_SUBST(AM_LDFLAGS)
722 LDFLAGS="$SAVED_LDFLAGS"
724 AC_CONFIG_FILES([Makefile
725                  compat/Makefile
726                  libexec/Makefile
727                  libexec/got-read-tree/Makefile
728                  libexec/got-fetch-pack/Makefile
729                  libexec/got-index-pack/Makefile
730                  libexec/got-read-blob/Makefile
731                  libexec/got-read-commit/Makefile
732                  libexec/got-read-gitconfig/Makefile
733                  libexec/got-read-gotconfig/Makefile
734                  libexec/got-read-object/Makefile
735                  libexec/got-read-pack/Makefile
736                  libexec/got-read-patch/Makefile
737                  libexec/got-read-tag/Makefile
738                  libexec/got-send-pack/Makefile
739                  got/Makefile
740                  gotadmin/Makefile
741                  gotwebd/Makefile
742                  tog/Makefile
743                  Makefile.common:Makefile.common.in])
744 AC_OUTPUT
746 executables="$(eval echo ${exec_prefix}/bin)"
747 helpers="$(eval echo ${libexecdir})"
748 manpages="$(eval echo ${mandir})"
750 echo "
751 Configured got-portable with:
753  Version:      $VERSION
755  Prefix:       ${prefix}
756  Executables:  ${executables}
757  Bison:        $YACC
758  Helpers:      ${helpers}
759  Man pages:    ${manpages}