Really fix cursor in history mode with a rotated board.
[cboard.git] / configure.ac
blob15628d461c3acffa1910810931b0e5b12dca0da9
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(cboard, 0.6.2-dev, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_AUX_DIR(build)
5 AC_CANONICAL_TARGET
6 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
7 AC_USE_SYSTEM_EXTENSIONS()
8 AM_CONFIG_HEADER([config.h])
9 AM_GNU_GETTEXT([external])
10 AM_GNU_GETTEXT_VERSION([0.18.1])
12 case "$target_os" in
13     darwin*)
14         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
15         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
16         ;;
17     *)
18         ;;
19 esac
21 dnl Checks for programs.
22 AC_PROG_CXX
23 AC_PROG_AWK
24 AC_PROG_CC
25 AC_PROG_CPP
26 AC_PROG_INSTALL
27 AC_PROG_LN_S
28 AC_PROG_MAKE_SET
29 AC_PROG_RANLIB
31 dnl Checks for library functions.
32 AX_WITH_CURSES
33 AX_WITH_CURSES_PANEL
34 AX_WITH_CURSES_MENU
35 AX_WITH_CURSES_FORM
37 OLDLIBS="$LIBS"
38 LIBS="$CURSES_LIB $LIBS"
39 AC_MSG_CHECKING([if curses installation has wresize()])
40 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[void *w = 0; wresize(w, 0, 0);]])],
41                                     [have_curses_wresize=yes],
42                                     [have_curses_wresize=no])
43 AC_MSG_RESULT($have_curses_wresize)
44 if test x"$have_curses_wresize" = "xyes"; then
45     AC_DEFINE([HAVE_WRESIZE], 1, \
46               [Define if your curses installation contains wresize().])
49 AC_MSG_CHECKING([if curses installation has attr_t])
50 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
51 #if defined(HAVE_NCURSESW_CURSES_H)
52 #  include <ncursesw/curses.h>
53 #elif defined(HAVE_NCURSESW_H)
54 #  include <ncursesw.h>
55 #elif defined(HAVE_NCURSES_CURSES_H)
56 #  include <ncurses/curses.h>
57 #elif defined(HAVE_NCURSES_H)
58 #  include <ncurses.h>
59 #elif defined(HAVE_CURSES_H)
60 #  include <curses.h>
61 #else
62 #  error "SysV or X/Open-compatible Curses header file required"
63 #endif
64 ]], [[attr_t n = 0;]])], [have_curses_attr_t=yes], [have_curses_attr_t=no])
65 AC_MSG_RESULT($have_curses_attr_t)
66 if test x"$have_curses_attr_t" = "xyes"; then
67     AC_DEFINE([HAVE_ATTR_T], 1, \
68               [Define if your curses installation contains attr_t.])
71 LIBS="$OLDLIBS"
72 OLDLIBS="$LIBS"
73 LIBS="$FORM_LIB $LIBS"
74 AC_MSG_CHECKING([if curses form installation defines TYPE_IPV4])
75 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
76 #if defined(HAVE_NCURSESW_FORM_H)
77 #include <ncursesw/form.h>
78 #elif defined(HAVE_NCURSES_FORM_H)
79 #include <ncurses/form.h>
80 #elif defined(HAVE_FORM_H)
81 #include <form.h>
82 #else
83 #error "SysV-compatible Curses Form header file required"
84 #endif
85 ]], [[FIELDTYPE *t = TYPE_IPV4;]])],
86                [have_curses_form_ipv4=yes],
87                [have_curses_form_ipv4=no])
88 AC_MSG_RESULT($have_curses_form_ipv4)
89 if test x"$have_curses_form_ipv4" = "xyes"; then
90     AC_DEFINE([HAVE_TYPE_IPV4], 1, [Define if form.h defines TYPE_IPV4.])
93 LIBS="$OLDLIBS"
95 AC_ARG_WITH(libperl, AC_HELP_STRING([--with-libperl], [PERL support.]),
96     want_libperl=yes, want_libperl=no)
98 AC_MSG_CHECKING([if PERL support is wanted])
99 AC_MSG_RESULT($want_libperl)
101 if test "$want_libperl" = "yes"; then
102     AC_CHECK_LIB(perl, perl_run, have_libperl=yes, have_libperl=no)
104     if test "$have_libperl" = "yes"; then
105         LIBPERL_CFLAGS=`perl -MExtUtils::Embed -e ccopts`
107         if test $? -ne 0; then
108             AC_MSG_ERROR([Missing or incomplete PERL installation.])
109         fi
111         AC_SUBST(LIBPERL_CFLAGS)
112         LIBPERL_LDFLAGS=`perl -MExtUtils::Embed -e ldopts`
113         AC_SUBST(LIBPERL_LDFLAGS)
114         AC_DEFINE([WITH_LIBPERL], 1, [Define if you want PERL support.])
115     else
116         AC_MSG_ERROR([Missing or incomplete PERL installation.])
117     fi
120 AM_CONDITIONAL([WITH_LIBPERL], [test "$have_libperl" = "yes"])
121 dnl Checks for header files.
122 AC_HEADER_DIRENT
123 AC_HEADER_SYS_WAIT
124 AC_HEADER_STDC
125 AC_CHECK_HEADERS([fcntl.h paths.h sys/socket.h limits.h sys/time.h unistd.h \
126                   stdlib.h string.h strings.h wchar.h getopt.h sys/param.h \
127                   regex.h stdarg.h paths.h])
128 AC_CHECK_HEADERS([err.h],, [AC_CHECK_FUNCS([fputs_unlocked putwc_unlocked \
129                  putw_unlocked])])
131 AM_CONDITIONAL([NO_ERR_H], [test "x$ac_cv_header_err_h" = "xno"])
133 if test x"$ac_cv_header_err_h" = "xyes"; then
134     AC_MSG_CHECKING([for __progname])
135     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
136 #include <stdio.h>
137 #include <err.h>
138 extern char *__progname;
139 ]], [[
140 printf("%s\n", __progname);
141 ]])], [have_progname=yes], [have_progname=no])
142     AC_MSG_RESULT($have_progname)
143     if test x"$have_progname" = "xyes"; then
144         AC_DEFINE([HAVE_PROGNAME], 1, \
145                   [Define if your system has __progname.])
146     fi
149 AC_CHECK_HEADERS([glob.h])
150 if test x"$ac_cv_header_glob_h" = "xyes"; then
151     AC_MSG_CHECKING([if glob.h defines GLOB_NOMATCH])
152     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
153 #include <glob.h>
154 ]], [[
155 int n = GLOB_NOMATCH;
156 ]])], [have_glob_nomatch=yes], [have_glob_nomatch=no])
157     AC_MSG_RESULT($have_glob_nomatch)
158     if test x"$have_glob_nomatch" = "xyes"; then
159          AC_DEFINE([HAVE_GLOB_NOMATCH], 1, \
160                    [Define if glob.h defines GLOB_NOMATCH.])
161     fi
164 dnl Checks for typedefs, structures, and compiler characteristics.
165 AC_HEADER_STDBOOL
166 AC_C_CONST
167 AC_TYPE_PID_T
168 AC_TYPE_SIZE_T
169 AC_HEADER_TIME
170 AC_STRUCT_TM
172 dnl Checks for library functions.
173 AC_FUNC_ALLOCA
174 AC_FUNC_MEMCMP
175 AC_FUNC_VPRINTF
176 AC_FUNC_FORK
177 AC_FUNC_MALLOC
178 AC_FUNC_REALLOC
179 AC_FUNC_SELECT_ARGTYPES
180 AC_TYPE_SIGNAL
181 AC_FUNC_STAT
182 AC_FUNC_STRFTIME
183 AC_CHECK_FUNCS([bzero dup2 getcwd gethostbyname memset mkdir mkfifo regcomp \
184                 select socket strcasecmp strdup strerror strrchr strstr \
185                 vasprintf strsep strchr strncasecmp strpbrk putenv])
187 AM_CONDITIONAL([NO_STRSEP], [test "x$ac_cv_func_strsep" = "xno"])
189 AC_DEFUN([AC_DEBUG],
191     if test "$1"; then
192         ac_cv_sys_debug=$1
193     fi
195     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
196         [ac_cv_sys_debug=no])
197     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
200 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
201     AC_DEBUG([$enableval]), AC_DEBUG)
203 AC_MSG_CHECKING([for Unix98 pty support])
204 if test -c "/dev/ptmx"; then
205     have_ptmx=yes
206 else
207     have_ptmx=no
210 ptmx_works=no
212 if test "x$have_ptmx" = "xyes"; then
213     AC_LANG([C])
214     AC_RUN_IFELSE([AC_LANG_SOURCE([[\
215                    #include <stdio.h>
216                    #include <sys/types.h>
217                    #include <sys/stat.h>
218                    #include <fcntl.h>
220                    int main()
221                    {
222                        int fd;
224                        if ((fd = open("/dev/ptmx", O_RDWR)) == -1)
225                            exit(1);
227                        if (ptsname(fd) == NULL)
228                            exit(1);
230                        exit(0);
231                    }
232                    ]])], [ptmx_works=yes], [ptmx_works=no])
234     if test "x$ptmx_works" = "xyes"; then
235         AC_MSG_RESULT([yes])
236         AC_DEFINE([UNIX98], 1, [Define if your system has Unix98 pty support.])
237     else
238         AC_MSG_RESULT([no])
239     fi
242 if test "x$have_ptmx" = "xno" -o "x$ptmx_works" = "xno"; then
243 # From the GNU Screen package.
244     AC_MSG_CHECKING([pty ranges])
245     if test -d /dev/ptym; then
246     pdir='/dev/ptym'
247     else
248     pdir='/dev'
249     fi
251     ptys=`echo $pdir/pty??`
253     if test "$ptys" != "$pdir/pty??" ; then
254     p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
255     p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
257     AC_DEFINE_UNQUOTED([PTY_MAJOR], "$p0", [Pseudo tty ranges.])
258     AC_DEFINE_UNQUOTED([PTY_MINOR], "$p1", [Pseudo tty ranges.])
259     AC_MSG_RESULT($p0 $p1)
260     fi
263 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile data/Makefile \
264                  libchess/Makefile po/Makefile.in doc/cboard.6])
265 AC_OUTPUT