Jam


Table of Contents
1. Usage
2. Description
3. Options
4. Operations
5. Diagnostics
6. Bugs/Limitations

Chapter 1. Usage

jam [-a | -g | -n | -q | -h | -d (1)debugType | -f jamBase | -j jobs | -o actionsFile | -s VAR=value | -t target]

(1) [a | c | d | m | x]...


Chapter 2. Description

Jam is a program construction tool, like make(1). Jam recursively builds target files from source files, using dependency information and updating actions expressed in the Jambase file, which is written in jam's own interpreted language. The default Jambase is compiled into jam and provides a boilerplate for common use, relying on a user-provide file "Jamfile" to enumerate actual targets and sources. The Jambase is described in the Jambase Reference and the document Using Jamfiles and Jambase.


Chapter 3. Options

If target is provided on the command line, jam builds target; otherwise jam builds the target 'all'. Jam may be invoked with the following options:

OptionDescription
-aBuild all targets anyway, even if they are up-to-date.
-d c

Turn on display option c and off the default display (summary info and actions)

a : Show summary info, actions, quiet actions, and the use of temporary targets

c : Show the names of files that cause rebuilds, i.e. new sources, missing targets, etc.

d : Display a dependency graph (in jam syntax).

m : Display the dependency analysis, and target/source timestamps and paths

x : Show shell arguments

-d n

Enable cummulative debugging levels from 1 to n. Interesting values are:

1 : Show actions and summary info (the default) (DEBUG_MAKE)

3 : Equivalent to -dm : display the dependency analysis, and target/source timestamps/paths (DEBUG_MAKEPROG)

4 : Show execcmd() (DEBUG_EXECCMD)

5 : Show rule invocations and variable expansions(DEBUG_COMPILE)

6 : Show directory/header file/archive scans(DEBUG_HEADER, DEBUG_BINDSCAN, DEBUG_SEARCH)

7 : Show variable settings(DEBUG_VARSET)

8 : Show variable fetches(DEBUG_VARGET, DEBUG_VAREXP, DEBUG_IF)

9 : Show variable manipulation, scanner tokens(DEBUG_LISTS, DEBUG_SCAN, DEBUG_MEM)

11: Equivalent to -da : show even quiet actions(DEBUG_MAEQ)

12: Equivalent to -dx : show text of actions(DEBUG_EXEC)

13: Equivalent to -dd : show dependency graph(DEBUG_DEPENDS)

14: Equivalent to -dc : show dependency graph(DEBUG_CAUSES)

-d +nEnable only the debugg level n.
-d 0Turn OFF all debugging levels. Only errors are reported.
-f jamBaseRead jamBase instead of using the built-in Jambase. Multiple -f flags ARE permitted.
-gBuild targets with the newest sources first, rather than in the order of appearance in the Jambase/Jamfiles.
-j n Run up to n shell commands concurrently (UNIX and NT only). The default is 1.
-nDon't actually execute the updating actions, but do everything else. This changes the debug level to -dax.
-o fileWrite the updating actions to the specified file instead of running them (or outputting them, as on the Mac).
-qQuit quickly (as if an interrupt was received) as soon as any target build fails.
-s varname=valueSet the variable `varname` to `value`, overriding both internal variables and variables imported from the environment.
-t targetRebuild target and everything that depends on it, even if it is up-to-date.
-vPrint the version of jam and exit.
-hPrint usage instructions and exit.


Chapter 4. Operations

Jam has four phases of operation: Start-up, Parsing, Binding and Updating.

Start-up

Upon start-up, jam performs the following steps:

  1. Imports environment variable settings into jam variables.

    1. Environment variables are split at blanks with each word becoming an element in the variable's list of values.

    2. Environment variables whose names end in PATH are split at $(SPLITPATH) characters (e.g., ":" for Unix).

  2. To set a variable's value on the command line, overriding the variable's environment value, use the -s option.

    To see variable assignments made during jam's execution, use the -d+7 option.

Parsing

