linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] sparse: Add cmd line  --version option
@ 2013-03-06 17:22 Joe Perches
  2013-03-06 21:19 ` Christopher Li
  2013-03-06 21:45 ` Josh Triplett
  0 siblings, 2 replies; 9+ messages in thread
From: Joe Perches @ 2013-03-06 17:22 UTC (permalink / raw)
  To: linux-sparse

There's no current way to know the version
of sparse.  Add --version to see it.

---

I'm not at all tied to this implementation
but it's always nice to be able to see what
version is being used.

Likely it needs something to always recompile
lib.o whenever appropriate.

 Makefile | 11 +++++++++--
 lib.c    |  7 +++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b195528..8d2ffea 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,12 @@
 VERSION=0.4.4
 
+HAVE_GIT:=$(shell git describe >/dev/null 2>&1 && echo 'yes')
+ifeq ($(HAVE_GIT),yes)
+SPARSE_VERSION=$(shell git describe)
+else
+SPARSE_VERSION=$(VERSION)
+endif
+
 OS = linux
 
 
@@ -27,7 +34,8 @@ HAVE_LLVM_VERSION:=$(shell llvm-config --version | grep "^[3-9].*" >/dev/null 2>
 LLVM_VERSION=$(shell llvm-config --version)
 
 GCC_BASE = $(shell $(CC) --print-file-name=)
-BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\"
+BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\" \
+	       -DSPARSE_VERSION=\"$(SPARSE_VERSION)\"
 
 ifeq ($(HAVE_GCC_DEP),yes)
 BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
@@ -160,7 +168,6 @@ install: all-installable
 sparse.pc: sparse.pc.in
 	$(QUIET_GEN)sed $(SED_PC_CMD) sparse.pc.in > sparse.pc
 
-
 compile_EXTRA_DEPS = compile-i386.o
 
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)_EXTRA_DEPS) $(LIBS)))
diff --git a/lib.c b/lib.c
index 4f69e11..ddc9a93 100644
--- a/lib.c
+++ b/lib.c
@@ -646,6 +646,12 @@ static char **handle_base_dir(char *arg, char **next)
 	return next;
 }
 
+static char **handle_version(char *arg, char **next)
+{
+	die("%s", SPARSE_VERSION);
+	return next;
+}
+
 struct switches {
 	const char *name;
 	char **(*fn)(char *, char **);
@@ -656,6 +662,7 @@ static char **handle_switch(char *arg, char **next)
 	static struct switches cmd[] = {
 		{ "nostdinc", handle_nostdinc },
 		{ "gcc-base-dir", handle_base_dir},
+		{ "-version", handle_version },
 		{ NULL, NULL }
 	};
 	struct switches *s;



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-07  5:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-06 17:22 [RFC PATCH] sparse: Add cmd line --version option Joe Perches
2013-03-06 21:19 ` Christopher Li
2013-03-06 21:41   ` Joe Perches
2013-03-06 21:45 ` Josh Triplett
2013-03-06 21:57   ` Joe Perches
2013-03-07  4:18     ` Chris Li
2013-03-07  4:33       ` Joe Perches
2013-03-07  5:10         ` Christopher Li
2013-03-07  4:34       ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).