help-gnu-utils
[Top][All Lists]
Advanced

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

Re: Makefile -- Evaluate dependencies in order, don't consider it prere


From: Paul D. Smith
Subject: Re: Makefile -- Evaluate dependencies in order, don't consider it prerequisite?
Date: 13 Jul 2004 18:28:18 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

%% chessaurus@yahoo.com (Chess Saurus) writes:

  cs>   apple.file : orange banana pineapple
  cs>       @echo "Apple"

  cs>   orange : orange.file
  cs>       @echo "Orange"

  cs>   banana : 
  cs>       @echo "Banana"

  cs>   pineapple : pineapple.file
  cs>       @echo "Pineapple"

  cs> What I want is for gmake to to process all of the prerequisites in
  cs> order, but not to consider "banana" as a prerequisite to actually
  cs> rebuild apple.

Make doesn't always guarantee that prerequisites will be built in the
order they appear in the prerequisites list.  As long as you're running
serial make yes, they will be built in that order.  But as soon as you
invoke parallel make (-j) make will not guarantee any order in which
prerequisites are built _EXCEPT_ that they will all be complete before
the target's build script is invoked.

If, in the makefile above, you are relying on orange to be built before
banana your makefile is not properly constructed.  If you want to ensure
that orange is built before banana and banana is built before pineapple,
you have to declare that:

  apple.file : orange
        ...
  orange: banana
        ...
  banana: pineapple
        ...
  pineapple:
        ...

  cs> In other words, if apple.file exists, orange.file exists, and
  cs> pineapple.file exists (and assuming that apple.file is the most
  cs> recent), I would want the words "Banana" printed, but not have to
  cs> rebuild apple.file.

  cs> I apologize if this is a little bit confusing.  I have read in the
  cs> gmake manual that there are "order-only-prerequisites", which are
  cs> almost perfect, except that I can't interleave their order with the
  cs> actual prerequisites.

See above.

In that "correct" makefile you would simply change the banana
prerequisite to be order-only and leave the rest:

  apple.file : orange
        ...
  orange: | banana
        ...
  banana: pineapple
        ...
  pineapple:
        ...

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          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]