My specific goal: automatically edit a Makefile variable's (EXTRAVERSION)
value in a kernel Makefile.
So, I have a shell script that takes one parameter, a version string:
buildkernel.sh 2.6.18.21.7-custom
In the script, I assign the parameter to K_VER:
K_VER="2.6.18.21.7-custom"
I perform string operations until I get this:
XTRA_K_VER=".21.7-custom"
I export it (thinking that the proper value would be substitued when
make was run, but the variable is not expanded):
export XTRA_K_VER
So, maybe I should forget the export?
I am using the variable, XTRA_K_VER, in a substitution in a
Makefile with the idea that the variable would be expanded:
sed -f script.sed <Makefile.old >Makefile.new
where script.sed contains the following:
s#\([[:blank:]]*EXTRAVERSION\)[[:blank:]]*=[[:blank:]]*.*#\1 = $XTRA_K_VER#
The issue I am experiencing is that I want the value of XTRA_K_VER to
be used in the Makefile as opposed to the literal variable name. I do not
have a preference whether I insert the variable form of the entity (into
the Makefile) or the literal string value of the variable.
From what I have described, is there a reasonably clean way to let the
sed script expand the value of the variable before the substitution? I
thought about re-writing the sed script dynamically upon every invocation
of the program, but that seems a bit extreme to me (and potentially
challenging for others to maintain in the future).
Thanks in advance. I really appreciate the experience of the people on this site.
Cheers,
:-D