+SG_CONFIGURE_PART([Checking for threads, contexts or assimilated...])
+
+dnl #
+dnl # 1. determine possibilities
+dnl #
+
+dnl # check for MCSC method
+AC_CHECK_MCSC(mcsc=yes, mcsc=no)
+
+dnl # check for pthread method
+AC_CHECK_HEADERS([pthread.h])
+AC_CHECK_LIB(pthread,pthread_create,pthread=yes, pthread=no)
+
+dnl #
+dnl # 2. make a general decision
+dnl #
+
+if test ".$mcsc" = .yes; then
+ mcsc=yes
+elif test ".$pthread" = .yes; then
+ pthread=yes
+else
+ ac_header=windows.h
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ windows_context=yes
+ else
+ AC_ERROR([no appropriate backend found])
+ fi
+fi
+
+dnl #
+dnl # 3. allow decision to be overridden by user
+dnl #
+
+AC_MSG_CHECKING(what kind of backend should we use)
+
+AC_ARG_WITH(pthread, [ --with-pthread Use pthread instead of ucontext.],with_context=pthread)
+AC_ARG_WITH(pthread, [ --with-pthreads Use pthread instead of ucontext.],with_context=pthread)
+
+AC_ARG_WITH(context,
+ [ --with-context=[ucontext/pthread] Use either (System V) swapcontext or pthread [[default=auto]].],,
+ with_context=auto)
+
+if test "x$with_context$mcsc" = "xucontextno" ; then
+ AC_MSG_ERROR([--with-context=ucontext specified but ucontext unusable. Relaunch configure without this argument.], 77)
+fi
+
+case $with_context in
+ ucontext) ;;
+ pthread) ;;
+ pthreads) ;;
+ 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([CONTEXT_UCONTEXT],1,[Define if xbt contexts are based on 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" = "xpthreads"; then
+ with_context=pthread
+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 (try --with-context=ucontext if you haven't already tried).]])])
+ AC_DEFINE([CONTEXT_THREADS],1,[Define if xbt contexts are based on our threads implementation 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
+
+
+#########################################
+## Build optional modules (simix)
+##
+SG_CONFIGURE_PART(Optional modules)
+AC_ARG_ENABLE(simix,
+ AS_HELP_STRING([--enable-simix], [Use the new SimIX module (default=no)]),
+ enable_simix=$enableval,enable_simix=no)
+if test "x$enable_simix" = "xyes" ; then
+ AC_MSG_RESULT("***** You have decided to use the experimental SimIX. We hope you know what you're doing.. ****")
+ AC_DEFINE(USE_SIMIX, 1, [Indicates whether we should use SimIX or not])
+else
+ AC_MSG_RESULT(Eventually you will come to SimIX: x$enable_simix)
+fi
+AM_CONDITIONAL(USE_SIMIX,test x$enable_simix != xno)
+
+#########################################
+## Check for libraries extra-dependencies
+##
+
+SG_CONFIGURE_PART(Checking extra libraries dependencies...)
+
+SIMGRID_DEP=""