[PATCHv2] configure: Find SpiderMonkey with pkg-config
Kalle Olavi Niemitalo <[email protected]> Sun, 1 May 2011 01:49:51 +0300
| Newsgroups | gmane.comp.web.links |
|---|---|
| Message-ID | <[email protected]> |
--===============0618614571== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Don't search for SpiderMonkey in hardcoded directories (/usr /usr/local /opt/spidermonkey /opt/js), and don't support =2D-with-spidermonkey=3DDIR (which I think was never documented). Instead, ask pkg-config for mozjs185 or mozilla-js. Everyone who installed SpiderMonkey in an unusual place must either set PKG_CONFIG_PATH appropriately or use --with-xulrunner-includes and --with-xulrunner-libs. This commit also includes a few minor changes in the SpiderMonkey section of the configure script: * Update the SpiderMonkey version number in "checking" messages from 1.5 RC3a to 1.8.5, which matches the actual checks. * Rename --with-xulrunner_includes to --with-xulrunner-includes, and --with-xulrunner_libs likewise. This only affects the --help output; the configure script accepts both spellings. * Wrap the option documentation with AS_HELP_STRING. * Use the Autoconf-generated $with_xulrunner_includes etc. variables directly, instead of copying $withval. * Quote the arguments of macros more consistently. * Warn if SpiderMonkey was requested but not found. =2D-- =D8=A3=D8=AD=D9=85=D8=AF =D8=A7=D9=84=D9=85=D8=AD=D9=85=D9=88=D8=AF=D9=8A <= [email protected]> writes: > Could this be changed to a for loop that checks for either mozjs185 or= =20 > mozilla-js ? In Debian, mozjs is installed as part of iceweasel, ie.=20 > firefox, and that installs a mozilla-js.pc instead of mozjs185.pc Done. configure.in | 190 ++++++++++++++++++++++++++++++++--------------= --- doc/installation.txt | 2 +- 2 files changed, 125 insertions(+), 67 deletions(-) diff --git a/configure.in b/configure.in index 2bd6830..65c4dbf 100644 =2D-- a/configure.in +++ b/configure.in @@ -623,78 +623,136 @@ fi # Check for SpiderMonkey, optional even if installed. # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 =2Dxulrunner_includes=3D =2Dxulrunner_libs=3D =2DAC_ARG_WITH(xulrunner_includes, [ --with-xulrunner_includes=3DDIR =2D When set, the libmozjs of xulrunner is used in= stead of "standalone" SpiderMonkey], =2D [xulrunner_includes=3D"$withval"]) =2DAC_ARG_WITH(xulrunner_libs, [ --with-xulrunner_libs=3DOPTIONS =2D Linker options for xulrunner, =2D eg. --with-xulrunner_libs=3D"-Wl,-R/usr/lib/xu= lrunner -L/usr/lib/xulrunner -lmozjs"], =2D [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)]) =2D +# These options set the $with_xulrunner_includes, +# $with_xulrunner_libs, and $with_spidermonkey variables. +AC_ARG_WITH([xulrunner-includes], + [AS_HELP_STRING([--with-xulrunner-includes=3DDIR], + [When set, the libmozjs of xulrunner is used instead of "standalone" Spi= derMonkey])]) +AC_ARG_WITH([xulrunner-libs], + [AS_HELP_STRING([--with-xulrunner-libs=3DOPTIONS], + [Linker options for xulrunner, eg. --with-xulrunner-libs=3D"-Wl,-R/usr/l= ib/xulrunner -L/usr/lib/xulrunner -lmozjs"])]) +AC_ARG_WITH([spidermonkey], + [AS_HELP_STRING([--without-spidermonkey], + [disable SpiderMonkey Mozilla JavaScript engine support])]) + +dnl EL_LINK_SPIDERMONKEY_IFELSE(if-found, if-not-found) +AC_DEFUN([EL_LINK_SPIDERMONKEY_IFELSE], + [AC_LINK_IFELSE([AC_LANG_PROGRAM( +[[/* mozilla-js.pc may have -DXP_UNIX in Cflags. + * Avoid warnings about conflicting definitions. */ +#ifndef XP_UNIX +# define XP_UNIX 1 +#endif +#include <jsapi.h> +#ifndef JS_VERSION +# error <jsapi.h> did not define JS_VERSION +#elif JS_VERSION < 185 +# error too old +#endif]], [])], + [$1], [$2])]) + +# CONFIG_SPIDERMONKEY is initially blank. We change it to "yes" or "no" +# when we know for sure whether we're going to use SpiderMonkey or not. +# (features.conf is not supposed to define it.) +CONFIG_SPIDERMONKEY=3D EL_SAVE_FLAGS =2Dcf_result=3Dno =20 =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" =2D =2D AC_LINK_IFELSE([AC_LANG_PROGRAM([[#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]) +case "$with_spidermonkey" in + no) + # The user specified --without-spidermonkey. + # That overrides the other SpiderMonkey options. + AC_MSG_CHECKING([for SpiderMonkey]) + AC_MSG_RESULT([disabled]) + CONFIG_SPIDERMONKEY=3D"no" + ;; + "" | yes) + ;; + *) + AC_MSG_WARN([This version of ELinks does not support --with-spidermonkey= =3DDIRECTORY.]) + ;; +esac + +case "$with_xulrunner_includes" in + no) + # Discard --without-xulrunner-includes. + with_xulrunner_includes=3D + ;; + yes) + AC_MSG_WARN([Please use --with-xulrunner-includes=3DDIR, not only --with= -xulrunner-includes.]) + with_xulrunner_includes=3D + ;; +esac +case "$with_xulrunner_libs" in + no) + # Discard --without-xulrunner-libs. + with_xulrunner_libs=3D + ;; + yes) + AC_MSG_WARN([Please use --with-xulrunner-libs=3DOPTIONS, not only --with= -xulrunner-libs.]) + with_xulrunner_libs=3D + ;; +esac + +if test -z "$CONFIG_SPIDERMONKEY" && (test -n "$with_xulrunner_includes" |= | test -n "$with_xulrunner_libs"); then + AC_MSG_CHECKING([for SpiderMonkey (1.8.5 or later) in xulrunner]) + SPIDERMONKEY_LIBS=3D"$with_xulrunner_libs" + SPIDERMONKEY_CFLAGS=3D"${with_xulrunner_includes:+-I$with_xulrunner_inclu= des}" + LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X" + CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS" + CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" + + EL_LINK_SPIDERMONKEY_IFELSE( + [CONFIG_SPIDERMONKEY=3Dyes], + [# Because the user specifically asked for xulrunner, + # do not search for SpiderMonkey in other places. + CONFIG_SPIDERMONKEY=3Dno]) + AC_MSG_RESULT([$CONFIG_SPIDERMONKEY]) +fi + +# The SpiderMonkey 1.8.5 standalone sources install mozjs185.pc, +# but the Debian libmozjs-dev package installs mozilla-js.pc. +# Check mozjs185 first, because it has the version number in the name +# and therefore is less likely to be a newer incompatible version. +# (This configure script rejects older incompatible versions +# but can let newer ones through.) +for package in mozjs185 mozilla-js; do + if test -n "$CONFIG_SPIDERMONKEY"; then + break 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_CHECKING([for SpiderMonkey (1.8.5 or later) in pkg-config $packag= e]) + # 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 $package > /dev/null 2>&AS_MESSAGE_LOG_FD;= then + SPIDERMONKEY_LIBS=3D"$(pkg-config --libs $package)" + SPIDERMONKEY_CFLAGS=3D"$(pkg-config --cflags $package)" + LIBS=3D"$SPIDERMONKEY_LIBS $LIBS_X" + CFLAGS=3D"$CFLAGS_X $SPIDERMONKEY_CFLAGS" + CPPFLAGS=3D"$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" + EL_LINK_SPIDERMONKEY_IFELSE( + [CONFIG_SPIDERMONKEY=3Dyes + AC_MSG_RESULT([yes])], + [# Leave CONFIG_SPIDERMONKEY blank, to continue the search. + AC_MSG_RESULT([found but unusable])]) + else + AC_MSG_RESULT([no]) + fi fi +done + +if test -z "$CONFIG_SPIDERMONKEY"; then + # Didn't find SpiderMonkey anywhere. + CONFIG_SPIDERMONKEY=3Dno fi =20 =2DAC_MSG_RESULT($cf_result) =2DCONFIG_SPIDERMONKEY=3D"$cf_result" =2Dif test "$cf_result" =3D "yes"; then =2D AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]]) =2D AC_CHECK_FUNCS(JS_SetBranchCallback) =2D AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCAL= LBACK=3Dyes) +if test "$CONFIG_SPIDERMONKEY" =3D "yes"; then + # LIBS, CFLAGS, and CPPFLAGS still include the SpiderMonkey options. + AC_CHECK_FUNCS([JS_ReportAllocationOverflow]) + AC_CHECK_FUNCS([JS_SetBranchCallback]) + AC_CHECK_FUNCS([JS_TriggerOperationCallback], [HAVE_JS_TRIGGEROPERATIONCA= LLBACK=3Dyes]) +elif test -n "$with_spidermonkey" && test "x$with_spidermonkey" !=3D "xno"= ; then + AC_MSG_WARN([SpiderMonkey was not found even though you specified --with-= spidermonkey.]) fi EL_RESTORE_FLAGS =20 diff --git a/doc/installation.txt b/doc/installation.txt index c6c07a9..d5d4391 100644 =2D-- a/doc/installation.txt +++ b/doc/installation.txt @@ -51,7 +51,7 @@ LZMA Utils |Likewise, for LZMA compressed documents. = \ OpenSSL, GNU TLS, or nss_compat_ossl \ |For handling secure HTTP browsing. pkg-config |Needed for locating some libraries (at least \ =2D GNU TLS and TRE) + GNU TLS, TRE, and SpiderMonkey) GPM |'General Purpose Mouse' for mouse support. expat |'XML Parser Toolkit' needed for XBEL support. http://laurikari.net/tre/[TRE] \ =2D-=20 1.7.2.5 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk28pxEACgkQHm9IGt60eMh2kwCfRmvampe4wfESHchShxLkM7aU 4NAAoJRyXIsEqjUEwYkGt92WJzqjJxeD =+dQ0 -----END PGP SIGNATURE----- --=-=-=-- --===============0618614571== 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 --===============0618614571==--