aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:13:37 +0100
committerGravatar Christian Hesse <mail@eworm.de>2014-01-02 14:13:37 +0100
commit9929d74da19521284badb5e3b25083007981ee18 (patch)
tree9b7ecec2295474505581d89f689175e28529b211
parent9e12c450e5a7d27f46f8cea6ab2e4eba8785026f (diff)
downloadpacredir-9929d74da19521284badb5e3b25083007981ee18.tar.gz
pacredir-9929d74da19521284badb5e3b25083007981ee18.tar.zst
write version to header file
-rw-r--r--.gitignore1
-rw-r--r--Makefile17
-rw-r--r--pacredir.c1
3 files changed, 11 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 693b02f..87a5b1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ pacredir
config.h
avahi/pacdbserve.service
README.html
+version.h
diff --git a/Makefile b/Makefile
index 695a9dc..1d3e08f 100644
--- a/Makefile
+++ b/Makefile
@@ -13,25 +13,26 @@ CFLAGS += $(shell pkg-config --libs --cflags libcurl)
CFLAGS += $(shell pkg-config --libs --cflags avahi-client)
CFLAGS += $(shell pkg-config --libs --cflags libmicrohttpd)
CFLAGS += -liniparser
-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.1.1
-endif
all: pacredir avahi/pacdbserve.service README.html
arch: arch.c config.h
$(CC) -o arch arch.c
-pacredir: pacredir.c pacredir.h config.h
- $(CC) $(CFLAGS) $(LDFLAGS) -o pacredir pacredir.c \
- -DVERSION="\"$(VERSION)\""
+pacredir: pacredir.c pacredir.h config.h version.h
+ $(CC) $(CFLAGS) $(LDFLAGS) -o pacredir pacredir.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" >> $@
+
avahi/pacdbserve.service: arch avahi/pacdbserve.service.in
$(SED) 's/%ARCH%/$(shell ./arch)/' avahi/pacdbserve.service.in > avahi/pacdbserve.service
@@ -58,7 +59,7 @@ install-doc: README.html
$(INSTALL) -D -m0644 README.html $(DESTDIR)$(PREFIX)/share/doc/paccache/README.html
clean:
- $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service README.html
+ $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service README.html version.h
distclean:
- $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service README.html config.h
+ $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service README.html version.h config.h
diff --git a/pacredir.c b/pacredir.c
index 8e18cc0..3fa70eb 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -31,6 +31,7 @@
/* compile time configuration */
#include "config.h"
+#include "version.h"
/* define structs and functions */
#include "pacredir.h"