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