Reputation: 1119
I have the following in the makefile:
RESULT=ab
nums:
number=1 ; while [[ $$number -le $(DIRS_NUM) ]] ; do \
now=`echo $(CURR_DIR) | cut -d "/" -f 1-$$number` ;\
**RESULT = $$now;\**
echo $(RESULT);\
((number = number + 1)) ; \
done
I would like to update the RESULT
variable, but I'm not sure of how to do this.
Upvotes: 2
Views: 3880
Reputation: 13624
You cannot update a makefile variable from within a rule. You could use the $(shell cmd) macro to execute a command and get a value out of its output stream, but that's about as close as you can come. A simple example:
X := $(shell echo 5)
Now X
will have the value 5
.
Note the use of :=
here, rather than a simple =
. This expands everything on the right side immediately, rather than each time X
is referenced.
Upvotes: 3