aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Holstein <nathan.holstein@gmail.com>2015-08-09 17:52:39 -0400
committerNathan Holstein <nathan.holstein@gmail.com>2015-08-09 22:18:37 -0400
commitfc0380731a8b1b1e02e2319f2f992b1973526b45 (patch)
treefe42d395fc755db7143da46cf041f318b21a056c
parent24c8d75c7bdf3d67cbe6167b74fc5151f6d4807b (diff)
downloadopendoas-fc0380731a8b1b1e02e2319f2f992b1973526b45.tar.gz
Generate a version header file from Git.
This adds a rule to create the version.h file from the Git version. This enables automatically embedding the Git version information into the executable.
-rw-r--r--.gitignore2
-rw-r--r--bsd.prog.mk8
2 files changed, 10 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 6fd68eb..763bd71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
doas
+version.h
+
*.a
*.o
diff --git a/bsd.prog.mk b/bsd.prog.mk
index 197455a..1f01d29 100644
--- a/bsd.prog.mk
+++ b/bsd.prog.mk
@@ -30,12 +30,20 @@ ${BINDIR}:
${BINDIR}/${PROG}: .${PROG}.chmod ${BINDIR}
mv $< $@
+VERSION:=\#define VERSION "$(shell git describe --dirty --tags --long --always)"
+OLDVERSION:=$(shell [ -f version.h ] && cat version.h)
+version.h: ; @echo '$(VERSION)' > $@
+ifneq ($(VERSION),$(OLDVERSION))
+.PHONY: version.h
+endif
+
MAN:=$(join $(addprefix ${MANDIR}/man,$(patsubst .%,%/,$(suffix ${MAN}))),${MAN})
$(foreach M,${MAN},$(eval $M: $(notdir $M); cp $$< $$@))
install: ${BINDIR}/${PROG} ${MAN}
clean:
+ rm -f version.h
rm -f libopenbsd.a
rm -f ${OPENBSD}
rm -f ${OBJS}