Don't search for SpiderMonkey in hardcoded directories (/usr /usr/local /opt/spidermonkey /opt/js), and don't support --with-spidermonkey=DIR (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. --- أحمد المحمودي <aelmahmo...@sabily.org> writes: > Could this be changed to a for loop that checks for either mozjs185 or > mozilla-js ? In Debian, mozjs is installed as part of iceweasel, ie. > 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 --- a/configure.in +++ b/configure.in @@ -623,78 +623,136 @@ fi # Check for SpiderMonkey, optional even if installed. # =================================================================== -xulrunner_includes= -xulrunner_libs= -AC_ARG_WITH(xulrunner_includes, [ --with-xulrunner_includes=DIR - When set, the libmozjs of xulrunner is used instead of "standalone" SpiderMonkey], - [xulrunner_includes="$withval"]) -AC_ARG_WITH(xulrunner_libs, [ --with-xulrunner_libs=OPTIONS - Linker options for xulrunner, - eg. --with-xulrunner_libs="-Wl,-R/usr/lib/xulrunner -L/usr/lib/xulrunner -lmozjs"], - [xulrunner_libs="$withval"]) -AC_ARG_WITH(spidermonkey, [ --without-spidermonkey disable SpiderMonkey Mozilla JavaScript engine support], - [if test "$withval" = no; then disable_spidermonkey=yes; fi]) - -AC_MSG_CHECKING([for SpiderMonkey (1.5 RC3a or later)]) - +# 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=DIR], + [When set, the libmozjs of xulrunner is used instead of "standalone" SpiderMonkey])]) +AC_ARG_WITH([xulrunner-libs], + [AS_HELP_STRING([--with-xulrunner-libs=OPTIONS], + [Linker options for xulrunner, eg. --with-xulrunner-libs="-Wl,-R/usr/lib/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= EL_SAVE_FLAGS -cf_result=no -if test -z "$disable_spidermonkey"; then - if test ! -d "$withval"; then - withval=""; - fi - if test ! -z "$xulrunner_includes"; then - SPIDERMONKEY_LIBS="$xulrunner_libs" - SPIDERMONKEY_CFLAGS="-I$xulrunner_includes" - LIBS="$SPIDERMONKEY_LIBS $LIBS_X" - CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" - CPPFLAGS="$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]])], - [cf_result=yes],[cf_result=no]) +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="no" + ;; + "" | yes) + ;; + *) + AC_MSG_WARN([This version of ELinks does not support --with-spidermonkey=DIRECTORY.]) + ;; +esac + +case "$with_xulrunner_includes" in + no) + # Discard --without-xulrunner-includes. + with_xulrunner_includes= + ;; + yes) + AC_MSG_WARN([Please use --with-xulrunner-includes=DIR, not only --with-xulrunner-includes.]) + with_xulrunner_includes= + ;; +esac +case "$with_xulrunner_libs" in + no) + # Discard --without-xulrunner-libs. + with_xulrunner_libs= + ;; + yes) + AC_MSG_WARN([Please use --with-xulrunner-libs=OPTIONS, not only --with-xulrunner-libs.]) + with_xulrunner_libs= + ;; +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="$with_xulrunner_libs" + SPIDERMONKEY_CFLAGS="${with_xulrunner_includes:+-I$with_xulrunner_includes}" + LIBS="$SPIDERMONKEY_LIBS $LIBS_X" + CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" + CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" + + EL_LINK_SPIDERMONKEY_IFELSE( + [CONFIG_SPIDERMONKEY=yes], + [# Because the user specifically asked for xulrunner, + # do not search for SpiderMonkey in other places. + CONFIG_SPIDERMONKEY=no]) + 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 - for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do - for spidermonkeyinclude in "/include" "/include/js" "/include/smjs" "/include/mozjs"; do - for spidermonkeylib in js smjs mozjs; do - if test "$cf_result" = no; then - SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib -l$spidermonkeylib" - SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude" - - LIBS="$SPIDERMONKEY_LIBS $LIBS_X" - CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" - CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define XP_UNIX - #define XP_UNIX - #include <jsapi.h>]], [[ - #ifndef JS_VERSION - #error JS_VERSION - #endif - #if JS_VERSION < 185 - #error too old - #endif]])], - [cf_result=yes],[cf_result=no]) - fi - done - done - done + AC_MSG_CHECKING([for SpiderMonkey (1.8.5 or later) in pkg-config $package]) + # 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="$(pkg-config --libs $package)" + SPIDERMONKEY_CFLAGS="$(pkg-config --cflags $package)" + LIBS="$SPIDERMONKEY_LIBS $LIBS_X" + CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" + CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" + EL_LINK_SPIDERMONKEY_IFELSE( + [CONFIG_SPIDERMONKEY=yes + 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=no fi -AC_MSG_RESULT($cf_result) -CONFIG_SPIDERMONKEY="$cf_result" -if test "$cf_result" = "yes"; then - AC_CHECK_FUNCS([[JS_ReportAllocationOverflow]]) - AC_CHECK_FUNCS(JS_SetBranchCallback) - AC_CHECK_FUNCS(JS_TriggerOperationCallback, HAVE_JS_TRIGGEROPERATIONCALLBACK=yes) +if test "$CONFIG_SPIDERMONKEY" = "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_TRIGGEROPERATIONCALLBACK=yes]) +elif test -n "$with_spidermonkey" && test "x$with_spidermonkey" != "xno"; then + AC_MSG_WARN([SpiderMonkey was not found even though you specified --with-spidermonkey.]) fi EL_RESTORE_FLAGS diff --git a/doc/installation.txt b/doc/installation.txt index c6c07a9..d5d4391 100644 --- 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 \ - 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] \ -- 1.7.2.5
pgpTbDroVuWA1.pgp
Description: PGP signature
_______________________________________________ elinks-dev mailing list elinks-dev@linuxfromscratch.org http://linuxfromscratch.org/mailman/listinfo/elinks-dev