summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:30:38 +0100
committerGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:30:38 +0100
commitcc48e628207fdf53157795987ee36aed3aad729a (patch)
treeed7cce7084cf5a9d0d2cf81ff15811d2a9e98d0f
parentc73fd3815da7af0b0e954b52f3d1e218b262a14d (diff)
downloadmpd-notification-cc48e628207fdf53157795987ee36aed3aad729a.tar.gz
mpd-notification-cc48e628207fdf53157795987ee36aed3aad729a.tar.zst
write version to header file
-rw-r--r--.gitignore1
-rw-r--r--Makefile21
-rw-r--r--mpd-notification.c1
3 files changed, 13 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 859d77e..5c59d97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
config.h
mpd-notification
README.html
+version.h
diff --git a/Makefile b/Makefile
index a6fa535..1d059c7 100644
--- a/Makefile
+++ b/Makefile
@@ -6,24 +6,25 @@ INSTALL := install
CP := cp
RM := rm
CFLAGS += -O2 -Wall -Werror
-CFLAGS += $(shell pkg-config --cflags --libs libmpdclient) \
- $(shell pkg-config --cflags --libs libnotify)
-VERSION := $(shell git describe --tags --long 2>/dev/null)
+CFLAGS += $(shell pkg-config --cflags --libs libmpdclient)
+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.4.3
-endif
all: mpd-notification README.html
-mpd-notification: mpd-notification.c config.h
- $(CC) $(CFLAGS) -o mpd-notification mpd-notification.c \
- -DVERSION="\"$(VERSION)\""
+mpd-notification: mpd-notification.c config.h version.h
+ $(CC) $(CFLAGS) -o mpd-notification mpd-notification.c
config.h:
$(CP) config.def.h config.h
+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
@@ -39,7 +40,7 @@ install-doc: README.html
$(INSTALL) -D -m0644 screenshot.png $(DESTDIR)/usr/share/doc/mpd-notification/screenshot.png
clean:
- $(RM) -f *.o *~ README.html mpd-notification
+ $(RM) -f *.o *~ README.html mpd-notification version.h
distclean:
- $(RM) -f *.o *~ README.html mpd-notification config.h
+ $(RM) -f *.o *~ README.html mpd-notification version.h config.h
diff --git a/mpd-notification.c b/mpd-notification.c
index 2d79d67..7ad3aa0 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -16,6 +16,7 @@
#include <signal.h>
#include "config.h"
+#include "version.h"
#define PROGNAME "mpd-notification"