-
-# Can we rebuild the documentation?
-GTK_DOC_CHECK()
-AC_SUBST([htmldir], ['${datadir}/doc/gras/html'])dnl
-
-dnl ####[ Search libs ]#######################################################
-dnl A CI_PACKAGE([S imGrid],[the SimGrid simulator],[SG_init],[-lsimgrid],[simgrid.h],,:)
-dnl A M_CONDITIONAL(HAVE_SG,test x$HAVE_SimGrid = xyes)
-dnl if test x$HAVE_SimGrid = xyes; then
-dnl GRAS_SG_DEP="-lsimgrid"
-dnl else
- GRAS_SG_DEP=""
-dnl fi
-AC_SUBST([GRAS_SG_DEP])
-
-
-dnl A C_CHECK_LIB(pthread, pthread_mutex_lock, LIBS="$LIBS -lpthread")
-GRAS_RL_DEP=""
-AC_CHECK_LIB(nsl, gethostbyname, [GRAS_RL_DEP="$GRAS_RL_DEP -lnsl"])
-AC_CHECK_LIB(socket, connect, [GRAS_RL_DEP="$GRAS_RL_DEP -lsocket"])
-
-AC_MSG_CHECKING(for extra dependencies of libgrasrl)
+
+case $with_context in
+ ucontext) ;;
+ pthread) ;;
+ windows) ;;
+ auto) with_context=ucontext;;
+ *) AC_MSG_ERROR([--with-context must be either ucontext or pthread]) ;;
+esac
+
+if test "x$with_context" = "xucontext" ; then
+ if test ".$mcsc" = .yes; then
+ AC_MSG_RESULT(found working ucontext. Great!)
+ AC_DEFINE([USE_UCONTEXT],1,[Define if we use ucontext or not])
+ else
+ if test ".$windows_context" = .yes ; then
+ AC_MSG_RESULT(use windows context portability layer.)
+ with_context=windows
+ else
+ AC_MSG_RESULT([[no working ucontext found. Try pthreads as a fallback]])
+ with_context=pthread
+ fi
+ fi
+fi
+
+if test "x$with_context" = "xpthread"; then
+ AC_CHECK_HEADERS([pthread.h])
+ AC_CHECK_LIB(pthread,pthread_create,,
+ [AC_MSG_ERROR([[Cannot find pthreads, no way (try --with-context=ucontext if you haven't already tried).]])])
+ AC_DEFINE([USE_PTHREADS],1,[Define if we use pthreads or not])
+ AC_MSG_RESULT(You have pthreads. Let's use them.)
+fi
+
+dnl #
+dnl # 4. determine a few additional details
+dnl #
+
+if test "x$with_context" = "xucontext" ; then
+dnl # direction of stack grow
+ AC_CHECK_STACKGROWTH(PTH_STACKGROWTH)
+ if test ".$ac_cv_check_stackgrowth" = ".down"; then
+ PTH_STACK_GROWTH="down"
+ else
+ PTH_STACK_GROWTH="up"
+ fi
+ AC_SUBST(PTH_STACK_GROWTH)
+
+ AC_CHECK_STACKSETUP(makecontext, pth_skaddr_makecontext, pth_sksize_makecontext)
+fi
+
+#########################################
+## Check for libraries extra-dependencies
+##
+
+SG_CONFIGURE_PART(Checking extra libraries dependencies...)
+
+AC_MSG_CHECKING(for csdp)
+SIMGRID_DEP=""
+sdp=no
+AC_CHECK_LIB(sdp,sdp,csdp=yes, csdp=no,-llapack -lblas -lm)
+if test "x$csdp" = xyes; then
+ SIMGRID_DEP="$SIMGRID_DEP -lsdp -llapack -lblas -lm"
+ AC_MSG_RESULT(Found working sdp library.)
+else
+ AC_MSG_RESULT(Could not find any working sdp library.)
+fi;
+AM_CONDITIONAL(HAVE_SDP,test x$csdp != xno)
+
+AC_SUBST([SIMGRID_DEP])
+
+GRAS_DEP=""
+AC_CHECK_LIB(nsl, gethostbyname, [GRAS_DEP="$GRAS_DEP -lnsl"])
+AC_CHECK_LIB(socket, connect, [GRAS_DEP="$GRAS_DEP -lsocket"])
+
+AC_MSG_CHECKING(for extra dependencies of libgras)