Jam language


Table of Contents
1. Overview
2. Lexical Features
3. Datatype
4. Rules
5. Updating Actions
6. Statements
7. Variables
8. Variable expansion
9. Built-in Rules
10. Built-in Variables
List of Tables
10-1. Values of $(OS)
List of Examples
3-1. One-dimensional list
4-1. Rule example

Chapter 1. Overview

Jam has a interpreted, procedural language with a few select features to effect program construction. Statements in jam are rule (procedure) definitions, rule invocations, updating action definitions, flow-of-control structures, variable assignments, and sundry language support.


Chapter 2. Lexical Features


Chapter 3. Datatype

Jam's only data type is a one-dimensional list of arbitrary strings. They arise as literal (whitespace-separated) tokens in the Jambase or included files, as the result of variable expansion of those tokens, or as the return value from a rule invocation.

Example 3-1. One-dimensional list

            VAR = [ element1 element2 element3 ] ;
            

Chapter 4. Rules

The basic jam language entity is called a rule. A rule is simply a procedure definition, with a body of jam statements to be run when the rule is invoked. The syntax of rule invocation make it possible to write Jamfiles that look a bit like Makefiles.

Rules take up to 9 arguments ($(1) through $(9), each a list) and can have a return value (a single list). A rule's return value can be expanded in a list by enclosing the rule invocation with [ and ]

Example 4-1. Rule example

                put it here
            

Chapter 5. Updating Actions

A rule may have updating actions associated with it, in which case arguments $(1) and $(2) are treated as built targets and sources, respectively. Updating actions are the OS shell commands to execute when updating the built targets of the rule.

When an rule with updating actions is invoked, those actions are added to those associated with its built targets ($(1)) before the rule's procedure is run. Later, to build the targets in the updating phase, the actions are passed to the OS command shell, with $(1) and $(2) replaced by bound versions of the target names. See Binding operation in Jam's documentation .


Chapter 6. Statements

lots of text here


Chapter 7. Variables


Chapter 8. Variable expansion

Lots of text here


Chapter 9. Built-in Rules


Chapter 10. Built-in Variables

This section discusses variables that have special meaning to jam

  1. $(SEARCH) and $(LOCATE) Variables

    These two variables control the binding of file target names to locations in the file system.

    Generally, $(SEARCH) is used to find existing sources.

    while $(LOCATE) is used to fix the location for built targets.

    Rooted (absolute path) file targets are bound as is.

    Unrooted file target names are also normally bound as is, and thus relative to the current directory, but the settings of $(LOCATE) and $(SEARCH) alter this:

    • If $(LOCATE) is set, then the target is bound relative to the first directory in $(LOCATE). Only the first element is used for binding.

    • If $(SEARCH) is set, then the target is bound to the first directory in $(SEARCH) where the target file already exists.

    • If searching in $(SEARCH) fails, the target is bound relative to the current directory anyhow.

    Both $(SEARCH) and $(LOCATE) should be set target-specific and not globally. If they were set globally, jam would use the same paths for all file binding, which is not likely to produce sane results. Almost all of the rules defined in Jambase set $(SEARCH) and $(LOCATE) to sensible values for sources they are looking for and targets they create, respectively. Provide an example

    Note

    When writing your own rules, especially ones not built upon those in Jambase, you may need to set $(SEARCH) or $(LOCATE) directly.

  2. $(HDRSCAN) and $(HDRRULE) Variables

    These two variable control header file scanning.

    • $(HDRSCAN) is an egrep(1) pattern, with ()'s surrounding the file name, used to find file inclusion statements in source files. Jambase uses $(HDRPATTERN) as the pattern for $(HDRSCAN).

    • $(HDRRULE) is the name of a rule to invoke with the results of the scan: the scanned file is the target, the found files are the sources. $(HDRRULE) is run under the influence of the scanned file's target-specific variables.

    Note

    Both $(HDRSCAN) and $(HDRRULE) must be set for header file scanning to take place, and they should be set target-specific and not globally. If they were set globally, all files, including executables and libraries, would be scanned for header file include statements.

    The scanning for header file inclusions is not exact, but it is at least dynamic, so there is no need to run something like makedepend(GNU) to create a static dependency file. The scanning mechanism errs on the side of inclusion (i.e., it is more likely to return filenames that are not actually used by the compiler than to miss include files) because it can't tell if #include lines are inside #ifdefs or other conditional logic. In Jambase, HdrRule applies the NOCARE rule to each header file found during scanning so that if the file isn't present yet doesn't cause the compilation to fail, jam won't care.

    Also, scanning for regular expressions only works where the included file name is literally in the source file. It can't handle languages that allow including files using variable names (as the Jam language itself does).

  3. Platform Identifier Variables

    Jam built-in variables that can be used to identify the runtime platform:

    1. $(OS) : OS identifier string ( e.g. if( $(OS) = LINUX ) { Echo "Building on Linux" })

      Valid values of $(OS) are :

      Table 10-1. Values of $(OS)

      AIXAMIGAAS400BEOSBSDI
      COHERENTCYGWINDGUXFREEBSDHPUX
      INTERIXIRIXISCLINUXLYNX
      MACMACHTENMAXOSXMINGWMPEIX
      NCRNETBSDNEXTNTOS2
      OSFPTXQNXQNXNTORHAPSODY
      SCOSINIXSOLARISSUNOSULTRIX
      UNICOSUNIXWAREUNKNOWNVMS 

    2. $(OSPLAT) : Underlying architecture, when applicable(wtf does that mean?)

    3. $(MAC) : true on MAC platform

    4. $(NT) : true on NT platform

    5. $(OS2) : true on OS2 platform

    6. $(UNIX) : true on Unix platforms

    7. $(VMS) : true on VMS platform

    8. $(CWD) : Current working directory

  4. Other Jam Variables

    1. $(JAMDATE) : Time and date at jam start-up.(what is the format of the date?)

    2. $(JAMUNAME) : Ouput of uname -a command (Unix only)

      i686 #2 Mon May 22 23:10:59 UTC 2006 2.6.16-2-686 cucu Linux

    3. $(JAMVERSION) : jam version, as reported by jam -v.

      Echo $(JAMVERSION) ; -> 2.5