help-make
[Top][All Lists]
Advanced

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

Re: Getting the target of an implicit rule within the rule


From: Paul D. Smith
Subject: Re: Getting the target of an implicit rule within the rule
Date: Mon, 26 Jul 2004 16:00:16 -0400

%% Ronald Landheer-Cieslak <address@hidden> writes:

  rl> %.d : $(srcdir)/$(subst .d,.c,$@)
  rl>       blah

  rl> $@, however, is empty here (as the docs duely indicate).

  >> Why not just use the obvious:
  >> 
  >> %.d : $(srcdir)/%.c

  rl> because the obvious doesn't work if there's a pathname in the
  rl> target filename (i.e. target == dir/file.d, prereq would become
  rl> dir/$(srcdir)/file.c because the stem of the pattern is "file",
  rl> not "dir/file").

Well sure, that won't work, but that's not the example you gave.  It's
hard to give solutions that work for examples that are not provided :).


Typically what I do is not try to install the srcdir inside the pathname
but rather have it at the top.  If you have to put it inside you'll have
to write a different rule for each value of "dir".  You can use $(eval
...) (in the newest releases of GNU make) to do this without typing it
all out.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "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]