dnl Process this file with autoconf to produce a configure script.
AC_INIT(regex.c)

AC_CONFIG_HEADER(config.h)

dnl default value for RUBYDIR
RUBYDIR=".."
AC_ARG_WITH(rubydir,
	[  --with-rubydir=RUBYDIR  specify value for RUBYDIR (default ..)], 
	[ RUBYDIR=$withval ])
AC_SUBST(RUBYDIR)

dnl default value for STATISTICS
STATISTICS=""
AC_ARG_WITH(statistics,
	[  --with-statistics  take matching time statistical data], 
	[ STATISTICS=-DREG_DEBUG_STATISTICS ])
AC_SUBST(STATISTICS)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
dnl AC_PROG_INSTALL

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(stdlib.h string.h strings.h sys/time.h unistd.h sys/times.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
AC_C_CONST
AC_HEADER_TIME

dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP

AC_CACHE_CHECK(for prototypes, cv_have_prototypes,
  [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
	cv_have_prototypes=yes,
	cv_have_prototypes=no)])
if test "$cv_have_prototypes" = yes; then
  AC_DEFINE(HAVE_PROTOTYPES)
fi

AC_CACHE_CHECK(for variable length prototypes and stdarg.h, cv_stdarg,
  [AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
	va_list va;
	va_start(va, x);
	va_arg(va, int);
	va_arg(va, char *);
	va_arg(va, double);
	return 0;
}
], [return foo(10, "", 3.14);],
	cv_stdarg=yes,
	cv_stdarg=no)])
if test "$cv_stdarg" = yes; then
  AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi

AC_SUBST()

AC_OUTPUT(Makefile)
