[jamming] Jamming with subdirectories

Ingo Weinhold bonefish at cs.tu-berlin.de
Wed Feb 5 04:47:06 PST 2003


On Wed, 5 Feb 2003, Russell wrote:

> In the top level Jamfile, i've got:
>
> SubDir TOP ;
> Main myprog : main.c analog.c serial.c
> SubInclude TOP main ;
> SubInclude TOP analog ;
> SubInclude TOP serial ;
>
> In the 'main' subdirectory jamfile, i have:
>
> SubDir TOP main ;
> Objects main.c ;
>
> In the 'analog' subdirectory jamfile, i have:
>
> SubDir TOP analog ;
> Objects analog.c ;
>
> In the 'serial' subdirectory jamfile, i have:
>
> SubDir TOP serial ;
> Objects serial.c ;
>
>
> When i run jam from the top directory, i get errors:
>    don't know how to make main.c
>    don't know how to make analog.c
>    don't know how to make serial.c

Supposing that your source files reside in the respective subdirectories,
this is not surprising.

As a general remark: The Main rule is intended to compile the source
files and link the objects. The Objects rule compiles source files to
objects. So in the way you apply these rules, the source files would be
compiled twice. So you should either drop the Objects rules or use
MainFromObjects instead of Main.

1) Dropping the Objects rules (and, if you like also the then-empty
Jamfiles in the subdirectories): The errors jam reports are caused by the
fact, that it doesn't know, where the listed source files are located. By
default jam searches only the directory of the Jamfile, so you have to
tell it explicitly, e.g. by:

  SEARCH_SOURCE += [ FDirName $(TOP) main ] [ FDirName $(TOP) analog ]
                   [ FDirName $(TOP) serial ] ;

This must be inserted before the invocation of the Main rule.

2) Using MainFromObjects instead of Main:

  MainFromObjects myprog : <main>main.o <analog>analog.o
                           <serial>serial.o ;

The grist (the `<...>' annotation) is needed to make jam find the object
files. The concept can be looked up in the documentation.

CU, Ingo





More information about the jamming mailing list