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