i am trying to set a variable’s value to use during the compilation.
I try to do that in a separate makefile target
svnversion:
SVN_REV=$(shell svnversion -cn | sed -e 's/.*://' -e 's/\([0-9]*\).*/\1/' | grep '[0-9]')
$(info svn_rev = $(SVN_REV))
I have read that this is the way to set the value of a variable.
Yet when i run ‘make’ I see :
SVN_REV=613
svn_rev =
so the variable seems to be empty. Afterwards I expect that this variable will be present while the compilation takes place (in other targets). Is this the case? or should I add an ‘export’ command in the svnversion target? and how to I address the SVN_REV variable? $(SVN_REV) or $$(SVN_REV).
thank you
You are actually assigning the value SVN_REV in the subshell that is concluded at the end of the line,
what you probably want is:
This sets the variable when the target is set.
If this isn’t what was intended, say you want to do some processing with the variable, then you need to make each line a continuation of the previous one using the horrible
; \at the end of line semantics. If you are then referencing shell variables (like the one evaluated in your first line), then you need to use the$$syntax before the variable namee.g.
but because it’s in a shell, you can’t use the variable in the
$(infocommand, as that takes place outside of the evaluation of the target.