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