Ok this seems to be not an as easy question as I thought so I worked out a solution on my own. It uses a script to achieve the end result so I still hope that a Jam guru will have a jam-only solution.
SubDir . ;
SubInclude . src ;
SubInclude . test ;
- Create a Jamfile in the src directory
SubDir .. src ;
Library mylib : mylib.c ;
- Create a Jamfile in the test directory
SubDir .. test ;
Main mytest : mytest.c ;
Depends mytest : mylib$(SUFLIB) ;
With this setting, as long as I am in the root directory, whenever I try to build mytest the library will also be recompiled (if needed). I found an old message on the jammer mailing list describing it.
Alas this doesn't work if I'm in the test subdirectory since jam can only look down into subdirectories.
So, I created a simple script called jmk
and put it together with the jam
executable (so that both are in the path):
if [ "$JMKROOT" = "" ] ; then
JMKROOT=`pwd`
export JMKROOT
fi
cd $JMKROOT
jam $*
and I set the JMKROOT environment variable to the root of my project.
For when I compile in a Windows shell (that's why I want to use Jam) I simply use this small jmk.bat
batch file:
@echo off
if "%JMKROOT%" EQU "" set JMKROOT=%CD%
set OLDCD=%CD%
cd %JMKROOT%
jam %1 %2 %3 %4 %5 %6 %7 %8 %9
cd %OLDCD%