Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Sep 2003 15:56:59 +0200
From:      David Landgren <david@landgren.net>
To:        freebsd-questions@freebsd.org
Subject:   Emulating gmake functionality in make
Message-ID:  <3F70512B.5090707@landgren.net>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F70512B.5090707>