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 --- Makefile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3-70-g09d2