help-make
[Top][All Lists]
Advanced

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

Re: Dependency checked for existance but not timestamp


From: Paul D. Smith
Subject: Re: Dependency checked for existance but not timestamp
Date: Mon, 7 Feb 2005 14:31:40 -0500

%% Torc Online <address@hidden> writes:

  to> all: testdir/testfile
  to>         @echo Done

  to> %: $(@F)
  to>         @mkdir -p $(@D)
  to>         cp -f $(@F) $@

Just so you're clear, the $(@F) in the prerequisites list expands to the
empty string.  Automatic variables like $@, $(@F), etc. are available
_ONLY_ within the command script.  They are not set or available in the
prerequisites list.

So this rule is identical to writing this:

  %:
         @mkdir -p $(@D)
         cp -f $(@F) $@

which explains your results.  Since there are no prerequisites, then as
long as the target exists, regardless of any timestamp comparison, the
rule will not fire.



  to> --- John Graham-Cumming <address@hidden>
  to> wrote:

  >> On Fri, 2005-02-04 at 15:22, Torc Online wrote:
  >> > =================================================
  >> > all: testdir/testfile
  >> >        @echo Done
  >> > 
  >> > # Any file not covered by other rules is just
  >> copied.
  >> > %: $(@F)
  >> >        @mkdir -p $(@D)
  >> >        cp -f $(@f) $@
  >> 
  >> Problems:
  >> 
  >> 1. $(@F) expands to an empty string in the rule that
  >> you are defining
  >> because $(@F) is invalid in the prerequisite list.  
  >> What you want is
  >> $$(@F).
  >> 
  >> 2. In the rule body you have a $(@f) in the cp
  >> command, that needs to be
  >> $(@F): note that capital F.
  >> 
  >> 3: Your match-anything rule is using a single-colon
  >> which means it is
  >> non-terminal and hence GNU Make may spend a lot of
  >> time searching for
  >> ways to make its prerequisite.  Would be better to
  >> use a double-colon so
  >> that GNU Make doesn't have to search for how to make
  >> $$(@F).
  >> 
  >> 4. Even if you change to $$(@F) it doesn't do what
  >> you want because
  >> $$(@F) is going to be the filename of % which isn't
  >> what you mean.
  >> 
  >> So you really need to rewrite this completely.  I
  >> think the best way is
  >> going to be something like this:
  >> 
  >> all: testdir/testfile
  >> @echo Done
  >> 
  >> testdir/%: %
  >> @mkdir -p $(@D)
  >> cp -f $< $@
  >> 
  >> Of course that does meant that you are going to need
  >> to have a rule for
  >> each subdirectory.
  >> 
  >> John.
  >> -- 
  >> John Graham-Cumming
  >> 
  >> Home: http://www.jgc.org/
  >> Work: http://www.electric-cloud.com/
  >> POPFile: http://getpopfile.org/
  >> 
  >> 
  >> 
  >> 
  >> _______________________________________________
  >> Help-make mailing list
  >> address@hidden
  >> http://lists.gnu.org/mailman/listinfo/help-make
  >> 



                
  to> __________________________________ 
  to> Do you Yahoo!? 
  to> Yahoo! Mail - now with 250MB free storage. Learn more.
  to> http://info.mail.yahoo.com/mail_250


  to> _______________________________________________
  to> Help-make mailing list
  to> address@hidden
  to> http://lists.gnu.org/mailman/listinfo/help-make

-- 
-------------------------------------------------------------------------------
 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]