[Top][All Lists]

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

Re: non-recursive build question

From: Sandy Currier
Subject: Re: non-recursive build question
Date: Tue, 27 Apr 2004 17:15:47 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

Paul D. Smith wrote:

>Not so.  GNU make will check the timestamp of the target file after the
>rule is run and, if it hasn't changed, it will assume that the target
>was not updated.

This is a good thing!

>Second, in both cases above you're updating the target (if the
>output is equal you still "touch $@").  The whole point here is to _NOT_
>update the target if the content has not changed.  That means that
>targets that depend on this one won't be rebuilt.

Actually, though the primary point is to not have targets that depend on
foo.exp rebuild when it is not physically changed, the secondary point
IS to touch the foo.exp target.  By touching it when it is rebuilt, then the
next time that make is run, if none of the $(ALL_FOO_OFILES) have changed,
then the neither foo.exp or is rebuilt.

The solution provided below will always rebuild foo.exp and

Note that a subtle but on-purpose aspect of the design is to have one target, foo.exp, be responsible for two derived objects, namely foo.exp and This is because some downstream targets need to depend on foo.exp only
(while still requiring the existance of a proper and some depend
on just  The solution needs to work with -jN, so we have to make
certain that the foo.exp target does not complete without a proper
having been generated.

Note that foo.exp _is_ the export list of symbols.  This file is used by
the link line of to tell the linker which symbols need to be
exported by the shared library.  Thus, foo.exp must occur before
But to support -jN, the foo.exp target cannot complete without a valid  (linking takes a while...)

Perhaps this:

foo.exp : $(ALL_FOO_OFILES) address@hidden $^
         if [ "x` address@hidden" = "x` address@hidden" ]; then \
           rm address@hidden; \
         else \
           mv address@hidden $@; \
         endif : $(ALL_FOO_OFILES) foo.exp $(basename $@).so $(filter-out foo.exp,$^)

It doesn't look like touching the file at the end of the build will work
since if foo.exp is touched, then is out of date, and so on and
so on.  It needs to be touched during the rule.  And the above still results
with foo.exp always running until it can finally do the 'mv'..

That was one reason for the $(old <target>) idea - tell gmake that this
target is really old and ignore its newness on the fly.



>Try rewriting it something like this:
>  foo.exp : $(ALL_FOO_OFILES)
> address@hidden $^
> $(basename $@).so $^
>          if [ "x` address@hidden" = "x` address@hidden" ]; then 
>            rm address@hidden; \
>          else \
>            mv address@hidden $@; \
>          endif

reply via email to

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