summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:33:11 +0100
committerGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:33:11 +0100
commit4fd873f078e56e4094dd400362e6da82221938e2 (patch)
treef9bc8af36a7e65ab3e139d50e455c693ad7acea4
parent3488a6e741b736e1c422519531a4640ca750c266 (diff)
downloadudev-block-notify-4fd873f078e56e4094dd400362e6da82221938e2.tar.gz
udev-block-notify-4fd873f078e56e4094dd400362e6da82221938e2.tar.zst
write version to header file
-rw-r--r--.gitignore1
-rw-r--r--Makefile19
-rw-r--r--udev-block-notify.c2
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 <libnotify/notify.h>
#include <libudev.h>
+#include "version.h"
+
#define PROGNAME "udev-block-notify"
#define NOTIFICATION_TIMEOUT 10000