[LinuxBIOS] [PATCH] superiotool: Make --version actually work correctly
Ulf Jordan
jordan at chalmers.se
Sun Oct 7 11:09:24 CEST 2007
On Sat, 6 Oct 2007, Ulf Jordan wrote:
> svnversion -c might be better, but it doesn't recurse, and has an
> interesting output format in the general case (but sed will fix it!)
The issue of how to derive version numbers from svn revision information
is indeed non-trivial, as shown by our discussion here and on other lists
like the Subversion users' list.
To obtain a global revision number from a working copy there is a very
good example in the svn FAQ (it's the only one in a red box, so I guess
it's really frequently asked):
http://subversion.tigris.org/faq.html#version-value-in-source
However, I believe we don't want the superiotool version to increase just
because there are other commits in the v2 tree, so the example needs
adapting by adding -c to svnversion.
Attached is a patch that:
* derives the superiotool version number from the latest committed change
to superiotool files (NOT the latest svn up of the superiotool directory)
* strips away extra information from svnversion, to arrive at a single
version number like 2828 instead of 2814:2828M ("this build is made up of
files with latest modification in rev 2814 to 2828 plus local
modifications").
* does not recurse down into subdirectories or svn:externals (there are no
such things in superiotool for the moment)
* does all the work in determining the version number at build time
* depends on GNU make features (although it could be rewritten more
portably using a version.h file instead, like my previous patch)
This approach could easily be combined with a traditional version number
from a #define in superiotool.h, as Robinson pointed out.
Corey: if you apply this patch to current svn superiotool, does the
trailing garbage go away?
/ulf
-------------- next part --------------
Set the superiotool version number from svn at build time.
Signed-off-by: Ulf Jordan <jordan at chalmers.se>
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%s\n", SUPERIOTOOL_VERSION);
}
int main(int argc, char *argv[])
Index: superiotool.h
===================================================================
--- superiotool.h (revision 2828)
+++ superiotool.h (working copy)
@@ -29,8 +29,6 @@
#include <getopt.h>
#include <sys/io.h>
-#define SUPERIOTOOL_VERSION "$Rev$"
-
#define USAGE "Usage: superiotool [-d] [-D] [-V] [-v] [-h]\n\n\
-d | --dump Dump Super I/O registers\n\
-D | --dump-readable Dump Super I/O registers in human-readable format\n\
Index: Makefile
===================================================================
--- Makefile (revision 2828)
+++ Makefile (working copy)
@@ -24,14 +24,19 @@
INSTALL = /usr/bin/install
PREFIX = /usr/local
+SVNDEF := -D'SUPERIOTOOL_VERSION="$(shell svnversion -cn . \
+ | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/")"'
+
# TODO: -pedantic
CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \
- -Werror-implicit-function-declaration -ansi
+ -Werror-implicit-function-declaration -ansi $(SVNDEF)
OBJS = superiotool.o ali.o fintek.o ite.o nsc.o smsc.o winbond.o
all: $(PROGRAM)
+superiotool.o: *.c superiotool.h
+
$(PROGRAM): $(OBJS) superiotool.h
$(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS)
More information about the coreboot
mailing list