Re: [PATCH] show tgtd and tgtadm version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 17 Dec 2008 12:49:58 +0900
FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> wrote:

> > What could be other options?
> 
> I think that you can put some magic to Makefile.
> 
> For example, Makefile detects if it's a git repository, you can put
> the object name to TGT_VERSION:
> 
> fujita@viola:/tmp/tgt$ git-show-ref --heads --abbrev
> 5a21a44 refs/heads/master
> 
> So TGT_VERSION could be something like 0.9.2-5a21a44 if you compile
> the git tree. As long as things are done automatically, it's fine by
> me.
> 
> I guess that Debian's kernel build tool does similar things.

How about this?

If you compile the git tree, you get:

fujita@lily:~/git/tgt/usr$ ./tgtadm -h
Usage: tgtadm [OPTION]
Linux SCSI Target Framework Administration Utility, version 0.9.2-git-9f4cbd1

If you compile a release version (or on a box without git installed),
you get:

fujita@lily:/tmp/tgt-0.9.2/usr$ ./tgtadm -h|head
Usage: tgtadm [OPTION]
Linux SCSI Target Framework Administration Utility, version 0.9.2


I don't know about Makefile well but it seems to work.


diff --git a/usr/Makefile b/usr/Makefile
index fba86c0..68027a0 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -1,3 +1,6 @@
+VERSION = 0.9.2
+EXTRAVERSION = $(if $(shell git-show-ref 2>/dev/null),-git-$(shell git-show-ref --heads --abbrev|grep "refs/heads/master"|awk '{print $$1}'))
+
 mandir = /usr/share/man
 
 ifneq ($(IBMVIO),)
@@ -51,6 +54,7 @@ INCLUDES += -I. -I../include -I$(KERNELSRC)/include
 CFLAGS += -D_GNU_SOURCE
 CFLAGS += $(INCLUDES)
 CFLAGS += -g -O2 -Wall -Wstrict-prototypes -fPIC
+CFLAGS += -DTGT_VERSION=\"$(VERSION)$(EXTRAVERSION)\"
 
 LIBS += -lpthread
 
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index de7aed1..8d20c9c 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -122,7 +122,7 @@ static void usage(int status)
 	else {
 		printf("Usage: %s [OPTION]\n", program_name);
 		printf("\
-Linux SCSI Target Framework Administration Utility.\n\
+Linux SCSI Target Framework Administration Utility, version %s\n\
 \n\
   --lld [driver] --mode target --op new --tid=[id] --targetname [name]\n\
                         add a new target with [id] and [name]. [id] must not be zero.\n\
@@ -164,7 +164,7 @@ Linux SCSI Target Framework Administration Utility.\n\
                         target.\n\
   --help                display this help and exit\n\
 \n\
-Report bugs to <stgt-devel@xxxxxxxxxxxxxxxx>.\n");
+Report bugs to <stgt-devel@xxxxxxxxxxxxxxxx>.\n", TGT_VERSION);
 	}
 	exit(status == 0 ? 0 : EINVAL);
 }
diff --git a/usr/tgtd.c b/usr/tgtd.c
index 520e77c..8569d41 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -64,11 +64,11 @@ static void usage(int status)
 	else {
 		printf("Usage: %s [OPTION]\n", program_name);
 		printf("\
-Target framework daemon.\n\
+Target framework daemon, version %s\n\
   -f, --foreground        make the program run in the foreground\n\
   -d, --debug debuglevel  print debugging information\n\
   -h, --help              display this help and exit\n\
-");
+", TGT_VERSION);
 	}
 	exit(status);
 }
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux