[gjs] Base version detection on mozilla-js.pc version



commit 8a3b63078195d6bc0803b69b4c62510ad65fd042
Author: Colin Walters <walters verbum org>
Date:   Wed Oct 20 11:14:48 2010 -0400

    Base version detection on mozilla-js.pc version
    
    Remove the base library checks, and just differentiate between
    xulrunner 1.9.x and 2.

 configure.ac     |   30 ++++++++++++------------------
 gjs/compat.h     |    4 +---
 gjs/importer.c   |    2 +-
 gjs/jsapi-util.c |    2 +-
 4 files changed, 15 insertions(+), 23 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index da52366..5bc7286 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,25 +138,19 @@ fi
 AC_SUBST(JS_PACKAGE)
 AC_SUBST(FIREFOX_JS_LIBDIR)
 
-AC_CHECK_LIB([mozjs], [JS_CallTracer], :,
-             [AC_MSG_ERROR([SpiderMonkey is too old, Firefox 3 is required])],
-             [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_DefinePropertyById], :,
-             [AC_MSG_ERROR([SpiderMonkey is too old, xulrunner 1.9.1 is required])],
-             [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_AddValueRoot], [have_js_addvalueroot=true],
-             [have_js_addvalueroot=false],
-             [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_NewGlobalObject], [have_js_newglobalobject=true],
-             [have_js_newglobalobject=false],
-             [$JS_LIBS])
-if test "x$have_js_addvalueroot" = xtrue; then
-  AC_DEFINE(HAVE_JS_ADDVALUEROOT, 1,
-    [Define if -lmozjs has AddValueRoot])
+AC_MSG_CHECKING([for mozilla-js >= 1.9.2 ])
+if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 1.9.2`; then
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_ERROR([$JS_PACKAGE >= 1.9.2 is required])
 fi
-if test "x$have_js_newglobalobject" = xtrue; then
-  AC_DEFINE(HAVE_JS_NEWGLOBALOBJECT, 1,
-    [Define if -lmozjs has NewGlobalObject])
+
+AC_MSG_CHECKING([for mozilla-js >= 2 ])
+if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
+  AC_MSG_RESULT([yes])
+  AC_DEFINE(HAVE_MOZJS_2, [1], [Define if mozilla-js is at least 2])
+else
+  AC_MSG_RESULT([no])
 fi
 
 ## workaround for Ubuntu Hardy bug where mozilla-js.pc gives CFLAGS
diff --git a/gjs/compat.h b/gjs/compat.h
index 1ff1c31..c634b06 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -38,7 +38,7 @@ G_BEGIN_DECLS
 #endif
 
 /* See https://bugzilla.gnome.org/show_bug.cgi?id=622896 */
-#ifndef HAVE_JS_ADDVALUEROOT
+#ifndef HAVE_MOZJS_2
 
 /* The old JS_AddRoot accepted anything via void *, new
  * api is stricter.
@@ -60,8 +60,6 @@ G_BEGIN_DECLS
 #define JSID_IS_VOID(id) (id == JSVAL_VOID)
 #define INT_TO_JSID(i) ((jsid) INT_TO_JSVAL(i))
 
-#else
-#define HAVE_JSENUMERATE_INIT_ALL 1
 #endif
 
 G_END_DECLS
diff --git a/gjs/importer.c b/gjs/importer.c
index 0c6f6f3..8487c10 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -729,7 +729,7 @@ importer_new_enumerate(JSContext  *context,
     ImporterIterator *iter;
 
     switch (enum_op) {
-#ifdef HAVE_JSENUMERATE_INIT_ALL
+#ifdef HAVE_MOZJS_2
     case JSENUMERATE_INIT_ALL:
 #endif
     case JSENUMERATE_INIT: {
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 0c55ed6..9b80499 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -254,7 +254,7 @@ gboolean
 gjs_init_context_standard (JSContext       *context)
 {
     JSObject *global;
-#ifdef HAVE_JS_NEWGLOBALOBJECT
+#ifdef HAVE_MOZJS_2
     global = JS_NewGlobalObject(context, &global_class);
     if (global == NULL)
         return FALSE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]