dnl Process this file with autoconf to produce a configure script.
dnl *****************************************************************
dnl IMPORTANT: Don't forget to add corresponding output for --options
dnl if you add a non-trivial configure option here.
dnl *****************************************************************
dnl this is to determine if the config script is running in the proper place
dnl just give it one file relative to where it should be
AC_CONFIG_SRCDIR([engine/dragon.c])
AM_CONFIG_HEADER(config.h)
AC_PREREQ(2.52)dnl dnl Minimum Autoconf version required.
[Define to the name of the distribution.])
AH_TEMPLATE([GNU_PACKAGE],
[The concatenation of the strings "GNU ", and PACKAGE.])
[Define to the version of the distribution.])
dnl this defines VERSION and PACKAGE
GNU_PACKAGE="GNU $PACKAGE"
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE")
dnl See if user has expressed a preference for use of curses and/or color
dnl These set variables $enable_color and $with_curses to "no" if disabled
dnl "yes" if enabled, or undefined if not specified
[ --with-readline try to use GNU Readline for command reading
--without-readline do not use GNU Readline (default)])
[ --with-curses try to use curses for colored debugging output (default)
--without-curses do not use curses for colored debugging output])
[ --enable-color use curses or ansi escape sequences for colored
--disable-color do not try to generated colored debug output])
dnl and look to see if they want to disable the grid optimisation
[ --enable-grid-opt enable the grid optimisation within the pattern
--enable-grid-opt=distrust enable the grid optimisation in non-trusting mode
--disable-grid-opt disable the grid optimisation])
default_semeai_node_limit=500
default_owl_node_limit=1000
AC_ARG_ENABLE(cache-size,
[ --enable-cache-size=n reserve n MB RAM for caching (special value -1
default, corresponding to 8-11 MB depending on
[ --enable-level=n n = default level (10 standard)])
AC_ARG_ENABLE(semeai-node-limit,
[ --enable-semeai-node-limit=n n = semeai variations (500 standard)])
[ --enable-owl-node-limit=n n = owl node limit (1000 standard)])
[ --disable-dfa use old non-dfa pattern matcher],
[ if test ${enableval} = no; then
AC_ARG_ENABLE(chinese-rules,
[ --enable-chinese-rules use Chinese (area) counting
--disable-chinese-rules use Japanese counting (default)])
AC_ARG_ENABLE(resignation-allowed,
[ --enable-resignation-allowed resign lost games (default)
--disable-resignation-allowed never resign])
AC_ARG_ENABLE(metamachine,
[ --enable-metamachine enable metamachine
--disable-metamachine don't enable metamachine (default)])
AC_ARG_ENABLE(experimental-break-in,
[ --enable-experimental-break-in use the breakin module (default)
--disable-experimental-break-in don't use the breakin module])
AC_ARG_ENABLE(experimental-owl-ext,
[ --enable-experimental-owl-ext use the experimental GAIN/LOSS codes
--disable-experimental-owl-ext use standard owl module (default)])
AC_ARG_ENABLE(cosmic-gnugo,
[ --enable-cosmic-gnugo use center-oriented influence code
--disable-cosmic-gnugo use standard influence code (default)])
AC_ARG_ENABLE(large-scale,
[ --enable-large-scale look for large scale captures
--disable-large-scale don't seek large scale captures (default)])
AC_ARG_ENABLE(experimental-connections,
[ --enable-experimental-connections use experimental connection analysis
--disable-experimental-connections use standard connection analysis])
AC_ARG_ENABLE(alternate-connections,
[ --enable-alternate-connections use alternate experimental connection
--disable-alternate-connections use primary experimental connection
AC_ARG_ENABLE(socket-support,
[ --disable-socket-support don't compile GTP over TCP/IP support
--enable-socket-support compile TCP/IP support (default)])
dnl add -lm to library list since we use some
dnl math functions such as pow and fabs
if test $ac_cv_mingw32 = yes;then
AC_SEARCH_LIBS(vsnprintf, mingwex)
dnl required since we use SUBDIRS in Makefile.am
AC_CHECK_HEADERS(unistd.h sys/time.h sys/times.h)
AC_CHECK_HEADERS(curses.h term.h ncurses/curses.h ncurses/term.h)
if test "$ac_cv_header_curses_h" = "yes";then
elif test "$ac_cv_header_ncurses_curses_h" = "yes";then
curses_header="ncurses/curses.h"
if test "$ac_cv_header_term_h" = "yes";then
elif test "$ac_cv_header_ncurses_term_h" = "yes";then
term_header="ncurses/term.h"
AC_CHECK_SIZEOF(long,,[#include <stdio.h>])
dnl vsnprintf not universally available
dnl usleep not available in Unicos and mingw32
AC_CHECK_FUNCS(vsnprintf gettimeofday usleep times)
dnl if snprintf not available try to use g_snprintf from GLib
if test $ac_cv_func_vsnprintf = no; then
AC_CHECK_PROG(glibconfig,glib-config,yes,no)
if test $ac_cv_prog_glibconfig = yes;then
glib_cflags=`glib-config --cflags`
glib_libs=`glib-config --libs`
CPPFLAGS="$CPPFLAGS $glib_cflags"
AC_CHECK_FUNCS(g_vsnprintf)
if test $ac_cv_func_g_vsnprintf = no; then
AC_MSG_WARN([GLib installation problem.
Continuing without GLib ])
AC_MSG_WARN([Neither vsnprintf nor GLib found. GNU Go is
compiled but it is safer to get GLib at
dnl ------ variadic #define -----------------------
AH_TEMPLATE([HAVE_VARIADIC_DEFINE],
[Define if #define can take a variable number of arguments])
[for variadic cpp define],
gnugo_cv_cpp_variadic_define,
#define zz(fmt,arg...) printf(fmt,##arg)],
[zz("Hello");zz("%s","Hello");zz("%s%s","Hello","World")],
gnugo_cv_cpp_variadic_define="yes",
gnugo_cv_cpp_variadic_define="no")
if test "$gnugo_cv_cpp_variadic_define" = "yes";then
AC_DEFINE(HAVE_VARIADIC_DEFINE)
dnl ------ transparent unions ---------------------
AH_TEMPLATE([HAVE_TRANSPARENT_UNIONS],
[Define if your compiler supports transparent unions])
[whether $CC supports transparent unions],
gnugo_cv_transparent_unions,
gnugo_cv_transparent_unions="yes",
gnugo_cv_transparent_unions="no")
if test "$gnugo_cv_transparent_unions" = "yes"; then
AC_DEFINE(HAVE_TRANSPARENT_UNIONS)
dnl -------- color debugging support -----------
[Define to 1 if termcap/terminfo is available.])
AH_TEMPLATE([ANSI_COLOR],
[Define to use ansi escape sequences for color debugging])
if test "$with_curses" != no -a "$enable_color" != no ; then
tmp_color_result="none (curses failed)"
dnl Do a separate test for curses and termcap
dnl DJGPP does have pdcurses, but not termcap
dnl make sure that both curses.h and term.h are available
dnl FIXME: better to actually figure out here what headers
if test "$term_header" != "no" -a "$curses_header" != "no" ; then
dnl check for a working termcap library
AC_SEARCH_LIBS(tparm,ncurses curses pdcurses termcap terminfo termlib)
if test "$ac_cv_search_tparm" != "no" ; then
tmp_color_result="curses"
if test "$with_curses" = no -a "$enable_color" != no ; then
dnl we asked for color, but there is no termcap
tmp_color_result="ANSI color"
AC_MSG_CHECKING(for color support)
AC_MSG_RESULT($tmp_color_result)
dnl -------- readline support -------------------
AH_TEMPLATE([READLINE], [Enable GNU Readline support])
if test "$with_readline" = yes ; then
dnl check for a working termcap and readline library
AC_SEARCH_LIBS(readline,termcap readline)
if test "$ac_cv_search_readline" != "no" ; then
dnl ---------- grid optimisation ------------
[Define as 1 to use the grid optimisation, or 2 to run it in self-test mode])
if test "$enable_grid_opt" = "distrust" ; then
if test "$enable_grid_opt" = "no" ; then
dnl ------------ set cache size ----------
AH_TEMPLATE([DEFAULT_MEMORY],
[Default hash table size in megabytes])
if test "$enable_cache_size" ; then
AC_DEFINE_UNQUOTED(DEFAULT_MEMORY, $enable_cache_size)
AC_DEFINE_UNQUOTED(DEFAULT_MEMORY, $default_cache_size)
dnl ------------ set default level ----------
AH_TEMPLATE([DEFAULT_LEVEL],
[Default level (strength). Up to 10 supported])
if test "$enable_level" ; then
AC_DEFINE_UNQUOTED(DEFAULT_LEVEL, $enable_level)
AC_DEFINE_UNQUOTED(DEFAULT_LEVEL, $default_level)
dnl ------------ set cache size ----------
AH_TEMPLATE([OWL_NODE_LIMIT],
if test "$enable_owl_node_limit" ; then
AC_DEFINE_UNQUOTED(OWL_NODE_LIMIT, $enable_owl_node_limit)
AC_DEFINE_UNQUOTED(OWL_NODE_LIMIT, $default_owl_node_limit)
dnl ------------ set semeai variations ----------
AH_TEMPLATE([SEMEAI_NODE_LIMIT],
[Semeai Variations. 500 default])
if test "$enable_semeai_node_limit" ; then
AC_DEFINE_UNQUOTED(SEMEAI_NODE_LIMIT, $enable_semeai_node_limit)
AC_DEFINE_UNQUOTED(SEMEAI_NODE_LIMIT, $default_semeai_node_limit)
dnl ------------ dfa -------------------
AM_CONDITIONAL(DFA_ENABLED, test "$enable_dfa" != "no")
dnl FIXME: Is there a more elegant approach for this?
dnl force owl c files rebuild
patterns/owl_attackpat.c \
patterns/owl_defendpat.c \
patterns/owl_vital_apat.c
dnl ------------ Chinese Rules -------------------
AH_TEMPLATE([CHINESE_RULES],
[Ruleset. Default Japanese])
if test "$enable_chinese_rules" = "yes" ; then
AC_DEFINE(CHINESE_RULES, 1)
AC_DEFINE(CHINESE_RULES, 0)
dnl ------------ Resignation allowed-------------------
AH_TEMPLATE([RESIGNATION_ALLOWED],
[Allow resignation. Default enabled])
if test "$disable_resignation_allowed" = "yes" ; then
AC_DEFINE(RESIGNATION_ALLOWED, 0)
AC_DEFINE(RESIGNATION_ALLOWED, 1)
dnl ------------ Oracle enabled-------------------
[Oracle. Default not enabled.])
if test "$enable_metamachine" = "yes" ; then
dnl ------------ Experimental Breakin enabled-------------------
AH_TEMPLATE([USE_BREAK_IN],
[Break-in module. Enabled by default.])
if test "$enable_experimental_break_in" = "no" ; then
AC_DEFINE(USE_BREAK_IN, 0)
AC_DEFINE(USE_BREAK_IN, 1)
dnl ------------ Owl extensions ------------
AH_TEMPLATE([EXPERIMENTAL_OWL_EXT],
[GAIN/LOSS codes. Disabled by default.])
if test "$enable_experimental_owl_ext" = "yes" ; then
AC_DEFINE(EXPERIMENTAL_OWL_EXT, 1)
AC_DEFINE(EXPERIMENTAL_OWL_EXT, 0)
dnl ------------ Cosmic Consciousness -------------------
AH_TEMPLATE([COSMIC_GNUGO],
[Center oriented influence. Disabled by default.])
if test "$enable_cosmic_gnugo" = "yes" ; then
AC_DEFINE(COSMIC_GNUGO, 1)
AC_DEFINE(COSMIC_GNUGO, 0)
dnl ------------ Large Scale -------------------
AH_TEMPLATE([LARGE_SCALE],
[Large Scale Captures. Disabled by default.])
if test "$enable_large_scale" = "yes" ; then
AC_DEFINE(LARGE_SCALE, 1)
AC_DEFINE(LARGE_SCALE, 0)
dnl ------------ Connections -------------------
AH_TEMPLATE([EXPERIMENTAL_CONNECTIONS],
[Connection module. Default experimental.])
if test "$enable_experimental_connections" = "no" ; then
AC_DEFINE(EXPERIMENTAL_CONNECTIONS, 0)
AC_DEFINE(EXPERIMENTAL_CONNECTIONS, 1)
dnl ------------ Connections -------------------
AH_TEMPLATE([ALTERNATE_CONNECTIONS],
[Connection module. Default standard.])
if test "$enable_alternate_connections" = "no" ; then
AC_DEFINE(ALTERNATE_CONNECTIONS, 0)
AC_DEFINE(ALTERNATE_CONNECTIONS, 1)
dnl ------------ Owl Threats -------------------
AH_TEMPLATE([OWL_THREATS],
[Owl Threats. 0 standard.])
if test "$enable_owl_threats" = "yes" ; then
AC_DEFINE(OWL_THREATS, 1)
AC_DEFINE(OWL_THREATS, 0)
dnl ------------ additional valgrind macros ------
AH_TEMPLATE([USE_VALGRIND],
[Define special valgrind macros.])
if test "$enable_valgrind" = "yes" ; then
AC_DEFINE(USE_VALGRIND, 1)
AC_DEFINE(USE_VALGRIND, 0)
dnl ----------- special-case use of gcc ---------
dnl Not sure if we are supposed to be accessing this variable, but...
AM_CONDITIONAL(GCC_ONLY, test "$ac_compiler_gnu" = "yes")
dnl Now lines in Makefile.am can be prefixed @GCC_ONLY@.
AC_SUBST(GCC_MAJOR_VERSION)
AC_SUBST(GCC_MINOR_VERSION)
AC_SUBST(GNU_GO_WARNINGS)
if test "$ac_compiler_gnu" = "yes"; then
dnl M4 escaping of brackets
GCC_MAJOR_VERSION=`echo __GNUC__ | $CC -E -xc - | tail -n 1`
GCC_MINOR_VERSION=`echo __GNUC_MINOR__ | $CC -E -xc - | tail -n 1`
GNU_GO_WARNINGS='-Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wundef'
if (test $GCC_MAJOR_VERSION -eq 3 && test $GCC_MINOR_VERSION -ge 4) || test $GCC_MAJOR_VERSION -gt 3; then
GNU_GO_WARNINGS="$GNU_GO_WARNINGS -Wdeclaration-after-statement"
dnl FIXME: please add warnings for other compilers!
AH_TEMPLATE([ENABLE_SOCKET_SUPPORT],
[Compile support for GTP communication over TCP/IP channel.])
if test "$enable_socket_support" != "no"; then
# Check for all required headers, macros, structures and functions
[whether socket support can be compiled],
gnugo_cv_sockets_supported,
AC_TRY_LINK([#if !defined(_WIN32) && !defined(_WIN32_WCE)
#endif /* on Windows */],
A.sin_addr.s_addr = htonl(INADDR_ANY);
socket(PF_INET, SOCK_STREAM, 0);
gnugo_cv_sockets_supported="yes",
gnugo_cv_sockets_supported="no"))
if test "$gnugo_cv_sockets_supported" = "yes"; then
AC_DEFINE(ENABLE_SOCKET_SUPPORT)
if test "$enable_socket_support" = "yes"; then
*** Socket support was requested but does not pass configure test. ***
*** Proceed only if you know what you are doing. ***]])
AC_DEFINE(ENABLE_SOCKET_SUPPORT)
#AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
dnl autoconf 2.50 recommends AC_CONFIG_FILES and AC_OUPUT
dnl This however requires automake 1.4p2 or better
AC_OUTPUT([Makefile interface/Makefile patterns/Makefile sgf/Makefile
utils/Makefile engine/Makefile doc/Makefile regression/Makefile config.vc:config.vcin])