Update URL's to GitLab.
[cboard.git] / configure.ac
blob6bb6e56bf63e964a7ab3766056db6363f8929ddc
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.60)
3 AC_INIT(cboard, 0.7.4-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.19.8])
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 AC_ARG_WITH(libperl, AC_HELP_STRING([--with-libperl], [PERL support.]),
38     want_libperl=yes, want_libperl=no)
40 AC_MSG_CHECKING([if PERL support is wanted])
41 AC_MSG_RESULT($want_libperl)
43 if test "$want_libperl" = "yes"; then
44     AC_CHECK_LIB(perl, perl_run, have_libperl=yes, have_libperl=no)
46     if test "$have_libperl" = "yes"; then
47         LIBPERL_CFLAGS=`perl -MExtUtils::Embed -e ccopts`
49         if test $? -ne 0; then
50             AC_MSG_ERROR([Missing or incomplete PERL installation.])
51         fi
53         AC_SUBST(LIBPERL_CFLAGS)
54         LIBPERL_LDFLAGS=`perl -MExtUtils::Embed -e ldopts`
55         AC_SUBST(LIBPERL_LDFLAGS)
56         AC_DEFINE([WITH_LIBPERL], 1, [Define if you want PERL support.])
57     else
58         AC_MSG_ERROR([Missing or incomplete PERL installation.])
59     fi
62 AM_CONDITIONAL([WITH_LIBPERL], [test "$have_libperl" = "yes"])
63 dnl Checks for header files.
64 AC_HEADER_DIRENT
65 AC_HEADER_SYS_WAIT
66 AC_HEADER_STDC
67 AC_CHECK_HEADERS([fcntl.h paths.h sys/socket.h limits.h sys/time.h unistd.h \
68                   stdlib.h string.h strings.h wchar.h getopt.h sys/param.h \
69                   regex.h stdarg.h paths.h])
70 AC_CHECK_HEADERS([err.h],, [AC_CHECK_FUNCS([fputs_unlocked putwc_unlocked \
71                  putw_unlocked])])
73 AM_CONDITIONAL([NO_ERR_H], [test "x$ac_cv_header_err_h" = "xno"])
75 if test x"$ac_cv_header_err_h" = "xyes"; then
76     AC_MSG_CHECKING([for __progname])
77     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
78 #include <stdio.h>
79 #include <err.h>
80 extern char *__progname;
81 ]], [[
82 printf("%s\n", __progname);
83 ]])], [have_progname=yes], [have_progname=no])
84     AC_MSG_RESULT($have_progname)
85     if test x"$have_progname" = "xyes"; then
86         AC_DEFINE([HAVE_PROGNAME], 1, \
87                   [Define if your system has __progname.])
88     fi
91 AC_CHECK_HEADERS([glob.h])
92 if test x"$ac_cv_header_glob_h" = "xyes"; then
93     AC_MSG_CHECKING([if glob.h defines GLOB_NOMATCH])
94     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
95 #include <glob.h>
96 ]], [[
97 int n = GLOB_NOMATCH;
98 ]])], [have_glob_nomatch=yes], [have_glob_nomatch=no])
99     AC_MSG_RESULT($have_glob_nomatch)
100     if test x"$have_glob_nomatch" = "xyes"; then
101          AC_DEFINE([HAVE_GLOB_NOMATCH], 1, \
102                    [Define if glob.h defines GLOB_NOMATCH.])
103     fi
106 dnl Checks for typedefs, structures, and compiler characteristics.
107 AC_HEADER_STDBOOL
108 AC_C_CONST
109 AC_TYPE_PID_T
110 AC_TYPE_SIZE_T
111 AC_HEADER_TIME
112 AC_STRUCT_TM
114 dnl Checks for library functions.
115 AC_FUNC_ALLOCA
116 AC_FUNC_MEMCMP
117 AC_FUNC_VPRINTF
118 AC_FUNC_FORK
119 AC_FUNC_MALLOC
120 AC_FUNC_REALLOC
121 AC_FUNC_SELECT_ARGTYPES
122 AC_TYPE_SIGNAL
123 AC_FUNC_STAT
124 AC_FUNC_STRFTIME
125 AC_CHECK_FUNCS([bzero dup2 getcwd gethostbyname memset mkdir mkfifo regcomp \
126                 select socket strcasecmp strdup strerror strrchr strstr \
127                 vasprintf strsep strchr strncasecmp strpbrk putenv mkstemp])
129 AM_CONDITIONAL([NO_STRSEP], [test "x$ac_cv_func_strsep" = "xno"])
131 AC_DEFUN([AC_DEBUG],
133     if test "$1"; then
134         ac_cv_sys_debug=$1
135     fi
137     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
138         [ac_cv_sys_debug=no])
139     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
142 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
143     AC_DEBUG([$enableval]), AC_DEBUG)
145 AC_MSG_CHECKING([for Unix98 pty support])
146 if test -c "/dev/ptmx"; then
147     have_ptmx=yes
148 else
149     have_ptmx=no
152 ptmx_works=no
154 if test "x$have_ptmx" = "xyes"; then
155     AC_LANG([C])
156     AC_RUN_IFELSE([AC_LANG_SOURCE([[\
157                    #include <stdio.h>
158                    #include <sys/types.h>
159                    #include <sys/stat.h>
160                    #include <fcntl.h>
162                    int main()
163                    {
164                        int fd;
166                        if ((fd = open("/dev/ptmx", O_RDWR)) == -1)
167                            exit(1);
169                        if (ptsname(fd) == NULL)
170                            exit(1);
172                        exit(0);
173                    }
174                    ]])], [ptmx_works=yes], [ptmx_works=no])
176     if test "x$ptmx_works" = "xyes"; then
177         AC_MSG_RESULT([yes])
178         AC_DEFINE([UNIX98], 1, [Define if your system has Unix98 pty support.])
179     else
180         AC_MSG_RESULT([no])
181     fi
184 if test "x$have_ptmx" = "xno" -o "x$ptmx_works" = "xno"; then
185 # From the GNU Screen package.
186     AC_MSG_CHECKING([pty ranges])
187     if test -d /dev/ptym; then
188     pdir='/dev/ptym'
189     else
190     pdir='/dev'
191     fi
193     ptys=`echo $pdir/pty??`
195     if test "$ptys" != "$pdir/pty??" ; then
196     p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
197     p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\012'`
199     AC_DEFINE_UNQUOTED([PTY_MAJOR], "$p0", [Pseudo tty ranges.])
200     AC_DEFINE_UNQUOTED([PTY_MINOR], "$p1", [Pseudo tty ranges.])
201     AC_MSG_RESULT($p0 $p1)
202     fi
205 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile data/Makefile \
206                  libchess/Makefile po/Makefile.in doc/cboard.6])
207 AC_OUTPUT