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