BUILD(1) General Commands Manual BUILD(1)

buildfollow embedded build instructions

build [-dddfq] file [...]

build is a program which follows simple build instructions embedded in source files. The number of -d flags control the printing of debugging information. The -f flag disables modification time checks, forcing the build process. The -q flag disables the printing of executed commands.

build is decidedly not a make(1) replacement, except in trivial cases. In such cases, however, it is a nice and simple solution. The program is originally designed for generating troff(1) documents, but can be used with arbitrary source files.

The first twenty lines of each file are scanned for build information. Build information is encoded in two ways:

command line (one or more)
[anything] <whitespace> "$ " <shell command>
dependency line (only one)
[anything] <whitespace> "% " <files separated by whitespace>

Within each command line, build searches for a :

">" <filename without whitespace>
" -o " <filename without whitespace>

The last target found will be counted as the real target for the build process. If no target is found, the commands will always be executed, regardless of modification times.

Unlike make(1), build executes all command lines, joined by newlines, in the same shell process. This means that you can keep state across multiple commands. Note that all commands are executed regardless of the exit status of previous commands.

If a command fails, build exits with a positive status and aborts the build process.

Assuming that the file prg.c starts with the following text,

  *  To build this program, use the following invocation:
  *     $ cc -O2 -o prg prg.c

the invocation

$ build prg.c

will build prg, if it is older than prg.c.

Assuming that the file doc.t starts with the following text,

.\" This document is built with the following shell commands:
.\"    $ export LC_ALL=en_US.UTF-8
.\"    $ refer -p refs doc.t | troff -ms | dpost > doc.ps
.\"    $ ps2pdf doc.ps > doc.pdf
.\"    $ rm doc.ps
.\" Apart from this file, it depends on the following files:
.\"    % refs x.tmac

the invocation

$ build doc.t

will build doc.pdf, depending on the relative modification times of doc.pdf, doc.t and x.tmac.

build is written by John Ankarström <john (at) ankarstrom.se>.

October 3, 2022 OpenBSD 7.0