help-make
[Top][All Lists]
Advanced

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

Re: a syntax for multitarget rules


From: Steven Simpson
Subject: Re: a syntax for multitarget rules
Date: Fri, 14 Nov 2014 11:47:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 14/11/14 10:35, Tim Murphy wrote:
To save typing here's an example of some of the possible hacks:
http://www.cmcrossroads.com/article/rules-multiple-outputs-gnu-make

You'll see the problem with "chaining" dependencies - there is a situation when a file is deleted and running make again doesn't recreate it. Basically only one target in your chain has a "command" or "recipe" so if that file exists then make won't run the recipe even if some other file in the chain is missing.

What I was proposing seems most like the one on the second page, but there is a difference. It suggests:

parser.h parser.c: generate_parser

generate_parser: parser.i
        create parser.h and parser.c
        touch $@

I'm suggesting that the first rule is removed. If something now needs (say) parser.h, it should have rules like:

foo: generate_parser
foo: parser.h

The first foo rule should ensure that parser.h exists and is up-to-date, before the second tests for parser.h.

In a recent thread:

<http://lists.gnu.org/archive/html/help-make/2014-10/msg00014.html>

...I was doing something similar, but the first foo rule was order-only. My issue was that this failed on a parallel build, which is probably a problem here too. I was shown a way round it, which works, with caveats, and might apply here too.

On the issue of defining a new kind of rule, rather than it declaring that a group of files are created together, perhaps it could declare that several items are by-products of creating a target:

parser.h parser.c &: generate_parser

foo: generate_parser
foo: parser.h

A parallel Make could now infer that generate_parser must complete before testing parser.h.

Note that the new rule doesn't actually group parser.h and parser.c; it just adds two new independent relationships (between parser.h and generate_parser) and (between parser.c and generate_parser), so they could be expressed independently too:

parser.h &: generate_parser
parser.c &: generate_parser

Cheers!





reply via email to

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