> ## Documentation Index
> Fetch the complete documentation index at: https://hypotenuse.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Install the Hypotenuse Compiler on Linux and macOS

> Set up the Hypotenuse Compiler from source in three steps. Covers Linux x86_64, macOS ARM64, cross-compilation with Docker, and PATH configuration.

Installing the Hypotenuse Compiler means cloning the repository, building a self-contained binary with PyInstaller, and copying it to a location on your `PATH`. The installer also sets up the `PLIBS/` directory that the compiler searches when you import from `<plstd>` or any other library. Before you start, make sure your system has the tools listed below.

## Prerequisites

You need the following software installed before running the installer.

* **Python 3.14 or later** — the compiler itself is written in Python, and PyInstaller bundles it during the build step.
* **Linux (x86\_64) or macOS (ARM64)** — the two host platforms that build and install automatically. Windows (x86\_64) is supported as a **manual** target — see [Windows Support](#windows-support) below.
* **GCC** — used to compile the C output that the Hypotenuse Compiler generates and to link the final binary.
* **NASM** — used to assemble any `asm` blocks in your C△ source files.

<Note>
  On most Linux distributions you can install GCC and NASM with your package manager — for example, `sudo apt install gcc nasm` on Debian/Ubuntu or `sudo dnf install gcc nasm` on Fedora. On macOS, install Xcode Command Line Tools (`xcode-select --install`) for GCC, and NASM via Homebrew (`brew install nasm`).
</Note>

## Install from Source

<Steps>
  <Step title="Clone the repository">
    Run the following command to download the source code and enter the project directory.

    ```bash theme={null}
    git clone https://github.com/setuser1/The-Hypotenuse-Compiler
    cd The-Hypotenuse-Compiler
    ```
  </Step>

  <Step title="Run the installer">
    Run `make full-install` to build the compiler binary and install it alongside the standard library.

    ```bash theme={null}
    make full-install
    ```

    This command does the following:

    1. Installs PyInstaller and the other required Python build dependencies via pip.
    2. Bundles the compiler into a single self-contained binary named `hypotenuse` using PyInstaller.
    3. Copies the binary to `/usr/local/bin/hypotenuse` if you have write access, or to `~/.local/bin/hypotenuse` otherwise.
    4. Creates the `PLIBS/plstd` directory (`/usr/lib/PLIBS/plstd` or `~/.local/lib/PLIBS/plstd`) and copies the standard library into it.
  </Step>

  <Step title="Verify the installation">
    Confirm that the compiler is on your `PATH` and responding correctly.

    ```bash theme={null}
    hypotenuse --help
    ```

    You should see the Hypotenuse Compiler help text listing all available flags. If the command is not found, see the **PATH setup** section below.
  </Step>
</Steps>

## Install from a prebuilt weekly release

If you do not want to build from source, you can download a prebuilt package from the project's [GitHub Releases page](https://github.com/setuser1/The-Hypotenuse-Compiler/releases). A GitHub Actions workflow publishes a new pre-release every **Friday** containing the compiler binary, the `plstd` standard library, and a minimal Makefile.

Two assets are attached to each weekly release:

* **`hypotenuse-macos.zip`** — built on `macos-latest`. Use this on macOS (ARM64).
* **`hypotenuse-x86_64.zip`** — built on `ubuntu-latest`. Use this on Linux x86\_64.

Each archive contains:

* `hypotenuse` — the bundled, self-contained compiler binary.
* `plstd/` — the standard library that the compiler loads from `PLIBS/plstd`.
* `makefile` — a minimal Makefile with a single `install` target that copies the binary and the standard library into the correct system locations.

<Warning>
  Weekly packages are tagged as **pre-releases** and are versioned by ISO year and week (for example, `26.23`). They are built directly from the latest `main` and may be unstable. For production use, prefer building a tagged stable release from source.
</Warning>

<Steps>
  <Step title="Download the package">
    Open the [Releases page](https://github.com/setuser1/The-Hypotenuse-Compiler/releases), find the most recent weekly pre-release, and download the asset that matches your platform.

    ```bash theme={null}
    # macOS (ARM64)
    unzip hypotenuse-macos.zip -d hypotenuse-weekly

    # Linux (x86_64)
    unzip hypotenuse-x86_64.zip -d hypotenuse-weekly
    ```
  </Step>

  <Step title="Run the bundled installer">
    The included Makefile installs the binary onto your `PATH` and the standard library under `PLIBS/`, using the same locations as `make full-install`.

    ```bash theme={null}
    cd hypotenuse-weekly
    make install
    ```

    This copies `hypotenuse` to `/usr/local/bin/hypotenuse` and `plstd/` to `/usr/lib/PLIBS/plstd` when you have write access to `/usr/local/bin`, or to `~/.local/bin/hypotenuse` and `~/.local/lib/PLIBS/plstd` otherwise.
  </Step>

  <Step title="Install manually (optional)">
    If you prefer to place the files yourself, copy the binary to any directory on your `PATH` and the standard library into a `PLIBS/` directory the compiler can find.

    ```bash theme={null}
    # Example: per-user install
    mkdir -p ~/.local/bin ~/.local/lib/PLIBS
    cp hypotenuse ~/.local/bin/hypotenuse
    chmod +x ~/.local/bin/hypotenuse
    cp -r plstd ~/.local/lib/PLIBS/
    ```

    See [PATH Setup](#path-setup) if `~/.local/bin` is not yet on your `PATH`.
  </Step>

  <Step title="Verify the installation">
    ```bash theme={null}
    hypotenuse --help
    ```
  </Step>
</Steps>

## Cross-compile for Linux x86\_64 on ARM64

If you are on an ARM64 Mac and need to produce a Linux x86\_64 ELF compiler binary, use the Docker-based cross-compilation targets. Docker must be installed and running before you begin.

```bash theme={null}
make build-x86_64-elf
make full-install-x86_64-elf
```

`make build-x86_64-elf` spins up a `linux/amd64` Docker container, installs PyInstaller inside it, and builds an ELF binary named `hypotenuse-x86_64-elf` in the `dist/` folder. `make full-install-x86_64-elf` then installs that binary to the same locations described above, renaming it to `hypotenuse`.

<Warning>
  NASM does not support generating ARM64 Mach-O object files, so `asm` blocks that use the `arm64_macho` syntax target must be compiled on a native ARM64 macOS host, not via this cross-compilation path.
</Warning>

## Windows Support

Windows (x86\_64) is a **technically supported** target, but the Hypotenuse Compiler cannot drive the full build for you the way it does on Linux and macOS. The compiler does not invoke MSVC, and no GCC/NASM-equivalent automation ships for the MSVC toolchain.

To build a C△ program on Windows you must do it in two steps:

1. Run the Hypotenuse Compiler **without `-c`** to emit the generated `.c` file instead of a linked binary. The `.c` output is portable standard C and can be fed to any C compiler.
2. Build the resulting `.c` file with **MSVC** (`cl.exe`) — or any other Windows-capable C toolchain — yourself, linking against whatever runtime your code requires.

<Warning>
  **`asm` blocks and `asm` functions do not work on Windows at all.** The NASM-driven assembly pipeline is not wired up for the MSVC path, so any source file containing `asm` will fail to produce a working binary on Windows. Strip or guard your `asm` code before building for Windows.
</Warning>

## PATH Setup

<Note>
  If the installer places the binary in `~/.local/bin/hypotenuse`, you need to add `~/.local/bin` to your `PATH`. Add the following line to your shell configuration file (`~/.bashrc`, `~/.zshrc`, or equivalent) and reload your shell.

  ```bash theme={null}
  export PATH="$HOME/.local/bin:$PATH"
  ```
</Note>

## Uninstall

To remove the `hypotenuse` binary from your system, run the uninstall target from inside the repository directory.

```bash theme={null}
make uninstall
```

This removes the binary from whichever location it was installed to — `/usr/local/bin/hypotenuse` or `~/.local/bin/hypotenuse`. It does not remove the `PLIBS/` directory or its contents.
