bug-make
[Top][All Lists]
Advanced

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

Re: Conditional recipe execution


From: Paul Smith
Subject: Re: Conditional recipe execution
Date: Sun, 18 Jan 2015 20:20:38 -0500

On Mon, 2015-01-19 at 00:08 +0100, SF Markus Elfring wrote:
> >> * I need to split an input file into several smaller files.
> > 
> > I don't see any way that $(eval ...) is needed or helpful for any of
> > those things.
> 
> Can a make variable be set by this function within a recipe?

Yes, I've already said it can.  But I can see no way that this ability
is helpful or needed in the situations you listed.  If you give examples
of what you're actually trying to do, instead of just providing very
general questions and abstract situations, then we can use concrete
examples to explain.

> How should it be achieved that a recipe will only be executed for its first
> run despite of the detail that multiple targets were specified for
> a specific rule?

> > There are other possibilities, but without a specific use-case we can't
> > say which one(s) are appropriate.
> 
> Would use cases around the standard command "split" be concrete enough
> for further clarification?
> https://en.wikipedia.org/wiki/Split_%28Unix%29

No.  You need to describe your situation.  Use words, but with detail.
"I have a command foo that takes as input bar and generates as output
baz.  Then I have another command that takes baz as input and generates
a widget, and I need to figure out how to ...", etc.  If you have
implemented a rule and it doesn't work, then paste the rule into your
email and cut/paste the output you're getting, and describe why that
output is wrong / what you wanted to happen instead.  If it's very
complicated, then write a small example makefile that does the same type
of thing and shows the same problem, and put that in your email.

Just writing down what you're trying to do like this in an email can
often help you figure things out for yourself, before you even send it.


It sounds to me like you what you mean is you have a single recipe which
generates multiple output files and you want those files to be
prerequisites of other targets.

There are two possibilities.  The best case is that the generated files
and the input file(s) are all related to each other through some aspect
of the filename: in that case you can use pattern rules and everything
is simple.

So for example the "bison" parser generator takes a file "foo.y" and
generates "foo.tab.h" and "foo.tab.c": the names of the output files are
related to the name of the input file through the "foo" prefix.  In this
case you can use:

    %.tab.h %.tab.c : %.y
            command ...

replacing the common part with "%" as a wildcard.  Now listing
"foo.tab.c" or "foo.tab.h" as a prerequisite will cause this rule to be
run one time, with "foo.y" as the prerequisite and make knows both files
are generated by a single invocation.

The other possibility is that the names of the generated files have no
relationship to the names of the input files.  In this case you'll have
to use a "sentinel file":

    output list: .sentinel ;

    .sentinel: input files
            command ...
            touch $@





reply via email to

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