dnl
dnl Configuration things for affyR.
dnl (http://www.cbs.dtu.dk/laurent/download/affyR/
dnl What is below (and in the other configuration fiels 
dnl was taken from different configuration scripts for R version 1.3.0.
dnl
dnl Acknowledgments: The author(s) of the R configure scripts, Kurt Hornik for the tip with autoconf.
dnl
dnl Laurent 2001


AC_INIT("DESCRIPTION")

dnl
dnl Are things (still) the same ?
dnl (taken from the 'writing R extensions manual')

dnl Now find the compiler and compiler flags to use
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
       echo "could not determine R_HOME"
       exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CPP=`"${R_HOME}/bin/R" CMD config CPP`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
AC_PROG_CC
AC_PROG_CPP





# Checks for libraries.
use_pthreads=no
AC_SEARCH_LIBS([pthread_create], [pthread],
  [use_pthreads=yes])

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])

if test "x${have_pthreads}" = xyes; then
  AC_CHECK_HEADERS([pthread.h], [],
    [use_pthreads=no])
fi


AC_MSG_CHECKING([if PTHREAD_STACK_MIN is defined])
AC_COMPILE_IFELSE([
	#include <pthread.h>
	#include <limits.h>

      int main () {size_t stacksize = PTHREAD_STACK_MIN + 0x4000;
}     	  
    ],[use_pthread_stack_min=yes], [use_pthread_stack_min=no])
AC_MSG_RESULT($use_pthread_stack_min)

if test "x$use_pthread_stack_min" = xno; then
	use_pthreads=no
fi



if test "x${use_pthreads}" = "xno"; then
  echo "------------------------------------------"
  echo " Unable to find pthreads on this system.  "
  echo " Building a single-threaded version.      "
  echo "------------------------------------------"
fi

if test "x${use_pthreads}" = "xyes"; then
  AC_DEFINE(USE_PTHREADS, 1)
fi




AC_OUTPUT(src/Makevars)