I am using make
to build my application, and I want to set a variable when building everything, containing the git version.
My preference is to do this all inside the Makefile
, so I am not dependant on any external scripts. I am trying the following:
build:
CFLAGS=$(CFLAGS) -DBUILD=$(dotnet-gitversion /showvariable FullSemVer)
target: build
cc $(CFLAGS) object.o -o name
This doesn't work, because the variables do not get set. How could I get this working?
Another solution would be to do something like this:
build:
./update-version.sh
target: build
cc object.o -o name
where ./update-version.sh
would call dotnet-gitversion
and "physically" update the file where the BUILD
directive is set. But this means I need an external script.
Question now is what would the best way to do this? (Is there perhaps another solution?)