help-make
[Top][All Lists]
Advanced

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

order-only dependency and transitivity


From: Ross Boylan
Subject: order-only dependency and transitivity
Date: Wed, 9 Jun 2004 11:58:20 -0700
User-agent: Mutt/1.5.5.1+cvs20040105i

I was surprised by the following behavior.  My Makefile is
--------------------------------------------------
m.touch: m.web
        @echo tangling web
        touch m.touch
        touch x.cc

x.cc: | m.touch
        @echo x.cc rule

x.o: x.cc
        @echo compiling x
        touch x.o
--------------------------------------------------
then I touch x.cc, x.o, and m.web in that order.
Then make x.o.  The result is
tangling web
touch m.touch
touch x.cc
If I make x.o again, I get
compiling x
touch x.o

My surprise is that the x.o rule didn't get executed the first time.

It seems that even though x.cc is guaranteed to execute after
m.touch, the x.o rule is somehow considered before this.

I've found I can correct this behavior by changing the rule to
x.o: x.cc | m.touch
but this is somewhat awkward, since it means I potentially have to
track down all the dependents of x.cc.

Should make behave like this?  Is there a better way around the
problem?  I'm use GNU Make 3.80 on Debian GNU/Linux.

For reference, here's the real problem I am trying to solve:
I have a web file m.web, which when processed by ftangle -F produces
many .cc and .h files.  With the -F option, only the files that have
changed are updated.  I want to ensure that ftangle is run if
necessary, and then all the necessary rebuilding takes place.

Simply declaring the files dependent on m.web with
$(SOURCEFILES): m.web
almost works, but it causes ftangle to be rerun repeatedly, once for
each source file that is not updated (since it keeps discovering m.web
is newer).  My use of the intermediate file m.touch above is an effort
to get around that problem.

Running ftangle with -F produces only one run of ftangle, but then
there are many unnecessary recompilations.




reply via email to

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