In the parsing phase, jam will:

  1. Read and execute the Jambase file. The default Jambase is built into jam executable, and is written using jam language

  2. The last action of the Jambase is to read (via the include rule) a user-provided file called "Jamfile".

    The Jambase defines boilerplate rules and variable assignments, and the Jamfile uses these to specify the actual relationship among the target and source files. Collectively, the purpose of the Jambase and the Jamfile is :

    1. To name build target and source files.

    2. Construct the dependency graph among them.

    3. Associate build actions with targets.

Binding

In this phase, jam recursively descends the dependency graph and binds every file target with a location in the filesystem.

  1. Any string value in jam can represent a target, and it does so if the DEPENDS or INCLUDES rules make it part of the dependency graph. Build targets are files to be updated. Source targets are the files used in updating build targets. Build targets and source targets are collectively referred to as file targets, and frequently build targets are source targets for other build targets. Pseudotargets are symbols which represent dependencies on other targets, but which are not themselves associated with any real file.

  2. A file target's identifier is generally the file's name, which can be absolutely rooted, relative to the directory of jam's invocation, or simply local (no directory). Most often it is the last case, and the actual file path is bound using the $(SEARCH) and $(LOCATE) special variables. See SEARCH and LOCATE Variables below. A local filename is optionally qualified with "grist," a string value used to assure uniqueness. A file target with an identifier of the form file(member) is a library member (usually an ar(1) archive on UNIX). The use of $(SEARCH) and $(LOCATE) allows jam to separate the the location of files from their names, so that Jamfiles can refer to files locally (i.e. relative to the Jamfile's directory), yet still be usable when jam is invoked from a distant directory. The use of grist allows files with the same name to be identified uniquely, so that jam can read a whole directory tree of Jamfiles and not mix up same-named targets.

  3. Update Determination. After binding each target, jam determines whether the target needs updating, and if so marks the target for the updating phase. A target is normally so marked if it is missing, it is older than any of its sources, or any of its sources are marked for updating. This behavior can be modified by the application of special built-in rules. See Modifying Binding below.

  4. Header File Scanning. During the binding phase, jam also performs header file scanning, where it looks inside source files for the implicit dependencies on other files caused by C #include syntax. This is controlled by the special variables $(HDRSCAN) and $(HDRRULE). The result of the scan is formed into a rule invocation, with the scanned file as the target and the found included file names as the sources. Note that this is the only case where rules are invoked outside the parsing phase. See HDRSCAN and HDRRULE Variables below.

Updading

jam again recursively descends the dependency graph, this time executing the update actions for each target marked for update during the binding phase. If a target's updating actions fail, then all other targets which depend on that target are skipped.

  1. The -j flag instructs jam to build more than one target at a time. If there are multiple actions on a single target, they are run sequentially. The -g flag reorders builds so that targets with newest sources are built first. Normally, they are built in the order of appearance in the Jamfiles.


Chapter 5. Diagnostics

In addition to generic error messages, jam may emit one of the following:

warning: unknown rule X

A rule was invoked that has not been defined with an "actions" or "rule" statement.

using N temp target(s)

Targets marked as being temporary (but nonetheless present) have been found.

updating N target(s)

Targets are out-of-date and will be updated.

can't find N target(s)

Source files can't be found and there are no actions to create them.

can't make N target(s)

Due to sources not being found, other targets cannot be made.

warning: X depends on itself

A target depends on itself either directly or through its sources.

don't know how to make X

A target is not present and no actions have been defined to create it.

X skipped for lack of Y

A source failed to build, and thus a target cannot be built.

warning: using independent target X

A target that is not a dependency of any other target is being referenced with $(<) or $(>).

X removed

Jam removed a partially built target after being interrupted.


Chapter 6. Bugs/Limitations

The -j flag can cause jam to get confused when single actions update more than one target at a time. jam may proceed as if the targets were built even though they are still under construction.

With the -j flag, errors from failed commands can get staggeringly mixed up.

For parallel building to be successful, the dependencies among files must be properly spelled out, as targets tend to get built in a quickest-first ordering.

Also, beware of un-parallelizable commands that drop fixed-named files into the current directory, like yacc(1) does.

A poorly set $(JAMSHELL) is likely to result in silent failure.