portable: regress: improve date wrapper
[got-portable.git] / configure.ac
blob411a05c09cda3abd712cecf458fd4db2de2cb536
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_sha256_h" = xyes; then
85         AC_DEFINE(HAVE_SHA256)
88 AM_CONDITIONAL([HAVE_SHA2], [test "x$ac_cv_header_sha2_h" = xyes])
90 # Check for SHA1_DIGEST_LENGTH
91 AC_CHECK_DECL([SHA1_DIGEST_LENGTH],
92         [AC_DEFINE(HAVE_SHA1_AS_SHA1)],
93         [
94                 dnl maybe sha.h is available
95                 AC_CHECK_DECL([SHA_DIGEST_LENGTH],
96                         [AC_DEFINE(HAVE_SHA_AS_SHA1)],
97                         [],
98                         [#include <sha.h>])
99         ],
100         [
101         #include <sys/types.h>
102         #include <sha1.h>
103         ])
105 # Checks for typ edefs, structures, and compiler characteristics.
106 AC_CHECK_HEADER_STDBOOL
107 AC_C_INLINE
108 AC_TYPE_INT64_T
109 AC_TYPE_MODE_T
110 AC_TYPE_OFF_T
111 AC_TYPE_PID_T
112 AC_TYPE_SIZE_T
113 AC_TYPE_SSIZE_T
114 AC_TYPE_UINT16_T
115 AC_TYPE_UINT32_T
116 AC_TYPE_UINT64_T
117 AC_TYPE_UINT8_T
119 # Check for ifgroupreq which is only available on BSD.
120 AC_CHECK_TYPES([struct ifgroupreq])
122 # Check for sockaddr_storage.  On some systems, ss_len is filled out, although
123 # this is not mandated by POSIX, and hence systems such as linux, don't have
124 # it.
125 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
126 #include <sys/types.h>
127 #include <sys/socket.h>
130 # Same thing as sockaddr_storage above, only now check if the member exists in
131 # the struct as well.
132 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
133         [ #include <netdb.h>
134           #include <netinet/in.h>
135           #include <sys/socket.h> ]
138 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
139         [ #include <netdb.h>
140           #include <netinet/in.h>
141           #include <sys/socket.h> ]
144 # Both checks above will result in:
146 # HAVE_STRUCT_SOCKADDR_AS_LEN
147 # SS_LEN
149 # Either being defined or not.
151 # Look for library needed for flock.
152 AC_SEARCH_LIBS(flock, bsd)
154 # Checks for library functions.
155 AC_FUNC_FORK
156 AC_FUNC_FSEEKO
157 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
158 AC_FUNC_MALLOC
159 AC_FUNC_MMAP
160 AC_FUNC_REALLOC
161 AC_FUNC_STRERROR_R
162 AC_FUNC_STRNLEN
163 AC_CHECK_FUNCS([ \
164         dup2 \
165         flock \
166         getcwd \
167         localtime_r \
168         memchr \
169         memmove \
170         memset \
171         mkdir \
172         munmap \
173         nl_langinfo \
174         realpath \
175         regcomp \
176         rmdir \
177         setlocale \
178         socket \
179         setresgid \
180         setresuid \
181         setproctitle \
182         strcasecmp \
183         strchr \
184         strcspn \
185         strdup \
186         strerror \
187         strlcpy \
188         strncasecmp \
189         strndup \
190         strrchr \
191         strspn \
192         strstr \
193         strtol \
194         strtoul \
195         wcwidth \
198 AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
199 AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
200 AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
202 # Siphash support.
203 AC_CHECK_FUNCS([SipHash])
204 AM_CONDITIONAL([HAVE_SIPHASH], [test "x$ac_cv_func_SipHash" = xyes])
206 # Check for functions with a compatibility implementation.
207 AC_REPLACE_FUNCS([ \
208         asprintf \
209         closefrom \
210         explicit_bzero \
211         fmt_scaled \
212         freezero \
213         getdtablecount \
214         getline \
215         getprogname \
216         recallocarray \
217         reallocarray \
218         strlcat \
219         strlcpy \
220         strndup \
221         strsep \
222         strtonum \
225 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
226 # musl does not set optarg to NULL for flags without arguments (although it is
227 # not required to, but it is helpful) 3) there are probably other weird
228 # implementations.
229 AC_LIBOBJ(getopt)
231 # Check the platform we're compiling on.
232 AC_MSG_CHECKING(platform)
233 case "$host_os" in
234         *linux*)
235                 AC_MSG_RESULT(linux)
236                 PLATFORM=linux
237                 ;;
238         *freebsd*)
239                 AC_MSG_RESULT(freebsd)
240                 PLATFORM=freebsd
241                 ;;
242         *darwin*)
243                 AC_MSG_RESULT(darwin)
244                 PLATFORM=darwin
245                 ;;
246         *netbsd*)
247                 AC_MSG_RESULT(netbsd)
248                 PLATFORM=netbsd
249                 ;;
250         *openbsd*)
251                 AC_MSG_RESULT(openbsd)
252                 PLATFORM=openbsd
253                 ;;
254         *dragonfly*)
255                 AC_MSG_RESULT(dragonfly)
256                 PLATFORM=dragonflybsd
257                 ;;
258         *)
259                 AC_MSG_RESULT(unknown)
260                 PLATFORM=unknown
261                 ;;
262 esac
263 AC_SUBST(PLATFORM)
264 AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"])
265 AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"])
266 AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"])
267 AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"])
268 AM_CONDITIONAL([HOST_OPENBSD], [test "$PLATFORM" = "openbsd"])
269 AM_CONDITIONAL([HOST_DRAGONFLYBSD], [test "$PLATFORM" = "dragonflybsd"])
271 # Look for yacc.
272 if test "YACC_OVERRIDE" = "yes" && test -n "$YACC" \
273         && ! command -v "$YACC" >/dev/null 2>&1; then
274         AC_MSG_ERROR("yacc not found: $YACC")
277 if test x"$PLATFORM" = "xdarwin"; then
278         # Check for and/or set HOMEBREW_PREFIX.  brew is a common way of
279         # installing applications.  The other is MacPorts.
280         #
281         # Before Apple Silicon existed (M1 onward), the paths for applications
282         # installed via homebrew was typically /usr/local.  However, with M1
283         # onward, this changed to a different path.
284         #
285         # Rather than hardcode this, check for HOMEBREW_PREFIX in the
286         # environment if it's already set, and use it.  Otherwise, check for
287         # brew(1) and use that.  If that fails, default to /usr/local
288         #
289         # This also means that MacPorts should continue to work.
290         #
291         # But with MacPorts, we should also check --prefix, and use that if it
292         # has been supplied.
293         #
294         # In both cases, the variable HOMEBREW_PREFIX is used for both.
295         HB_PREFIX=""
296         FOUND_BISON="no"
297         GNUBISON=""
298         if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"; then
299                 # HOMEBREW_PREFIX not set, check for brew(1)
300                 if command -v brew >/dev/null 2>&1; then
301                         AC_MSG_NOTICE("HOMEBREW_PREFIX set via 'brew --prefix'")
302                         export HOMEBREW_PREFIX="$(brew --prefix)"
303                 fi
305                 if test -z "$HOMEBREW_PREFIX" -o "$HOMEBREW_PREFIX" = "NONE"
306                 then
307                         # Default.
308                         if test -z "${prefix}" -o "${prefix}" = "NONE"; then
309                                 export HOMEBREW_PREFIX="/usr/local"
310                                 HB_PREFIX="/usr/local"
311                                 AC_MSG_NOTICE("HOMEBREW_PREFIX defaulting to $HB_PREFIX")
312                         else
313                                 HB_PREFIX="$(eval echo ${prefix})"
314                                 if test "$HB_PREFIX" = "NONE"; then
315                                         HB_PREFIX="/opt/local"
316                                 else
317                                         AC_MSG_NOTICE("HOMEBREW_PREFIX using --prefix")
318                                 fi
319                                 export HOMEBREW_PREFIX="$HB_PREFIX"
320                         fi
321                 fi
322         fi
324         AC_MSG_NOTICE("HOMEBREW_PREFIX determined as: $HOMEBREW_PREFIX")
326         if test "$YACC_OVERRIDE" = "no" && \
327                 ! test -x "${HOMEBREW_PREFIX}/opt/bison/bin/bison"; then
328                 AC_MSG_WARN([
329                              "***********************************************************
330                              GNU Bison not found: ${HOMEBREW_PREFIX}/opt/bison/bin/bison
331                              ***********************************************************
333                              Falling back to checking either /usr/local or \${prefix}"
334                 ])
336                 FOUND_BISON="no"
337                 AC_MSG_WARN("Trying ${HB_PREFIX}/opt/bison/bin/bison")
338                 if test -x "${HB_PREFIX}/opt/bison/bin/bison"; then
339                         export HOMEBREW_PREFIX="/usr/local"
340                         FOUND_BISON="yes"
341                         GNUBISON="${HB_PREFIX}/opt/bison/bin/bison"
342                 fi
344                 if test "$FOUND_BISON" = "no"; then
345                         HB_PREFIX="/opt/local"
346                         AC_MSG_WARN("Trying ${HB_PREFIX}/bin/bison")
348                         if test -x "${HB_PREFIX}/bin/bison"; then
349                                 export HOMEBREW_PREFIX="${HB_PREFIX}"
350                                 GNUBISON="${HB_PREFIX}/bin/bison"
351                                 FOUND_BISON="yes"
352                         fi
353                 fi
354         else
355                 FOUND_BISON="yes"
356                 GNUBISON="${HOMEBREW_PREFIX}/opt/bison/bin/bison"
357         fi
359         if test "$FOUND_BISON" = "no" && test "$YACC_OVERRIDE" = "no"; then
360                 AC_MSG_ERROR("*** Couldn't find GNU BISON ***")
361         fi
363         # Override YACC here to point to the GNU version of bison.
364         if test "$YACC_OVERRIDE" = "yes"; then
365                 export YACC="$YACC -y"
366         else
367                 AC_MSG_NOTICE("Found GNU Bison as: $GNUBISON")
368                 export YACC="${GNUBISON} -y"
369         fi
370         export LDFLAGS="-L${HOMEBREW_PREFIX}/opt/ncurses/lib -L${HOMEBREW_PREFIX}/opt/openssl@3/lib $LDFLAGS"
371         export CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/ncurses/include -I${HOMEBREW_PREFIX}/opt/openssl@3/include $CPPFLAGS"
372         export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/opt/ncurses/lib/pkgconfig"
373         export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${HOMEBREW_PREFIX}/opt/openssl@3/lib/pkgconfig"
376 # Landlock detection.
377 AC_MSG_CHECKING([for landlock])
378 AM_CONDITIONAL([HAVE_LINUX_LANDLOCK],
379     [test "x$ac_cv_header_linux_landlock_h" = "xyes"])
380 if test "x$ac_cv_header_linux_landlock_h" = "xyes"; then
381         AC_MSG_RESULT(yes)
382 else
383         AC_MSG_RESULT(no)
386 # Clang sanitizers wrap reallocarray even if it isn't available on the target
387 # system. When compiled it always returns NULL and crashes the program. To
388 # detect this we need a more complicated test.
389 AC_MSG_CHECKING([for working reallocarray])
390 AC_RUN_IFELSE([AC_LANG_PROGRAM(
391                 [#include <stdlib.h>],
392                 [return (reallocarray(NULL, 1, 1) == NULL);]
393         )],
394         AC_MSG_RESULT(yes),
395         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
396         [AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
398 AC_MSG_CHECKING([for working recallocarray])
399 AC_RUN_IFELSE([AC_LANG_PROGRAM(
400                 [#include <stdlib.h>],
401                 [return (recallocarray(NULL, 1, 1, 1) == NULL);]
402         )],
403         AC_MSG_RESULT(yes),
404         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
405         [AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
408 # Look for imsg_init in libutil.
409 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
410 AM_CONDITIONAL([HAVE_IMSG], [test "x$found_imsg_init" = "xyes"])
411 if test "x$found_imsg_init" = xno; then
412         AC_LIBOBJ(imsg)
413         AC_LIBOBJ(imsg-buffer)
416 # libevent (for gotwebd).  Lifted from tmux.
417 # Look for libevent. Try libevent_core or libevent with pkg-config first then
418 # look for the library.
419 PKG_CHECK_MODULES(
420         LIBEVENT_CORE,
421         [libevent_core >= 2],
422         [
423                 AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
424                 CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
425                 LIBS="$LIBEVENT_CORE_LIBS $LIBS"
426                 found_libevent=yes
427         ],
428         found_libevent=no
430 if test x$found_libevent = xno; then
431         PKG_CHECK_MODULES(
432                 LIBEVENT,
433                 [libevent >= 2],
434                 [
435                         AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
436                         CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
437                         LIBS="$LIBEVENT_LIBS $LIBS"
438                         found_libevent=yes
439                 ],
440                 found_libevent=no
441         )
443 if test x$found_libevent = xno; then
444         AC_SEARCH_LIBS(
445                 event_init,
446                 [event_core event event-1.4],
447                 found_libevent=yes,
448                 found_libevent=no
449         )
451 AC_CHECK_HEADER(
452         event2/event.h,
453         AC_DEFINE(HAVE_EVENT2_EVENT_H),
454         [
455                 AC_CHECK_HEADER(
456                         event.h,
457                         AC_DEFINE(HAVE_EVENT_H),
458                         found_libevent=no
459                 )
460         ]
462 if test "x$found_libevent" = xno; then
463         AC_MSG_ERROR("libevent not found")
466 # libcrypto (via libssl for SHA information)
467 PKG_CHECK_MODULES(
468         LIBCRYPTO,
469         libcrypto,
470         [
471                 AM_CFLAGS="$LIBCRYPTO_CFLAGS $AM_CFLAGS"
472                 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
473                 LIBS="$LIBCRYPTO_LIBS $LIBS"
474                 found_libcrypto=yes
475         ],
476         [
477                 found_libcrypto=no
478         ]
481 if test "x$found_libcrypto" = "xyes"; then
482         AC_DEFINE(HAVE_LIBCRYPTO)
485 AC_SEARCH_LIBS(uuid_create, , AC_DEFINE(HAVE_BSD_UUID))
486 AC_SEARCH_LIBS(uuid_create, found_uuid=no, found_uuid=yes)
487 AC_SEARCH_LIBS(mergesort, , AC_DEFINE(HAVE_BSD_MERGESORT))
489 # Don't define HAVE_BSD_UUID on darwin (Apple) as this breaks the BSD API.
490 # Instead, use the UUID implementation wrapper that's in compat/ plus uuid
491 # ossp
492 if test "x$found_uuid" = "xyes" -a "x$PLATFORM" != "darwin"; then
493         AC_DEFINE(HAVE_BSD_UUID)
494 else
495         PKG_CHECK_MODULES(
496                 LIBUUID,
497                 uuid,
498                 [
499                         AM_CFLAGS="$LIBUUID_CFLAGS $AM_CFLAGS"
500                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
501                         LIBS="$LIBUUID_LIBS $LIBS"
502                         found_libuuid=yes
503                 ],
504                 [
505                         found_libuuid=no
506                 ]
507         )
509         if test "x$found_libuuid" = "xno"; then
510                 AC_CHECK_HEADER(
511                         uuid.h,
512                         found_libuuid=yes,
513                         found_libuuid=no)
514         fi
517 if test "x$found_libuuid" = "xno"; then
518         AC_MSG_ERROR("*** couldn't find uuid ***")
521 PKG_CHECK_MODULES(
522         ZLIB,
523         zlib,
524         [
525                 AM_CFLAGS="$ZLIB_CFLAGS $AM_CFLAGS"
526                 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
527                 LIBS="$ZLIB_LIBS $LIBS"
528                 found_zlib=yes
529         ],
530         [
531                 found_zlib=no
532         ]
535 if test "x$found_zlib" = "xno"; then
536         AC_CHECK_HEADER(
537                 zlib.h,
538                 ,
539                 found_zlib=no)
542 if test "x$found_zlib" = "xno"; then
543         AC_MSG_ERROR("*** couldn't find zlib ***")
546 if test "$PLATFORM" = "linux"; then
547         PKG_CHECK_MODULES(
548                 LIBMD,
549                 libmd,
550                 [
551                         AM_CFLAGS="$LIBMD_CFLAGS $AM_CFLAGS"
552                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
553                         LIBS="$LIBMD_LIBS $LIBS"
554                 ],
555                 [
556                         AC_MSG_ERROR("*** couldn't find libmd via pkg-config")
557                 ]
558         )
559         PKG_CHECK_MODULES(
560                 LIBBSD,
561                 libbsd-overlay,
562                 [
563                         AM_CFLAGS="$LIBBSD_CFLAGS $AM_CFLAGS"
564                         CFLAGS="$AM_CFLAGS $SAVED_CFLAGS"
565                         LIBS="$LIBBSD_LIBS $LIBS"
566                         AC_DEFINE(HAVE_LIBBSD)
567                 ],
568                 [
569                         AC_MSG_ERROR("*** couldn't find libbsd-overlay via pkg-config")
570                 ]
572         )
575 # Look for a suitable queue.h.  We hope libbsd is enough, but that is missing
576 # some declarations.
577 AC_CHECK_DECL(
578         TAILQ_CONCAT,
579         found_queue_h=yes,
580         found_queue_h=no,
581         [#include <sys/queue.h>]
583 AC_CHECK_DECL(
584         TAILQ_PREV,
585         ,
586         found_queue_h=no,
587         [#include <sys/queue.h>]
589 AC_CHECK_DECL(
590         TAILQ_FOREACH_SAFE,
591         ,
592         found_queue_h=no,
593         [#include <sys/queue.h>]
596 if test "x$found_queue_h" = xyes; then
597         AC_DEFINE(HAVE_QUEUE_H)
598 else
599         AC_MSG_ERROR("*** sys/queue.h missing key defines ***)
602 AC_CHECK_DECL(
603         RB_GENERATE_STATIC,
604         found_sys_tree_h=yes,
605         found_sys_tree_h=no,
606         [#include <sys/tree.h>]
609 if test "x$found_sys_tree_h" = xyes; then
610         AC_DEFINE(HAVE_TREE_H)
611 else
612         AC_MSG_NOTICE("Using compat/tree.h")
615 # Look for __progname.
616 AC_MSG_CHECKING(for __progname)
617 AC_LINK_IFELSE([AC_LANG_SOURCE(
618         [
619                 #include <stdio.h>
620                 #include <stdlib.h>
621                 extern char *__progname;
622                 int main(void) {
623                         const char *cp = __progname;
624                         printf("%s\n", cp);
625                         exit(0);
626                 }
627         ])],
628         [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
629         AC_MSG_RESULT(no)
632 PKG_CHECK_MODULES(
633         LIBPANELW,
634         panelw,
635         found_panel=yes,
636         found_panel=no
639 PKG_CHECK_MODULES(
640         LIBPANELW,
641         gnupanelw,
642         found_panel=yes,
643         found_panel=no
646 PKG_CHECK_MODULES(
647         LIBPANELW,
648         panel,
649         found_panel=yes,
650         found_panel=no
652 if test "x$found_panel" = "xno"; then
653         AC_CHECK_LIB(panelw, update_panels, [],
654                 AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]),
655                 [-lncurses]
656         )
658         LIBPANELW_LIBS="-lpanelw"
661 PKG_CHECK_MODULES(
662         LIBNCURSES,
663         ncursesw,
664         found_ncurses=yes,
665         found_ncurses=no
667 if test "x$found_ncurses" = xyes; then
668         AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $AM_CFLAGS"
669         CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $LIBPANELW_CFLAGS $CFLAGS"
670         LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBPANELW_LIBS $LIBS"
671 else
672         AC_CHECK_LIB(
673                 ncursesw,
674                 setupterm,
675                 found_ncurses=yes,
676                 found_ncurses=no
677         )
678         if test "x$found_ncurses" = xyes; then
679                 AC_CHECK_HEADER(
680                         ncurses.h,
681                         AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
682                         CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
683                         LIBS="$LIBS -lncursesw $LIBPANELW_LIBS",
684                         found_ncurses=no
685                 )
686         fi
688 if test "x$found_ncurses" = xyes; then
689         AC_DEFINE(HAVE_NCURSES_H)
690 else
691         # No ncurses, try curses.
692         AC_CHECK_LIB(
693                 cursesw,
694                 setupterm,
695                 found_curses=yes,
696                 found_curses=no
697         )
698         AC_CHECK_HEADER(
699                 curses.h,
700                 ,
701                 found_curses=no)
702         if test "x$found_curses" = xyes; then
703                 AM_CFLAGS="$LIBPANELW_CFLAGS $AM_CFLAGS"
704                 CFLAGS="$LIBPANEL_CFLAGS $CFLAGS"
705                 LIBS="$LIBS -lcursesw $LIBPANELW_LIBS"
706                 AC_DEFINE(HAVE_CURSES_H)
707         else
708                 AC_MSG_ERROR("curses not found")
709         fi
712 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
713 # variables.
714 AC_SUBST(AM_CPPFLAGS)
715 CPPFLAGS="$SAVED_CPPFLAGS"
716 AC_SUBST(AM_CFLAGS)
717 CFLAGS="$SAVED_CFLAGS"
718 AC_SUBST(AM_LDFLAGS)
719 LDFLAGS="$SAVED_LDFLAGS"
721 AC_CONFIG_FILES([Makefile
722                  compat/Makefile
723                  libexec/Makefile
724                  libexec/got-read-tree/Makefile
725                  libexec/got-fetch-pack/Makefile
726                  libexec/got-index-pack/Makefile
727                  libexec/got-read-blob/Makefile
728                  libexec/got-read-commit/Makefile
729                  libexec/got-read-gitconfig/Makefile
730                  libexec/got-read-gotconfig/Makefile
731                  libexec/got-read-object/Makefile
732                  libexec/got-read-pack/Makefile
733                  libexec/got-read-patch/Makefile
734                  libexec/got-read-tag/Makefile
735                  libexec/got-send-pack/Makefile
736                  got/Makefile
737                  gotadmin/Makefile
738                  gotwebd/Makefile
739                  tog/Makefile
740                  Makefile.common:Makefile.common.in])
741 AC_OUTPUT
743 executables="$(eval echo ${exec_prefix}/bin)"
744 helpers="$(eval echo ${libexecdir})"
745 manpages="$(eval echo ${mandir})"
747 echo "
748 Configured got-portable with:
750  Version:      $VERSION
752  Prefix:       ${prefix}
753  Executables:  ${executables}
754  Bison:        $YACC
755  Helpers:      ${helpers}
756  Man pages:    ${manpages}