[Sheepdog] [PATCH] add version information
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue Jan 26 09:06:43 CET 2010
The version string is auto-generated by git commit hash values.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
Makefile | 4 +++-
collie/Makefile | 2 +-
collie/collie.c | 6 ++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index bbe8d85..b28b162 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,8 @@
+VERSION ?= $(shell git log -1 --format=%h-%p || echo "unknown-version")
+
PREFIX ?= /usr
-export PREFIX
+export VERSION PREFIX
.PHONY:all
all:
diff --git a/collie/Makefile b/collie/Makefile
index 5e4beb0..2bfc9c6 100644
--- a/collie/Makefile
+++ b/collie/Makefile
@@ -1,7 +1,7 @@
sbindir ?= $(PREFIX)/sbin
CFLAGS += -g -O2 -Wall -Wstrict-prototypes -I../include
-CFLAGS += -D_GNU_SOURCE
+CFLAGS += -D_GNU_SOURCE -DSD_VERSION=\"$(VERSION)\"
LIBS += -lpthread -lcpg
PROGRAMS = collie
diff --git a/collie/collie.c b/collie/collie.c
index 6c247ab..da2a68a 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -38,12 +38,12 @@ static void usage(int status)
else {
printf("Usage: %s [OPTION] [PATH]\n", program_name);
printf("\
-Sheepdog Daemon\n\
+Sheepdog Daemon, version %s\n\
-p, --port specify the listen port number\n\
-f, --foreground make the program run in the foreground\n\
-d, --debug print debug messages\n\
-h, --help display this help and exit\n\
-");
+", SD_VERSION);
}
exit(status);
}
@@ -110,6 +110,8 @@ int main(int argc, char **argv)
if (ret)
exit(1);
+ dprintf("Sheepdog daemon (version %s) started\n", SD_VERSION);
+
event_loop(-1);
return 0;
--
1.6.5
More information about the sheepdog
mailing list