---
name: "samu"
section: "1"
platform: "linux"
package: "samurai"
version: "1.3-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/samu"
---

# samu(1)

ninja-compatible build tool

## NAME

**samu** – ninja-compatible build tool

## SYNOPSIS

**samu** \[**-C** *dir*\] \[**-d** *debugflag*\] \[**-f** *buildfile*\] \[**-j** *maxjobs*\] \[**-k** *maxfail*\] \[**-l** *maxload*\] \[**-w** *warnflag=action*\] \[**-nv**\] \[*target...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **clean** \[**-gr**\] \[*target...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **compdb** \[**-x**\] \[*rule...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **commands** \[*target...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **graph** \[*target...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **query** \[*target...*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **targets** \[**depth** \[*maxdepth*\]\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **targets** **rule** \[*rulename*\]

**samu** \[**-C** *dir*\] \[**-f** *buildfile*\] **-t** **targets** **all**

## DESCRIPTION

**samu** loads a build manifest from *buildfile* and rebuilds *targets* if they are out of date. If no targets are specified, the manifest's default targets are built. If there are no default targets, the leaf nodes of the dependency graph are built (outputs that have no consuming action).

Targets are out of date if they are older than the generating action's newest input, they have no entry in the build log, or if the command to build the target differs from what was used previously. Targets built with **generator** rules are not rebuilt if the command changes.

If the **clean** tool is used, the targets are cleaned instead. When a target is cleaned, it is removed and are all of its inputs are cleaned. Targets with no generating actions are never removed. Targets built with **generator** rules are only removed if **-g** is specified.

If the **commands** tool is used, a list of shell commands used to build the specified (or default) targets is printed.

If the **compdb** tool is used, a compilation database (**https://clang.llvm.org/docs/JSONCompilationDatabase.html**) is printed instead.

If the **graph** tool is used, a graphviz dot file is printed instead.

If the **query** tool is used, the inputs and outputs of the targets are printed instead.

If the **targets** tool is used, a list of targets will be displayed, either by rule or by depth. The first argument determines how the targets will be displayed:

- **depth**

  An indented tree of targets will be displayed, starting by the root targets (those with no dependent targets), up to the depth specified by *maxdepth* (defaults to 1).

- **rule**

  If *rulename* is given, a list of targets using the given rule will be displayed. Otherwise, a list of source files will be displayed.

- **all**

  A list of all targets will be displayed.

## OPTIONS

- **-C**

  Switch working directory to *dir* before building.

- **-d**

  Enable a debugging option. This flag may be specified multiple times to enable multiple debugging options. Possible values for *debugflag* are:

  - **explain**

    Print messages explaining why outputs were dirty.

  - **keepdepfile**

    Don't remove $depfile after it was parsed.

  - **keeprsp**

    Don't remove $rspfile after job completion or failure.

- **-f**

  Load manifest from *buildfile* instead of build.ninja.

- **-j**

  Run up to *maxjobs* jobs in parallel (default based on number of CPUs). If zero, allow unlimited concurrent jobs.

- **-k**

  Allow up to *maxfail* job failures. If negative or zero, allow any number of job failures.

- **-l**

  Do not spawn new jobs if the system load percentage is greater than *maxload*. If zero, spawn jobs as soon as possible.

- **-n**

  Do not actually execute the commands or update the log.

- **-v**

  Print full commands instead of just **description**.

- **-w**

  Control how certain errors are handled. If *warnflag* is **dupbuild**, *action* specifies what to do if an output is listed in multiple build edges. If *action* is **err**, treat it like an error and fail. If *action* is **warn**, only print a diagnostic message.

- **-t**

  Instead of building, invoke a subtool. All arguments and flags after the subtool are interpreted by the subtool. The currently supported subtools are **clean**, **commands**, **compdb**, **graph**, **query**, and **targets**.

- **-g**

  When cleaning, also clean outputs of **generator** actions.

- **-r**

  *targets* are interpreted as rules, and all outputs of actions with the specified rule types will be cleaned instead.

- **-x**

  When printing a compilation database, replace @$rspfile with $rspfile\_content (with \<blank\> in place of \<newline\>).

## ENVIRONMENT

- SAMUFLAGS

  Options for **samu** that get applied before those specified on the command-line. The only options allowed in SAMUFLAGS are **-v**, **-j** and **-l**.

- NINJA\_STATUS

  The status output printed to the left of each rule description, using printf-like conversion specifiers. If unset, the default is "\[%s/%t\] ".

  Available conversion specifiers:

  - **%s**

    Number of started jobs.

  - **%f**

    Number of finished jobs.

  - **%t**

    Total number of jobs.

  - **%r**

    Number of running jobs.

  - **%u**

    Number of remaining jobs.

  - **%p**

    Percentage of completed jobs.

  - **%o**

    Rate of finished jobs per second (to 1 decimal place).

  - **%e**

    Elapsed time in seconds (to 3 decimal places).

  - **%%**

    The '%' character.

## SEE ALSO

[make(1)](/make/1.md)
