summaryrefslogtreecommitdiff
path: root/extra/gjs/gjs-0.7.14-js185-backport.patch
blob: b8b2082a3cabc4611fee0b5e98d689e37f87c682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
From cef9c0835bfd8be105ff8905083d6b51d9010b8f Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 1 Apr 2011 21:04:57 +0200
Subject: [PATCH 1/4] Conditionally adapt to JS_DestroyScript removal

Upstream changed the behaviour of several things about JSScripts in
http://hg.mozilla.org/mozilla-central/rev/c919a7271ac1

We now have to use a JSObject instead of a JSScript in certain circumstances,
and we no longer have to call JS_DestroyScript which no longer exists

https://bugzilla.gnome.org/show_bug.cgi?id=646471

Conflicts:

	configure.ac
---
 configure.ac      |    1 +
 modules/console.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 715f2c3..f81704b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,6 +160,7 @@ AC_CHECK_LIB([mozjs], [JS_GetFunctionName], AC_DEFINE([HAVE_JS_GETFUNCTIONNAME],
 AC_CHECK_LIB([mozjs], [JS_GetStringChars], AC_DEFINE([HAVE_JS_GETSTRINGCHARS], [1], [Define if we still have JS_GetStringChars]),, [$JS_LIBS])
 AC_CHECK_LIB([mozjs], [JS_StrictPropertyStub], AC_DEFINE([HAVE_JS_STRICTPROPERTYSTUB], [1], [Define if we have JS_StrictPropertyStub]),, [$JS_LIBS])
 AC_CHECK_LIB([mozjs], [JS_GetGlobalForScopeChain], AC_DEFINE([HAVE_JS_GETGLOBALFORSCOPECHAIN], [1], [Define if we have JS_GetGlobalForScopeChain]),, [$JS_LIBS])
+AC_CHECK_LIB([mozjs], [JS_DestroyScript], AC_DEFINE([HAVE_JS_DESTROYSCRIPT], [1], [Define if we still have JS_DestroyScript]),, [$JS_LIBS])
 
 AC_MSG_CHECKING([for mozilla-js >= 2 ])
 if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
diff --git a/modules/console.c b/modules/console.c
index 49f891b..e6945be 100644
--- a/modules/console.c
+++ b/modules/console.c
@@ -161,7 +161,11 @@ gjs_console_interact(JSContext *context,
 {
     JSObject *object = JS_THIS_OBJECT(context, vp);
     gboolean eof = FALSE;
+#ifdef HAVE_JS_DESTROYSCRIPT
     JSScript *script = NULL;
+#else
+    JSObject *script = NULL;
+#endif
     jsval result;
     JSString *str;
     GString *buffer = NULL;
@@ -219,8 +223,10 @@ gjs_console_interact(JSContext *context,
         }
 
  next:
+#ifdef HAVE_JS_DESTROYSCRIPT
         if (script)
             JS_DestroyScript(context, script);
+#endif
         g_string_free(buffer, TRUE);
     } while (!eof);
 
-- 
1.7.5.4


From 3c8396821c78e362c8b3a89a27dcf4d32e25ee05 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 29 Apr 2011 01:01:03 +0200
Subject: [PATCH 2/4] conditonally adapt to JS_BufferIsCompilableUnit changes

Upstream added an argument to JS_BufferIsCompilableUnit in commit
http://hg.mozilla.org/mozilla-central/rev/a773890b676f
We now have to tell if the bytes are utf8 or not.

https://bugzilla.gnome.org/show_bug.cgi?id=646471
---
 configure.ac      |    1 +
 modules/console.c |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index f81704b..270bc46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,7 @@ AC_CHECK_LIB([mozjs], [JS_GetStringChars], AC_DEFINE([HAVE_JS_GETSTRINGCHARS], [
 AC_CHECK_LIB([mozjs], [JS_StrictPropertyStub], AC_DEFINE([HAVE_JS_STRICTPROPERTYSTUB], [1], [Define if we have JS_StrictPropertyStub]),, [$JS_LIBS])
 AC_CHECK_LIB([mozjs], [JS_GetGlobalForScopeChain], AC_DEFINE([HAVE_JS_GETGLOBALFORSCOPECHAIN], [1], [Define if we have JS_GetGlobalForScopeChain]),, [$JS_LIBS])
 AC_CHECK_LIB([mozjs], [JS_DestroyScript], AC_DEFINE([HAVE_JS_DESTROYSCRIPT], [1], [Define if we still have JS_DestroyScript]),, [$JS_LIBS])
+AC_CHECK_LIB([mozjs], [JS_DecodeUTF8], AC_DEFINE([HAVE_JS_DECODEUTF8], [1], [Define if we have JS_DecodeUTF8]),, [$JS_LIBS])
 
 AC_MSG_CHECKING([for mozilla-js >= 2 ])
 if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
diff --git a/modules/console.c b/modules/console.c
index e6945be..8e20db3 100644
--- a/modules/console.c
+++ b/modules/console.c
@@ -196,7 +196,11 @@ gjs_console_interact(JSContext *context,
             g_string_append(buffer, temp_buf);
             g_free(temp_buf);
             lineno++;
+#ifdef HAVE_JS_DECODEUTF8
+        } while (!JS_BufferIsCompilableUnit(context, JS_TRUE, object, buffer->str, buffer->len));
+#else
         } while (!JS_BufferIsCompilableUnit(context, object, buffer->str, buffer->len));
+#endif
 
         script = JS_CompileScript(context, object, buffer->str, buffer->len, "typein",
                                   startline);
-- 
1.7.5.4


From 00dd38de7ac8e82ac35c40909707fa91665c3102 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 5 May 2011 12:49:09 -0400
Subject: [PATCH 3/4] JS_CLASS_TRACE is a preprocessor macro, can't use
 AC_CHECK_LIB

Conflicts:

	configure.ac
---
 configure.ac |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 270bc46..d259471 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,30 @@ if test "$have_jslocale_to_unicode_const" = yes; then
      AC_DEFINE([JS_LOCALETOUNICODE_NEEDS_CONST_CHAR], [1], [Define if JSLocaleToUnicode takes a const char* for its src])
 fi
 
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $JS_CFLAGS"
+AC_MSG_CHECKING([for JS_CLASS_TRACE macro])
+AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+        [[
+            #include <jsapi.h>
+	    #ifndef JS_CLASS_TRACE
+	    #error "No JS_CLASS_TRACE"
+	    #endif
+        ]],
+        [[(void) 0;]]
+    )],
+    [have_js_class_trace=yes],
+    [have_js_class_trace=no])
+
+if test "x$have_js_class_trace" = xyes; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE([HAVE_JS_CLASS_TRACE], [1], [Define if we still have JS_CLASS_TRACE])
+else
+    AC_MSG_RESULT([no])
+fi
+CFLAGS="$save_CFLAGS"
+
 common_packages="gobject-2.0 >= gobject_required_version $JS_PACKAGE"
 gjs_packages="gmodule-2.0 gthread-2.0 $common_packages"
 gjs_gi_packages="gobject-introspection-1.0 >= 0.10.1 $common_packages"
-- 
1.7.5.4


From 5553cdd691ffddae3e3ffa5cc75e6575a237d0b7 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Wed, 4 May 2011 14:14:18 -0400
Subject: [PATCH 4/4] Support compilation with standalone mozjs185 release

Adjust the detection logic so that we look for mozjs-185.pc first.  If
we have this, we can skip all kinds of insanity.

See https://bugzilla.mozilla.org/show_bug.cgi?id=628723
for the discussion about creating this release.

https://bugzilla.gnome.org/show_bug.cgi?id=646369

Conflicts:

	configure.ac
---
 configure.ac |  218 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 121 insertions(+), 97 deletions(-)

diff --git a/configure.ac b/configure.ac
index d259471..cb54ffc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,124 +91,148 @@ m4_define(gobject_required_version, 2.18.0)
 AC_CHECK_HEADERS([malloc.h])
 AC_CHECK_FUNCS(mallinfo)
 
-# Look for Spidermonkey. If js-config exists, use that;
-# otherwise we try some pkgconfig files from various distributions.
+# First, try separate mozjs185 release
+AC_MSG_CHECKING([for standalone mozjs])
+PKG_CHECK_EXISTS([mozjs185], JS_PACKAGE=mozjs185,)
+if test x$JS_PACKAGE != x; then
+    FIREFOX_JS_LIBDIR=`$PKG_CONFIG --variable=libdir $JS_PACKAGE`
+    MOZJS_IS_STANDALONE=yes
+    MOZJS_LIB=mozjs185
+    AC_MSG_RESULT([yes])
+    PKG_CHECK_MODULES(JS, $JS_PACKAGE)
+else
+    AC_MSG_RESULT([no])
+    MOZJS_LIB=mozjs
+fi
+
+# If we didn't find mozjs185 (the standalone spidermonkey); look for
+# one from Firefox/XULRunner. If js-config exists, use that; otherwise
+# we try some pkgconfig files from various distributions.
 
 AC_ARG_VAR([JS_CONFIG], [The js-config program to use])
-if test "$ac_cv_env_JS_CONFIG_set" != "set"; then
+if test x$JS_PACKAGE = x && test "$ac_cv_env_JS_CONFIG_set" != "set"; then
     AC_PATH_PROG([JS_CONFIG], [js-config], [])
 fi
 
-if test -n "$JS_CONFIG"; then
-    JS_CFLAGS="$($JS_CONFIG --cflags)"
-    JS_LIBS="$($JS_CONFIG --libs)"
-    FIREFOX_JS_LIBDIR="$($JS_CONFIG --libdir)"
-    JS_PACKAGE=
-
-    # js-config gives almost usable CFLAGS, we must define one of XP_BEOS,
-    # XP_OS2, XP_WIN or XP_UNIX
-    JS_CFLAGS="$JS_CFLAGS -DXP_UNIX"
-else
-    ## spidermonkey .pc file name varies across distributions and Gecko version
-    ##
-    ## mozilla-js: Gecko 1.9, all distributions
-    ## xulrunner-js: Gecko 1.8 (and earlier?) Debian/Ubuntu
-    ## firefox-js: ???
-    ##
-    ## Checking for mozilla-js first will hopefully get us the newest version
-    ## of spidermonkey.
-    PKG_CHECK_EXISTS([mozilla-js], [JS_PACKAGE=mozilla-js],
-                     [PKG_CHECK_EXISTS([xulrunner-js], [JS_PACKAGE=xulrunner-js], [JS_PACKAGE=firefox-js])])
-
-    PKG_CHECK_MODULES(JS, $JS_PACKAGE)
-
-    ## some flavors of Firefox .pc only set sdkdir, not libdir
-    FIREFOX_JS_SDKDIR=`$PKG_CONFIG --variable=sdkdir $JS_PACKAGE`
-    FIREFOX_JS_LIBDIR=`$PKG_CONFIG --variable=libdir $JS_PACKAGE`
+if test x$JS_PACKAGE = x; then
+    if test -n "$JS_CONFIG"; then
+	JS_CFLAGS="$($JS_CONFIG --cflags)"
+	JS_LIBS="$($JS_CONFIG --libs)"
+	FIREFOX_JS_LIBDIR="$($JS_CONFIG --libdir)"
+	JS_PACKAGE=
+
+	# js-config gives almost usable CFLAGS, we must define one of XP_BEOS,
+	# XP_OS2, XP_WIN or XP_UNIX
+	JS_CFLAGS="$JS_CFLAGS -DXP_UNIX"
+    else
+	## spidermonkey .pc file name varies across distributions and Gecko version
+	##
+	## mozilla-js: Gecko 1.9, all distributions
+	## xulrunner-js: Gecko 1.8 (and earlier?) Debian/Ubuntu
+	## firefox-js: ???
+	##
+	## Checking for mozilla-js first will hopefully get us the newest version
+	## of spidermonkey.
+	if test x$JS_PACKAGE = x; then
+	    PKG_CHECK_EXISTS([mozilla-js], [JS_PACKAGE=mozilla-js],)
+
+	fi
+	if test x$JS_PACKAGE = x; then
+	    PKG_CHECK_EXISTS([xulrunner-js], [JS_PACKAGE=xulrunner-js])
+	fi
+	if test x$JS_PACKAGE = x; then
+	    PKG_CHECK_EXISTS([firefox-js], [JS_PACKAGE=firefox-js])
+	fi
+	if test x$JS_PACKAGE = x; then
+	    AC_MSG_ERROR([Unable to find spidermonkey package])
+	fi
+
+	PKG_CHECK_MODULES(JS, $JS_PACKAGE)
+
+	## some flavors of Firefox .pc only set sdkdir, not libdir
+	FIREFOX_JS_SDKDIR=`$PKG_CONFIG --variable=sdkdir $JS_PACKAGE`
+	FIREFOX_JS_LIBDIR=`$PKG_CONFIG --variable=libdir $JS_PACKAGE`
+
+	## Ubuntu does not set libdir in mozilla-js.pc
+	if test x"$FIREFOX_JS_LIBDIR" = x ; then
+	   ## Ubuntu returns xulrunner-devel as the sdkdir, but for the
+	   ## libdir we want the runtime location on the target system,
+	   ## so can't use -devel.
+	   ## The library is in the non-devel directory also.
+	   ## Don't ask me why it's in two places.
+	   FIREFOX_JS_LIBDIR=`echo "$FIREFOX_JS_SDKDIR" | sed -e 's/-devel//g'`
+
+	   if ! test -d "$FIREFOX_JS_LIBDIR" ; then
+	       FIREFOX_JS_LIBDIR=
+	   fi
+	fi
+    fi
 
-    ## Ubuntu does not set libdir in mozilla-js.pc
     if test x"$FIREFOX_JS_LIBDIR" = x ; then
-       ## Ubuntu returns xulrunner-devel as the sdkdir, but for the
-       ## libdir we want the runtime location on the target system,
-       ## so can't use -devel.
-       ## The library is in the non-devel directory also.
-       ## Don't ask me why it's in two places.
-       FIREFOX_JS_LIBDIR=`echo "$FIREFOX_JS_SDKDIR" | sed -e 's/-devel//g'`
-
-       if ! test -d "$FIREFOX_JS_LIBDIR" ; then
-           FIREFOX_JS_LIBDIR=
-       fi
+       AC_MSG_ERROR([Could not figure out where Firefox JavaScript library lives])
     fi
-fi
 
-if test x"$FIREFOX_JS_LIBDIR" = x ; then
-   AC_MSG_ERROR([Could not figure out where Firefox JavaScript library lives])
+    ## workaround for Ubuntu Hardy bug where mozilla-js.pc gives CFLAGS
+    ## -I.../stable while jsapi.h is in .../unstable
+    AC_MSG_CHECKING([if SpiderMonkey needs extra compiler flags])
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $JS_CFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jsapi.h>]])],
+	[js_extra_cflags_needed=no],
+	[js_extra_cflags_needed=yes])
+    CFLAGS="$save_CFLAGS"
+    AC_MSG_RESULT([$js_extra_cflags_needed])
+
+    JS_EXTRA_CFLAGS=
+    if test "$js_extra_cflags_needed" = yes; then
+	try_cflags="-I`$PKG_CONFIG --variable=includedir $JS_PACKAGE`/unstable"
+	AC_MSG_CHECKING([if $try_cflags works])
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $JS_CFLAGS $try_cflags"
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jsapi.h>]])],
+	    [AC_MSG_RESULT([yes])
+	     JS_EXTRA_CFLAGS="$try_cflags"],
+	    [AC_MSG_RESULT([no])])
+	CFLAGS="$save_CFLAGS"
+
+	if test x"$JS_EXTRA_CFLAGS" = x; then
+	    AC_MSG_ERROR([Unable to determine extra compiler flags needed])
+	fi
+    fi
+    AC_SUBST([JS_EXTRA_CFLAGS])
+
+    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
 fi
 
 AC_SUBST(JS_PACKAGE)
 AC_SUBST(FIREFOX_JS_LIBDIR)
 
