Installing js (Mozilla's Spidermonkey) and jsl (Matthias Miller's Javascript-Lint)

2007-Aug29:  Twice in rapid succession I have encountered free downloadable software that came as a large tar.gz archive containing absolutely nothing about how to install the thing.  The first was Spidermonkey from Mozilla.org.  The second was jsl by Matthias Miller, which being based on Spidermonkey has seemingly inherited that same contemptuous attitude toward anyone wanting to use it.  In fairness, I should point out that Mozilla.org does provide a separate webpage containing some bare-bones instructions about installing js; it's just that they're seriously misleading due to a missing directory-name, and that together with my not knowing the first thing about OS-X led me to understand their instructions to say their Makefile installed the executables into an appropriate place, which it does not do.

To install jsl:  once you've done the untgz on the downloaded jsl, and are in the resulting directory, do the following:
cd src
make -f Makefile.ref
cd *.OBJ*
sudo cp jsl jscpucfg /usr/bin/
sudo cp jsautocfg.h /usr/include/
sudo cp libjs.so /usr/lib/
jsl -help:conf >/tmp/jsl.conf
sudo cp /tmp/jsl.conf /etc   ## now edit /etc/jsl.conf with your texteditor to configure the options for jsl

Note that you may already have copies of jscpucfg, jsautocfg.h and libjs.so in appropriate places from having installed other Mozilla software, in which case you may choose to skip those copying steps.

To install js:  I first installed Spidermonkey using yum, to get around its lack of instructions.  However, when yum was not an option for jsl, I googled and pieced together the jsl instructions reproduced above.  I now realize that essentially the same method will work for Spidermonkey.  The key insight involves the location of the resulting executables.  They will be under src/Linux_All_DBG.OBJ if you run Linux;  in general it looks to be safe to say they'll be under src/*.OBJ* (and there'll be exactly one such subdirectory, for straightforward uses of Makefile.ref).  Here are the steps for js:
cd src
make -f Makefile.ref
cd *.OBJ*
sudo cp js jscpucfg /usr/bin/
sudo cp jsautocfg.h /usr/include/
sudo cp libjs.so /usr/lib/

The same remarks (as for jsl above) apply regarding the copying of jscpucfg, jsautocfg.h and libjs.so.  Should you wish to use Spidermonkey from C programs, then you'll also need to copy src/jsapi.h to an appropriate place.  I'm hoping to simply use it from the commandline with js, but don't yet know whether that'll allow me to do the sorts of things I want to do...

PS:  You can find js at ftp.mozilla.org/pub/mozilla.org/js/js-1.60.tar.gz
and jsl at www.javascriptlint.com/download/jsl-0.3.0-src.tar.gz
(depending on when you're reading this, you may want to check for newer versions). 


2010-04:
The good news: Spidermonkey now provides perfectly decent installation-instructions, and beginning with the soon-to-be-released v1.8.1 it will use the customary autoconf and configure tools.  The bad news: version 1.8.1 has been in "release candidate" status for more than a year, which casts some doubt on the "coming-soon" status.  More bad news: you'll need to have exactly autoconf-2.13, nothing newer will work!  With autoconf's reliance on m4 macros it is less than obvious how to go about installing multiple versions of it (essential since other packages will insist on a newer autoconf), however the instructions at lfs.phayoune.org/hints/downloads/files/autotools-multiversion.txt provide the answer.  Incidentally autoconf-2.13 is from 1999. 


2010-04:
An alternative to Spidermonkey-based js is the Webkit-based jsc described in svn.webkit.org/wiki/JSC.