Hi John,
I actually tried out these examples:
case 1:
test:
@export QA_STEP=start;touch ${QA_STEP}
This case actually gave the error of "touch: file arguments missing". Note
that using curly or normal braces gave the same error.
If i understand correctly, the reason for failure is that make tries to
de-references all the variables before it passes the contents to the shell.
Before passing the contents to the shell, make tried to evaluate QA_STEP
which ofcourse turned out to be empty and hence the error.
case 2:
export QA_STEP=start
test:
@touch ${QA_STEP}
This case worked perfectly :)
Regards
Kalyan
On Fri, Feb 27, 2009 at 10:20 PM, John Calcote <[email protected]>wrote:
> Kaylan,
>
>
>
> There are two contexts for the export keyword here. Make supports an export
> keyword, and the shell also support an export keyword. These two contexts
> are separate and not related to each other in any way. When a **command**
> uses export, its context is only within the shell assigned to run that
> command.
>
>
>
> This is why you need to ensure that both the export command, and the
> following command that uses the exported shell variable are both executed by
> the same shell. Since each command is executed by a separate shell, you need
> to use a semicolon and an optional backslash. If you don’t want to use a
> backslash, you can simply append the two lines into one like this:
>
>
>
> test:
>
> export QA_STEP=start; touch ${QA_STEP}
>
>
>
> Outside of **commands**, the word export is used to communicate that a **
> make** variable should be exported to child processes of the current make
> process—so that make variable will be available to child make processes –
> like this:
>
>
>
> export QA_STEP_MAKE_VAR=start
>
>
>
> test:
>
> touch $(QA_STEP_MAKE_VAR)
>
>
>
> Also note the difference in dereference syntax. Make variables are
> dereferenced by make before the command is passed to the shell by using $()
> syntax, whereas shell variables are dereferenced by the shell after it
> receives the command, by using the ${} syntax.
>
>
>
> John
>
>
>
> *From:* kalyan [mailto:[email protected]]
> *Sent:* Thursday, February 26, 2009 8:39 PM
> *To:* John Calcote
> *Cc:* albob; [email protected]
> *Subject:* Re: Using environmnet variables in make
>
>
>
> i guess backslash wouldnt work because export is not recognized as a shell
> command in make..
> Also, make manual hints that export can be used to communicate variables to
> sub-make, so i am not sure if exporting a variable and using it in the same
> makefile would work..
>
> kalyan
>
> On Fri, Feb 27, 2009 at 4:38 AM, John Calcote <[email protected]>
> wrote:
>
> Alan,
>
> Try adding a backslash after the export QA... statement like this:
>
>
> test:
> export QA_STEP=start; \
> touch ${QA_STEP};
>
> make executes each line in a separate shell, so QA_STEP will not be set in
> the shell that executes the touch statement unless you execute both
> commands
> in the same statement.
>
> John
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:help-make-bounces+john.calcote <help-make-bounces%2Bjohn.calcote>=
> [email protected]] On Behalf Of albob
> Sent: Thursday, February 26, 2009 10:28 AM
> To: [email protected]
> Subject: Using environmnet variables in make
>
>
> Hi,
> I have the following Makefile
>
> .EXPORT_ALL_VARIABLES:
> .SUFFIXES:
>
> test:
> export QA_STEP=start ;
> touch ${QA_STEP};
>
> Which I run using "gmake". This gives me:
>
> slappy628: gmake test
> export QA_STEP=qa_rtl ;
> touch ;
> touch: file arguments missing
> Try `touch --help' for more information.
> gmake: *** [test] Error 1
>
> Can anyone tell me what I am doing wrong? No matter what I try I can not
> get
> it to pick up on the environment variable set. Help would be much
> appreciated.
> Thanks
> Alan
>
> --
> View this message in context:
>
> http://www.nabble.com/Using-environmnet-variables-in-make-tp22229241p2222924
> 1.html<http://www.nabble.com/Using-environmnet-variables-in-make-tp22229241p2222924%0A1.html>
> Sent from the Gnu - Make - Help mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
> Help-make mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-make
>
>
>
> _______________________________________________
> Help-make mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-make
>
>
>
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make