From d791854f52356e94a4d2ce4600555712d7a76382 Mon Sep 17 00:00:00 2001
From: Witold Filipczyk <witekfl@poczta.onet.pl>
Date: Sat, 30 Jun 2007 18:42:27 +0200
Subject: [PATCH] configure: Check for see-2.0 or later.

---
 configure.in | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/configure.in b/configure.in
index 1e3c38657..ac52c43af 100644
--- a/configure.in
+++ b/configure.in
@@ -572,12 +572,9 @@ AC_ARG_WITH(see, [  --with-see              enable Simple Ecmascript Engine (SEE
 # to compile CVS. Also, the macro seems to be really stupid regarding searching
 # for Guile in $PATH etc. --pasky
 
-AC_MSG_CHECKING([for SEE])
-
 CONFIG_ECMASCRIPT_SEE=no
 
 if test "$enable_see" = "yes"; then
-	AC_MSG_RESULT(yes);
 	## Based on the SEE_FLAGS macro.
 
 	if test -d "$withval"; then
@@ -587,16 +584,24 @@ if test "$enable_see" = "yes"; then
 	fi
 
 	AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
-
-	## First, let's just see if we can find Guile at all.
+	AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
 	if test "$SEE_CONFIG" != no; then
-		cf_result="yes";
-
+		EL_SAVE_FLAGS
 		SEE_LIBS="`$SEE_CONFIG --libs`"
 		SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
-		LIBS="$SEE_LIBS $LIBS"
-		EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
-		AC_SUBST(SEE_CFLAGS)
+		CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
+		LIBS="$SEE_LIBS $LIBS_X"
+		AC_TRY_LINK([#include <see/see.h>],[#if SEE_VERSION_API_MAJOR < 2
+			choke_on_see();
+			#endif
+		], cf_result=yes, cf_result=no)
+		EL_RESTORE_FLAGS
+		if test "$cf_result" = yes; then
+			LIBS="$SEE_LIBS $LIBS"
+			EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
+			AC_SUBST(SEE_CFLAGS)
+		fi
+		AC_MSG_RESULT($cf_result)
 	else
 		if test -n "$withval" && test "x$withval" != xno; then
 			AC_MSG_ERROR([SEE not found])
@@ -605,10 +610,10 @@ if test "$enable_see" = "yes"; then
 		fi
 	fi
 else
+	AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
 	AC_MSG_RESULT(no);
 fi
 
-
 dnl ===================================================================
 dnl Check for SpiderMonkey, optional even if installed.
 dnl ===================================================================