help-make
[Top][All Lists]
Advanced

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

RE: how make concludes that target is out of date


From: Dave Korn
Subject: RE: how make concludes that target is out of date
Date: Fri, 1 Jun 2007 12:38:10 +0100

On 01 June 2007 12:22, sharan basappa wrote:

> I have following make rules in my file
> 
> one : a.c
>         echo "hello"
> 
> two : c.c
>         echo "hello"
> 
> 
> a.c exists and c.c does not exist ..
> 
> My question is
> 
> a) How make takes up a rule and decides that target is
> out of date and hence command needs to be executed.

  If the target does not exist or is older than any prereq it needs rebuilding
and the associated commands are executed.
 
> b) If the target is not a file 

  The target is always a file.  Your makefile above describes how to produce
two output files, called 'one' and 'two', from two input files, a.c and c.c.
The fact that your commands do not actually create files named 'one' or 'two'
is incidental.

> but prereq is and this preq file exists then
> what happens.
> Rule one above a.c exists but make exits with message make: `one' is up to
> date.

  You must have a file called 'one' in the directory where you are working, I
get the hello.
 
> c) If target exists but prereq does not. If you refer to second rule above
> then
> make does not execute the command echo "hello" and exits with message
> make: *** No rule to make target `c.c', needed by `two'.  Stop.

  Yep, you have told it that 'two' is a file made depending on 'c.c', so it
assumes that if there is no 'c.c', and it also cannot find a rule in the
makefile to create 'c.c', then your commands for creating 'two' will fail
because they do not have 'c.c', so it prints an error.

> I would be glad if someone could point me to right documentation to
> understand better

  "info make", or "man make" depending on which format you prefer. 


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....





reply via email to

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