diff options
author | Christian Hesse <mail@eworm.de> | 2014-01-02 14:09:09 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-01-02 14:09:09 +0100 |
commit | 704a47ec921fe3ed95e16b1135cc1a9106f039b3 (patch) | |
tree | 804004a97068f20b2bd64852d305c0cd91cb53e0 | |
parent | 007c236e7c08933b04847b2ac78983c5c8463410 (diff) | |
download | dyndhcpd-704a47ec921fe3ed95e16b1135cc1a9106f039b3.tar.gz dyndhcpd-704a47ec921fe3ed95e16b1135cc1a9106f039b3.tar.zst |
write version to header file
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | dyndhcpd.c | 1 |
3 files changed, 11 insertions, 8 deletions
@@ -3,3 +3,4 @@ dyndhcpd config.h README.html +version.h @@ -6,21 +6,22 @@ INSTALL := install RM := rm CP := cp 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: dyndhcpd README.html config.h: $(CP) config.def.h config.h -dyndhcpd: dyndhcpd.c config.h - $(CC) $(CFLAGS) -o dyndhcpd dyndhcpd.c \ - -DVERSION="\"$(VERSION)\"" +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" >> $@ + +dyndhcpd: dyndhcpd.c config.h version.h + $(CC) $(CFLAGS) -o dyndhcpd dyndhcpd.c README.html: README.md $(MD) README.md > README.html @@ -37,7 +38,7 @@ install-doc: README.html $(INSTALL) -D -m0644 README.html $(DESTDIR)/usr/share/doc/dyndhcpd/README.html clean: - $(RM) -f *.o *~ dyndhcpd README.html + $(RM) -f *.o *~ dyndhcpd README.html version.h distclean: - $(RM) -f *.o *~ dyndhcpd README.html config.h + $(RM) -f *.o *~ dyndhcpd README.html version.h config.h @@ -18,6 +18,7 @@ #include <string.h> #include "config.h" +#include "version.h" /*** str_replace ***/ char * str_replace(char * original, const char * pattern, const char * replacement) { |