# Standard ML of New Jersey

This is the main development repository for **SML/NJ** and is under
active development, it is not considered stable.  As such, we recommend
the [legacy version](https://github.com/smlnj/legacy) of the system
for production use cases.

This version works on AMD64 (a.k.a. x86-64) and Arm64 (a.k.a. AArch64)
hardware running **Linux** or **macOS**.

---

## Contents

- [Dependencies](#dependencies)
- [Installing with Homebrew](#installing-with-homebrew)
- [Building From Source](#building-from-source)
- [Recompiling the System](#recompiling-the-system)

---

## Dependencies

To build the system from sources, you must have the following software
installed on your machine.[^1]

* **C++17** -- You need a **C++** compiler, such as **clang** or **gcc**,
  that can handle **C++17**.

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

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

[^1]: We provide installer packages for **macOS** that avoid these
dependencies.

## Installing with Homebrew

If you use Homebrew, run the following command to get started
   ```bash
   brew install smlnj
   ```

Dependencies are automatically installed when using this method.

## Building From Source

**_Note_**  The process for building the system from source code has
changed from the legacy system.

If you want to build and install `smlnj` from source yourself, follow
these steps:

1. Set `VERSION` to the version of **SML/NJ** that you want to build;
   for example
   ``` bash
   VERSION=2026.2
   ```

2. Clone the repository
    ``` bash
    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.

3. build the installation
    ``` bash
    cd smlnj
    ./build.sh
    ```
    Use `build.sh -h` to see the list of options accepted by the build script.

    As of version 2025.1, the `build.sh` script will download the pre-compiled
    boot files if they are not present.

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

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

## Recompiling the System

The process of recompiling the system from source code is similar
to before.

1. Switch to the [`system`](system/) directory and run the `cmb-make` command:
    ``` bash
    cd system
    ./cmb-make ../bin/sml
    ```

    The "`../bin/sml`" argument is optional. If omitted, the `sml`
    command in the user's `PATH` takes precedence. When appropriate, you can
    also specify a different path to an `sml` command.

2. Bootstrap the system
    ``` bash
    ./makeml
    ```

3. Install the system
    ``` bash
    ./installml -clean -boot
    ```
    The `-boot` option is optional. If given, the existing boot files in
    the root directory (*e.g.*, `boot.amd64-unix.tgz`) will be replaced
    by the files generated by the `cmb-make` command (*e.g.*,
    `system/sml.boot.arm64-unix`)

4. Rebuild the libraries and tools
    ``` bash
    cd ..
    ./build.sh
    ```
