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

Diane Holt holt.diane at gmail.com
Mon Dec 1 20:12:07 PST 2008


You should write SharedLibrary and SharedObjects rules, and set your compile
and link flags that way. You should also give your shared objects a
different suffix, to distinguish them from regular .o's and so you can set
your flags on them. (I suppose you could build them out to a different
subdir, or grist them differently, but a different suffix seems easier to
me.)

Diane

On Mon, Dec 1, 2008 at 6:14 PM, warkda rrior <
announcements.for.warkdarrior at gmail.com> wrote:

> Hi,
>
> 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).
>
>
> Thanks,
>
> Mihai
>
> --
> _______________________________________________
> jamming mailing list  -  jamming at perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/jamming/attachments/20081201/8242dcd3/attachment-0001.html>


More information about the jamming mailing list