Extract superiotool version number from the svn revision numbers of the *.c and superiotool.h files. Signed-off-by: Ulf Jordan Index: fintek.c =================================================================== --- fintek.c (revision 2828) +++ fintek.c (arbetskopia) @@ -19,6 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define DEVICE_ID_BYTE1_REG 0x20 Index: winbond.c =================================================================== --- winbond.c (revision 2828) +++ winbond.c (arbetskopia) @@ -19,6 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define DEVICE_ID_REG_OLD 0x09 Index: ite.c =================================================================== --- ite.c (revision 2828) +++ ite.c (arbetskopia) @@ -19,6 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define CHIP_ID_BYTE1_REG 0x20 Index: nsc.c =================================================================== --- nsc.c (revision 2828) +++ nsc.c (arbetskopia) @@ -19,6 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define CHIP_ID_REG 0x20 /* Super I/O ID (SID) / family */ Index: superiotool.c =================================================================== --- superiotool.c (revision 2828) +++ superiotool.c (arbetskopia) @@ -20,6 +20,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" /* Command line options. */ @@ -167,12 +174,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: ali.c =================================================================== --- ali.c (revision 2828) +++ ali.c (arbetskopia) @@ -18,6 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define DEVICE_ID_BYTE1_REG 0x20 Index: smsc.c =================================================================== --- smsc.c (revision 2828) +++ smsc.c (arbetskopia) @@ -18,6 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $Rev$ + */ + #include "superiotool.h" #define DEVICE_ID_REG_OLD 0x0d Index: superiotool.h =================================================================== --- superiotool.h (revision 2828) +++ superiotool.h (arbetskopia) @@ -29,7 +29,13 @@ #include #include -#define SUPERIOTOOL_VERSION "$Rev$" +/* + * Each superiotool source file should have a revision comment for + * version tracking. The largest revision is extracted by the build + * system into version.h + * $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 (arbetskopia) @@ -32,6 +32,14 @@ all: $(PROGRAM) +superiotool.o: version.h + +version.h: *.c superiotool.h + sed -ne 's/.*Rev: \([0-9]*\) .*/\1/p' $^ \ + | sort -n \ + | tail -1 \ + | sed 's/.*/#define SUPERIOTOOL_VERSION "&"/' >$@ + $(PROGRAM): $(OBJS) superiotool.h $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) @@ -39,7 +47,7 @@ $(INSTALL) $(PROGRAM) $(PREFIX)/bin clean: - rm -f $(PROGRAM) *.o + rm -f $(PROGRAM) *.o version.h .PHONY: all install clean