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