From 1a7c70f44b496134a2d5e5236d072615ccd918a3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 2 Jan 2014 14:02:45 +0100 Subject: wirte version to header file --- .gitignore | 1 + Makefile | 17 +++++++++-------- cqrlogo.c | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 6efd070..b836954 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ config.h cqrlogo *.png README.html +version.h diff --git a/Makefile b/Makefile index ccacb99..07911d1 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,19 @@ CFLAGS += -liniparser CFLAGS += $(shell pkg-config --cflags --libs libpng) CFLAGS += $(shell pkg-config --cflags --libs zlib) CFLAGS += $(shell pkg-config --cflags --libs libqrencode) -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.3.5 -endif all: cqrlogo README.html cqrlogo.png -cqrlogo: cqrlogo.c config.h - $(CC) $(CFLAGS) $(LDFLAGS) -o cqrlogo cqrlogo.c \ - -DVERSION="\"$(VERSION)\"" +cqrlogo: cqrlogo.c config.h version.h + $(CC) $(CFLAGS) $(LDFLAGS) -o cqrlogo cqrlogo.c + +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 @@ -142,7 +143,7 @@ check: $(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$' clean: - $(RM) -f *.o *~ *.png README.html cqrlogo + $(RM) -f *.o *~ *.png README.html cqrlogo version.h distclean: - $(RM) -f *.o *~ *.png README.html cqrlogo config.h + $(RM) -f *.o *~ *.png README.html cqrlogo version.h config.h diff --git a/cqrlogo.c b/cqrlogo.c index 9ad2a19..4121b20 100644 --- a/cqrlogo.c +++ b/cqrlogo.c @@ -17,6 +17,7 @@ #include #include "config.h" +#include "version.h" /* define structs and functions */ #include "cqrlogo.h" -- cgit v1.2.3-70-g09d2