Jambase Reference

Jambase is a base set of Jam/MR rules which provide roughly make(1)-like functionality for jam, the Jam/MR executable program. This document, which started out as the Jambase(5) man page, is a reference guide to the rules, pseudotargets, and variables defined in Jambase for use in Jamfiles.

For further information see:

Jam/MR documentation and source are available from the Perforce Public Depot. For detailed information about any of the rules summarized below, see the Jambase file itself.

Jambase Rules

As obj.o : source.s ;

Assemble the file source.s. Called by the Object rule.
Bulk directory : sources ;
Copies sources into directory.
Cc object : source ;
Compile the file source into object, using the C compiler $(CC), its flags $(CCFLAGS) and $(OPTIM), and the header file directories $(HDRS). Called by the Object rule.
C++ obj.o : source.cc ;
Compile the C++ source file source.cc. Called by the Object rule.
Chmod target ;
(Unix and VMS only.) Change file permissions on target to target-specific $(MODE) value set by Link, File, Install*, and Shell rules.
Clean clean : targets ;
Removes existing targets when clean is built. clean is not a dependency of all, and must be built explicitly for targets to be removed.
File target : source ;
Copies source into target.
Fortran obj.o : source.f ;
Compile the Fortran source file source.f. Called by the Object rule.

GenFile target : image sources ;

Runs the command "image target sources" to create target from sources and image. (where image is an executable built by the Main rule.)
HardLink target : source ;
Makes target a hard link to source, if it isn't one already. (Unix only.)
HdrRule source : headers ;
Arranges the proper dependencies when the file source includes the files headers through the "#include" C preprocessor directive.

This rule is not intended to be called explicitly. It is called automatically during header scanning on sources handled by the Object rule (e.g., sources in Main or Library rules).

InstallBin dir : sources ;
Copy sources into dir with mode $(EXEMODE).
InstallLib dir : sources ;
Copy sources into dir with mode $(FILEMODE).
InstallMan dir : sources ;
Copy sources into the appropriate subdirectory of dir with mode $(FILEMODE). The subdirectory is mans, where s is the suffix of each of sources.
InstallShell dir : sources ;
Copy sources into dir with mode $(SHELLMODE).
Lex source.c : source.l ;
Process the lex(1) source file source.l and rename the lex.yy.c to source.c. Called by the Object rule.
Library library : sources ;
Compiles sources and archives them into library. The intermediate objects are deleted. Calls Objects and LibraryFromObjects.

If Library is invoked with no suffix on library, the $(SUFLIB) suffix is used.

LibraryFromObjects library : objects ;
Archives objects into library. The objects are then deleted.

If library has no suffix, the $(SUFLIB) suffix is used.

Link image : objects ;
Links image from objects and sets permissions on image to $(EXEMODE). Image must be actual filename; suffix is not supplied. Called by Main.
LinkLibraries image : libraries ;
Makes image depend on libraries and includes them during the linking.

Image may be referenced without a suffix in this rule invocation; LinkLibraries supplies the suffix.

Main image : sources ;
Compiles sources and links them into image. Calls Objects and MainFromObjects.

Image may be referenced without a suffix in this rule invocation; Main supplies the suffix.

MainFromObjects image : objects ;
Links objects into image. Dependency of exe. MainFromObjects supplies the suffix on image filename.
MakeLocate target : dir ;
Creates dir and causes target to be built into dir.
MkDir dir ;
Creates dir and its parent directories.
Object object : source ;
Compiles a single source file source into object. The Main and Library rules use this rule to compile source files.

Causes source to be scanned for "#include" directives and calls HdrRule to make all included files dependedencies of object.

Calls one of the following rules to do the actual compiling, depending on the suffix of source:

		     *.c:   Cc 
		     *.cc:  C++ 
		     *.cpp: C++
		     *.C:   C++ 
		     *.l:   Lex 
		     *.y:   Yacc
		     *.*:   UserObject
