= Installing SML/NJ on Unix
:revnumber: {version}
:revdate: {release-date}
:source-highlighter: pygments
:dist-url: https://smlnj.org/dist/working/{version}
:history: {dist-url}/HISTORY.html
:release-notes: {dist-url}/README.html
:stem: latexmath
:source-highlighter: pygments

These instructions are for installing the development version
of **Standard ML of New Jersey** (**SML/NJ**) on **Unix** and
Unix-like operating systems (including **Linux** and **macOS**).

== Install from Sources

=== Dependencies

To build the system from sources, you must have several common software
systems installed on your machine.

* **{cpp}17** -- You need a **{cpp}** compiler, such as **clang** or **gcc**,
  that can handle **{cpp}17**.

* **CMake** -- You need Version 3.23 or later of https://cmake.org[CMake].

* **Autoconf** -- Parts of the documentation and the **ASDL** tool require
  the GNU **autoconf** tool (version 2.71 or later).

=== Installation Steps

Assuming that you have the necessary tools installed, you can either clone the
repository or download and unpack one of the source tarballs.  In either
case, the process for building the system is the same once you have acquired
the source code.

==== Cloning the Repository

To clone the repository, use the following command:

[subs="+attributes"]
----
git clone --depth 1 --branch v{version} --recurse-submodules https://github.com/smlnj/smlnj.git
----

The `--depth` option limits the download to just one commit (_i.e._, no
history), the `--branch` option specifies the version of the source
code that you are requesting, and the `--recurse-submodules` option is
necessary to fetch the customized version of the **LLVM** library that we
use.

Note that you can also clone the entire repository and then switch to the
`v{version}` tag.

Also note that the repository does **not** contain the boot files that are
necessary to bootstrap the compiler.  These files are downloaded as part of
running the `build.sh` script below (when they are not present).  If you
need a distribution that you can build without network access, then download
one of the source distributions.

==== Downloading a Source Tarball

You can either click on the appropriate link on the {dist-url}/index.html[distribution-files
page] or use a shell command (_e.g._, *curl* or *wget*) to download the file.

For example, the commands

[subs="+attributes"]
----
curl -O {dist-url}/smlnj-<arch>-unix-{version}.tgz
tar -xzf smlnj-<arch>-unix-{version}.tgz
----

will download and unpack the sources for `<arch>` (which should be either `amd64`
or `arm64`).

==== Build the System

Once you have either cloned the repository or unpacked the source distribution,
we can build the system with the following commands:

----
cd smlnj
./build.sh
----

Use `build.sh -h` to see the list of options accepted by the build script.

As before, you can modify the `config/targets` file to add/remove components
from the build.

After successful running of the `build.sh` script, `bin/sml` will be the interactive
system.

== macOS Installation Packages

We provide notarized installers for **macOS** running on both
{dist-url}/smlnj-amd64-{version}.pkg[AMD64 (x86-64)] and
{dist-url}/smlnj-arm64-{version}.pkg[Arm64 (AArch64)] systems.
