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: Torc Online
Subject: Re: Dependency checked for existance but not timestamp
Date: Mon, 7 Feb 2005 10:28:25 -0800 (PST)

Thanks for the response!  However, I think that I
probably did not
express the problem well.  Please let me try again.

I am trying to create a generic rule that does the
following to all files
that are not covered by a specific rule.
--------------------------
> cd projectdir
> make clean
      [ rm -f testdir/testfile ]
> make
      [ cp -f testfile testdir/testfile ]
> make
      [ Nothing ]
> touch testfile
> make
      [ cp -f testfile testdir/testfile ]
--------------------------
      
My solution looked like this:
--------------------------
all: testdir/testfile
        @echo Done

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

The actual results look like this:
--------------------------
> cd projectdir
> make clean
      [ rm -f testdir/testfile ]
> make
      [ cp -f testfile testdir/testfile ]
> make
      [ Nothing ]
> touch testfile
> make
      [ Nothing ]
--------------------------

Please note that the source and target are being
correctly compared the
first time make is run.  Make detects that the target
does not exist and
copies the file over.  

Unfortunately, the last step is not doing another
copy.  The make debug 
output shows that make is getting the correct source
and target, it 
appears to be failing to compare their time stamps
correctly.  The relevant 
"make -d" lines look like this:
--------------------------
  Considering target file `testdir/testfile'.
   Looking for an implicit rule for
`testdir/testfile'.
   Trying pattern rule with stem `testfile'.
   Found an implicit rule for `testdir/testfile'.
   Finished prerequisites of target file
`testdir/testfile'.
  No need to remake target `testdir/testfile'.
--------------------------

Thanks!
Dustan




--- John Graham-Cumming <address@hidden>
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
> 



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




reply via email to

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