4 messages in com.perforce.jamming[jamming] SubInclude and current work...
FromSent OnAttachments
Dag Asheim07 May 2003 05:37 
Ingo Weinhold07 May 2003 07:52 
Dag Asheim07 May 2003 09:24 
Ingo Weinhold07 May 2003 09:56 
Subject:[jamming] SubInclude and current working directory for the compiler
From:Dag Asheim (da@linpro.no)
Date:05/07/2003 05:37:56 AM
List:com.perforce.jamming

Hello.

I have a problem with the SubInclude command, because I (incorrectly) thought it should behave as if "doing an cd to the subdirectory in question and doing the actions from the local Jamfile".

I have condensed my problem down to just a few files:

~/simple/src/Jamfile: HDRS = ../include ;

Main hello : hello.c ;

~/simple/src/hello.c: #include <message.h>

main() { printf(STR); }

~/simple/include/message.h #define STR "Hello, World!\n"

~/simple/src/Jamfile: SubInclude TOP src ;

I have also defined the environment variable TOP:

export TOP=$HOME/simple

When I stand in the ~/simple/src directory and build it, everything works as expected. But when I stand in the directory ~/simple, things break down:

...found 12 target(s)... ...updating 2 target(s)... Cc src/hello.o src/hello.c:1: message.h: No such file or directory

cc -c -o src/hello.o -O -Isrc -I../include src/hello.c

...failed Cc src/hello.o ... ...skipped hello for lack of <src>hello.o... ...failed updating 1 target(s)... ...skipped 1 target(s)...

The compiler can no longer find hello.h. I can see why this is happening (the compiler seemingly has a working directory of ~/simple instead of ~/simple/src), but is there a better way to write the ~/simple/Jamfile to avoid this problem?

A work around is to abolish all relative paths from the local Jamfiles (using HDRS = $(TOP)/include ;), but I would rather avoid that.

Btw, I have tried this with both Jam 2.5rc2 and jam-2.5rc3 with same results.

Thanks in advance (and hi Arnt!),