diff --git a/Makefile.config.in b/Makefile.config.in index 4eb8e485..cfb37945 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -76,7 +76,6 @@ PYTHON_LIBS = @PYTHON_LIBS@ RANLIB = @RANLIB@ RUBY_CFLAGS = @RUBY_CFLAGS@ RUBY_LIBS = @RUBY_LIBS@ -SEE_CFLAGS = @SEE_CFLAGS@ SPARSE = @SPARSE@ SPIDERMONKEY_CFLAGS = @SPIDERMONKEY_CFLAGS@ SPIDERMONKEY_LIBS = @SPIDERMONKEY_LIBS@ @@ -134,10 +133,10 @@ CONFIG_RISCOS = @CONFIG_RISCOS@ CONFIG_RUBY = @CONFIG_RUBY@ CONFIG_SCANNER = @CONFIG_SCANNER@ CONFIG_SCRIPTING = @CONFIG_SCRIPTING@ -CONFIG_SEE = @CONFIG_SEE@ CONFIG_SHA1 = @CONFIG_SHA1@ CONFIG_SMALL = @CONFIG_SMALL@ CONFIG_SMB = @CONFIG_SMB@ +CONFIG_SM_SCRIPTING = @CONFIG_SM_SCRIPTING@ CONFIG_SPIDERMONKEY = @CONFIG_SPIDERMONKEY@ CONFIG_SSL = @CONFIG_SSL@ CONFIG_SYSMOUSE = @CONFIG_SYSMOUSE@ diff --git a/configure.in b/configure.in index 92062cd5..e89ac427 100644 --- a/configure.in +++ b/configure.in @@ -496,6 +496,63 @@ if test "$CONFIG_WIN32" = yes; then EL_CONFIG_WIN32 fi +dnl =================================================================== +dnl Check for SpiderMonkey, optional even if installed. +dnl =================================================================== + +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]) + +EL_SAVE_FLAGS +cf_result=no + +if test -z "$disable_spidermonkey"; then + if test ! -d "$withval"; then + withval=""; + fi + for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do + for spidermonkeyinclude in "/include" "/include/js" "/include/smjs"; do + for spidermonkeylib in js smjs; do + if test "$cf_result" = no; then + SPIDERMONKEY_LIBS="-l$spidermonkeylib" + + if test ! -z "$spidermonkeydir"; then + SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS" + SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude" + fi + + LIBS="$SPIDERMONKEY_LIBS $LIBS_X" + CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" + CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" + + AC_TRY_LINK([#define XP_UNIX + #include ], + [JS_GetImplementationVersion()], + cf_result=yes, cf_result=no) + fi + done + done + done +fi + +AC_MSG_RESULT($cf_result) + +if test "$cf_result" != yes; then + EL_RESTORE_FLAGS +else + EL_CONFIG(CONFIG_SPIDERMONKEY, [SpiderMonkey]) + + CFLAGS="$CFLAGS_X" + AC_SUBST(SPIDERMONKEY_LIBS) + AC_SUBST(SPIDERMONKEY_CFLAGS) +fi + +AC_SUBST(CONFIG_SPIDERMONKEY) + +EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_SPIDERMONKEY], [ECMAScript (JavaScript)]) + + dnl =================================================================== dnl Check for Guile, optional even if installed. dnl =================================================================== @@ -724,77 +781,36 @@ dnl =================================================================== EL_CONFIG_RUBY +dnl =================================================================== +dnl Optional Spidermonkey-based ECMAScript browser scripting +dnl =================================================================== + +AC_ARG_ENABLE(sm-scripting, + [ --disable-sm-scripting ECMAScript browser scripting (requires Spidermonkey)], + [if test "$enableval" != no; then enableval="yes"; fi + CONFIG_SM_SCRIPTING="$enableval";]) + +if test "x$CONFIG_SPIDERMONKEY" = xyes && + test "x$CONFIG_SM_SCRIPTING" = xyes; then + EL_CONFIG(CONFIG_SM_SCRIPTING, [SpiderMonkey]) +else + CONFIG_SM_SCRIPTING=no +fi + dnl =================================================================== dnl Setup global scripting dnl =================================================================== -EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_GUILE CONFIG_LUA CONFIG_PERL CONFIG_PYTHON CONFIG_RUBY CONFIG_SEE], [Scripting]) +EL_CONFIG_DEPENDS(CONFIG_SCRIPTING, [CONFIG_GUILE CONFIG_LUA CONFIG_PERL CONFIG_PYTHON CONFIG_RUBY CONFIG_SM_SCRIPTING], [Browser scripting]) AC_SUBST(CONFIG_GUILE) AC_SUBST(CONFIG_LUA) AC_SUBST(CONFIG_PERL) AC_SUBST(CONFIG_PYTHON) AC_SUBST(CONFIG_RUBY) -AC_SUBST(CONFIG_SEE) +AC_SUBST(CONFIG_SM_SCRIPTING) AC_SUBST(CONFIG_SCRIPTING) -dnl =================================================================== -dnl Check for SpiderMonkey, optional even if installed. -dnl =================================================================== - -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]) - -EL_SAVE_FLAGS -cf_result=no - -if test -z "$disable_spidermonkey"; then - if test ! -d "$withval"; then - withval=""; - fi - for spidermonkeydir in "$withval" "" /usr /usr/local /opt/spidermonkey /opt/js; do - for spidermonkeyinclude in "/include" "/include/js" "/include/smjs"; do - for spidermonkeylib in js smjs; do - if test "$cf_result" = no; then - SPIDERMONKEY_LIBS="-l$spidermonkeylib" - - if test ! -z "$spidermonkeydir"; then - SPIDERMONKEY_LIBS="-L$spidermonkeydir/lib $SPIDERMONKEY_LIBS" - SPIDERMONKEY_CFLAGS="-I$spidermonkeydir$spidermonkeyinclude" - fi - - LIBS="$SPIDERMONKEY_LIBS $LIBS_X" - CFLAGS="$CFLAGS_X $SPIDERMONKEY_CFLAGS" - CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS" - - AC_TRY_LINK([#define XP_UNIX - #include ], - [JS_GetImplementationVersion()], - cf_result=yes, cf_result=no) - fi - done - done - done -fi - -AC_MSG_RESULT($cf_result) - -if test "$cf_result" != yes; then - EL_RESTORE_FLAGS -else - EL_CONFIG(CONFIG_SPIDERMONKEY, [SpiderMonkey]) - - CFLAGS="$CFLAGS_X" - AC_SUBST(SPIDERMONKEY_LIBS) - AC_SUBST(SPIDERMONKEY_CFLAGS) -fi - -AC_SUBST(CONFIG_SPIDERMONKEY) - -EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_SPIDERMONKEY], [ECMAScript (JavaScript)]) - - dnl =================================================================== dnl Check for SSL support. dnl =================================================================== diff --git a/features.conf b/features.conf index 0394f4d8..90a03f33 100644 --- a/features.conf +++ b/features.conf @@ -395,6 +395,22 @@ CONFIG_CSS=yes CONFIG_HTML_HIGHLIGHT=no +### ECMAScript (JavaScript) Browser Scripting +# +# By enabling this feature, certain parts of ELinks, such as the goto URL +# dialog, may be extended using ECMAScript (aka. JavaScript) scripts. This can +# be useful to optimise your usage of ELinks. +# +# For example you can define shortcuts (or abbreviations) for URLs of sites you +# often visit by having a goto URL hook expand them. This can also be achieved +# with the URI rewrite feature (CONFIG_URI_REWRITE), however it is not as +# powerful as doing it with scripting. +# +# Default: enabled if Spidermonkey is found + +CONFIG_SM_SCRIPTING=yes + + ### Mouse Support # # ELinks may be controlled not only by keyboard, but also by mouse to quite some diff --git a/src/scripting/Makefile b/src/scripting/Makefile index 9d897eba..7e94a63d 100644 --- a/src/scripting/Makefile +++ b/src/scripting/Makefile @@ -6,8 +6,7 @@ SUBDIRS-$(CONFIG_LUA) += lua SUBDIRS-$(CONFIG_PERL) += perl SUBDIRS-$(CONFIG_PYTHON) += python SUBDIRS-$(CONFIG_RUBY) += ruby -SUBDIRS-$(CONFIG_SEE) += see -SUBDIRS-$(CONFIG_SPIDERMONKEY) += smjs +SUBDIRS-$(CONFIG_SM_SCRIPTING) += smjs OBJS = scripting.o