how to programmatically generate makefile variable

I make to parse the release version from a text file and set the release version label into a Makefile variable. I tried:

VERSION := `grep vsn s1db.app|sed -e s/[^\"]*\"// -e s/\"[^\"]*//`

but looks like make, unlike shell, literally just take the entire `grep ...` as the variable value.

Then I tried to put the shell command in:

release: forced

    export VERSION=`grep vsn s1db.app|sed -e s/[^\"]*\"// -e s/\"[^\"]*//`
    echo $(VERSION)

but it seems that the "export" command does not set the $VERSION value.

How can I programmatically parse and set a makefile variable?

Thanks in advance,

Benk

It does, but will evaluate the backticks when you use it.

Shell lines in a makefile are executed individually and separately. exporting something won't do a thing to any other line.

Corona688, thanks for you reply. I'm kind of new to the makefile business...

You are right, if I use "echo $VERSION" under any of the rules, the "`" expression will be evaluated, and the correct version string will be printed. So, is this the correct way people do to get some contents into the makefile?

This seems kind of odd to me, because each occurrence of $VERSION will cause an evaluation of the "`" expression. This is not what I would expect the behavior for the "variable" be. Or is there a better way to do this in make?

There's supposed to be a better way in GNU make, a 'simple variable', done with VAR:=`something` but it doesn't do what it says it's supposed to, and just evaluates every time.

Short of creating a makefile from template or something, I don't think so.