From 4fd873f078e56e4094dd400362e6da82221938e2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 2 Jan 2014 14:33:11 +0100 Subject: write version to header file --- .gitignore | 1 + Makefile | 19 ++++++++++--------- udev-block-notify.c | 2 ++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f54a73f..f505a9b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.o udev-block-notify README.html +version.h diff --git a/Makefile b/Makefile index d4042b2..6214e53 100644 --- a/Makefile +++ b/Makefile @@ -5,20 +5,21 @@ MD := markdown INSTALL := install RM := rm CFLAGS += -O2 -Wall -Werror -CFLAGS += $(shell pkg-config --cflags --libs libudev) \ - $(shell pkg-config --cflags --libs libnotify) -VERSION := $(shell git describe --tags --long 2>/dev/null) +CFLAGS += $(shell pkg-config --cflags --libs libudev) +CFLAGS += $(shell pkg-config --cflags --libs libnotify) # this is just a fallback in case you do not use git but downloaded # a release tarball... -ifeq ($(VERSION),) VERSION := 0.7.2 -endif all: udev-block-notify README.html -udev-block-notify: udev-block-notify.c - $(CC) $(CFLAGS) -o udev-block-notify udev-block-notify.c \ - -DVERSION="\"$(VERSION)\"" +udev-block-notify: udev-block-notify.c version.h + $(CC) $(CFLAGS) -o udev-block-notify udev-block-notify.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" >> $@ README.html: README.md $(MD) README.md > README.html @@ -35,4 +36,4 @@ install-doc: README.html $(INSTALL) -D -m0644 screenshot.png $(DESTDIR)/usr/share/doc/udev-block-notify/screenshot.png clean: - $(RM) -f *.o *~ README.html udev-block-notify + $(RM) -f *.o *~ README.html udev-block-notify version.h diff --git a/udev-block-notify.c b/udev-block-notify.c index 1772d51..003b9cf 100644 --- a/udev-block-notify.c +++ b/udev-block-notify.c @@ -13,6 +13,8 @@ #include #include +#include "version.h" + #define PROGNAME "udev-block-notify" #define NOTIFICATION_TIMEOUT 10000 -- cgit v1.2.3-70-g09d2