help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on multiple targets


From: Bart Robinson
Subject: Re: Help on multiple targets
Date: Tue, 22 Dec 2009 20:16:07 -0800

On Tue, Dec 22, 2009 at 1:43 PM, Philip Guenther <address@hidden> wrote:
On Tue, Dec 22, 2009 at 2:55 AM, 袁野 <address@hidden> wrote:
> How to write this with maybe multiple targets and patterns?
>
> foo.o foo.h : foo.src
>         cmd foo.src -o foo.o -h foo.h
> bar.o bar.h : bar.src
>         cmd bar.src -o bar.o -h bar.h
>
> I have lots of *.src files.

I would do it with this:

%.o %.h: %.src
       cmd $< -o ${@:.h=.o} -h ${@:.o=.h}

The odd address@hidden bits are so that the proper files are generated
regardless of whether make hits this with, for example, "foo.o" as the
target or "foo.h" as the target.  Since it bases them off of $@ and
not $<, it'll also work properly with VPATH.

Might want to consider $*.  I.e., "cmd $< -o $*.o -h $*.h"
Same behavior but a little more concise.

Cheers
-- bart


reply via email to

[Prev in Thread] Current Thread [Next in Thread]