[jamming] Compiling the same file with different flags for different targets

warkda rrior announcements.for.warkdarrior at gmail.com
Mon Dec 1 18:14:52 PST 2008


I would like to create one Jamfile, which has two targets that share one
source file. This source file must be compiled with different compiler
flags depending on the target.

Basically, I'd like to have a Jamfile as follows:

CC = gcc ;
LINK = gcc ;

Main test1 : test1.c lib.c ;

Main libtest.so : lib.c ;
   CCFLAGS on lib.o = -fPIC ;
   LINKFLAGS on libtest.so = -shared ;

Main test2 : test2.c ;
   LINKFLAGS on test2 = -Xlinker -rpath -Xlinker . -L . -l test ;

such that the file lib.c is compiled with the option "-fPIC" when it is
to be linked into the target libtest.so and without that option for the
target test1.

I can certainly do this with two Jamfiles. Is there a way to do this
with one Jamfile? It seems that CCFLAGS is defined once for the whole
file (i.e., setting CCFLAGS multiple times does not matter).




More information about the jamming mailing list