Krolyxon
Commit 8bf1adc

Branches

Refs →

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.
Author
Bert Münnich
Date
2018-06-09 11:33 +0200
Parent
b78aaee
Commit
8bf1adcd9a61cba1bcc9d35ac0b86a0785d2a7bd

+13 −3

2 files changed

  1. M Makefile +11 −2
  2. M options.c +2 −1
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20180411
1+VERSION = 24+
22
33 srcdir = .
44 VPATH = $(srcdir)
@@ -20,7 +20,7 @@ HAVE_GIFLIB = 1
2020 HAVE_LIBEXIF = 1
2121
2222 ALL_CFLAGS = $(DEF_CFLAGS) $(CFLAGS)
23−REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 -DVERSION=\"$(VERSION)\" \
23+REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 \
2424 -DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF)
2525 ALL_CPPFLAGS = $(REQ_CPPFLAGS) $(DEF_CPPFLAGS) $(CPPFLAGS)
2626
@@ -46,6 +46,7 @@ sxiv: $(OBJS)
4646 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJS) $(LDLIBS)
4747
4848 $(OBJS): Makefile sxiv.h commands.lst config.h
49+options.o: version.h
4950 window.o: icon/data.h
5051
5152 .c.o:
@@ -56,6 +57,14 @@ config.h:
5657 @echo "GEN $@"
5758 cp $(srcdir)/config.def.h $@
5859
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+
5968 clean:
6069 rm -f *.o sxiv
6170
M options.c View
@@ -19,6 +19,7 @@
1919 #include "sxiv.h"
2020 #define _IMAGE_CONFIG
2121 #include "config.h"
22+#include "version.h"
2223
2324 #include <stdlib.h>
2425 #include <string.h>
@@ -36,7 +37,7 @@ void print_usage(void)
3637
3738 void print_version(void)
3839 {
39− printf("sxiv %s - Simple X Image Viewer\n", VERSION);
40+ puts("sxiv " VERSION);
4041 }
4142
4243 void parse_options(int argc, char **argv)