AC_INIT(xtet42.c)

PACKAGE=xtet42
VERSION=2.21
AC_DEFINE_UNQUOTED(PACKAGE, $PACKAGE)
AC_DEFINE_UNQUOTED(VERSION, $VERSION)

AC_PROG_CC
AC_PROG_INSTALL
AC_C_CONST
AC_PATH_XTRA
AC_CHECK_LIB(nsl,gethostname)
AC_CHECK_LIB(socket,connect)

saved_cflags="$CFLAGS"
saved_ldflags="$LDFLAGS"
CFLAGS="$CFLAGS $X_CFLAGS"
LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
AC_CHECK_LIB(X11, XOpenDisplay,, dnl x_libs="$X_PRE_LIBS -lX11 $X_EXTRA_LIBS",
  AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]))

AC_CHECK_HEADERS(pwd.h unistd.h)
AC_CHECK_FUNCS(usleep cuserid random)

AC_ARG_ENABLE(log,   [  --disable-log           disable logging of two players ],,enable_log=yes)
LOG=
if test -n "$enable_log" -a " $enable_log" != " no"; then
  LOG=-DLog
fi
AC_SUBST(LOG)

AC_ARG_ENABLE(setgid,[  --enable-setgid=GROUP   install program set-group-id ])

INSTALL_SETGID_ARG=
INSTALL_WGROUP_ARG="-m 644"
INSTALL_WGROUPDIR_ARG="-m 755"
if test -n "$enable_setgid" -a " $enable_setgid" != " no"; then 
  if test " $enable_setgid" = " yes"; then
    enable_setgid=games
  fi
  INSTALL_SETGID_ARG="-m 2755 -g $enable_setgid"
  INSTALL_WGROUP_ARG="-m 664 -g $enable_setgid"
  INSTALL_WGROUPDIR_ARG="-m 775 -g $enable_setgid"
fi 
AC_SUBST(INSTALL_SETGID_ARG)
AC_SUBST(INSTALL_WGROUP_ARG)
AC_SUBST(INSTALL_WGROUPDIR_ARG)


AC_OUTPUT(Makefile)
