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.
Philip Guenther
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make