help-make
[Top][All Lists]
Advanced

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

Re: Passing environment variables in reciepes


From: David Boyce
Subject: Re: Passing environment variables in reciepes
Date: Wed, 8 Dec 2010 07:31:46 -0500

On Wed, Dec 8, 2010 at 5:29 AM, Warlich, Christof
<address@hidden> wrote:
> I tried to use environment variables in the example above, which doesn't seem 
> to work (why?), but there may be better ways ?!

You're barking up the wrong tree. Each line of the recipe is passed by
make to a separate instance of the shell. Each of these processes is
the child of make, thus making them siblings. Environment variables
won't work for the same reason you can't inherit a trait from your
sister.

If you're using make 3.82 the simplest fix is to add the line

.ONESHELL:

to the Makefile. This will cause all lines of each recipe to be
grafted together and passed to a single shell instance which makes
communication much easier. If using an older version you need to do
the grafting manually, e.g.:

target:
        line 1 &&\
        line 2 &&\
        line3

And forget eval and escaped $$. Those are completely unrelated.

-David Boyce



reply via email to

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