bug-make
[Top][All Lists]
Advanced

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

Re: Static multiple target rules


From: Edward Welbourne
Subject: Re: Static multiple target rules
Date: Tue, 02 Mar 2010 11:45:18 +0100

> I've been struggling for some time now with how to write rules for 
> commands that generate multiple targets

A familiar and annoying problem: make really believes in commands that
generate just one (relevant) file, and doesn't fit so well with ones
that generate several.

> The next thing to try is using a proxy or timestamp file:
>
>    yacc.ts: grammar.y
>        yacc -d -v $^
>        touch $@
>
>    y.tab.h y.tab.c y.output: yacc.ts

A quarter of an hour after reading your mail, I had a mildly perverted
idea: instead of a touch-file, use a tar-file !  The problem you point
to is when the touch file exists but the files we want don't: we need
a command for the rule that declares their dependency on it; and that
command needs to be able to generate the outputs from the fake file.

    yacc.ts: grammar.y
        yacc -d -v $^
        tar cf $@ y.tab.h y.tab.c y.output

    y.tab.h y.tab.c y.output: yacc.ts
        tar xf $< -m

Note the crucial -m in the extracting tar, so that we touch the
outputs after the tar-file has been created, thereby avoiding
re-extracting every time we run make.

Not sure how well that'd work but it *looks* like it should ... and it
should generalise reasonably well.  Unfortunately I can't, just yet,
see how to turn it into a pattern rule for general .y file processing,

        Eddy.




reply via email to

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