Commit a01558fe authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

ioping: keep VERSION right in ioping.c

Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent 522fd2cc
...@@ -13,7 +13,8 @@ DOCS=README LICENSE changelog ...@@ -13,7 +13,8 @@ DOCS=README LICENSE changelog
SPEC=ioping.spec SPEC=ioping.spec
PACKAGE=ioping PACKAGE=ioping
VERSION=$(shell cat version) EXTRA_VERSION:=$(shell test -d .git && git describe --tags --dirty=+ | sed 's/^v[^-]*//;s/-/./g')
VERSION:=$(shell sed -ne 's/\# define VERSION \"\(.*\)\"/\1/p' ioping.c)${EXTRA_VERSION}
DISTDIR=$(PACKAGE)-$(VERSION) DISTDIR=$(PACKAGE)-$(VERSION)
DISTFILES=$(SRCS) $(MANS) $(DOCS) $(SPEC) Makefile DISTFILES=$(SRCS) $(MANS) $(DOCS) $(SPEC) Makefile
PACKFILES=$(BINS) $(MANS) $(MANS_F) $(DOCS) PACKFILES=$(BINS) $(MANS) $(MANS_F) $(DOCS)
...@@ -28,10 +29,10 @@ TARGET=win32 ...@@ -28,10 +29,10 @@ TARGET=win32
BINS:=$(BINS:=.exe) BINS:=$(BINS:=.exe)
endif endif
all: version $(BINS) all: $(BINS)
version: $(DISTFILES) version:
test ! -d .git || git describe --tags --dirty=+ | sed 's/^v//;s/-/./g' > $@ @echo ${VERSION}
clean: clean:
$(RM) -f $(OBJS) $(BINS) $(MANS_F) $(RM) -f $(OBJS) $(BINS) $(MANS_F)
...@@ -45,8 +46,8 @@ install: $(BINS) $(MANS) ...@@ -45,8 +46,8 @@ install: $(BINS) $(MANS)
mkdir -p $(DESTDIR)$(MAN1DIR) mkdir -p $(DESTDIR)$(MAN1DIR)
install -m 644 $(MANS) $(DESTDIR)$(MAN1DIR) install -m 644 $(MANS) $(DESTDIR)$(MAN1DIR)
%.o: %.c version %.o: %.c
$(CC) $(CFLAGS) -DVERSION=\"${VERSION}\" -c -o $@ $< $(CC) $(CFLAGS) -DEXTRA_VERSION=\"${EXTRA_VERSION}\" -c -o $@ $<
%.ps: %.1 %.ps: %.1
man -t ./$< > $@ man -t ./$< > $@
...@@ -60,7 +61,7 @@ install: $(BINS) $(MANS) ...@@ -60,7 +61,7 @@ install: $(BINS) $(MANS)
$(BINS): $(OBJS) $(BINS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)
dist: version $(DISTFILES) dist: $(DISTFILES)
tar -cz --transform='s,^,$(DISTDIR)/,S' $^ -f $(DISTDIR).tar.gz tar -cz --transform='s,^,$(DISTDIR)/,S' $^ -f $(DISTDIR).tar.gz
binary-tgz: $(PACKFILES) binary-tgz: $(PACKFILES)
...@@ -71,4 +72,4 @@ binary-zip: $(PACKFILES) ...@@ -71,4 +72,4 @@ binary-zip: $(PACKFILES)
${STRIP} ${BINS} ${STRIP} ${BINS}
zip ${PACKAGE}-${VERSION}-${TARGET}.zip $^ zip ${PACKAGE}-${VERSION}-${TARGET}.zip $^
.PHONY: all clean install dist .PHONY: all clean install dist version
...@@ -18,6 +18,14 @@ ...@@ -18,6 +18,14 @@
* *
*/ */
#ifndef VERSION
# define VERSION "0.9"
#endif
#ifndef EXTRA_VERSION
# define EXTRA_VERSION ""
#endif
#define _GNU_SOURCE #define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
...@@ -249,14 +257,9 @@ void usage(void) ...@@ -249,14 +257,9 @@ void usage(void)
); );
} }
#ifndef VERSION
# warning ioping version undefined
# define VERSION ""
#endif
void version(void) void version(void)
{ {
fprintf(stderr, "ioping %s\n", VERSION); fprintf(stderr, "ioping %s\n", VERSION EXTRA_VERSION);
} }
struct suffix { struct suffix {
......
Name: ioping Name: ioping
Version: %(cat version) Version: %(make version)
Release: 1%{?dist} Release: 1%{?dist}
Summary: simple disk I/O latency monitoring tool Summary: simple disk I/O latency monitoring tool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment