In this appendix I describe how to download and install SML/NJ version 110.0.7 This is the latest stable version at the time of writing. You will be installing from the source files. You can get RPMs for Linux but these won't include the source, which is very useful. It's quite easy and fast to install it from source. My installation is on RedHat 7.1 Linux with the GCC 2.96 compiler.
A characteristic of the installation is that the installed files will end up in the same directory tree as the source files. So you must unpack the source in the place where you want the installed files to go.
To start, go to the SML/NJ home page. This is at
http://cm.bell-labs.com/cm/cs/what/smlnj/index.html
There is an FTP site at Sourceforge but I've found the Bell Labs site to be the most reliable. Follow the link "Downloading SML/NJ Software for Unix or Windows". This has a link to some on-line installation instructions.
Create a directory on your computer where you will install the SML/NJ system. The installation instructions call this SMLROOT and recommend a path like /usr/local/sml[1]. I recommend using a subdirectory for the version e.g. /usr/local/sml/110.0.7 and a symbolic link /usr/local/sml/current to point to it. This will allow you to try out new versions. You use the current name in your CM files.
In the SMLROOT directory download the following files. These are for Intel x86 architecture on Unix. Use the FTP links. Don't download the Concurrent ML package from this page.
config.tar.Z | Installation scripts |
runtime.tar.Z | Runtime system |
cm.tar.Z | Compilation Manager |
bin.x86-unix.tar.Z | for Intel Pentium processors running UNIX |
smlnj-lib.tar.Z | Standard ML of New Jersey Library |
ml-lex.tar.Z | ML-Lex lexical analyzer generator |
ml-yacc.tar.Z | ML-Yacc parser generator |
ml-burg.tar.Z | ML-Burg code-generator generator |
sml-nj.tar.Z | Source code for SML/NJ compiler |
You probably won't use ML-Burg but the installation script assumes that you have it. The compiler source file is useful for the source of the Basis library, which is in its boot subdirectory.
If you go back to the SML/NJ home page you can follow the links to the Concurrent ML page. In its "What's new" section there is a link to a directory containing a patched version. The link is
ftp://ftp.research.bell-labs.com/dist/smlnj/packages/cml
Download the latest.tar.gz file into the SMLROOT directory renaming it to cml.tar.Z. This will work as long as the zcat program on your computer is actually from the Gnu gzip package (which it is on Linux). The install script expects the .Z suffix.
In the SMLROOT directory unpack the config.tar.Z file.
zcat config.tar.Z | tar -xf - |
This will create a subdirectory called config.
Edit the config/targets file to comment out the following line.
TARGETS="$TARGETS eXene" |
You won't need this for any of the examples in this book. You might be interested to read the eXene documentation so you could download the tar file later.
In the SMLROOT directory, NOT the config subdirectory, do
sh config/install.sh |
This will compile and install everything. The tar files will be unpacked into a src subdirectory. The SML compiler is in the bin subdirectory. The CM files are in the lib subdirectory. You can delete the tar files.
The compilation process first compiles the run-time. This is a normal C language compilation using make. I get lots of warnings from the X86.prim.asm file but this doesn't cause a problem.
Next the compiler is built from its bin files. You will see lots of messages like [Loading core.sml.bin]. Then the various packages are compiled and installed. These produce the usual SML compiler blurb with lots of GC messages.
The CM files in the SMLROOT/lib directory are just aliases for files in the SMLROOT/src directory. The compiled binary files are saved in CM subdirectories in the source directories so you can't delete them. The aliases (and the configuration manager) use absolute paths so you can't move them. This rigidity has been addressed in later versions of the SML/NJ system.
You can update a package in the system, other than CM and the compiler, by just replacing the source directory with the new version and compiling in its source directory (where the sources.cm file is) in the usual way. With care you can make some changes to the run-time and recompile it without having to rebuild anything at the SML level. Look at the install script for the commands to make the run-time.
[1] | I use /src/smlnj and this path appears in all of my examples |