c7f55f6b0735db0ec7c5a3bfad17656b7c521f2f
[xboard.git] / configure.in
1 dnl| configure.in
2 dnl|
3 dnl| You can process this file with autoconf to produce a configure script.
4 dnl| However, normally the supplied configure script will work fine.
5 dnl|
6 dnl| If you do need to change the configure script, instead of editing
7 dnl| it directly, try to edit configure.in (in a way that will keep
8 dnl| it portable to sites and systems other than your own), and run autoconf 
9 dnl| to regenerate configure.  Then submit your changes to be folded into
10 dnl| the standard version of xboard.
11
12 AC_INIT(xboard.c)
13 AC_CONFIG_HEADER(config.h)
14
15 PRODUCT=xboard
16 VERSION=4.2
17 PATCHLEVEL=7
18
19 if test -z "$CFLAGS" ; then
20 dnl| Prevent the next macro from setting CFLAGS to -g
21   CFLAGS=" "
22 fi
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_ISC_POSIX
26 AC_PROG_INSTALL
27 AC_CHECK_PROGS(LEX, lex flex, lex_not_found)
28 if test "$LEX" != lex_not_found ; then
29   AC_DECL_YYTEXT
30 fi
31 AC_CHECK_PROGS(RSH, remsh rsh, rsh)
32 AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$RSH")
33 AC_CHECK_PROG(NROFF, nroff, [nroff -man], cat)
34 AC_SUBST(NROFFFLAGS)
35 AC_PATH_PROGS(AWKPATH, awk mawk gawk nawk)
36 AC_PATH_PROGS(PERLPATH, perl)
37
38 AC_ARG_WITH(Xaw3d, [  --with-Xaw3d            use Xaw3d instead of Xaw],
39   [AC_DEFINE(USE_XAW3D)
40    XAW_LIBS="-lXaw3d"],
41   XAW_LIBS="-lXaw")
42 AC_SUBST(XAW_LIBS)
43
44 AC_HEADER_STDC
45 AC_HEADER_TIME
46 AC_HEADER_SYS_WAIT
47 AC_HEADER_DIRENT
48 AC_TYPE_SIGNAL
49 AC_CHECK_HEADERS(stropts.h sys/time.h string.h unistd.h sys/systeminfo.h)
50 AC_CHECK_HEADERS(fcntl.h sys/fcntl.h, break)
51 AC_CHECK_HEADERS(sys/socket.h lan/socket.h, break)
52 AC_CHECK_HEADER(stddef.h, [], AC_DEFINE(X_WCHAR, 1))
53
54 AC_CHECK_FUNCS(_getpty grantpt setitimer usleep)
55 AC_CHECK_FUNCS(gettimeofday ftime, break)
56 AC_CHECK_FUNCS(random rand48, break)
57 AC_CHECK_FUNCS(gethostname sysinfo, break)
58 AC_CHECK_FUNC(setlocale, [],
59   AC_CHECK_LIB(i, setlocale, [], AC_DEFINE(X_LOCALE, 1)))
60
61 AC_CHECK_LIB(seq, getpseudotty)
62
63 AC_PATH_XTRA
64 if test -n "$no_x" ; then
65   echo $PRODUCT requires the X Window System header files and libraries!
66   echo They were not found on your system.  See FAQ topic C.2.
67   echo configure failed
68   exit 1
69 fi
70
71 AC_CANONICAL_HOST
72
73 dnl| The following info is mostly gathered from GNU Emacs 19.24.  Basically,
74 dnl| we are trying to find out whether this is a System-V derivative in
75 dnl| which pipes don't work with select() and if so, whether there is anything
76 dnl| strange about the way to open a pty.  Some of the work was done above
77 dnl| by looking for _getpty, grantpt, and getpseudotty.  A few other strange
78 dnl| properties of particular systems are also handled here.
79
80 dnl| 4/6/97 I'm not sure there really are any systems where pipes
81 dnl| don't work with select(), and ptys cause problems on many
82 dnl| systems, so I'm changing the default to disable ptys in all
83 dnl| cases.  I will change it back if I get bug reports that are fixed
84 dnl| by doing a "configure --enable-ptys"
85
86 USE_PTYS=0
87 case "$host" in
88   *-*-hpux* )
89     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
90         [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
91     AC_DEFINE(PTY_NAME_SPRINTF,
92         [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
93 dnl| USE_PTYS=1
94     if test "$GCC" = yes; then
95       CONF_CFLAGS="-fwritable-strings"
96     else
97
98 dnl| Note: You might be able to build xboard even if your compiler does not
99 dnl| support ANSI C (-Aa).  xboard itself does not require ANSI C.  I don't
100 dnl| know whether the X header files on HP-UX require it.
101
102       CONF_CFLAGS="-Aa -D_HPUX_SOURCE"
103     fi
104
105 dnl| HP doesn't supply a full set of X header files and libraries.  People
106 dnl| often have some things installed in one place and some in another. 
107 dnl| AC_PATH_XTRA will find only one place, so we try to add all the
108 dnl| likely ones that might be missing here.  It might be better to
109 dnl| change AC_PATH_XTRA to try to extract this information from imake,
110 dnl| since folks who install the missing bits often configure their
111 dnl| imake to find them, but I don't want to delve into autoconf and
112 dnl| hack on its internals.
113
114     if test -d /opt/hppd/include/X11; then
115       X_CFLAGS="$X_CFLAGS -I/opt/hppd/include"
116       X_LIBS="$X_LIBS -L/opt/hppd/lib"
117     elif test -d /usr/contrib/X11R5/include; then
118       X_CFLAGS="$X_CFLAGS -I/usr/contrib/X11R5/include"
119       X_LIBS="$X_LIBS -L/usr/contrib/X11R5/lib"
120     elif test -d /usr/contrib/mitX11R5/include; then
121       X_CFLAGS="$X_CFLAGS -I/usr/contrib/mitX11R5/include"
122       X_LIBS="$X_LIBS -L/usr/contrib/mitX11R5/lib"
123     elif test -d /MIT/X11R5/include; then
124       X_CFLAGS="$X_CFLAGS -I/MIT/X11R5/include"
125       X_LIBS="$X_LIBS -L/MIT/X11R5/lib"
126     elif test -d /usr/local/include/X11R5; then
127       X_CFLAGS="$X_CFLAGS -I/usr/local/include/X11R5"
128       X_LIBS="$X_LIBS -L/usr/local/lib/X11R5"
129     fi
130     if test -d /usr/include/X11R5; then
131       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R5"
132       X_LIBS="$X_LIBS -L/usr/lib/X11R5 -L/usr/lib/X11R4"
133     elif test -d /usr/include/X11R4; then
134       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R4"
135       X_LIBS="$X_LIBS -L/usr/lib/X11R4"
136     fi
137   ;;
138
139   romp-ibm-aix* )
140     AC_DEFINE(IBMRTAIX, 1)
141 dnl| USE_PTYS=1
142   ;;
143
144   i386-ibm-aix )
145 dnl| USE_PTYS=1
146     if test "$GCC" = yes; then
147       CONF_CFLAGS="-fwritable-strings"
148     fi
149   ;;
150
151   *-*-aix3* | *-*-bosx* )
152     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
153     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
154     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
155 dnl| USE_PTYS=1
156   ;;
157
158   *-*-cxux* )
159     AC_DEFINE(FIRST_PTY_LETTER, 'A')
160     AC_DEFINE(LAST_PTY_LETTER, 'P')
161 dnl| USE_PTYS=1
162   ;;
163
164   *-*-uniplus* )
165     AC_DEFINE(UNIPLUS, 1)
166 dnl| USE_PTYS=1
167   ;;
168
169   *-*-rtu* )
170     AC_DEFINE(FIRST_PTY_LETTER, 'z')
171     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
172         [sprintf (pty_name, "/dev/ttyp%x", i);])
173     AC_DEFINE(PTY_NAME_SPRINTF,
174         [sprintf (pty_name, "/dev/pty%x", i);])
175     AC_DEFINE(RTU, 1)
176 dnl| USE_PTYS=1
177   ;;
178
179   *-*-iris* | *-*-irix3* )
180     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
181     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
182     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
183         [sprintf (pty_name, "/dev/ttyq%d", minor(stb.st_rdev));])
184 dnl| USE_PTYS=1
185   ;;
186
187   *-*-irix* )
188 dnl| USE_PTYS=1
189   ;;
190
191   *-*-sunos4* | *-*-solaris1* )
192
193 dnl| Work around a bug in the SunOS 4.x linker.  Not needed if you have patches
194 dnl|  100512-02 and 100573-03 from Sun.  The X FAQ says that the following is
195 dnl|  "overkill," but doesn't explain what should be done instead.
196
197     if test "$GCC" = yes; then
198       PRE_XMULIB="-static"
199       POST_XMULIB="-dynamic"
200     else
201       PRE_XMULIB="-Bstatic"
202       POST_XMULIB="-Bdynamic"
203     fi
204   ;;
205
206   *-*-sunos5* | *-*-solaris2* )
207 dnl| USE_PTYS=1
208
209 dnl| I'm not sure -lelf is needed, but it was in the old Imakefile.
210 dnl| The other libraries should all be found by Ac_PATH_XTRA or other
211 dnl| code above.
212
213     X_LIBS="$X_LIBS -lelf"
214   ;;
215
216   *-*-sco* )
217     AC_DEFINE(PTY_ITERATION, [for (i = 0; ; i++)])
218     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptyp%d", i);])
219     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ttyp%d", i);])
220 dnl| USE_PTYS=1
221   ;;
222         
223   *-*-dynix* | *-*-ptx* )
224 dnl| USE_PTYS=1
225   ;;
226
227   *-*-esix* )
228 dnl| USE_PTYS=1
229   ;;
230
231   *-*-usg5-4* | *-*-sysvr4* )
232 dnl| USE_PTYS=1
233   ;;
234
235   *-*-usg* | *-*-sysv* | *-*-aix* )
236 dnl| USE_PTYS=1
237   ;;
238
239   vax-*-ultrix )
240     if test "$GCC" = yes; then
241       CONF_CFLAGS="-fwritable-strings"
242     fi
243   ;;
244 esac
245
246 AC_ARG_ENABLE(xpm,
247 [  --enable-xpm            libXpm will be used if found (default)
248   --disable-xpm           libXpm will not be used],
249 [enable_xpm="$enableval"], [enable_xpm="yes"])
250
251 if test "$enable_xpm" = "yes"; then
252   save_cflags="$CFLAGS"
253   CFLAGS="$CFLAGS $X_CFLAGS"
254   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
255   AC_CHECK_HEADERS(X11/xpm.h)
256   CFLAGS="$save_cflags"
257   if test "$ac_cv_header_X11_xpm_h" = "yes"; then
258     save_ldflags="$LDFLAGS"
259     LDFLAGS="$LDFLAGS $X_LIBS"
260     AC_CHECK_LIB(Xpm, XpmReadFileToPixmap,
261                  [X_PRE_LIBS="-lXpm $X_PRE_LIBS"; AC_DEFINE(HAVE_LIBXPM)], [],
262                  [$X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
263     LDFLAGS="$save_ldflags"
264   fi
265 fi
266
267 AC_SUBST(PRE_XMULIB)
268 AC_SUBST(POST_XMULIB)
269 AC_SUBST(CONF_CFLAGS)
270 AC_SUBST(CONF_LDFLAGS)
271
272 AC_MSG_CHECKING(whether ptys or pipes should be used)
273 AC_ARG_ENABLE(ptys, 
274 [  --enable-ptys           force use of pseudo-ttys with child processes
275   --disable-ptys          force use of pipes with child processes],
276 [if test "$enableval" = yes; then
277   USE_PTYS=1
278   AC_MSG_RESULT([ptys (user override)])
279 fi
280 if test "$enableval" = no; then
281   USE_PTYS=0
282   AC_MSG_RESULT([pipes (user override)])
283 fi],
284 [if test "$USE_PTYS" = 1; then
285   AC_MSG_RESULT(ptys)
286 else
287   AC_MSG_RESULT(pipes)
288 fi])
289 AC_DEFINE_UNQUOTED(USE_PTYS, $USE_PTYS)
290
291 AC_ARG_ENABLE(zippy, 
292 [  --enable-zippy          support interfacing a chess program to ICS (default)
293   --disable-zippy         do not support interfacing a chess program to ICS],
294 [enable_zippy="$enableval"], [enable_zippy="yes"])
295 if test "$enable_zippy" = yes; then
296   AC_DEFINE(ZIPPY, 1)
297   ZIPPY_O=zippy.o
298   ZIPPY_H=zippy.h
299 fi
300 AC_SUBST(ZIPPY_O)  
301 AC_SUBST(ZIPPY_H)  
302
303 AC_ARG_ENABLE(sigint, 
304 [  --enable-sigint         sending SIGINT (^C) wakes up GNU Chess (default)
305   --disable-sigint        typing a command wakes up GNU Chess],
306 [if test "$enableval" = yes; then
307   AC_DEFINE(ATTENTION, 1)
308 fi],
309 [AC_DEFINE(ATTENTION, 1)])
310
311 AC_DEFINE_UNQUOTED(PRODUCT, "$PRODUCT")
312 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
313 AC_DEFINE_UNQUOTED(PATCHLEVEL, "$PATCHLEVEL")
314 AC_SUBST(PRODUCT)
315 AC_SUBST(VERSION)
316 AC_SUBST(PATCHLEVEL)
317
318 AC_OUTPUT(Makefile cmail xboard.texinfo,
319 [test -z "$CONFIG_HEADERS" || date > stamp-h
320 chmod 755 cmail
321 ])