nsxiv8bf1adc
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.
+13 −3
2 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20180411 | |
| 1 | + | VERSION = 24+ | |
| 2 | 2 | ||
| 3 | 3 | srcdir = . | |
| 4 | 4 | VPATH = $(srcdir) | |
| @@ -20,7 +20,7 @@ HAVE_GIFLIB = 1 | |||
| 20 | 20 | HAVE_LIBEXIF = 1 | |
| 21 | 21 | ||
| 22 | 22 | ALL_CFLAGS = $(DEF_CFLAGS) $(CFLAGS) | |
| 23 | − | REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 -DVERSION=\"$(VERSION)\" \ | |
| 23 | + | REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 \ | |
| 24 | 24 | -DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) | |
| 25 | 25 | ALL_CPPFLAGS = $(REQ_CPPFLAGS) $(DEF_CPPFLAGS) $(CPPFLAGS) | |
| 26 | 26 | ||
| @@ -46,6 +46,7 @@ sxiv: $(OBJS) | |||
| 46 | 46 | $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJS) $(LDLIBS) | |
| 47 | 47 | ||
| 48 | 48 | $(OBJS): Makefile sxiv.h commands.lst config.h | |
| 49 | + | options.o: version.h | |
| 49 | 50 | window.o: icon/data.h | |
| 50 | 51 | ||
| 51 | 52 | .c.o: | |
| @@ -56,6 +57,14 @@ config.h: | |||
| 56 | 57 | @echo "GEN $@" | |
| 57 | 58 | cp $(srcdir)/config.def.h $@ | |
| 58 | 59 | ||
| 60 | + | version.h: Makefile .git/index | |
| 61 | + | @echo "GEN $@" | |
| 62 | + | VERSION="$$(cd $(srcdir); git describe 2>/dev/null)"; \ | |
| 63 | + | [ -z "$$VERSION" ] && VERSION="$(VERSION)"; \ | |
| 64 | + | echo "#define VERSION \"$$VERSION\"" >$@ | |
| 65 | + | ||
| 66 | + | .git/index: | |
| 67 | + | ||
| 59 | 68 | clean: | |
| 60 | 69 | rm -f *.o sxiv | |
| 61 | 70 | ||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | #include "sxiv.h" | |
| 20 | 20 | #define _IMAGE_CONFIG | |
| 21 | 21 | #include "config.h" | |
| 22 | + | #include "version.h" | |
| 22 | 23 | ||
| 23 | 24 | #include <stdlib.h> | |
| 24 | 25 | #include <string.h> | |
| @@ -36,7 +37,7 @@ void print_usage(void) | |||
| 36 | 37 | ||
| 37 | 38 | void print_version(void) | |
| 38 | 39 | { | |
| 39 | − | printf("sxiv %s - Simple X Image Viewer\n", VERSION); | |
| 40 | + | puts("sxiv " VERSION); | |
| 40 | 41 | } | |
| 41 | 42 | ||
| 42 | 43 | void parse_options(int argc, char **argv) | |