diff options
author | Christian Hesse <mail@eworm.de> | 2014-01-02 12:49:10 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-01-02 12:49:10 +0100 |
commit | cf92d0c21b33ab2885e4fa873ee5b437239834ee (patch) | |
tree | 9cc84e32a7630065336a0f9899a9c8a389db2012 | |
parent | 85ac081c469ca63a78797456d0b434247471cc39 (diff) | |
download | nullshell-cf92d0c21b33ab2885e4fa873ee5b437239834ee.tar.gz nullshell-cf92d0c21b33ab2885e4fa873ee5b437239834ee.tar.zst |
write version to header file
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | nullshell.c | 1 |
3 files changed, 11 insertions, 8 deletions
@@ -1,3 +1,4 @@ -nullshell config.h +nullshell README.html +version.h @@ -7,18 +7,19 @@ MD := markdown INSTALL := install RM := rm CFLAGS += -O2 -Wall -Werror -VERSION := $(shell git describe --tags --long 2>/dev/null) # this is just a fallback in case you do not use git but downloaded # a release tarball... -ifeq ($(VERSION),) VERSION := 0.0.2 -endif all: nullshell README.html -nullshell: nullshell.c config.h - $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell \ - -DVERSION="\"$(VERSION)\"" +nullshell: nullshell.c config.h version.h + $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell + +version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile + echo "#ifndef VERSION" > $@ + echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@ + echo "#endif" >> $@ config.h: $(CP) config.def.h config.h @@ -36,4 +37,4 @@ install-doc: README.html $(INSTALL) -D -m0755 README.html $(DESTDIR)$(PREFIX)/share/doc/nullshell/README.html clean: - $(RM) -f README.html nullshell + $(RM) -f README.html nullshell version.h diff --git a/nullshell.c b/nullshell.c index 7986cbf..52a5a81 100644 --- a/nullshell.c +++ b/nullshell.c @@ -14,6 +14,7 @@ #include <unistd.h> #include "config.h" +#include "version.h" int main(int argc, char **argv) { time_t now; |