]> git.armaanb.net Git - opendoas.git/commitdiff
Generate a version header file from Git.
authorNathan Holstein <nathan.holstein@gmail.com>
Sun, 9 Aug 2015 21:52:39 +0000 (17:52 -0400)
committerNathan Holstein <nathan.holstein@gmail.com>
Mon, 10 Aug 2015 02:18:37 +0000 (22:18 -0400)
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.

.gitignore
bsd.prog.mk

index 6fd68ebf7e5558a24339518ce6d5aa9a5def26fd..763bd7144d9b8be9385b817a4fb56aca7d638431 100644 (file)
@@ -1,5 +1,7 @@
 doas
 
+version.h
+
 *.a
 *.o
 
index 197455a2e897edff5095035c08591fed0f11f354..1f01d29aacb43776b5b5a7e1c98501113756d568 100644 (file)
@@ -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}