help-make
[Top][All Lists]
Advanced

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

Re: Unexpected behavior from make after running the shell command


From: Sam Ravnborg
Subject: Re: Unexpected behavior from make after running the shell command
Date: Tue, 14 Apr 2009 03:06:24 +0200
User-agent: Mutt/1.4.2.1i

On Mon, Apr 13, 2009 at 05:53:30PM -0700, Randy Kao wrote:
> Hi All,
> 
> I have a feeling this is going to be a silly question but it's baflling me,
> and I haven't been able to find something similar on the archives and
> googling.
> 
> I'm running "GNU Make version 3.79.1, by Richard Stallman and Roland
> McGrath.
> Built for i386-redhat-linux-gnu" and the contents of my makefile are basic.
> 
> VAR :=
> 
> newtest:
>         @echo "Determing the OS:"
>         VAR := $(shell uname)
>         @echo "The end."
> 
> 
> I'm just trying to save the output from the shell command uname and stuff it
> into a make variable (VAR := $(shell uname)).
> 
> However when running this, it seems as though make is trying to execute the
> variable that I assigned the output too.
> 
> 
> *Determing the OS:
> VAR := Linux
> make: VAR: Command not found
> make: *** [newtest] Error 127
> *
> 
> Anyone happen to know offhand what I'm doing wrong here? I know it is
> something simple but just can't see it.
Everything in a command is executed. So you pass on the
following to the shell:

    "VAR := Linux"

And it is obviously not what you want.


One way to get around it is to move the assingment out of the
command block and let make evaluate it either when it see it
the first time (use := as assignmnet) or at each
usage (use = as assignment operator). 

        Sam




reply via email to

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