Fix castling regression introduced in commit 9b35db4.
[cboard.git] / configure.ac
blob98d874b5cce896fb1b6b88cfae50e3aa6674d0e8
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 AC_CONFIG_SRCDIR([src/cboard.c])
9 AM_CONFIG_HEADER([config.h])
11 case "$target_os" in
12     darwin*)
13         LDFLAGS="$LDFLAGS -flat_namespace -L/sw/lib"
14         CPPFLAGS="$CPPFLAGS -I/sw/include -L/sw/lib"
15         ;;
16     *)
17         ;;
18 esac
20 dnl Checks for programs.
21 AC_PROG_CXX
22 AC_PROG_AWK
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_INSTALL
26 AC_PROG_LN_S
27 AC_PROG_MAKE_SET
28 AC_PROG_RANLIB
30 dnl Checks for library functions.
31 AX_WITH_CURSES
32 AX_WITH_CURSES_PANEL
33 AX_WITH_CURSES_MENU
34 AX_WITH_CURSES_FORM
36 AC_ARG_WITH(libperl, AC_HELP_STRING([--with-libperl], [PERL support.]),
37     want_libperl=yes, want_libperl=no)
39 AC_MSG_CHECKING([if PERL support is wanted])
40 AC_MSG_RESULT($want_libperl)
42 if test "$want_libperl" = "yes"; then
43     AC_CHECK_LIB(perl, perl_run, have_libperl=yes, have_libperl=no)
45     if test "$have_libperl" = "yes"; then
46         LIBPERL_CFLAGS=`perl -MExtUtils::Embed -e ccopts`
48         if test $? -ne 0; then
49             AC_MSG_ERROR([Missing or incomplete PERL installation.])
50         fi
52         AC_SUBST(LIBPERL_CFLAGS)
53         LIBPERL_LDFLAGS=`perl -MExtUtils::Embed -e ldopts`
54         AC_SUBST(LIBPERL_LDFLAGS)
55         AC_DEFINE([WITH_LIBPERL], 1, [Define if you want PERL support.])
56     else
57         AC_MSG_ERROR([Missing or incomplete PERL installation.])
58     fi
61 AM_CONDITIONAL([WITH_LIBPERL], [test "$have_libperl" = "yes"])
62 dnl Checks for header files.
63 AC_HEADER_DIRENT
64 AC_HEADER_SYS_WAIT
65 AC_HEADER_STDC
66 AC_CHECK_HEADERS([fcntl.h paths.h sys/socket.h limits.h sys/time.h unistd.h \
67                   stdlib.h string.h strings.h curses.h panel.h form.h wchar.h \
68                   getopt.h sys/param.h regex.h glob.h stdarg.h paths.h])
69 AC_CHECK_HEADERS([err.h],, [AC_CHECK_FUNCS([fputs_unlocked putwc_unlocked \
70                  putw_unlocked])])
72 AM_CONDITIONAL([NO_ERR_H], [test "x$ac_cv_header_err_h" = "xno"])
74 AC_TRY_COMPILE([#include <curses.h>], [attr_t n = 0;],
75                AC_DEFINE([HAVE_ATTR_T], 1, \
76                          [Define if your curses installation contains attr_t.]))
78 AC_TRY_LINK([#include <err.h>], [extern char *__progname;],
79                AC_DEFINE([HAVE_PROGNAME], 1, \
80                          [Define if your system has __progname.]))
82 AC_TRY_COMPILE([#include <glob.h>], [int n = GLOB_NOMATCH;],
83                AC_DEFINE([HAVE_GLOB_NOMATCH], 1, \
84                          [Define if glob.h defines GLOB_NOMATCH.]))
86 AC_TRY_COMPILE([#include <form.h>], [FIELDTYPE *t = TYPE_IPV4;],
87                AC_DEFINE([HAVE_TYPE_IPV4], 1, \
88                          [Define if form.h defines TYPE_IPV4.]))
90 dnl Checks for typedefs, structures, and compiler characteristics.
91 AC_HEADER_STDBOOL
92 AC_C_CONST
93 AC_TYPE_PID_T
94 AC_TYPE_SIZE_T
95 AC_HEADER_TIME
96 AC_STRUCT_TM
98 dnl Checks for library functions.
99 AC_FUNC_ALLOCA
100 AC_FUNC_MEMCMP
101 AC_FUNC_VPRINTF
102 AC_FUNC_FORK
103 AC_FUNC_MALLOC
104 AC_FUNC_REALLOC
105 AC_FUNC_SELECT_ARGTYPES
106 AC_TYPE_SIGNAL
107 AC_FUNC_STAT
108 AC_FUNC_STRFTIME
109 AC_CHECK_FUNCS([bzero dup2 getcwd gethostbyname memset mkdir mkfifo regcomp \
110                 select socket strcasecmp strdup strerror strrchr strstr \
111                 vasprintf strsep strchr strncasecmp strpbrk putenv])
112 AC_FUNC_ALLOCA
113 AC_FUNC_FORK
114 AC_FUNC_MALLOC
115 AC_FUNC_REALLOC
117 AM_CONDITIONAL([NO_STRSEP], [test "x$ac_cv_func_strsep" = "xno"])
119 AC_TRY_LINK([#include <curses.h>], [WINDOW *w; wresize(w, 0, 0);],
120            AC_DEFINE([HAVE_WRESIZE], 1, \
121                      [Define if your curses installation contains wresize().]))
123 AC_DEFUN([AC_DEBUG],
125     if test "$1"; then
126         ac_cv_sys_debug=$1
127     fi
129     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
130         [ac_cv_sys_debug=no])
131     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
134 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
135     AC_DEBUG([$enableval]), AC_DEBUG)
137 AC_MSG_CHECKING([for Unix98 pty support])
138 if test -c "/dev/ptmx"; then
139     have_ptmx=yes
140 else
141     have_ptmx=no
144 ptmx_works=no
146 if test "x$have_ptmx" = "xyes"; then
147     AC_LANG([C])
148     AC_RUN_IFELSE([AC_LANG_SOURCE([[\
149                    #include <stdio.h>
150                    #include <sys/types.h>
151                    #include <sys/stat.h>
152                    #include <fcntl.h>
154                    int main()
155                    {
156                        int fd;
158                        if ((fd = open("/dev/ptmx", O_RDWR)) == -1)
159                            exit(1);
161                        if (ptsname(fd) == NULL)
162                            exit(1);
164                        exit(0);
165                    }
166                    ]])], [ptmx_works=yes], [ptmx_works=no])
168     if test "x$ptmx_works" = "xyes"; then
169         AC_MSG_RESULT([yes])
170         AC_DEFINE([UNIX98], 1, [Define if your system has Unix98 pty support.])
171     else
172         AC_MSG_RESULT([no])
173     fi
176 if test "x$have_ptmx" = "xno" -o "x$ptmx_works" = "xno"; then
177 # From the GNU Screen package.
178     AC_MSG_CHECKING([pty ranges])
179     if test -d /dev/ptym; then
180     pdir='/dev/ptym'
181     else
182     pdir='/dev'
183     fi
185     ptys=`echo $pdir/pty??`
187     if test "$ptys" != "$pdir/pty??" ; then
188     p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
189     p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
191     AC_DEFINE_UNQUOTED([PTY_MAJOR], "$p0", [Pseudo tty ranges.])
192     AC_DEFINE_UNQUOTED([PTY_MINOR], "$p1", [Pseudo tty ranges.])
193     AC_MSG_RESULT($p0 $p1)
194     fi
197 AM_WITH_DMALLOC
199 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile data/Makefile \
200                  libchess/Makefile])
201 AC_OUTPUT