[Top][All Lists]

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

Re: Difficulties from the combination of functions "call" and "eval"

From: Paul Smith
Subject: Re: Difficulties from the combination of functions "call" and "eval"
Date: Sun, 18 Jan 2015 16:03:17 -0500

On Sun, 2015-01-18 at 20:50 +0100, SF Markus Elfring wrote:
> > The rule of thumb is, if you're using $(eval ...) inside a recipe,
> > you're doing something wrong.
> Which make function should be used for recipe generation instead then?

If you just want to expand inside a recipe, you can use $(call ...) (as
has already been suggested).

> > $(eval ...) is for parsing MAKEFILE content.
> Do recipes belong also to each make script?

I don't understand this question.

> > There is only one situation I can think of where it _might_ make sense
> > to use $(eval ...) inside a recipe: if you want to assign a make
> > variable when the recipe is invoked.
> I want to use also exactly this functionality.

Possible, but I'm skeptical.

> > But a real need for this is rare;
> I have got an opposite experience.
> I need this immediately for the handling of rules with multiple
> output files.

Without knowing exactly what you mean by "handling of rules with
multiple output files" I can't say for sure, but I think it's unlikely
that $(eval ...) can help with this.

Just to be clear, you cannot create new rules, or add to the targets or
prerequisites of existing rules, using $(eval ...) _inside a recipe_.
Recipes are only expanded after all makefiles have been read in, and
once all makefiles have been read in it's not possible to create more
targets or change prerequisites of targets.

Also, the entire recipe is expanded before any part of the recipe is
invoked in the shell.  So, you cannot assign any output from the recipe,
or use any other result of running the recipe, including things like
running $(wildcard ...) to see what files were created, etc.

This means the ONLY time setting a variable from within a recipe is
helpful is if the only place you need to use that variable is INSIDE
some other recipe that has not been run yet.

> > usually there are simpler and more straightforward ways
> > to get the result you're looking for.
> I would like to know them so that I can optimise my make
> source code more.

Well, if you tell us specifically what result you're looking for we
might be able to help.

reply via email to

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