On Sat, 6 Oct 2007, Ulf Jordan wrote:

On Sat, 6 Oct 2007, Robinson Tryon wrote:

What about pulling the version directly out of SVN at build time?  Like this:

svn info | sed -n 's/.*Revision: \([0-9]*\)/\1/ p'

As long as the Makefile lives at the top level of the project, this
value should always reflect the latest commit in the current checkout.

That looks like a good solution.

Attached is the much shorter patch using Robinson's suggestion to get
the svn revision number as the superiotool version number.

/ulf
Set the superiotool version number from svn.

Signed-off-by: Ulf Jordan <[EMAIL PROTECTED]>

Index: superiotool.c
===================================================================
--- superiotool.c       (revision 2828)
+++ superiotool.c       (working copy)
@@ -167,12 +167,7 @@
 
 static void print_version(void)
 {
-       char tmp[80];
-
-       strncpy((char *)&tmp,
-               (const char *)&SUPERIOTOOL_VERSION[6],
-               strlen(SUPERIOTOOL_VERSION) - 8);
-       printf("superiotool r%s\n", (char *)&tmp);
+       printf("superiotool r" SUPERIOTOOL_VERSION "\n");
 }
 
 int main(int argc, char *argv[])
Index: superiotool.h
===================================================================
--- superiotool.h       (revision 2828)
+++ superiotool.h       (working copy)
@@ -29,7 +29,7 @@
 #include <getopt.h>
 #include <sys/io.h>
 
-#define SUPERIOTOOL_VERSION "$Rev$"
+#include "version.h"
 
 #define USAGE "Usage: superiotool [-d] [-D] [-V] [-v] [-h]\n\n\
   -d | --dump            Dump Super I/O registers\n\
Index: Makefile
===================================================================
--- Makefile    (revision 2828)
+++ Makefile    (working copy)
@@ -32,6 +32,13 @@
 
 all: $(PROGRAM)
 
+superiotool.o: version.h
+
+version.h: *.c superiotool.h
+       svn info \
+       | sed -n 's/.*Revision: \([0-9]*\)/\1/ p' \
+       | sed 's/.*/#define SUPERIOTOOL_VERSION "&"/' >$@
+
 $(PROGRAM): $(OBJS) superiotool.h
        $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS)
 
@@ -39,7 +46,7 @@
        $(INSTALL) $(PROGRAM) $(PREFIX)/bin
 
 clean:
-       rm -f $(PROGRAM) *.o
+       rm -f $(PROGRAM) *.o version.h
 
 .PHONY: all install clean
 
-- 
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to