ifeq ($(OS),Windows_NT) GIT=C:\\Program Files (x86)\\Git\\bin\\git.exe ifeq ($(shell $(GIT) version),) GIT=C:\\Program Files\\Git\\bin\\git.exe ifeq ($(shell $(GIT) version),) GIT=git.exe endif endif else # UNIX GIT=git endif VERSION:=$(shell "$(GIT)" describe) VERSION:=$(if $(VERSION),$(VERSION),unknown) ifneq ($(VERSION),unknown) # Always update version.h if we are in a git repo. Otherwise create # the file only if it does not exist. .PHONY: version.h endif version.h: ifeq ($(OS),Windows_NT) echo #define GIT_VERSION "$(VERSION)" > $@ else echo '#define GIT_VERSION "$(VERSION)"' > $@ endif