[Top][All Lists]

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

re: non-recursive build question

From: Paul D. Smith
Subject: re: non-recursive build question
Date: Tue, 27 Apr 2004 13:45:07 -0400

%% sandy currier <address@hidden> writes:

  sc> There seems to be a problem when trying to convert this trick to a
  sc> non-recusive build.  The problem is that in a non-recursive system,
  sc> the command rules of the export list target are always executed when,
  sc> in this scenario, the object files that comprise the shared library
  sc> have changed.  This happens whether the export file ends up being changed
  sc> or remains the same.  But, even when the export file is not modified,
  sc> that fact that the rules have fired appears to tell gmake to remake all
  sc> the targets that depend on this (export file) target.

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.

  sc> Have I missed something here?

Yep :).

  sc> Is there a way to do something like the following:

  sc> foo.exp : $(ALL_FOO_OFILES)
  sc> address@hidden $^
  sc> $(basename $@).so $^
  sc> ifeq ($(shell $@),$(shell address@hidden))
  sc> $(old $@)
  sc>   rm address@hidden && touch $@
  sc> else
  sc>   mv address@hidden $@
  sc> endif

This can't work.  First, remember the distinction between command
scripts and makefile commands.  The ifeq line is a make preprocessor
statement: it is evaluated when the makefile is read in, _NOT_ when the
command script was run.  You have to make the comparison part of the
command script so it gets evaluated when the rule is run.

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.

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 $@; \

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]