-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
-
-AC_CHECK_LIB([mozjs], [JS_GetStringBytes], AC_DEFINE([HAVE_JS_GETSTRINGBYTES], [1], [Define if we still have JS_GetStringBytes]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_GetFunctionName], AC_DEFINE([HAVE_JS_GETFUNCTIONNAME], [1], [Define if we still have JS_GetFunctionName]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_GetStringChars], AC_DEFINE([HAVE_JS_GETSTRINGCHARS], [1], [Define if we still have JS_GetStringChars]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_StrictPropertyStub], AC_DEFINE([HAVE_JS_STRICTPROPERTYSTUB], [1], [Define if we have JS_StrictPropertyStub]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_GetGlobalForScopeChain], AC_DEFINE([HAVE_JS_GETGLOBALFORSCOPECHAIN], [1], [Define if we have JS_GetGlobalForScopeChain]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_DestroyScript], AC_DEFINE([HAVE_JS_DESTROYSCRIPT], [1], [Define if we still have JS_DestroyScript]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_DecodeUTF8], AC_DEFINE([HAVE_JS_DECODEUTF8], [1], [Define if we have JS_DecodeUTF8]),, [$JS_LIBS])
-
-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])
-  AC_CHECK_LIB([mozjs], [JS_FreezeObject], AC_DEFINE([HAVE_JS_FREEZEOBJECT], [1], [Define if we have JS_FreezeObject]),
+AC_CHECK_LIB([$MOZJS_LIB], [JS_GetStringBytes], AC_DEFINE([HAVE_JS_GETSTRINGBYTES], [1], [Define if we still have JS_GetStringBytes]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_GetFunctionName], AC_DEFINE([HAVE_JS_GETFUNCTIONNAME], [1], [Define if we still have JS_GetFunctionName]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_GetStringChars], AC_DEFINE([HAVE_JS_GETSTRINGCHARS], [1], [Define if we still have JS_GetStringChars]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_StrictPropertyStub], AC_DEFINE([HAVE_JS_STRICTPROPERTYSTUB], [1], [Define if we have JS_StrictPropertyStub]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_GetGlobalForScopeChain], AC_DEFINE([HAVE_JS_GETGLOBALFORSCOPECHAIN], [1], [Define if we have JS_GetGlobalForScopeChain]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_CLASS_TRACE], AC_DEFINE([HAVE_JS_CLASS_TRACE], [1], [Define if we still have JS_CLASS_TRACE]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_DestroyScript], AC_DEFINE([HAVE_JS_DESTROYSCRIPT], [1], [Define if we still have JS_DestroyScript]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_DecodeUTF8], AC_DEFINE([HAVE_JS_DECODEUTF8], [1], [Define if we have JS_DecodeUTF8]),, [$JS_LIBS])
+AC_CHECK_LIB([$MOZJS_LIB], [JS_FreezeObject], AC_DEFINE([HAVE_JS_FREEZEOBJECT], [1], [Define if we have JS_FreezeObject]),
               , [$JS_LIBS])
-  AC_CHECK_LIB([mozjs], [JS_IsScriptFrame], AC_DEFINE([HAVE_JS_ISSCRIPTFRAME], [1], [Define if we have JS_IsScriptFrame]),
+AC_CHECK_LIB([$MOZJS_LIB], [JS_IsScriptFrame], AC_DEFINE([HAVE_JS_ISSCRIPTFRAME], [1], [Define if we have JS_IsScriptFrame]),
               , [$JS_LIBS])
-  AC_CHECK_LIB([mozjs], [JS_EndPC], AC_DEFINE([HAVE_JS_ENDPC], [1], [Define if we have JS_EndPC]),
+AC_CHECK_LIB([$MOZJS_LIB], [JS_EndPC], AC_DEFINE([HAVE_JS_ENDPC], [1], [Define if we have JS_EndPC]),
               , [$JS_LIBS])
-  AC_CHECK_LIB([mozjs], [JS_NewCompartmentAndGlobalObject],
+AC_CHECK_LIB([$MOZJS_LIB], [JS_NewCompartmentAndGlobalObject],
               AC_DEFINE([HAVE_JS_NEWCOMPARTMENTANDGLOBALOBJECT], [1], [Define if we have JS_NewCompartmentAndGlobalObject]),
               , [$JS_LIBS])
 
-else
-  AC_MSG_RESULT([no])
-fi
-
-## workaround for Ubuntu Hardy bug where mozilla-js.pc gives CFLAGS
-## -I.../stable while jsapi.h is in .../unstable
-AC_MSG_CHECKING([if SpiderMonkey needs extra compiler flags])
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $JS_CFLAGS"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jsapi.h>]])],
-    [js_extra_cflags_needed=no],
-    [js_extra_cflags_needed=yes])
-CFLAGS="$save_CFLAGS"
-AC_MSG_RESULT([$js_extra_cflags_needed])
-
-JS_EXTRA_CFLAGS=
-if test "$js_extra_cflags_needed" = yes; then
-    try_cflags="-I`$PKG_CONFIG --variable=includedir $JS_PACKAGE`/unstable"
-    AC_MSG_CHECKING([if $try_cflags works])
-    save_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS $JS_CFLAGS $try_cflags"
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jsapi.h>]])],
-        [AC_MSG_RESULT([yes])
-         JS_EXTRA_CFLAGS="$try_cflags"],
-        [AC_MSG_RESULT([no])])
-    CFLAGS="$save_CFLAGS"
-
-    if test x"$JS_EXTRA_CFLAGS" = x; then
-        AC_MSG_ERROR([Unable to determine extra compiler flags needed])
-    fi
+if test x$MOZJS_IS_STANDALONE = xyes || `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
+  AC_DEFINE(HAVE_MOZJS_2, [1], [Define if mozilla-js is at least 2])
 fi
-AC_SUBST([JS_EXTRA_CFLAGS])
 
 AC_MSG_CHECKING([whether JSLocaleToUnicode takes a const char*])
 save_CFLAGS="$CFLAGS"
-- 
1.7.5.4