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
SPEC=ioping.spec
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)
DISTFILES=$(SRCS) $(MANS) $(DOCS) $(SPEC) Makefile
PACKFILES=$(BINS) $(MANS) $(MANS_F) $(DOCS)
......@@ -28,10 +29,10 @@ TARGET=win32
BINS:=$(BINS:=.exe)
endif
all: version $(BINS)
all: $(BINS)
version: $(DISTFILES)
test ! -d .git || git describe --tags --dirty=+ | sed 's/^v//;s/-/./g' > $@
version:
@echo ${VERSION}
clean:
$(RM) -f $(OBJS) $(BINS) $(MANS_F)
......@@ -45,8 +46,8 @@ install: $(BINS) $(MANS)
mkdir -p $(DESTDIR)$(MAN1DIR)
install -m 644 $(MANS) $(DESTDIR)$(MAN1DIR)
%.o: %.c version
$(CC) $(CFLAGS) -DVERSION=\"${VERSION}\" -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -DEXTRA_VERSION=\"${EXTRA_VERSION}\" -c -o $@ $<
%.ps: %.1
man -t ./$< > $@
......@@ -60,7 +61,7 @@ install: $(BINS) $(MANS)
$(BINS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)
dist: version $(DISTFILES)
dist: $(DISTFILES)
tar -cz --transform='s,^,$(DISTDIR)/,S' $^ -f $(DISTDIR).tar.gz
binary-tgz: $(PACKFILES)
......@@ -71,4 +72,4 @@ binary-zip: $(PACKFILES)
${STRIP} ${BINS}
zip ${PACKAGE}-${VERSION}-${TARGET}.zip $^
.PHONY: all clean install dist
.PHONY: all clean install dist version
......@@ -18,6 +18,14 @@
*
*/
#ifndef VERSION
# define VERSION "0.9"
#endif
#ifndef EXTRA_VERSION
# define EXTRA_VERSION ""
#endif
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
......@@ -249,14 +257,9 @@ void usage(void)
);
}
#ifndef VERSION
# warning ioping version undefined
# define VERSION ""
#endif
void version(void)
{
fprintf(stderr, "ioping %s\n", VERSION);
fprintf(stderr, "ioping %s\n", VERSION EXTRA_VERSION);
}
struct suffix {
......
Name: ioping
Version: %(cat version)
Version: %(make version)
Release: 1%{?dist}
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