help-make
[Top][All Lists]
Advanced

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

Re: Will a rule be updated if its dependent file is modified by another


From: Paul Smith
Subject: Re: Will a rule be updated if its dependent file is modified by another rule?
Date: Sun, 07 Mar 2010 09:29:59 -0500

On Fri, 2010-03-05 at 12:00 -0600, Peng Yu wrote:
> In order to make the dependence in dir1 current, I'll have to specify
> dir1 as a PHONY in the current directory Makefile (call it the main
> Makefile), hence make always invoke make -C on dir1. At the time of
> invoking make -C on dir1, dir1/file3 and hence file3 may not be
> updated yet. Hence according to my understanding. The rule file1:
> file2 file3 should not be invoked in the main Makefile. However, the
> following commands show that 'file1: file2 file3' is invoked.

I don't see the behavior you're seeing.  When I run make the first time
after dir1/file3 is touched, it updates file1.  When I run make again,
it doesn't update anything.  This is exactly what I would expect: if
file3 is newer than file1, then file1 will be rebuilt.  If file3 is not
newer, then file1 will not be rebuilt.  That's pretty much all there is
to it.

If you're seeing some different behavior, why not try using "make -d"
and examining the debug output to understand why make feels that it
needs to update file1?


        mk1$ touch dir1/file3
        
        mk1$ make
        make -C dir1
        make[1]: Entering directory `/tmp/mk1/dir1'
        make[1]: Nothing to be done for `all'.
        make[1]: Leaving directory `/tmp/mk1/dir1'
        touch file1
        
        mk1$ make
        make -C dir1
        make[1]: Entering directory `/tmp/mk1/dir1'
        make[1]: Nothing to be done for `all'.
        make[1]: Leaving directory `/tmp/mk1/dir1'
        
        mk1$

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