help-make
[Top][All Lists]
Advanced

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

Re: Uupdate value of variable


From: Tim Murphy
Subject: Re: Uupdate value of variable
Date: Thu, 1 Jun 2017 05:55:10 +0100

Hi

On 31 May 2017 at 14:28, icvallejo <address@hidden>
wrote:

> Hello all, I'm rookie with gnu make and I have a question; I'm doing a
> Makefile like this:
>
> #!/bin/bash
>
^^^^^ This doesn't make any sense - this is not a bash script.


> # Makefile
>
> IMPORT_PATH := github.com/...
> CHECK := 0
>
> .PHONY: install
> install:
>         $Q printf "\\nLet's install..."
> #             $Q export CHECK=0
>         $Q if grep -q \!string "$(DIR)" ; then CHECK = $($CHECK + 1) ; fi
>

^^^^ The assignment here creates a shell variable "CHECK" which doesn't
exist after the recipe finishes and it tries to assign a make variable
called " + 1" into it which also doesn't make sense.


>         $Q printf "done!"
>

You're going to get into trouble here with the difference between make
variables $(VARIABLE) and bash variables $VARIABLE and also with the time
at which recipes are expanded.

Expansion in a recipe usually happens just before the recipe is executed.
You can change the value of a variable (using $(eval))  before the recipe
is run but that's no use to you here because you want the change to depend
on something the recipe does.

It might seem dull but I think you should probably read the GNU make manual
for a while and then post here again with the thing you're trying to
achieve.

Regards,

Tim


reply via email to

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