summaryrefslogtreecommitdiff
path: root/src/GNUmakefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/GNUmakefile')
-rw-r--r--src/GNUmakefile15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile
index bba3ee6..9b42844 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -122,7 +122,20 @@ PROFILE += -DDUMP_TREE
endif
endif # EVERYTHING
-CFLAGS = -DPROFILE="\"$(PROFILE)\"" $(PROFILE) -Wall -Wno-nan-infinity-disabled -Ifathom
+# Short commit hash (plus a -dirty suffix if the working tree has
+# uncommitted changes) baked into the binary so a --logfile trace can
+# be tied back to the exact source state, not just a build timestamp --
+# distinguishing rebuilds of the same day/commit during A/B testing was
+# previously only possible by diffing binaries. Placed here, after all
+# the PROFILE-overwriting `=` assignments above (not `+=`), so it
+# survives into CFLAGS instead of being wiped out by them.
+GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
+GIT_DIRTY := $(shell git diff --quiet 2>/dev/null || echo -dirty)
+# Kept out of PROFILE itself (not folded in via +=): PROFILE gets
+# stringified whole into -DPROFILE="..." below for the "Make profile
+# used" trace line, and this value's embedded quotes broke that outer
+# string literal when it was included there.
+CFLAGS = -DPROFILE="\"$(PROFILE)\"" -DGIT_COMMIT=\"$(GIT_COMMIT)$(GIT_DIRTY)\" $(PROFILE) -Wall -Wno-nan-infinity-disabled -Ifathom
HEADERS = chess.h compiler.h
FATHOM_CFLAGS = -std=gnu99 -O2 -Ifathom $(filter -m32 -m64,$(PROFILE))