HGM fixed cygwin compile for winboard
[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=pre8
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 AM_GNU_GETTEXT([external])
74
75 dnl| The following info is mostly gathered from GNU Emacs 19.24.  Basically,
76 dnl| we are trying to find out whether this is a System-V derivative in
77 dnl| which pipes don't work with select() and if so, whether there is anything
78 dnl| strange about the way to open a pty.  Some of the work was done above
79 dnl| by looking for _getpty, grantpt, and getpseudotty.  A few other strange
80 dnl| properties of particular systems are also handled here.
81
82 dnl| 4/6/97 I'm not sure there really are any systems where pipes
83 dnl| don't work with select(), and ptys cause problems on many
84 dnl| systems, so I'm changing the default to disable ptys in all
85 dnl| cases.  I will change it back if I get bug reports that are fixed
86 dnl| by doing a "configure --enable-ptys"
87
88 USE_PTYS=0
89 case "$host" in
90   *-*-hpux* )
91     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
92         [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
93     AC_DEFINE(PTY_NAME_SPRINTF,
94         [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
95 dnl| USE_PTYS=1
96     if test "$GCC" = yes; then
97       CONF_CFLAGS="-fwritable-strings"
98     else
99
100 dnl| Note: You might be able to build xboard even if your compiler does not
101 dnl| support ANSI C (-Aa).  xboard itself does not require ANSI C.  I don't
102 dnl| know whether the X header files on HP-UX require it.
103
104       CONF_CFLAGS="-Aa -D_HPUX_SOURCE"
105     fi
106
107 dnl| HP doesn't supply a full set of X header files and libraries.  People
108 dnl| often have some things installed in one place and some in another. 
109 dnl| AC_PATH_XTRA will find only one place, so we try to add all the
110 dnl| likely ones that might be missing here.  It might be better to
111 dnl| change AC_PATH_XTRA to try to extract this information from imake,
112 dnl| since folks who install the missing bits often configure their
113 dnl| imake to find them, but I don't want to delve into autoconf and
114 dnl| hack on its internals.
115
116     if test -d /opt/hppd/include/X11; then
117       X_CFLAGS="$X_CFLAGS -I/opt/hppd/include"
118       X_LIBS="$X_LIBS -L/opt/hppd/lib"
119     elif test -d /usr/contrib/X11R5/include; then
120       X_CFLAGS="$X_CFLAGS -I/usr/contrib/X11R5/include"
121       X_LIBS="$X_LIBS -L/usr/contrib/X11R5/lib"
122     elif test -d /usr/contrib/mitX11R5/include; then
123       X_CFLAGS="$X_CFLAGS -I/usr/contrib/mitX11R5/include"
124       X_LIBS="$X_LIBS -L/usr/contrib/mitX11R5/lib"
125     elif test -d /MIT/X11R5/include; then
126       X_CFLAGS="$X_CFLAGS -I/MIT/X11R5/include"
127       X_LIBS="$X_LIBS -L/MIT/X11R5/lib"
128     elif test -d /usr/local/include/X11R5; then
129       X_CFLAGS="$X_CFLAGS -I/usr/local/include/X11R5"
130       X_LIBS="$X_LIBS -L/usr/local/lib/X11R5"
131     fi
132     if test -d /usr/include/X11R5; then
133       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R5"
134       X_LIBS="$X_LIBS -L/usr/lib/X11R5 -L/usr/lib/X11R4"
135     elif test -d /usr/include/X11R4; then
136       X_CFLAGS="$X_CFLAGS -I/usr/include/X11R4"
137       X_LIBS="$X_LIBS -L/usr/lib/X11R4"
138     fi
139   ;;
140
141   romp-ibm-aix* )
142     AC_DEFINE(IBMRTAIX, 1)
143 dnl| USE_PTYS=1
144   ;;
145
146   i386-ibm-aix )
147 dnl| USE_PTYS=1
148     if test "$GCC" = yes; then
149       CONF_CFLAGS="-fwritable-strings"
150     fi
151   ;;
152
153   *-*-aix3* | *-*-bosx* )
154     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
155     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
156     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
157 dnl| USE_PTYS=1
158   ;;
159
160   *-*-cxux* )
161     AC_DEFINE(FIRST_PTY_LETTER, 'A')
162     AC_DEFINE(LAST_PTY_LETTER, 'P')
163 dnl| USE_PTYS=1
164   ;;
165
166   *-*-uniplus* )
167     AC_DEFINE(UNIPLUS, 1)
168 dnl| USE_PTYS=1
169   ;;
170
171   *-*-rtu* )
172     AC_DEFINE(FIRST_PTY_LETTER, 'z')
173     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
174         [sprintf (pty_name, "/dev/ttyp%x", i);])
175     AC_DEFINE(PTY_NAME_SPRINTF,
176         [sprintf (pty_name, "/dev/pty%x", i);])
177     AC_DEFINE(RTU, 1)
178 dnl| USE_PTYS=1
179   ;;
180
181   *-*-iris* | *-*-irix3* )
182     AC_DEFINE(PTY_ITERATION, [for (c = 0; !c; c++)])
183     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
184     AC_DEFINE(PTY_TTY_NAME_SPRINTF,
185         [sprintf (pty_name, "/dev/ttyq%d", minor(stb.st_rdev));])
186 dnl| USE_PTYS=1
187   ;;
188
189   *-*-irix* )
190 dnl| USE_PTYS=1
191   ;;
192
193   *-*-sunos4* | *-*-solaris1* )
194
195 dnl| Work around a bug in the SunOS 4.x linker.  Not needed if you have patches
196 dnl|  100512-02 and 100573-03 from Sun.  The X FAQ says that the following is
197 dnl|  "overkill," but doesn't explain what should be done instead.
198
199     if test "$GCC" = yes; then
200       PRE_XMULIB="-static"
201       POST_XMULIB="-dynamic"
202     else
203       PRE_XMULIB="-Bstatic"
204       POST_XMULIB="-Bdynamic"
205     fi
206   ;;
207
208   *-*-sunos5* | *-*-solaris2* )
209 dnl| USE_PTYS=1
210
211 dnl| I'm not sure -lelf is needed, but it was in the old Imakefile.
212 dnl| The other libraries should all be found by Ac_PATH_XTRA or other
213 dnl| code above.
214
215     X_LIBS="$X_LIBS -lelf"
216   ;;
217
218   *-*-sco* )
219     AC_DEFINE(PTY_ITERATION, [for (i = 0; ; i++)])
220     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptyp%d", i);])
221     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ttyp%d", i);])
222 dnl| USE_PTYS=1
223   ;;
224         
225   *-*-dynix* | *-*-ptx* )
226 dnl| USE_PTYS=1
227   ;;
228
229   *-*-esix* )
230 dnl| USE_PTYS=1
231   ;;
232
233   *-*-usg5-4* | *-*-sysvr4* )
234 dnl| USE_PTYS=1
235   ;;
236
237   *-*-usg* | *-*-sysv* | *-*-aix* )
238 dnl| USE_PTYS=1
239   ;;
240
241   vax-*-ultrix )
242     if test "$GCC" = yes; then
243       CONF_CFLAGS="-fwritable-strings"
244     fi
245   ;;
246 esac
247
248 AC_ARG_ENABLE(xpm,
249 [  --enable-xpm            libXpm will be used if found (default)
250   --disable-xpm           libXpm will not be used],
251 [enable_xpm="$enableval"], [enable_xpm="yes"])
252
253 if test "$enable_xpm" = "yes"; then
254   save_cflags="$CFLAGS"
255   CFLAGS="$CFLAGS $X_CFLAGS"
256   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
257   AC_CHECK_HEADERS(X11/xpm.h)
258   CFLAGS="$save_cflags"
259   if test "$ac_cv_header_X11_xpm_h" = "yes"; then
260     save_ldflags="$LDFLAGS"
261     LDFLAGS="$LDFLAGS $X_LIBS"
262     AC_CHECK_LIB(Xpm, XpmReadFileToPixmap,
263                  [X_PRE_LIBS="-lXpm $X_PRE_LIBS"; AC_DEFINE(HAVE_LIBXPM)], [],
264                  [$X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
265     LDFLAGS="$save_ldflags"
266   fi
267 fi
268
269 AC_SUBST(PRE_XMULIB)
270 AC_SUBST(POST_XMULIB)
271 AC_SUBST(CONF_CFLAGS)
272 AC_SUBST(CONF_LDFLAGS)
273
274 AC_MSG_CHECKING(whether ptys or pipes should be used)
275 AC_ARG_ENABLE(ptys, 
276 [  --enable-ptys           force use of pseudo-ttys with child processes
277   --disable-ptys          force use of pipes with child processes],
278 [if test "$enableval" = yes; then
279   USE_PTYS=1
280   AC_MSG_RESULT([ptys (user override)])
281 fi
282 if test "$enableval" = no; then
283   USE_PTYS=0
284   AC_MSG_RESULT([pipes (user override)])
285 fi],
286 [if test "$USE_PTYS" = 1; then
287   AC_MSG_RESULT(ptys)
288 else
289   AC_MSG_RESULT(pipes)
290 fi])
291 AC_DEFINE_UNQUOTED(USE_PTYS, $USE_PTYS)
292
293 AC_ARG_ENABLE(zippy, 
294 [  --enable-zippy          support interfacing a chess program to ICS (default)
295   --disable-zippy         do not support interfacing a chess program to ICS],
296 [enable_zippy="$enableval"], [enable_zippy="yes"])
297 if test "$enable_zippy" = yes; then
298   AC_DEFINE(ZIPPY, 1)
299   ZIPPY_O=zippy.o
300   ZIPPY_H=zippy.h
301 fi
302 AC_SUBST(ZIPPY_O)  
303 AC_SUBST(ZIPPY_H)  
304
305 AC_ARG_ENABLE(sigint, 
306 [  --enable-sigint         sending SIGINT (^C) wakes up GNU Chess (default)
307   --disable-sigint        typing a command wakes up GNU Chess],
308 [if test "$enableval" = yes; then
309   AC_DEFINE(ATTENTION, 1)
310 fi],
311 [AC_DEFINE(ATTENTION, 1)])
312
313 AC_DEFINE_UNQUOTED(PRODUCT, "$PRODUCT")
314 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
315 AC_DEFINE_UNQUOTED(PATCHLEVEL, "$PATCHLEVEL")
316 AC_SUBST(PRODUCT)
317 AC_SUBST(VERSION)
318 AC_SUBST(PATCHLEVEL)
319
320 AC_OUTPUT(Makefile cmail xboard.texinfo po/Makefile.in ,
321 [test -z "$CONFIG_HEADERS" || date > stamp-h
322 chmod 755 cmail
323 ])