7 messages in com.perforce.jamming[jamming] NEWBIE:directory dependencies?
FromSent OnAttachments
Roar...@Stac.com10 Aug 1999 12:28 
Scot...@pe-i.com10 Aug 1999 14:26 
Dian...@whistle.com10 Aug 1999 15:46 
Roar...@Stac.com10 Aug 1999 18:45 
Dann...@ishiboo.com10 Aug 1999 20:53 
Dian...@whistle.com10 Aug 1999 23:24 
Dian...@whistle.com10 Aug 1999 23:33 
Subject:[jamming] NEWBIE:directory dependencies?
From:Dian...@whistle.com (Dian@whistle.com)
Date:08/10/1999 03:46:57 PM
List:com.perforce.jamming

When you're sitting in your top-level dir, your SubInclude's say to read in the Jamfiles in the directories listed.

When you're sitting in the "test" dir, Jam is only going to read in the local Jamfile, because you've not given it any directive to read in any other Jamfile. So if you're only reading in the local Jamfile, then it's only going to know about what's in that one. Having the executable link against a library that gets built elsewhere isn't enough to make Jam go someplace else to try and build it -- how would it know where it's supposed to go? Using a relative (or even a full) path to specify where the library can be found still isn't telling Jam where to go to build it (for all it knows, maybe it gets built one place and installed into where it can be found).

Ordinarily, things are organized from a "top-down" perspective, and when you're sitting in a subdirectory, you only want to build what's in that directory (and anything below it). But there's no law that says you can't go build things in other places if that's what you want to do. You just need to tell it where to go.

BTW: I've gotten rid of things that aren't relevant to this particular thing, like the header stuff -- oh, and I've used the -L flag to point to where s.a lives (I didn't bother to make it libs.a...I was feeling lazy :)

So, given your example...

# Top-level Jamfile

SubInclude TOP shared ; SubInclude TOP test ;

# Jamfile for shared

SubDir TOP shared ;

# To avoid being multiply included S_INCLUDED = true ;

Library s : s.c ;

# Jamfile for test

# Note: Put this first so SubDir will still get set correctly if ! $(S_INCLUDED) { SubInclude TOP shared ; }

SubDir TOP test ;

Main RunMe : main.c ; LINKFLAGS on RunMe = -L $(TOP)/shared ; LinkLibraries RunMe : s ;

Now, if you're in the "test" dir, and (lib)s.a needs to get built, it will:

% cd test % jam -n ...found 19 target(s)... ...updating 4 target(s)... Cc /tmp/roark/shared/s.o cc -c -O -I/tmp/roark/shared -o /tmp/roark/shared/s.o /tmp/roark/shared/s.c Archive /tmp/roark/shared/s.a ar ru /tmp/roark/shared/s.a /tmp/roark/shared/s.o Ranlib /tmp/roark/shared/s.a RmTemps /tmp/roark/shared/s.a Cc /tmp/roark/test/main.o cc -c -O -I/tmp/roark/test -o /tmp/roark/test/main.o
/tmp/roark/test/main.cLink /tmp/roark/test/RunMe cc -L /tmp/roark/shared -o /tmp/roark/test/RunMe /tmp/roark/test/main.o /tm p/roark/shared/s.a Chmod /tmp/roark/test/RunMe chmod 711 /tmp/roark/test/RunMe ...updated 4 target(s)...

And it will also work from the top-level directory:

% cd $TOP % jam -n ...found 19 target(s)... ...updating 4 target(s)... Cc /tmp/roark/shared/s.o cc -c -O -I/tmp/roark/shared -o /tmp/roark/shared/s.o /tmp/roark/shared/s.c Archive /tmp/roark/shared/s.a ar ru /tmp/roark/shared/s.a /tmp/roark/shared/s.o Ranlib /tmp/roark/shared/s.a ranlib /tmp/roark/shared/s.a RmTemps /tmp/roark/shared/s.a rm -f /tmp/roark/shared/s.o Cc /tmp/roark/test/main.o cc -c -O -I/tmp/roark/test -o /tmp/roark/test/main.o
/tmp/roark/test/main.cLink /tmp/roark/test/RunMe cc -L /tmp/roark/shared -o /tmp/roark/test/RunMe /tmp/roark/test/main.o /tm p/roark/shared/s.a Chmod /tmp/roark/test/RunMe chmod 711 /tmp/roark/test/RunMe ...updated 4 target(s)...

Hope this helps,

Diane (dia@whistle.com)