help-make
[Top][All Lists]
Advanced

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

Re: Command producing several targets at once


From: Britton Kerin
Subject: Re: Command producing several targets at once
Date: Wed, 26 Jul 2017 09:17:52 -0800

On Wed, Jul 26, 2017 at 5:31 AM, Paul Smith <address@hidden> wrote:
> On Wed, 2017-07-26 at 15:21 +0200, Sébastien Hinderer wrote:
>> Sorry, I meant:
>>
>> parsers := foo.mly bar.mly baz.mly
>>
>> $(parsers): %.ml %.mli: %.mly%.ml %.mli: %.mly
>>             ocamlyacc $<
>
> No.  That's a static pattern rule.  You can't get this multiple targets
> built with a single recipe feature with a static pattern rule, only with
> normal pattern rules.
>
> Just write it as I put in my email:
>
>   %.ml %.mli: %.mly
>           ocamlyacc $<

Another option if you don't like non-static pattern rules or the
special-case stuff involved, is to use a stamp file:

yaccouts.stamp: parser.mly
        ocamlyacc $<

Since .ml and .mli files are always produced together by the same
program, they don't need individual nodes in your dependency graph so
you arrange yaccouts.stamp to represent them (and depend on the stamp
file in turn where needed).  This approach works with static pattern
rules and is useful in other situations as well, e.g. when you want to
represent completeness of a build in a subdir or other place, to
represent verification of expensive-to-verify build requirements, etc.

Britton



reply via email to

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