[0.13 PATCH] JS: Use pkg-config mozjs185, not hardcoded directories

Kalle Olavi Niemitalo <[email protected]> Sat, 23 Apr 2011 11:58:26 +0300
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
--===============0594582806==
Content-Type: multipart/signed; boundary="=-=-=";
	micalg=pgp-sha1; protocol="application/pgp-signature"

--=-=-=
Content-Transfer-Encoding: quoted-printable

The --with-spidermonkey option no longer supports a DIR argument.
AFAICT, that argument was never documented anyway.

This commit also changes the SpiderMonkey version number in "checking"
messages from 1.5 RC3a to 1.8.5, which matches the actual checks.
=2D--

Witek recently changed the master branch (ELinks 0.13.GIT) to
require SpiderMonkey 1.8.5.  The elinks-0.11 and elinks-0.12
branches do not support SpiderMonkey 1.8.5.  I'd like to be able
to build both branches, so I have installed SpiderMonkey 1.8.5 in
my home directory: ~/prefix/x86_64-unknown-linux-gnu/lib/ and
~/prefix/include/js/.  I had difficulty getting ELinks 0.13.GIT
to use SpiderMonkey from those directories, however.  Because
SpiderMonkey 1.8.5 also installs mozjs185.pc, which refers to the
correct directories, I'd like to make the configure script of
ELinks 0.13.GIT use that.  Then, only $PKG_CONFIG_PATH needs to
be set.

Please post if this patch would cause difficulty to you.
I will probably be offline for a day or two.

 configure.in |   90 ++++++++++++++++++++++++++++--------------------------=
---
 1 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/configure.in b/configure.in
index 6055a0e..72be7f8 100644
=2D-- a/configure.in
+++ b/configure.in
@@ -632,26 +632,25 @@ AC_ARG_WITH(xulrunner_libs, [  --with-xulrunner_libs=
=3DOPTIONS
                           Linker options for xulrunner,
                           eg. --with-xulrunner_libs=3D"-Wl,-R/usr/lib/xulr=
unner -L/usr/lib/xulrunner -lmozjs"],
             [xulrunner_libs=3D"$withval"])
=2DAC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonke=
y Mozilla JavaScript engine support],
=2D            [if test "$withval" =3D no; then disable_spidermonkey=3Dyes;=
 fi])
=2D
=2DAC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)])
+AC_ARG_WITH(spidermonkey, [  --without-spidermonkey  disable SpiderMonkey =
Mozilla JavaScript engine support])
=20
+# features.conf is not supposed to define CONFIG_SPIDERMONKEY.
+CONFIG_SPIDERMONKEY=3D
 EL_SAVE_FLAGS
=2Dcf_result=3Dno
=2D
=2Dif test -z "$disable_spidermonkey"; then
=2D	if test ! -d "$withval"; then
=2D		withval=3D"";
=2D	fi
=2D	if test ! -z "$xulrunner_includes"; then
=2D		SPIDERMONKEY_LIBS=3D"$xulrunner_libs"
=2D		SPIDERMONKEY_CFLAGS=3D"-I$xulrunner_includes"
=2D		LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X"
=2D		CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS"
=2D		CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
=20
=2D		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
+if test "$with_spidermonkey" =3D "no"; then
+	AC_MSG_CHECKING([for SpiderMonkey])
+	AC_MSG_RESULT([disabled])
+	CONFIG_SPIDERMONKEY=3D"no"
+elif test -n "$xulrunner_includes"; then
+	AC_MSG_CHECKING([for SpiderMonkey (1.8.5 or later) in xulrunner])
+	SPIDERMONKEY_LIBS=3D"$xulrunner_libs"
+	SPIDERMONKEY_CFLAGS=3D"-I$xulrunner_includes"
+	LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X"
+	CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS"
+	CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
+
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
 		#include <jsapi.h>]], [[
 		#ifndef JS_VERSION
 		#error JS_VERSION
@@ -659,39 +658,38 @@ if test -z "$disable_spidermonkey"; then
 		#if JS_VERSION < 185
 		#error too old
 		#endif]])],
=2D		[cf_result=3Dyes],[cf_result=3Dno])
+		[CONFIG_SPIDERMONKEY=3Dyes],[CONFIG_SPIDERMONKEY=3Dno])
+	AC_MSG_RESULT([$CONFIG_SPIDERMONKEY])
+else
+	AC_MSG_CHECKING([for mozjs185 (SpiderMonkey 1.8.5) in pkg-config])
+	# In pkg-config 0.25, pkg-config --exists mozjs185 returns 0 (success)
+	# even if mozjs185 depends on nspr, which has not been installed.
+	# However, pkg-config --cflags mozjs185 returns 1 then.
+	if pkg-config --cflags --libs mozjs185 > /dev/null 2>&AS_MESSAGE_LOG_FD; =
then
+		SPIDERMONKEY_LIBS=3D"$(pkg-config --libs mozjs185)"
+		SPIDERMONKEY_CFLAGS=3D"$(pkg-config --cflags mozjs185)"
+		LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X"
+		CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS"
+		CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
+			#include <jsapi.h>]], [[
+			#ifndef JS_VERSION
+			#error JS_VERSION
+			#endif
+			#if JS_VERSION < 185
+			#error too old
+			#endif]])],
+			[AC_MSG_RESULT([yes])
+			 CONFIG_SPIDERMONKEY=3Dyes],
+			[AC_MSG_RESULT([found but does not work])
+			 CONFIG_SPIDERMONKEY=3Dno])
 	else
=2D		for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey=
 /opt/js; do
=2D			for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "=
/include/mozjs"; do
=2D				for spidermonkeylib in js smjs mozjs; do
=2D					if test "$cf_result" =3D no; then
=2D						SPIDERMONKEY_LIBS=3D"-L$spidermonkeydir/lib -l$spidermonkeylib"
=2D						SPIDERMONKEY_CFLAGS=3D"-I$spidermonkeydir$spidermonkeyinclude"
=2D
=2D						LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X"
=2D						CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS"
=2D						CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
=2D
=2D						AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX
=2D							#define XP_UNIX
=2D							#include <jsapi.h>]], [[
=2D							#ifndef JS_VERSION
=2D							#error JS_VERSION
=2D							#endif
=2D							#if JS_VERSION < 185
=2D							#error too old
=2D							#endif]])],
=2D							[cf_result=3Dyes],[cf_result=3Dno])
=2D					fi
=2D				done
=2D			done
=2D		done
+		AC_MSG_RESULT([no])
+		CONFIG_SPIDERMONKEY=3Dno
 	fi
 fi
=20
=2DAC_MSG_RESULT($cf_result)
=2DCONFIG_SPIDERMONKEY=3D"$cf_result"
=2Dif test "$cf_result" =3D "yes"; then
+if test "$CONFIG_SPIDERMONKEY" =3D "yes"; then
 	AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]])
 	AC_CHECK_FUNCS(JS_SetBranchCallback)
 	AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCALLB=
ACK=3Dyes)
=2D-=20
1.7.2.3

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk2yq/8ACgkQHm9IGt60eMgLSACfbSwVlGjIMafkq6qbZyH/hPR9
AZ8AnjkbQe4mM9EY12wgzXZgQYQCSddD
=XnOz
-----END PGP SIGNATURE-----
--=-=-=--

--===============0594582806==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

--===============0594582806==--