Extensive bugfix of promotion pseudo-popup
[xboard.git] / configure.ac
1 dnl| configure.in
2 dnl|
3 dnl| Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, 2007, 
4 dnl| 2008, 2009 Free Software Foundation, Inc.
5 dnl|
6 dnl| GNU XBoard is free software: you can redistribute it and/or modify
7 dnl| it under the terms of the GNU General Public License as published by
8 dnl| the Free Software Foundation, either version 3 of the License, or (at
9 dnl| your option) any later version.
10 dnl| 
11 dnl| GNU XBoard is distributed in the hope that it will be useful, but
12 dnl| WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl| General Public License for more details.
15 dnl| 
16 dnl| You should have received a copy of the GNU General Public License
17 dnl| along with this program. If not, see http://www.gnu.org/licenses/.  
18 dnl| 
19 dnl| --------------------------------------------------------------------
20 dnl|
21 dnl| You can process this file with autoconf to produce a configure script.
22 dnl| However, normally the supplied configure script will work fine.
23 dnl|
24 dnl| If you do need to change the configure script, instead of editing
25 dnl| it directly, try to edit configure.in (in a way that will keep
26 dnl| it portable to sites and systems other than your own), and run autoconf 
27 dnl| to regenerate configure.  Then submit your changes to be folded into
28 dnl| the standard version of xboard.
29
30 dnl| define second argument as VERSION.PATCHLEVEL. e.g. 4.4.0j
31 AC_INIT([xboard],[gtk-20100118],[bug-xboard@gnu.org])
32
33 AM_INIT_AUTOMAKE
34
35 AC_CONFIG_HEADERS([config.h])
36
37 dnl | a bunch of templates for defines used below
38 AH_TEMPLATE([FIRST_PTY_LETTER],[template])
39 AH_TEMPLATE([HAVE_FCNTL_H],[template])
40 AH_TEMPLATE([HAVE_GETHOSTNAME],[template])
41 AH_TEMPLATE([HAVE_GETTIMEOFDAY],[template])
42 AH_TEMPLATE([HAVE_RANDOM],[template])
43 AH_TEMPLATE([HAVE_SYS_SOCKET_H],[template])
44 AH_TEMPLATE([IBMRTAIX],[template])
45 AH_TEMPLATE([LAST_PTY_LETTER],[template])
46 AH_TEMPLATE([PTY_ITERATION],[template])
47 AH_TEMPLATE([PTY_NAME_SPRINTF],[template])
48 AH_TEMPLATE([PTY_OPEN],[template])
49 AH_TEMPLATE([PTY_TTY_NAME_SPRINTF],[template])
50 AH_TEMPLATE([REMOTE_SHELL],[template])
51 AH_TEMPLATE([RTU],[template])
52 AH_TEMPLATE([UNIPLUS],[template])
53 AH_TEMPLATE([USE_PTYS],[template])
54 AH_TEMPLATE([X_WCHAR],[template])
55 AH_TEMPLATE([ATTENTION],[template])
56 AH_TEMPLATE([DEFINED_SYS_ERRLIST],[template])
57 AH_TEMPLATE([HAVE_LIBXPM],[template])
58 AH_TEMPLATE([USE_XAW3D],[template])
59 AH_TEMPLATE([X_LOCALE],[template])
60
61
62
63 if test -z "$CFLAGS" ; then
64 dnl| Prevent the next macro from setting CFLAGS to -g
65   CFLAGS=" "
66 fi
67 AC_PROG_CC
68 AC_PROG_CPP
69 AC_ISC_POSIX
70 AC_PROG_INSTALL
71
72 AC_PROG_LEX
73 if test "$LEX" != flex; then
74   LEX="$SHELL $missing_dir/missing flex"
75   AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
76   AC_SUBST([LEXLIB], [''])
77 fi
78
79
80 AC_CHECK_PROGS(RSH, remsh rsh, rsh)
81 AC_CHECK_PROGS(MINFO, makeinfo, makeinfo_not_found)
82 if test "$MINFO" == makeinfo_not_found ; then
83    echo Please install \"makeinfo\"
84    exit 1
85 fi
86 AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$RSH")
87 AC_CHECK_PROG(NROFF, nroff, [nroff -man], cat)
88 AC_SUBST(NROFFFLAGS)
89 AC_PATH_PROGS(AWKPATH, awk mawk gawk nawk)
90 AC_PATH_PROGS(PERLPATH, perl)
91
92 PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.16.0 gmodule-export-2.0 ])
93 AC_SUBST(GTK_CFLAGS)
94 AC_SUBST(GTK_LIBS)
95
96 AC_HEADER_STDC
97 AC_HEADER_TIME
98 AC_HEADER_SYS_WAIT
99 AC_HEADER_DIRENT
100 AC_TYPE_SIGNAL
101 AC_CHECK_HEADERS(stropts.h sys/time.h string.h unistd.h sys/systeminfo.h malloc.h)
102 AC_CHECK_HEADERS(fcntl.h sys/fcntl.h, break)
103 AC_CHECK_HEADERS(sys/socket.h lan/socket.h, break)
104 AC_CHECK_HEADER(stddef.h, [], AC_DEFINE(X_WCHAR, 1))
105
106 AC_CHECK_FUNCS(_getpty grantpt setitimer usleep)
107 AC_CHECK_FUNCS(gettimeofday ftime, break)
108 AC_CHECK_FUNCS(random rand48, break)
109 AC_CHECK_FUNCS(gethostname sysinfo, break)
110 AC_CHECK_FUNC(setlocale, [],
111   AC_CHECK_LIB(i, setlocale, [], AC_DEFINE(X_LOCALE, 1)))
112
113 AC_CHECK_LIB(seq, getpseudotty)
114
115
116 dnl | check for X-libraries
117 AC_PATH_XTRA
118 if test -n "$no_x" ; then
119   echo $PACKAGE requires the X Window System header files and libraries!
120   echo They were not found on your system.  See FAQ topic C.2.
121   echo configure failed
122   exit 1
123 fi
124
125 AC_CHECK_HEADER(X11/Intrinsic.h,xt="yes",xt="no")
126
127 if test "$xt" == "no" ; then
128    echo Xt headers not found
129    exit 1
130 fi
131
132 dnl | test if user wants ot use Xaw3d headers
133 AC_ARG_WITH([Xaw3d],
134             [AS_HELP_STRING([--with-Xaw3d],
135                             [use Xaw3d instead of Xaw])],
136             [with_xaw3d=yes],
137             [with_xaw3d=no])
138
139 XAW_LIBS=
140 AS_IF([test "x$with_xaw3d" != xno],
141       [AC_CHECK_LIB([Xaw3d], 
142                     [XawTextReplace],
143                     [AC_SUBST([XAW_LIBS], 
144                               ["-lXaw3d"])
145                      AC_DEFINE([USE_XAW3D], [1],
146                                [Define if you want to use Xaw3d])],
147                     [AC_CHECK_HEADER(X11/Xaw/Dialog.h,xaw_headers="yes")
148                      AC_MSG_FAILURE(
149                                [--with-Xaw3d was given, but test for Xaw3d failed])],
150                                [-lXaw])])
151 if test "$with_xaw3d" == "no" ; then
152    XAW_LIBS="-lXaw"
153 fi
154 AC_SUBST(XAW_LIBS)
155
156 dnl | end Xaw3d test
157
158 if test "$xaw_headers" == "no" ; then
159    echo Xaw headers not found 
160    exit 1
161
162 fi
163
164
165 AC_CANONICAL_HOST
166
167 dnl| The following info is mostly gathered from GNU Emacs 19.24.  Basically,
168 dnl| we are trying to find out whether this is a System-V derivative in
169 dnl| which pipes don't work with select() and if so, whether there is anything
170 dnl| strange about the way to open a pty.  Some of the work was done above
171 dnl| by looking for _getpty, grantpt, and getpseudotty.  A few other strange
172 dnl| properties of particular systems are also handled here.
173
174 dnl| 4/6/97 I'm not sure there really are any systems where pipes
175 dnl| don't work with select(), and ptys cause problems on many
176 dnl| systems, so I'm changing the default to disable ptys in all
177 dnl| cases.  I will change it back if I get bug reports that are fixed
178 dnl| by doing a "configure --enable-ptys"
179
180 USE_PTYS=0
181 case "$host" in
182   *-*-hpux* )
183     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
184         [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
185     AC_DEFINE(PTY_NAME_SPRINTF,
186         [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
187 dnl| USE_PTYS=1
188     if test "$GCC" = yes; then
189       CONF_CFLAGS="-fwritable-strings"
190     else
191
192 dnl| Note: You might be able to build xboard even if your compiler does not
193 dnl| support ANSI C (-Aa).  xboard itself does not require ANSI C.  I don't
194 dnl| know whether the X header files on HP-UX require it.
195
196       CONF_CFLAGS="-Aa -D_HPUX_SOURCE"
197     fi
198
199 dnl| HP doesn't supply a full set of X header files and libraries.  People
200 dnl| often have some things installed in one place and some in another. 
201 dnl| AC_PATH_XTRA will find only one place, so we try to add all the
202 dnl| likely ones that might be missing here.  It might be better to
203 dnl| change AC_PATH_XTRA to try to extract this information from imake,
204 dnl| since folks who install the missing bits often configure their
205 dnl| imake to find them, but I don't want to delve into autoconf and
206 dnl| hack on its internals.
207
208     if test -d /opt/hppd/include/X11; then
209       X_CFLAGS="$X_CFLAGS -I/opt/hppd/include"
210       X_LIBS="$X_LIBS -L/opt/hppd/lib"
211     elif test -d /usr/contrib/X11R5/include; then
212       X_CFLAGS="$X_CFLAGS -I/usr/contrib/X11R5/include"
213       X_LIBS="$X_LIBS -L/usr/contrib/X11R5/lib"
214     elif test -d /usr/contrib/mitX11R5/include; then
215       X_CFLAGS="$X_CFLAGS -I/usr/contrib/mitX11R5/include"
216       X_LIBS="$X_LIBS -L/usr/contrib/mitX11R5/lib"
217     elif test -d /MIT/X11R5/include; then
218       X_CFLAGS="$X_CFLAGS -I/MIT/X11R5/include"
219       X_LIBS="$X_LIBS -L/MIT/X11R5/lib"
220     elif test -d /usr/local/include/X11R5; then
221       X_CFLAGS="$X_CFLAGS -I/usr/local/include/X11R5"
222       X_LIBS="$X_LIBS -L/usr/local/lib/X11R5"
223     fi
224     if test -d /usr/include/X11R5; then
225       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R5"
226       X_LIBS="$X_LIBS -L/usr/lib/X11R5 -L/usr/lib/X11R4"
227     elif test -d /usr/include/X11R4; then
228       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R4"
229       X_LIBS="$X_LIBS -L/usr/lib/X11R4"
230     fi
231   ;;
232
233   romp-ibm-aix* )
234     AC_DEFINE(IBMRTAIX, 1)
235 dnl| USE_PTYS=1
236   ;;
237
238   i386-ibm-aix )
239 dnl| USE_PTYS=1
240     if test "$GCC" = yes; then
241       CONF_CFLAGS="-fwritable-strings"
242     fi
243   ;;
244
245   *-*-aix3* | *-*-bosx* )
246     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
247     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
248     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
249 dnl| USE_PTYS=1
250   ;;
251
252   *-*-cxux* )
253     AC_DEFINE(FIRST_PTY_LETTER, 'A')
254     AC_DEFINE(LAST_PTY_LETTER, 'P')
255 dnl| USE_PTYS=1
256   ;;
257
258   *-*-uniplus* )
259     AC_DEFINE(UNIPLUS, 1)
260 dnl| USE_PTYS=1
261   ;;
262
263   *-*-rtu* )
264     AC_DEFINE(FIRST_PTY_LETTER, 'z')
265     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
266         [sprintf (pty_name, "/dev/ttyp%x", i);])
267     AC_DEFINE(PTY_NAME_SPRINTF,
268         [sprintf (pty_name, "/dev/pty%x", i);])
269     AC_DEFINE(RTU, 1)
270 dnl| USE_PTYS=1
271   ;;
272
273   *-*-iris* | *-*-irix3* )
274     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
275     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
276     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
277         [sprintf (pty_name, "/dev/ttyq%d", minor(stb.st_rdev));])
278 dnl| USE_PTYS=1
279   ;;
280
281   *-*-irix* )
282 dnl| USE_PTYS=1
283   ;;
284
285   *-*-sunos4* | *-*-solaris1* )
286
287 dnl| Work around a bug in the SunOS 4.x linker.  Not needed if you have patches
288 dnl|  100512-02 and 100573-03 from Sun.  The X FAQ says that the following is
289 dnl|  "overkill," but doesn't explain what should be done instead.
290
291     if test "$GCC" = yes; then
292       PRE_XMULIB="-static"
293       POST_XMULIB="-dynamic"
294     else
295       PRE_XMULIB="-Bstatic"
296       POST_XMULIB="-Bdynamic"
297     fi
298   ;;
299
300   *-*-sunos5* | *-*-solaris2* )
301 dnl| USE_PTYS=1
302
303 dnl| I'm not sure -lelf is needed, but it was in the old Imakefile.
304 dnl| The other libraries should all be found by Ac_PATH_XTRA or other
305 dnl| code above.
306
307     X_LIBS="$X_LIBS -lelf"
308   ;;
309
310   *-*-sco* )
311     AC_DEFINE(PTY_ITERATION, [for (i = 0; ; i++)])
312     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptyp%d", i);])
313     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ttyp%d", i);])
314 dnl| USE_PTYS=1
315   ;;
316         
317   *-*-dynix* | *-*-ptx* )
318 dnl| USE_PTYS=1
319   ;;
320
321   *-*-esix* )
322 dnl| USE_PTYS=1
323   ;;
324
325   *-*-usg5-4* | *-*-sysvr4* )
326 dnl| USE_PTYS=1
327   ;;
328
329   *-*-usg* | *-*-sysv* | *-*-aix* )
330 dnl| USE_PTYS=1
331   ;;
332
333   vax-*-ultrix )
334     if test "$GCC" = yes; then
335       CONF_CFLAGS="-fwritable-strings"
336     fi
337   ;;
338
339 dnl| add some libs for OS X
340   *-apple-* )
341   ;;
342 esac
343
344 AC_ARG_ENABLE(  [xpm],
345                 [AS_HELP_STRING([--enable-xpm],[libXpm will be used if found (default)])],
346                 [enable_xpm="$enableval"],
347                 [enable_xpm="yes"])
348
349 if test x"$enable_xpm" != "xno"; then
350   save_cflags="$CFLAGS"
351   CFLAGS="$CFLAGS $X_CFLAGS"
352   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
353   AC_CHECK_HEADERS(X11/xpm.h)
354   CFLAGS="$save_cflags"
355   if test "$ac_cv_header_X11_xpm_h" = "yes"; then
356     save_ldflags="$LDFLAGS"
357     LDFLAGS="$LDFLAGS $X_LIBS"
358     AC_CHECK_LIB(Xpm, XpmReadFileToPixmap,
359                  [X_PRE_LIBS="-lXpm $X_PRE_LIBS"; AC_DEFINE(HAVE_LIBXPM)], [],
360                  [$X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
361     LDFLAGS="$save_ldflags"
362   fi
363 fi
364
365 AC_SUBST(PRE_XMULIB)
366 AC_SUBST(POST_XMULIB)
367 AC_SUBST(CONF_CFLAGS)
368 AC_SUBST(CONF_LDFLAGS)
369
370 AC_MSG_CHECKING(whether ptys or pipes should be used)
371 AC_ARG_ENABLE( [ptys], 
372                [AS_HELP_STRING([--enable-ptys],[force use of pseudo-ttys with child processes])],
373 [if test "$enableval" = yes; then
374   USE_PTYS=1
375   enable_ptys="ptys"
376   AC_MSG_RESULT([ptys (user override)])
377 fi
378 if test "$enableval" = no; then
379   USE_PTYS=0
380   enable_ptys="pipes"
381   AC_MSG_RESULT([pipes (user override)])
382 fi],
383 [if test "$USE_PTYS" = 1; then
384   AC_MSG_RESULT(ptys)
385   enable_ptys="ptys"
386 else
387   AC_MSG_RESULT(pipes)
388   enable_ptys="pipes"
389 fi])
390 AC_DEFINE_UNQUOTED(USE_PTYS, $USE_PTYS)
391
392
393 dnl | define not to build zippy as a default, so that autoheader is happy
394 AC_DEFINE(ZIPPY, 0,[should zippy be enabled])
395 AC_ARG_ENABLE( [zippy], 
396                [AS_HELP_STRING([--enable-zippy],[support interfacing a chess program to ICS (default)])],
397                [], 
398                [enable_zippy="yes"])
399
400 if test x"$enable_zippy" != xno; then
401   AC_DEFINE(ZIPPY, 1,[should zippy be enabled])
402 fi
403 AM_CONDITIONAL([ZIPPY], [test x$enable_zippy != xno])
404
405
406 AC_ARG_ENABLE(sigint, 
407 [AS_HELP_STRING([--enable-sigint],[sending SIGINT (^C) wakes up GNU Chess (default)])],
408 [if test "$enableval" = yes; then
409   AC_DEFINE(ATTENTION, 1)
410 fi
411 enable_sigint=$enableval
412 ],
413 [enable_sigint="yes"
414 AC_DEFINE(ATTENTION, 1)])
415
416
417 dnl | save all information for X in X_LIBS, also add the libraries themself
418 dnl | since AC_PATH_XTRA only adds the paths
419 X_LIBS="$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lXmu -lX11 -lXt "    
420 AC_SUBST(X_CFLAGS)
421 AC_SUBST(X_LIBS)
422
423
424 AC_CONFIG_FILES([Makefile cmail])
425 AC_CONFIG_COMMANDS([test-stamp-h],[test -z "$CONFIG_HEADERS" || date > stamp-h])
426 AC_CONFIG_COMMANDS([chmod-cmail],[chmod 755 cmail])
427 AC_OUTPUT
428
429 dnl
430 dnl Output a summary
431 dnl
432 echo ""
433 echo " Configurations summary:"
434 echo ""
435 echo "        prefix:          $prefix"
436 echo "        datarootdir:     $datarootdir"
437 echo "        infodir:         $infodir"
438 echo "        sysconfdir:      $sysconfdir"
439 echo ""
440 echo "        Xaw3d:           $with_xaw3d"
441 echo ""
442 echo "        xpm:             $enable_xpm"
443 echo "        ptys:            $enable_ptys"
444 echo "        zippy:           $enable_zippy"
445 echo "        sigint:          $enable_sigint"