help-gnu-utils
[Top][All Lists]
Advanced

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

How can I resolve a seeming circular dependency?


From: ark
Subject: How can I resolve a seeming circular dependency?
Date: 16 Oct 2005 11:06:06 -0700
User-agent: G2/0.2

Suppose I have three files: foo, bar, and diff.  Think of foo as a
master file and bar as a variation.  In reality there will be lots of
bar files and corresponding diff files, but I think that if I can solve
the problem for one, I can solve it for many.

The idea is that diff records the differences between foo and bar.  So
I have foo and bar, I can create diff by executing

    diff -u foo bar >diff

Similarly, if I have foo and diff, I can create bar by executing

    patch -i diff -o bar foo

I will never use foo or diff directly, but I will edit both foo and
bar.  Other files in the makefile will depend on bar, for example.

Because bar can be made from foo and diff, one would think I should say

    bar: foo diff
        patch -i diff -o bar foo

This will successfully recreate bar if I edit foo.  However, it will
not update diff.  In general, I would like to update diff as soon as I
change bar for any reason, which suggests adding this:

    diff: foo bar
        /bin/diff -u foo bar >diff

But of course this creates a circular dependency.

So far, the best way I've found to deal with this is the following:

    bar: foo diff
        patch -i foo -o bar diff
        -/bin/diff -u foo bar >diff
        touch --reference=diff bar

So the idea is that whenever bar is out of date, I remake it from diff
and foo, remake diff from foo and bar, and then give bar the same date
as diff so that it won't be made again the next time around.

But this procedure seems tricky enough that it makes me uncomfortable.
I wonder if someone else has a better idea.



reply via email to

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