help-make
[Top][All Lists]
Advanced

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

Re: USE A GENERIC RULE IN GNU_MAKE


From: Paul D. Smith
Subject: Re: USE A GENERIC RULE IN GNU_MAKE
Date: Thu, 18 Oct 2001 13:20:30 -0400

%% Sebastien Seulin <address@hidden> writes:

  ss> I would like to write a generic rule like this
 
  ss> %.o : %.c $(shell mypg %.c)
  ss>   $(CC) $(XFLAGS) $(LDFLAGS)  -o $@ $<
 
  ss> where mypg is a program that list all dependencies of a source file.
 
  ss> It doesn't work as %.c is not understood in $(shell mypg %.c)

It doesn't work because targets and prerequisite lines are expanded
(including both variables and functions) immediately as the makefile is
read in, but implicit rule patterns like %.c aren't expanded until
make is running and matches the implicit rule.

So, that shell function is being expanded with the static argument "mypg
%.c", not the expansion of %.c.

See the GNU make manual section 'How 'make' Reads a Makefile'.

If you're trying to handle dependency tracking, see my web site below
for a good way to do it.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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