This is a somewhat abstract example of one way in which you can use
Jam to build a project whose sources are spread over several
subdirectories.
In this example, we introduce the "Jamrules" file, which generally contains
site or project specific configuration, rules, and actions. In this
case, the Jamrules only sets the ALL_LOCATE_TARGET variable, which
specifies where to put generated files.
We also demonstrate the use of the SubDir and SubInclude rules to
compile the contents of sub directories.
Note that there's a Jamfile for each directory in which sources reside.
Each contains only a call to the Library rule specifying that a library
should be made from the source files in that directory. The Jamfiles
in the sub directories could of course be arbitrarily complex, but it
is usually best to keep them as simple as possible.
Things to try:
- Run jam, then touch or edit one of the header files - for example,
"b.h" in the "b" directory. Notice that jam knew which source files
#included "b.h" (see the section called "Header File Processing" in the
Jamfiles and Jambase document for information on how this works).
Then try making one header file #include another, and touch the
#included file. Jam understands the new relationship, without
the need for a "make depends", and it does it fast.
- Do a "jam clean" from the top directory, and then try running jam
from within one of the source sub directories. Note that (with this
particular setup) Jam will only compile the library corresponding
to that particular sub directory. This sort of arrangement can be
helpful in modularizing large and/or multi-platform projects.
- Try adding your own call to "InstallBin" in the top level Jamfile
(see the simple example for an example
of using InstallBin). Then, hypothesize that for this project
you actually want to install one or more of the libraries, and
add a call to "InstallLib" to tell jam which libraries to install
and where. (Hint: on a "real" project, the directory into which
things are installed would probably be specified one way or another
in the Jamrules. Try setting a variable containing your install
path in the Jamrules and then pass that variable to the appropriate
install rule.)
See the
Jamfiles and Jambase file for more information on InstallLib and
other rules.