bug-make
[Top][All Lists]
Advanced

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

Re: suspected bug in flag -n, in make-3.80


From: Paul D. Smith
Subject: Re: suspected bug in flag -n, in make-3.80
Date: Sat, 21 Feb 2004 16:38:25 -0500

%% Matteo Ciucci <address@hidden> writes:

  mc> I found that something strange happened to the -n flag from
  mc> version 3.80: it doesn't show what really make does.

When you run with -n, make can't know what your rules will _REALLY_ do
when you run them.  Instead, it simply assumes that your rules do what
you say they will do.

In this case:

  mc> speak :: a
  mc>   echo a

  mc> speak :: b
  mc>   echo b

The command script for your first rule for "speak" doesn't actually
create the target "speak", but make can't know that since it's not
running the rule.  It must assume that the command script _does_ create
the target "speak".  And, if it _DID_ create that target, then the
target would be up-to-date with relation to the "b" prerequisite, and
the second rule would never run.

You can prove this to yourself by having the command actually create the
target; change your makefile to this:

  speak :: a
        echo a
        @touch $@

  speak :: b
        echo b

When you run this without -n, you'll get the same results as with -n:

    $ make
    echo a


If that target is never supposed to exist then you should use the .PHONY
pseudo target to tell make that:

  .PHONY: speak

Then, make will behave as you expect both with -n and without it.

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