help-make
[Top][All Lists]
Advanced

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

Actions that may or may not update their targets


From: Sam Yates
Subject: Actions that may or may not update their targets
Date: Tue, 13 Feb 2007 13:30:51 +1030

Hello!

I'm hoping that someone may be able to help me with the
following problem.

I'm attempting to write a generic makefile for inclusion into
a set of project makefiles where some sources are built from
m4 macro files, and some are generated automatically from
other built executables. In order to resolve problems of the
automatic dependency generation building source files from
macro files without the correct target-specific build flags, the
current approach has the make file re-invoke itself in a second-pass,
to set up the variables explicitly for dependency file generation.

As a side effect, I have rules which conceptually are of the form:

.PHONY: foo-maker
foo-maker:
       # invokes make to rebuild foo,
       # but foo may or may not actually be updated

foo: | foo-maker

bar: foo
       # do stuff only if foo was updated

As it stands though, this does not work: no matter if
foo-maker updates foo or not, foo is regarded as not
being updated. Similarly, a simple rule:

foo: foo-maker

will always update bar whether or not foo-maker actually
updated foo or not.

I was able to work around this by the use of sentinel files:

foo.sentinel: ; touch $@
foo-maker:
       # maybe updates foo, but if it does, will touch foo.sentinel

foo: | foo-maker

bar: foo foo-sentinel
       # make bar using foo

However this fails for parallel make: at the time foo-sentinel
is checked, it is quite possible that foo-maker has not yet
updated it.

Forcing the order-only dependency

foo.sentinel: | foo

does not work, since then foo.sentinel is not regarded as being
updated no matter what foo-maker does.

In a hypothetical make that forced all order-only pre-requisites
to be updated completely before regular pre-requisites were
considered, one could use a rule like

bar: foo | foo-maker

Can anyone offer suggestions as to how to make make 3.81
perform this feat?

Alternatively, this whole mess could have been avoided were
there a way for the actions of a rule (in this case, for rebuilding
dependency files) to access the target-specific variables of
a different target. But I don't think that is possible short of the
make re-invocation tricks I'm already employing. Is it possible?

Many thanks,
Sam Yates




reply via email to

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