Emulating gmake functionality in make
David Landgren
david at landgren.net
Tue Sep 23 06:56:50 PDT 2003
Hello list,
gnu's make (a.k.a gmake) has a nifty piece of functionality that,
while it may be possible to perform with make, for the life of me I
can't figure out the syntax.
Let's say you have a list of files a b c d that get transformed by
program foo into a.x b.x c.x and d.x
Further, let us suppose that you have another list of files e f g that
get tranformed by bar into e.x f.x and g.x
Note how the resulting files all have a .x extension, yet are produced
with two different programs.
In gnu parlance, one would write something like
FOO = a.x b.x c.x d.x
BAR = e.x f.x g.x
$(FOO): %.x: %
foo $<
$(BAR): %.x: %
bar $<
Which roughly translates to "for the files in the FOO list, you get to
something.x from something, by running 'foo something' (since foo
produces something.x as a result). And the resulting Makefile is very
compact.
Can this be done with make (without repeating things in more than one
place in the Makefile)? I'm quite happy with the gmake way of doing
things, except of course I keep running 'make' instead of 'gmake' and
it complains out the syntax. If I could just teach make how to do this
it would be more comfortable.
Thanks,
David
:x
More information about the freebsd-questions
mailing list