+SG_CONFIGURE_PART([Checking for threads, contexts or assimilated...])
+AC_CHECK_UCONTEXT
+AC_MSG_CHECKING(on top of what can we build the contexts)
+AC_ARG_WITH(context,
+ [ --with-context=[ucontext/pthread] Use either (System V) swapcontext or pthread [[default=auto]].],,
+ with_context=auto)
+
+case $with_context in
+ ucontext) ;;
+ pthread) ;;
+ 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 "x$ac_check_ucontext" = "xyes"; then
+ AC_MSG_RESULT(found ucontext.h. Great!)
+ AC_DEFINE([USE_UCONTEXT],1,[Define if we use ucontext or not])
+ 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
+ AC_MSG_RESULT(there is no ucontext on windows, and none is needed.")
+ else
+ AC_MSG_RESULT([[no working ucontext found. Falling back to pthreads]])
+ with_context=pthread
+ fi
+ fi
+fi
+
+if test "x$with_context" = "xpthread"; then
+ AC_CHECK_HEADERS([pthread.h])