From a4076311f75284e3d70019a3649c246b51e06c87 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 28 Dec 2021 07:55:21 +0100 Subject: [PATCH] Only rebuild when GitVersion has actually changed --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 696ce9a..0bf1ab7 100644 --- a/Makefile +++ b/Makefile @@ -51,11 +51,17 @@ removehostfiles : /bin/rm -f $(CFGDIR)/DExtra_Hosts.txt /bin/rm -f $(CFGDIR)/DCS_Hosts.txt -GitVersion.h : FORCE +GitVersion.h : FORCE ifneq ("$(wildcard .git/index)","") - echo "#pragma once\nconst char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ + @echo "#pragma once\nconst char *gitversion = \"$(shell git rev-parse HEAD)\";" > /tmp/$@ else - echo "#pragma once\nconst char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ + @echo "#pragma once\nconst char *gitversion = \"0000000000000000000000000000000000000000\";" > /tmp/$@ endif + @cmp -s /tmp/$@ $@; \ + RETVAL=$$?; \ + if [ $$RETVAL -ne 0 ]; then \ + echo "Git version has changed"; \ + cp -f /tmp/$@ $@; \ + fi; FORCE: \ No newline at end of file