ObjectC++Flags source : flags ;
ObjectCcFlags source : flags ;
Add flags to the source-specific value of $(CCFLAGS) or $(C++FLAGS) when compiling source. Any file suffix on source is ignored.
ObjectHdrs source : dirs ;
Add dirs to the source-specific value of $(HDRS) when scanning and compiling source. Any file suffix on source is ignored.
Objects sources ;
For each source file in sources, calls Object to compile the source file into a similarly named object file.
RmTemps targets : sources ;
Marks sources as temporary with the TEMPORARY rule, and deletes sources once targets are built. Must be the last rule invoked on targets. Used internally by LibraryFromObjects rule.
Setuid images ;
Sets the setuid bit on each of images after linking. (Unix only.)
SubDir VAR d1 ... dn ;
Sets up housekeeping for the source files located in $(VAR)/d1/.../dn:

VAR is the name of a variable; d1 thru dn are elements of a directory path.

SubDirC++Flags flags ;
SubDirCcFlags flags ;
Adds flags to the compiler flags for source files in SubDir's directory.
SubDirHdrs paths ;
Adds paths to the header search paths for source files in SubDir's directory.
SubInclude VAR d1 ... dn ;
Reads the Jamfile in $(VAR)/d1/.../dn/.
Shell image : source ;
Copies source into the executable sh(1) script image. Ensures that the first line of the script is $(SHELLHEADER) (default #!/bin/sh).
Undefines images : symbols ;
Adds flags to mark symbols as undefined on link command for images. Images may be referenced unsuffixed; the Undefines rule supplies the suffix.
UserObject object : source ;
This rule is called by Object for source files with unknown suffixes, and should be defined in Jamrules with a user-provided rule to handle the source file types not handled by the Object rule. The Jambase UserObject rule merely issues a complaint when it encounters source with files suffixes it does not recognize.
Yacc source.c : source.y ;
Process the yacc(1) file source.y and renamed the resulting y.tab.c and y.tab.h to source.c. Produces a y.tab.h and renames it to source.h. Called by the Object rule.

Jambase Pseudotargets

There are two kinds of Jam/MR targets: file targets and pseudotargets. File targets are objects that can be found in the filesystem. Pseudotargets are symbolic, and usually represent other targets. Most Jambase rules that define file targets also define pseudotargets which are dependent on types of file targets. The Jambase pseudotargets are:

exe Executables linked by the Main or MainFromObjects rules
lib Libraries created by the Library or LibraryFromObjects rules
obj Compiled objects used to create Main or Library targets
dirs Directories where target files are written
file Files copied by File and Bulk rules
shell Files copied by Shell rule
clean Removal of built targets (except files copied by Install* rules)
install Files copied by Install* rules
uninstall Removal of targets copied by Install* rules

In addition, Jambase makes the jam default target "all" depend on "exe", "lib", "obj", "files", and "shell".

Jambase Variables

Most of the following variables have default values for each platform; refer to the Jambase file to see what those defaults are.


Alternative location of built targets. By default, Jambase rules locate built targets in the source tree. By setting $(ALL_LOCATE_TARGET) in Jamrules, you can cause jam to write built targets to a location outside the source tree.
The archive command used to update Library and LibraryFromObjects targets.
The assembler for As rule targets.
Flags handed to the assembler for As.
The name of awk interpreter, used when copying a shell script for the Shell rule.
Selects Borland compile and link actions on NT.
Not longer used. (I.e., used only for backward compatibility with the obsolete INSTALLBIN rule.)
C compiler used for Cc rule targets.
Compile flags for Cc rule targets. The Cc rule sets target-specific $(CCFLAGS) values on its targets.
C++ compiler used for C++ rule targets.
Compile flags for C++ rule targets. The C++ rule sets target-specific $(C++FLAGS) values on its targets.
The file copy program, used by File and Install* rules.
Permissions for executables linked with Link, Main, and MainFromObjects, on platforms with a Chmod action.
Permissions for files copied by File or Bulk, on platforms with a Chmod action.
The Fortran compiler used by Fortran rule.
Fortran compiler flags for Fortran rule targets.
(Unix only.) The group owner for Install* rule targets.
A regular expression pattern that matches C preprocessor "#include" directives in source files and returns the name of the included file.
Name of the rule to invoke with the results of header file scanning. Default is "HdrRule".

This is a jam-special variable. If both HDRRULE and HDRSCAN are set on a target, that target will be scanned for lines matching $(HDRSCAN), and $(HDDRULE) will be invoked on included files found in the matching $(HDRSCAN) lines.

Regular expression pattern to use for header file scanning. The Object rule sets this to $(HDRPATTERN). This is a jam-special variable; see HDRRULE.
Directories to be searched for header files. This is used by the Object rule to: (See STDHDRS.)
The file copying program for the Install* rules. If not set, $(CP) is used. On Unix, the $(INSTALL) default is "install".
Default is "Jamfile"; the name of the user-written rules file found in each source directory.
Default is "Jamrules"; the name of a rule definition file to be read in at the first SubDir rule invocation.
The lex(1) command and flags.
Not longer used. (I.e., used only for backward compatibility with the obsolete INSTALLLIB rule.)
The linker. Defaults to $(CC).
Flags handed to the linker. Defaults to $(CCFLAGS).
List of external libraries to link with. The target image does not depend on these libraries.
Used to set the location of generated source files. The Yacc, Lex, and GenFile rules set LOCATE on their targets to $(LOCATE_SOURCE). $(LOCATE_SOURCE) is initialized by the SubDir rule to the source directory itself. (Also, see ALL_LOCATE_TARGET.)
Used to set the location of built binary targets. The Object rule, and hence the Main and Library rules, set LOCATE on their targets to $(LOCATE_TARGET). $(LOCATE_TARGET) is initialized by the SubDir rule to the source directory itself. (See ALL_LOCATE_TARGET.)
The hard link command for HardLink rule.
Not longer used. (I.e., used only for backward compatibility with the obsolete INSTALLMAN rule.)
The 'create directory' command used for the MkDir rule.
The target-specific file mode (permissions) for targets of the Shell, Setuid, Link, and Install* rules. Used by the Chmod action; hence relevant to NT and VMS only.
Selects Microsoft Visual C 16-bit compile & link actions on NT.
Selects Microsoft Visual C NT compile & link actions on NT.
The file rename command and options.
The C compiler flag for optimization, used by Cc and C++ rules.
The owner of installed files. Used by Install* rules.
The name of the ranlib command. If set, causes the Ranlib action to be applied after the Archive action to targets of the Library rule.
If set, tells the Cc rule to move the output object file to its target directory because the cc command has a broken -o option.
The command and options to remove a file.
The directory to find sources listed with Main, Library, Object, Bulk, File, Shell, InstallBin, InstallLib, and InstallMan rules. This works by setting the jam-special variable SEARCH to the value of $(SEARCH_SOURCE) for each of the rules' sources. The SubDir rule initializes SEARCH_SOURCE for each directory.
A string inserted to the first line of every file created by the Shell rule.
Permissions for files installed by Shell rule.
Set by the SubDir to a value derived from the directory name, and used by Objects and related rules as 'grist' to perturb file names.
Directories where headers can be found without resorting to using the flag to the C compiler. The $(STDHDRS) directories are used to find headers during scanning, but are not passed to the compiler commands as -I paths.
The suffix for executable files, if none provided. Used by the Main rule.
The suffix for libraries. Used by the Library and related rules.
The suffix for object files. Used by the Objects and related rules.
The flag prefixed to each symbol for the Undefines rule (i.e., the compiler flag for undefined symbols).
Selects Watcom compile and link actions on OS2.
The yacc(1) command and flags.

Back to top.

Copyright 1997, 1999 Perforce Software, Inc.
Comments to info@perforce.com
Last updated: Jan 27, 1999