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.
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:
Now
Xwill have the value5.Note the use of
:=here, rather than a simple=. This expands everything on the right side immediately, rather than each timeXis referenced.