Updated README: Equal sign not required with `--mode` flag.
[sgk-go] / configure.in
CommitLineData
7eeb782e
AT
1dnl Process this file with autoconf to produce a configure script.
2
3dnl *****************************************************************
4dnl IMPORTANT: Don't forget to add corresponding output for --options
5dnl if you add a non-trivial configure option here.
6dnl *****************************************************************
7
8dnl this is to determine if the config script is running in the proper place
9dnl just give it one file relative to where it should be
10AC_INIT([gnugo], [3.8])
11AC_CONFIG_SRCDIR([engine/dragon.c])
12
13AM_CONFIG_HEADER(config.h)
14AC_PREREQ(2.52)dnl dnl Minimum Autoconf version required.
15
16AH_TEMPLATE([PACKAGE],
17[Define to the name of the distribution.])
18
19AH_TEMPLATE([GNU_PACKAGE],
20[The concatenation of the strings "GNU ", and PACKAGE.])
21
22AH_TEMPLATE([VERSION],
23[Define to the version of the distribution.])
24
25dnl this defines VERSION and PACKAGE
26AM_INIT_AUTOMAKE
27GNU_PACKAGE="GNU $PACKAGE"
28AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE")
29
30AM_MAINTAINER_MODE
31
32dnl See if user has expressed a preference for use of curses and/or color
33dnl These set variables $enable_color and $with_curses to "no" if disabled
34dnl "yes" if enabled, or undefined if not specified
35
36AC_ARG_WITH(readline,
37 [ --with-readline try to use GNU Readline for command reading
38 --without-readline do not use GNU Readline (default)])
39
40AC_ARG_WITH(curses,
41 [ --with-curses try to use curses for colored debugging output (default)
42 --without-curses do not use curses for colored debugging output])
43
44AC_ARG_ENABLE(color,
45 [ --enable-color use curses or ansi escape sequences for colored
46 debug output
47 --disable-color do not try to generated colored debug output])
48
49dnl and look to see if they want to disable the grid optimisation
50
51AC_ARG_ENABLE(grid-opt,
52 [ --enable-grid-opt enable the grid optimisation within the pattern
53 matcher (default)
54 --enable-grid-opt=distrust enable the grid optimisation in non-trusting mode
55 --disable-grid-opt disable the grid optimisation])
56
57default_cache_size=-1
58default_level=10
59default_semeai_node_limit=500
60default_owl_node_limit=1000
61
62AC_ARG_ENABLE(cache-size,
63 [ --enable-cache-size=n reserve n MB RAM for caching (special value -1
64 default, corresponding to 8-11 MB depending on
65 platform)])
66
67AC_ARG_ENABLE(level,
68 [ --enable-level=n n = default level (10 standard)])
69
70AC_ARG_ENABLE(semeai-node-limit,
71 [ --enable-semeai-node-limit=n n = semeai variations (500 standard)])
72
73AC_ARG_ENABLE(level,
74 [ --enable-owl-node-limit=n n = owl node limit (1000 standard)])
75
76AC_ARG_ENABLE(dfa,
77 [ --disable-dfa use old non-dfa pattern matcher],
78 [ if test ${enableval} = no; then
79 dfa_c=
80 else
81 dfa_c=dfa
82 fi] ,
83 [ dfa_c=dfa ])
84
85AC_ARG_ENABLE(chinese-rules,
86 [ --enable-chinese-rules use Chinese (area) counting
87 --disable-chinese-rules use Japanese counting (default)])
88
89AC_ARG_ENABLE(resignation-allowed,
90 [ --enable-resignation-allowed resign lost games (default)
91 --disable-resignation-allowed never resign])
92
93AC_ARG_ENABLE(metamachine,
94 [ --enable-metamachine enable metamachine
95 --disable-metamachine don't enable metamachine (default)])
96
97AC_ARG_ENABLE(experimental-break-in,
98 [ --enable-experimental-break-in use the breakin module (default)
99 --disable-experimental-break-in don't use the breakin module])
100
101AC_ARG_ENABLE(experimental-owl-ext,
102 [ --enable-experimental-owl-ext use the experimental GAIN/LOSS codes
103 --disable-experimental-owl-ext use standard owl module (default)])
104
105AC_ARG_ENABLE(cosmic-gnugo,
106 [ --enable-cosmic-gnugo use center-oriented influence code
107 --disable-cosmic-gnugo use standard influence code (default)])
108
109AC_ARG_ENABLE(large-scale,
110 [ --enable-large-scale look for large scale captures
111 --disable-large-scale don't seek large scale captures (default)])
112
113AC_ARG_ENABLE(experimental-connections,
114 [ --enable-experimental-connections use experimental connection analysis
115 (default)
116 --disable-experimental-connections use standard connection analysis])
117
118AC_ARG_ENABLE(alternate-connections,
119 [ --enable-alternate-connections use alternate experimental connection
120 analysis
121 --disable-alternate-connections use primary experimental connection
122 analysis (default)])
123
124AC_ARG_ENABLE(socket-support,
125 [ --disable-socket-support don't compile GTP over TCP/IP support
126 --enable-socket-support compile TCP/IP support (default)])
127
128AC_PROG_CC
129
130dnl for automake 1.4.x
131AC_EXEEXT
132
133dnl add -lm to library list since we use some
134dnl math functions such as pow and fabs
135
136AC_SEARCH_LIBS(pow,m)
137
138AC_CACHE_CHECK(
139 [for mingw32],
140 ac_cv_mingw32,
141 AC_TRY_COMPILE(,
142 [return __MINGW32__],
143 ac_cv_mingw32="yes",
144 ac_cv_mingw32="no")
145)
146
147if test $ac_cv_mingw32 = yes;then
148 LIBS="$LIBS -lwsock32"
149 AC_SEARCH_LIBS(vsnprintf, mingwex)
150fi
151
152AC_PROG_CPP
153AC_PROG_RANLIB
154
155dnl required since we use SUBDIRS in Makefile.am
156AC_PROG_MAKE_SET
157
158AC_HEADER_TIME
159
160AC_C_CONST
161
162AC_CHECK_HEADERS(unistd.h sys/time.h sys/times.h)
163AC_CHECK_HEADERS(curses.h term.h ncurses/curses.h ncurses/term.h)
164
165if test "$ac_cv_header_curses_h" = "yes";then
166 curses_header="curses.h"
167elif test "$ac_cv_header_ncurses_curses_h" = "yes";then
168 curses_header="ncurses/curses.h"
169else
170 curses_header="no"
171fi
172
173if test "$ac_cv_header_term_h" = "yes";then
174 term_header="term.h"
175elif test "$ac_cv_header_ncurses_term_h" = "yes";then
176 term_header="ncurses/term.h"
177else
178 term_header="no"
179fi
180
181AC_CHECK_SIZEOF(long,,[#include <stdio.h>])
182
183dnl vsnprintf not universally available
184dnl usleep not available in Unicos and mingw32
185AC_CHECK_FUNCS(vsnprintf gettimeofday usleep times)
186
187dnl if snprintf not available try to use g_snprintf from GLib
188if test $ac_cv_func_vsnprintf = no; then
189 AC_CHECK_PROG(glibconfig,glib-config,yes,no)
190 if test $ac_cv_prog_glibconfig = yes;then
191 glib_cflags=`glib-config --cflags`
192 glib_libs=`glib-config --libs`
193 CPPFLAGS="$CPPFLAGS $glib_cflags"
194 LIBS="$LIBS $glib_libs"
195 AC_CHECK_FUNCS(g_vsnprintf)
196 AC_CHECK_HEADERS(glib.h)
197 if test $ac_cv_func_g_vsnprintf = no; then
198 AC_MSG_WARN([GLib installation problem.
199 Continuing without GLib ])
200 fi
201 else
202 AC_MSG_WARN([Neither vsnprintf nor GLib found. GNU Go is
203 compiled but it is safer to get GLib at
204 http://www.gtk.org/])
205 fi
206fi
207
208dnl ------ variadic #define -----------------------
209
210AH_TEMPLATE([HAVE_VARIADIC_DEFINE],
211[Define if #define can take a variable number of arguments])
212
213AC_CACHE_CHECK(
214 [for variadic cpp define],
215 gnugo_cv_cpp_variadic_define,
216 AC_TRY_COMPILE(
217[#include <stdio.h>
218#define zz(fmt,arg...) printf(fmt,##arg)],
219 [zz("Hello");zz("%s","Hello");zz("%s%s","Hello","World")],
220 gnugo_cv_cpp_variadic_define="yes",
221 gnugo_cv_cpp_variadic_define="no")
222)
223if test "$gnugo_cv_cpp_variadic_define" = "yes";then
224 AC_DEFINE(HAVE_VARIADIC_DEFINE)
225fi
226
227dnl ------ transparent unions ---------------------
228
229AH_TEMPLATE([HAVE_TRANSPARENT_UNIONS],
230[Define if your compiler supports transparent unions])
231
232AC_CACHE_CHECK(
233 [whether $CC supports transparent unions],
234 gnugo_cv_transparent_unions,
235 AC_TRY_COMPILE([],
236[[ struct {
237 union {
238 int x;
239 float y;
240 }
241 } A = { { .y = 0.0 } };
242 A.y = 1.0;]],
243 gnugo_cv_transparent_unions="yes",
244 gnugo_cv_transparent_unions="no")
245)
246
247if test "$gnugo_cv_transparent_unions" = "yes"; then
248 AC_DEFINE(HAVE_TRANSPARENT_UNIONS)
249fi
250
251dnl -------- color debugging support -----------
252
253AH_TEMPLATE([TERMINFO],
254[Define to 1 if termcap/terminfo is available.])
255
256AH_TEMPLATE([ANSI_COLOR],
257[Define to use ansi escape sequences for color debugging])
258
259tmp_color_result="none"
260
261if test "$with_curses" != no -a "$enable_color" != no ; then
262 tmp_color_result="none (curses failed)"
263
264 dnl Do a separate test for curses and termcap
265 dnl DJGPP does have pdcurses, but not termcap
266
267 dnl make sure that both curses.h and term.h are available
268 dnl FIXME: better to actually figure out here what headers
269 dnl are really required
270 if test "$term_header" != "no" -a "$curses_header" != "no" ; then
271
272 dnl check for a working termcap library
273 AC_SEARCH_LIBS(tparm,ncurses curses pdcurses termcap terminfo termlib)
274
275 if test "$ac_cv_search_tparm" != "no" ; then
276 AC_DEFINE(TERMINFO)
277 tmp_color_result="curses"
278 fi
279 fi
280fi
281
282if test "$with_curses" = no -a "$enable_color" != no ; then
283 dnl we asked for color, but there is no termcap
284 AC_DEFINE(ANSI_COLOR)
285 tmp_color_result="ANSI color"
286
287fi
288
289AC_MSG_CHECKING(for color support)
290AC_MSG_RESULT($tmp_color_result)
291
292dnl -------- readline support -------------------
293
294AH_TEMPLATE([READLINE], [Enable GNU Readline support])
295
296if test "$with_readline" = yes ; then
297
298 dnl check for a working termcap and readline library
299 AC_SEARCH_LIBS(readline,termcap readline)
300
301 if test "$ac_cv_search_readline" != "no" ; then
302 AC_DEFINE(READLINE,1)
303 else
304 AC_DEFINE(READLINE,0)
305 fi
306else
307 AC_DEFINE(READLINE,0)
308fi
309
310dnl ---------- grid optimisation ------------
311
312AH_TEMPLATE([GRID_OPT],
313[Define as 1 to use the grid optimisation, or 2 to run it in self-test mode])
314
315if test "$enable_grid_opt" = "distrust" ; then
316 AC_DEFINE(GRID_OPT, 2)
317else
318 if test "$enable_grid_opt" = "no" ; then
319 AC_DEFINE(GRID_OPT, 0)
320 else
321 AC_DEFINE(GRID_OPT, 1)
322 fi
323fi
324
325
326dnl ------------ set cache size ----------
327
328AH_TEMPLATE([DEFAULT_MEMORY],
329[Default hash table size in megabytes])
330
331if test "$enable_cache_size" ; then
332 AC_DEFINE_UNQUOTED(DEFAULT_MEMORY, $enable_cache_size)
333else
334 AC_DEFINE_UNQUOTED(DEFAULT_MEMORY, $default_cache_size)
335fi
336
337
338dnl ------------ set default level ----------
339
340AH_TEMPLATE([DEFAULT_LEVEL],
341[Default level (strength). Up to 10 supported])
342
343if test "$enable_level" ; then
344 AC_DEFINE_UNQUOTED(DEFAULT_LEVEL, $enable_level)
345else
346 AC_DEFINE_UNQUOTED(DEFAULT_LEVEL, $default_level)
347fi
348
349dnl ------------ set cache size ----------
350
351AH_TEMPLATE([OWL_NODE_LIMIT],
352[Owl Node Limit])
353
354if test "$enable_owl_node_limit" ; then
355 AC_DEFINE_UNQUOTED(OWL_NODE_LIMIT, $enable_owl_node_limit)
356else
357 AC_DEFINE_UNQUOTED(OWL_NODE_LIMIT, $default_owl_node_limit)
358fi
359
360
361dnl ------------ set semeai variations ----------
362
363AH_TEMPLATE([SEMEAI_NODE_LIMIT],
364[Semeai Variations. 500 default])
365
366if test "$enable_semeai_node_limit" ; then
367 AC_DEFINE_UNQUOTED(SEMEAI_NODE_LIMIT, $enable_semeai_node_limit)
368else
369 AC_DEFINE_UNQUOTED(SEMEAI_NODE_LIMIT, $default_semeai_node_limit)
370fi
371
372dnl ------------ dfa -------------------
373
374AM_CONDITIONAL(DFA_ENABLED, test "$enable_dfa" != "no")
375
376dnl FIXME: Is there a more elegant approach for this?
377dnl force owl c files rebuild
378rm -f \
379 patterns/owl_attackpat.c \
380 patterns/owl_defendpat.c \
381 patterns/owl_vital_apat.c
382
383
384dnl ------------ Chinese Rules -------------------
385
386AH_TEMPLATE([CHINESE_RULES],
387[Ruleset. Default Japanese])
388
389if test "$enable_chinese_rules" = "yes" ; then
390 AC_DEFINE(CHINESE_RULES, 1)
391else
392 AC_DEFINE(CHINESE_RULES, 0)
393fi
394
395dnl ------------ Resignation allowed-------------------
396
397AH_TEMPLATE([RESIGNATION_ALLOWED],
398[Allow resignation. Default enabled])
399
400if test "$disable_resignation_allowed" = "yes" ; then
401 AC_DEFINE(RESIGNATION_ALLOWED, 0)
402else
403 AC_DEFINE(RESIGNATION_ALLOWED, 1)
404fi
405
406dnl ------------ Oracle enabled-------------------
407
408AH_TEMPLATE([ORACLE],
409[Oracle. Default not enabled.])
410
411if test "$enable_metamachine" = "yes" ; then
412 AC_DEFINE(ORACLE, 1)
413else
414 AC_DEFINE(ORACLE, 0)
415fi
416
417dnl ------------ Experimental Breakin enabled-------------------
418
419AH_TEMPLATE([USE_BREAK_IN],
420[Break-in module. Enabled by default.])
421
422if test "$enable_experimental_break_in" = "no" ; then
423 AC_DEFINE(USE_BREAK_IN, 0)
424else
425 AC_DEFINE(USE_BREAK_IN, 1)
426fi
427
428dnl ------------ Owl extensions ------------
429
430AH_TEMPLATE([EXPERIMENTAL_OWL_EXT],
431[GAIN/LOSS codes. Disabled by default.])
432
433if test "$enable_experimental_owl_ext" = "yes" ; then
434 AC_DEFINE(EXPERIMENTAL_OWL_EXT, 1)
435else
436 AC_DEFINE(EXPERIMENTAL_OWL_EXT, 0)
437fi
438
439dnl ------------ Cosmic Consciousness -------------------
440
441AH_TEMPLATE([COSMIC_GNUGO],
442[Center oriented influence. Disabled by default.])
443
444if test "$enable_cosmic_gnugo" = "yes" ; then
445 AC_DEFINE(COSMIC_GNUGO, 1)
446else
447 AC_DEFINE(COSMIC_GNUGO, 0)
448fi
449
450dnl ------------ Large Scale -------------------
451
452AH_TEMPLATE([LARGE_SCALE],
453[Large Scale Captures. Disabled by default.])
454
455if test "$enable_large_scale" = "yes" ; then
456 AC_DEFINE(LARGE_SCALE, 1)
457else
458 AC_DEFINE(LARGE_SCALE, 0)
459fi
460
461dnl ------------ Connections -------------------
462
463AH_TEMPLATE([EXPERIMENTAL_CONNECTIONS],
464[Connection module. Default experimental.])
465
466if test "$enable_experimental_connections" = "no" ; then
467 AC_DEFINE(EXPERIMENTAL_CONNECTIONS, 0)
468else
469 AC_DEFINE(EXPERIMENTAL_CONNECTIONS, 1)
470fi
471
472dnl ------------ Connections -------------------
473
474AH_TEMPLATE([ALTERNATE_CONNECTIONS],
475[Connection module. Default standard.])
476
477if test "$enable_alternate_connections" = "no" ; then
478 AC_DEFINE(ALTERNATE_CONNECTIONS, 0)
479else
480 AC_DEFINE(ALTERNATE_CONNECTIONS, 1)
481fi
482
483dnl ------------ Owl Threats -------------------
484
485AH_TEMPLATE([OWL_THREATS],
486[Owl Threats. 0 standard.])
487
488if test "$enable_owl_threats" = "yes" ; then
489 AC_DEFINE(OWL_THREATS, 1)
490else
491 AC_DEFINE(OWL_THREATS, 0)
492fi
493
494dnl ------------ additional valgrind macros ------
495
496AH_TEMPLATE([USE_VALGRIND],
497[Define special valgrind macros.])
498
499if test "$enable_valgrind" = "yes" ; then
500 AC_DEFINE(USE_VALGRIND, 1)
501else
502 AC_DEFINE(USE_VALGRIND, 0)
503fi
504
505dnl ----------- special-case use of gcc ---------
506
507dnl Not sure if we are supposed to be accessing this variable, but...
508
509AM_CONDITIONAL(GCC_ONLY, test "$ac_compiler_gnu" = "yes")
510
511dnl Now lines in Makefile.am can be prefixed @GCC_ONLY@.
512
513AC_SUBST(GCC_MAJOR_VERSION)
514AC_SUBST(GCC_MINOR_VERSION)
515AC_SUBST(GNU_GO_WARNINGS)
516
517if test "$ac_compiler_gnu" = "yes"; then
518
519 dnl M4 escaping of brackets
520 GCC_MAJOR_VERSION=`echo __GNUC__ | $CC -E -xc - | tail -n 1`
521 GCC_MINOR_VERSION=`echo __GNUC_MINOR__ | $CC -E -xc - | tail -n 1`
522
523 GNU_GO_WARNINGS='-Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wundef'
524
525 if (test $GCC_MAJOR_VERSION -eq 3 && test $GCC_MINOR_VERSION -ge 4) || test $GCC_MAJOR_VERSION -gt 3; then
526 GNU_GO_WARNINGS="$GNU_GO_WARNINGS -Wdeclaration-after-statement"
527 fi
528
529else
530 GCC_MAJOR_VERSION=0
531 GCC_MINOR_VERSION=0
532 GNU_GO_WARNINGS=''
533fi
534
535dnl FIXME: please add warnings for other compilers!
536
537
538AH_TEMPLATE([ENABLE_SOCKET_SUPPORT],
539[Compile support for GTP communication over TCP/IP channel.])
540
541if test "$enable_socket_support" != "no"; then
542 # Check for all required headers, macros, structures and functions
543 # at once.
544 AC_CACHE_CHECK(
545 [whether socket support can be compiled],
546 gnugo_cv_sockets_supported,
547 AC_TRY_LINK([#if !defined(_WIN32) && !defined(_WIN32_WCE)
548#include <sys/socket.h>
549#include <netinet/in.h>
550#include <arpa/inet.h>
551#include <netdb.h>
552#else /* on Windows */
553#include <winsock.h>
554#endif /* on Windows */],
555[[ struct sockaddr_in A;
556 struct hostent *H;
557 A.sin_family = AF_INET;
558 A.sin_addr.s_addr = htonl(INADDR_ANY);
559 A.sin_port = htons(0);
560 gethostbyname(0);
561 socket(PF_INET, SOCK_STREAM, 0);
562 connect(0, 0, 0);
563 bind(0, 0, 0);
564 listen(0, 0);
565 accept(0, 0, 0);]],
566 gnugo_cv_sockets_supported="yes",
567 gnugo_cv_sockets_supported="no"))
568
569 if test "$gnugo_cv_sockets_supported" = "yes"; then
570 AC_DEFINE(ENABLE_SOCKET_SUPPORT)
571 else
572 if test "$enable_socket_support" = "yes"; then
573 AC_MSG_WARN(
574[[
575*** Socket support was requested but does not pass configure test. ***
576*** Proceed only if you know what you are doing. ***]])
577 AC_DEFINE(ENABLE_SOCKET_SUPPORT)
578 fi
579 fi
580fi
581
582#AM_GNU_GETTEXT
583#AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
584
585dnl FIXME:
586dnl autoconf 2.50 recommends AC_CONFIG_FILES and AC_OUPUT
587dnl This however requires automake 1.4p2 or better
588
589AC_OUTPUT([Makefile interface/Makefile patterns/Makefile sgf/Makefile
590utils/Makefile engine/Makefile doc/Makefile regression/Makefile config.vc:config.vcin])