On Sat, Jul 05 2014, David Bremner <david at tethera.net> wrote: > Tomi Ollila <tomi.ollila at iki.fi> writes: > >> So that $(VERSION) and version.stamp uses the git-describe -based >> version data instead of the content of `version' file. >> >> For consistency also the git commands in Makefile[.local] target >> `verify-no-dirty-code' uses the git --git-dir=$srcdir/.git ... >> commands (inside ifeq($(IS_GIT),yes)). Attempting to make this >> target outside of the tree will fail in any case. > > This seems to work OK; I wondered if an alternate method of setting (and > exporting) GIT_DIR from the top level makefile would work as well, and > be less intrusive?
This looked like a good idea, and I tested it. But -- lo and behold -- the environment variables set in Makefile do not probagate to the commands executed with $(shell ...) -- see (*) (I wrapped git(1) in a shell script (executes env then execs real git) to verify this is still the case). I thoght now a bit whether we'd use variable in place of ${srcdir}/.git but IMHO is better in this way: - make does not have option to warn/die in case variable undefined, it is then just empty string so no internal error checking there - any human observer notices from the ${srcdir}/.git that we're not using git from any nonstandard place -- if there were variable one would have needed to dereference that to figure out this is the case. (*) http://www.cmcrossroads.com/article/basics-getting-environment-variables-gnu-make?page=0%2C1 > > d Tomi