help-make
[Top][All Lists]
Advanced

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

Presence-only dependencies?


From: Matthew Sanderson
Subject: Presence-only dependencies?
Date: Fri, 21 Oct 2005 12:36:43 +1000 (EST)

Hi Makers,

Thanks for GNU Make!

I think that I want 'presence-only dependencies' in GNU Make. I know of
order-only dependencies, but not of anything like a presence-only
dependency. But perhaps I don't really want what I think I want? :-)

To be precise: I am defining a presence-only dependency of A on B to mean
that A depends only on the presence of a file named B; B's last-mod-time
is not taken into account. A will not be re-generated if B is newer; but
if B is missing, a seperate (normal) rule may re-generate it, and if so,
then afterwards the presence-only dependency rule will cause A to also be
re-generated from the just-created B.

Rationale for this and description of problem follows.

One of the (many) things that we use GNU Make for to automate a test suite
for some of our software. The way we have this set up is (conceptually)
like this:

$(outfiles-correct): $(infiles) $(program)
        $(program) $(infiles) $(outfiles-correct)

$(outfiles-actual): $(infiles) $(program)
        $(program) $(infiles) $(outfiles-actual)

$(outfiles-correct-canonified): $(outfiles-correct)
        $(canonifier) $(outfiles-correct) $(outfiles-correct-canonified)

$(outfiles-actual-canonified): $(outfiles-actual)
        $(canonifier) $(outfiles-actual) $(outfiles-actual-canonified)

.PHONY: compare
compare: $(outfiles-correct-canonified) $(outfiles-actual-canonified)
        cmp ... || go bang really loud

Both the 'correct' and the 'actual' files are generated by the program in
an identical fashion; the only difference between them is that at some
time in the past, a human has manually verified the correctness of the
'correct' files according to various criteria, some of them rather
subjective and therefore not automatable. Ie this is not really a job for
DejaGNU or some expect-based system IMO, or not alone at least.

After generating output files (correct or actual), expected differences
are removed (the files are 'canonified'), and after that, comparison of
the canonified files can be used to find unexpected differences in output
which might indicate bugs/regressions/etc.

This is all very well, except for the third rule above:
$(outfiles-correct-canonified): $(outfiles-correct)

What this means to Make is that the correct, canonified files depend on
the correct output files being 1) present and 2) up-to-date. Thus, Make
will in turn use the first rule above to re-generate these
$(outfiles-correct) files if any of their pre-requisites (such as the
program binary) are newer. This second part is not what I really want.

What I really want to communicate to Make is that the 'correct' files must
be present, but they do not need to be up to date. I don't want Make to
re-generate those files, because that would afterwards require manually
re-verifying their correctness, which requires human intervention. But I
do want Make to depend on those files being present; if they are missing
for some reason, then something has gone Horribly Wrong and I need to be
notified. Since I'm using Make anyway, and since it deals with
dependencies, it would be nice to use Make to enforce this dependency
checking.

Is there some GNU Make feature that I've missed that would do this?
Alternatively, what other approaches could I use that would not lead to
this perceived requirement? Or even more alternatively, how could I work
around this, and thus not be requesting changes to Make of dubious general
utility?

I thought of 'touch'ing all of the correct output files in order to defeat
Make's up-to-dateness checking. But I would prefer to tell Make to ignore
the last-mod times, rather than defeat its last-mod-time checking in this
way. I'd rather tell it exactly what I want, than tell it to do something
else which i don't really want, then trick it into doing what I really
want nevertheless :-)

I also thought of simply not supplying a rule to re-generate the correct
files, and then on the rare occasions when they really do need to be
re-generated, doing this seperately, in a different Makefile or in a shell
script. But I would like to use Make uniformly. And the generation of
output files by the program from input files is identical in the 'correct'
and 'actual' cases, so I want to keep their rules together.

I'm not really sure what I'm asking here. I suppose what I really want is
someone to show me a better way to accomplish what I want that doesn't
lead to a perceived need for presence-only dependencies.

Thanks in advance,

--matt

Matthew Sanderson
Senior Programmer (UNIX)
TCG Information Systems Pty Ltd
Sydney, Australia
address@hidden
http://www.formtrap.com/
+61 (02) 8303 2407




reply via email to

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