SubDirHdrs question
<Paul_Donovan <at> scee.net>
2003-04-02 15:44:04 GMT
Hi,
I've just started using jam, version 2.4 under Linux.
I've succesfully made a couple of Jamfiles that build a library in a
subdirectory and build an executable in the top directory that is linked
with the library, but I've had to use the SubDirHdrs rule in a strange
(counter-intuitive) way. Perhaps I'm just not understanding the SubDir and
SubInclude rules? This is the structure of my test project:
Jamfile
support.cpp
animtable.cpp
xmlparser.cpp
expat_config.h
...
xmllib/
Jamfile
xmltok.c
xmlparse.c
xmlrole.c
...
The files in xmllib/ are compiled to produce a library (libexpat.a) in that
directory, which the executable (animtable) in the top directory is linked
with.
Jamfile contains this:
-----------------------------
SubDir TOP ;
LINKLIBS = -lstdc++ -lg ;
Main animtable : support.cpp animtable.cpp xmlelement.cpp xmlparser.cpp ;
LinkLibraries animtable : libexpat ;
SubInclude TOP xmllib ;
-----------------------------
And xmllib/Jamfile looks like this:
-----------------------------
SubDir TOP xmllib ;
SubDirHdrs . ;
Library libexpat : xmlparse.c xmltok.c xmlrole.c ;
-----------------------------
The .c files in xmllib/ contain #include "expat_config", which is actually
in the directory above. In order to get the compiler to find
expat_config.h, I've added the SubDirHdrs rule. What I don't fully
understand, or rather, what I find odd, is the fact that I have to set it
to '.' After all, the header being searched for isn't _in_ the directory
that the Jamfile is in (xmllib), it's in the directory above - '..'
Someone reading xmllib/Jamfile will assume I'm talking about the xmllib
directory!
From examining the commands Jam invokes, I can see that it actually calls
'cc' from the top directory on the .c files in xmllib/ :
cc -c -o xmllib/xmlparse.o -O -Ixmllib -I. xmllib/xmlparse.c
hence the reason that the -I. needs to be passed to the compiler.
So, what am I misunderstanding, or what am I doing wrong? I just think this
setup is odd. I realise that I could just move expat_config.h into xmllib/,
but that's no fun
Thanks,
Paul
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster <at> scee.net
This footnote also confirms that this email message has been checked
for all known viruses.
**********************************************************************
SCEE 2003