On Tue, Dec 22, 2009 at 1:43 PM, Philip Guenther <[email protected]> wrote:
> On Tue, Dec 22, 2009 at 2:55 AM, 袁野 <[email protected]> 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 $...@...} 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
_______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
