# Pkg-config fails on checking seamonkey-js 2.0b12 version
diff -urNad libproxy-0.4.7-orig/libproxy/cmake/modules/pacrunner_mozjs.cmk libproxy-0.4.7/libproxy/cmake/modules/pacrunner_mozjs.cmk
--- libproxy-0.4.7-orig/libproxy/cmake/modules/pacrunner_mozjs.cmk	2011-06-07 00:44:37.000000000 +0300
+++ libproxy-0.4.7/libproxy/cmake/modules/pacrunner_mozjs.cmk	2011-12-27 20:55:55.000000000 +0200
@@ -11,7 +11,7 @@
   option(WITH_MOZJS "Search for MOZJS package" ON)
   if (WITH_MOZJS)
     foreach(MOZJSLIB ${MOZJS_SEARCH_ORDER})
-      pkg_search_module(MOZJS ${MOZJSLIB}>=2.0b12)
+      pkg_search_module(MOZJS ${MOZJSLIB}>=2.0)
       if(MOZJS_FOUND)
         include_directories(${MOZJS_INCLUDE_DIRS})
         link_directories(${MOZJS_LIBRARY_DIRS})
# Necesary
diff -urNad libproxy-0.4.7-orig/libproxy/cmake/modules.cmk libproxy-0.4.7/libproxy/cmake/modules.cmk
--- libproxy-0.4.7-orig/libproxy/cmake/modules.cmk	2011-06-07 00:44:37.000000000 +0300
+++ libproxy-0.4.7/libproxy/cmake/modules.cmk	2011-12-27 20:55:30.000000000 +0200
@@ -39,7 +39,7 @@
 px_module(ignore_hostname          1                 1)
 px_module(ignore_ip                1                 1)
 px_module(network_networkmanager   "${NM_FOUND}"     0       ${NM_LIBRARIES})
-px_module(pacrunner_mozjs          "${MOZJS_FOUND}"  ${BIPR} ${MOZJS_LIBRARIES})
+px_module(pacrunner_mozjs          "${MOZJS_FOUND}"  ${BIPR} ${MOZJS_LDFLAGS})
 px_module(pacrunner_natus          "${NATUS_FOUND}"  ${BIPR} ${NATUS_LIBRARIES})
 px_module(pacrunner_webkit         "${WEBKIT_FOUND}" ${BIPR} ${WEBKIT_LIBRARIES})
 px_module(wpad_dns_alias           1                 1)
# Revert some changes to fix build
diff -urNad libproxy-0.4.7-orig/libproxy/modules/pacrunner_mozjs.cpp libproxy-0.4.7/libproxy/modules/pacrunner_mozjs.cpp
--- libproxy-0.4.7-orig/libproxy/modules/pacrunner_mozjs.cpp	2011-06-07 00:44:37.000000000 +0300
+++ libproxy-0.4.7/libproxy/modules/pacrunner_mozjs.cpp	2011-12-27 23:45:07.000000000 +0200
@@ -42,12 +42,12 @@
 #define INET6_ADDRSTRLEN 46
 #endif
 
-static JSBool dnsResolve_(JSContext *cx, jsval hostname, jsval *vp) {
+static JSBool dnsResolve(JSContext *cx, JSObject * /*obj*/, uintN /*argc*/, jsval *argv, jsval *rval) {
 	// Get hostname argument
-	char *tmp = JS_EncodeString(cx, JS_ValueToString(cx, hostname));
+	char *tmp = JS_strdup(cx, JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
 
 	// Set the default return value
-	JS_SET_RVAL(cx, vp, JSVAL_NULL);
+	*rval = JSVAL_NULL;
 
 	// Look it up
 	struct addrinfo *info = NULL;
@@ -66,7 +66,7 @@
 					NI_NUMERICHOST)) goto out;
 
 	// We succeeded
-	JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyN(cx, tmp, strlen(tmp))));
+	*rval = STRING_TO_JSVAL(JS_NewString(cx, tmp, strlen(tmp)));
 	tmp = NULL;
 
 	out:
@@ -75,20 +75,15 @@
 		return true;
 }
 
-static JSBool dnsResolve(JSContext *cx, uintN /*argc*/, jsval *vp) {
-	jsval *argv = JS_ARGV(cx, vp);
-	return dnsResolve_(cx, argv[0], vp);
-}
-
-static JSBool myIpAddress(JSContext *cx, uintN /*argc*/, jsval *vp) {
+static JSBool myIpAddress(JSContext *cx, JSObject *obj, uintN /*argc*/, jsval * /*argv*/, jsval *rval) {
 	char *hostname = (char *) JS_malloc(cx, 1024);
 	if (!gethostname(hostname, 1023)) {
-		JSString *myhost = JS_NewStringCopyN(cx, hostname, strlen(hostname));
+		JSString *myhost = JS_NewString(cx, hostname, strlen(hostname));
 		jsval arg = STRING_TO_JSVAL(myhost);
-		return dnsResolve_(cx, 1, &arg);
+		return dnsResolve(cx, obj, 1, &arg, rval);
 	}
 	JS_free(cx, hostname);
-	JS_SET_RVAL(cx, vp, JSVAL_NULL);
+	*rval = JSVAL_NULL;
 	return true;
 }
 
@@ -96,7 +91,7 @@
 // This MUST be a static global
 static JSClass cls = {
 		"global", JSCLASS_GLOBAL_FLAGS,
-		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
+		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
 		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
@@ -116,7 +111,7 @@
 	    //JS_SetOptions(this->jsctx, JSOPTION_VAROBJFIX);
 	    //JS_SetVersion(this->jsctx, JSVERSION_LATEST);
 	    //JS_SetErrorReporter(cx, reportError);
-		if (!(this->jsglb = JS_NewCompartmentAndGlobalObject(this->jsctx, &cls, NULL))) goto error;
+		if (!(this->jsglb = JS_NewObject(this->jsctx, &cls, NULL, NULL))) goto error;
 		if (!JS_InitStandardClasses(this->jsctx, this->jsglb))            goto error;
 
 		// Define Javascript functions
