Hey Nick,

thank you very much. That sounds like a very good solution to my problem that does not require changes to org-mode.

Best

Holger

On Sat, Nov 19, 2011 at 5:00 AM, Nick Dokos <nicholas.dokos@hp.com> wrote:
Holger Hoefling <hhoeflin@gmail.com> wrote:

> I think you misunderstood me there - I am actually not worried about how
> computationally intensive the tangling process is. This always works very
> quickly, so even if they have to be copied around and take a bit longer, I
> would not mind.
>

Ah, ok - so you are talking about

      tangle                    compile
  org -------> bunch of files -------------> output

The tangling step produces a bunch of files that are (re)compiled (or in
any case require some sort of lengthy processing) to produce some output file.


IMO, the best way to deal with it is still make: let's say

    foo.org  ----> a.x b.x c.x ------> foo.out

where the first arrow is the tangle and the second arrow is some processor, call it X.
The standard way to set up a makefile is schematically:

--8<---------------cut here---------------start------------->8---
foo.out: a.x b.x c.x
        X a.x b.c c.x -o foo.out

a.x b.x c.x: foo.org
        tangle foo.org

--8<---------------cut here---------------end--------------->8---


Rewrite the make file as follows:


--8<---------------cut here---------------start------------->8---
foo.out: a.y b.y c.y
    X a.y b.y c.y -o foo.out

a.y: a.x
    cmp --silent a.x a.y || cp a.x a.y

b.y: b.x
    cmp --silent b.x b.y || cp b.x b.y

c.y: c.x
    cmp --silent c.x c.y || cp c.x c.y

a.x b.x c.x: foo.org
    tangle foo.org
--8<---------------cut here---------------end--------------->8---


So if the *contents* of (say) a.x have not changed by the tangling, it compares
equal to a.y and the copy is skipped. That leaves a.y untouched.

OTOH, if the contents of a.x change (or a.y does not exist in the first
place), the comparison fails and we copy a.x to a.y.  That updates a.y
and forces further updates on anything that depends on it.

Using some make fu (works for GNU make, but not necessarily for other makes),
you can write it more compactly:


--8<---------------cut here---------------start------------->8---
foo.out: a.y b.y c.y
    X a.y b.y c.y -o foo.out

%.y: %.x
    -cmp --silent $< $@ || cp $< $@

a.x b.x c.x: foo.org
    tangle foo.org
--8<---------------cut here---------------end--------------->8---

HTH,
Nick