On Fri, Apr 25, 2014 at 8:43 PM, Casey Rodarmor <[email protected]> wrote:
> My project looks like this:
>
> /Tupfile
> /a.h
> /a.c
> /b.h
> /b.c
> /main1.c
> /main2.c
>
> I have rules to build a.o, b.o, main1.o, and main2.o
>
> I would like to write a rule that links a.o, b.o and main1.o into an
> executable, and a.o, b.o, and main2.o into an executable, but I'm not quite
> sure how to write it.
>
> Before I had two mains, my :-rule looked like this:
>
> : *.o |> $(CXX) $(LINKFLAGS) %f -o %o |> main
>
> Now I want to write something like:
>
> : *.o EXCEPT main2.o |> $(CXX) $(LINKFLAGS) %f -o %o |> main1
> : *.o EXCEPT main1.o |> $(CXX) $(LINKFLAGS) %f -o %o |> main2
>
> Or better yet:
>
> MAINS = main1 main2

Nah, don't define a symbol just to use it once.  Use a wildcard as shown below,

But add the following symbol, which you will use multiple times
    OBJS = a.o b.o

>
> : foreach $(MAINS) |> MAGICAL TUP GOODNESS |> %B

The rule should look something like this:
    : foreach main?.o | $(OBJS) |> $(CXX) $(LINKFLAGS) %f $(OBJS) -o %o |> %B

Good luck,

-- 
-- 
tup-users mailing list
email: [email protected]
unsubscribe: [email protected]
options: http://groups.google.com/group/tup-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"tup-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to