From 8bf1adcd9a61cba1bcc9d35ac0b86a0785d2a7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Sat, 9 Jun 2018 11:33:30 +0200 Subject: New version scheme VERSION string between releases is last release suffixed with '+'. Additionally, use output of git-describe instead of VERSION string, if it is not empty. --- Makefile | 13 +++++++++++-- options.c | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9f8b6ae..cc2c94f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = git-20180411 +VERSION = 24+ srcdir = . VPATH = $(srcdir) @@ -20,7 +20,7 @@ HAVE_GIFLIB = 1 HAVE_LIBEXIF = 1 ALL_CFLAGS = $(DEF_CFLAGS) $(CFLAGS) -REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 -DVERSION=\"$(VERSION)\" \ +REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 \ -DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) ALL_CPPFLAGS = $(REQ_CPPFLAGS) $(DEF_CPPFLAGS) $(CPPFLAGS) @@ -46,6 +46,7 @@ sxiv: $(OBJS) $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJS) $(LDLIBS) $(OBJS): Makefile sxiv.h commands.lst config.h +options.o: version.h window.o: icon/data.h .c.o: @@ -56,6 +57,14 @@ config.h: @echo "GEN $@" cp $(srcdir)/config.def.h $@ +version.h: Makefile .git/index + @echo "GEN $@" + VERSION="$$(cd $(srcdir); git describe 2>/dev/null)"; \ + [ -z "$$VERSION" ] && VERSION="$(VERSION)"; \ + echo "#define VERSION \"$$VERSION\"" >$@ + +.git/index: + clean: rm -f *.o sxiv diff --git a/options.c b/options.c index 6b3599c..de02407 100644 --- a/options.c +++ b/options.c @@ -19,6 +19,7 @@ #include "sxiv.h" #define _IMAGE_CONFIG #include "config.h" +#include "version.h" #include #include @@ -36,7 +37,7 @@ void print_usage(void) void print_version(void) { - printf("sxiv %s - Simple X Image Viewer\n", VERSION); + puts("sxiv " VERSION); } void parse_options(int argc, char **argv) -- cgit v1.2.3