patch for a verbose -fullversion

Patrick Tullmann tullmann at cs.utah.edu
Thu Mar 9 22:12:19 PST 2000


The following patch (two new files and a patch) adds a '-fullversion'
option to Kaffe that includes the compile date, compile host, a bunch
of compile-time flags, and other interesting compile/link-time
information.  (Anyone wanna add a bit to include the first line of the
ChangeLog?)  Makes it nice to figure out exactly what version of Kaffe
you're using... (I tend to have a couple versions lying around).  It
works by creating a version-info.h header file each time kaffe is
compiled.

One problem with this patch is that I probably didn't do the
Makefile.am stuff quite right.  It certainly works for me, but I'm not 
sure if I'm abusing some features.

The patch is in two parts: two new file (kaffe/kaffe/version.[ch]) and a
patch against kaffe/kaffe/Makefile.am and kaffe/kaffe/main.c.

Here's a ChangeLog entry:

Patrick Tullmann <tullmann at cs.utah.edu>
	* kaffe/kaffe/version.[ch]: added.  Provide the output for
	  -version and -fullversion.
	* kaffe/kaffe/{Makefile.am,main.c}: Add the -fullversion
	  option, build a version-info.h header file each time Kaffe
	  is compiled.

-Pat

----- ----- ---- ---  ---  --   -    -      -         -               -
Pat Tullmann                                       tullmann at cs.utah.edu
	    He who dies with the most toys is still dead.

kaffe/kaffe/version.c:
/*
 * version.c
 *
 * Copyright (c) 2000  The University of Utah.  All rights Reserved.
 *
 * This file is distributed as is under the terms of the GNU General
 * Public License.
 */

/* Print out the Kaffe version information.
 * This is in a separate file because the version-info.h header file is
 * re-generated for each compile, and this minimizes the dependencies.
 */
#include "config.h"
#include "config-std.h"
#include "version.h"
#include "version-info.h" /* generated at compile time */

extern char* engine_name;	/* defined in the engine's library */
extern char* engine_version;	/* defined in the engine's library */

static FILE* versionfd = stderr;

void
printShortVersion(void)
{
	fprintf(versionfd, "Kaffe Virtual Machine\n");
	fprintf(versionfd, "Copyright (c) 1996-2000\nTransvirtual Technologies, Inc.  All rights reserved\n");
	fprintf(versionfd, "Engine: %s   Version: %s   Java Version: %s\n",
		engine_name, engine_version, JAVA_VERSION_STRING);
}

void
printFullVersion(void)
{
	printShortVersion();
	fprintf(versionfd, "Configuration/Compilation options:\n");
	fprintf(versionfd, "  Compile date  : %s\n", VER_COMPILE_DATE);
	fprintf(versionfd, "  Compile host  : %s\n", VER_COMPILE_HOST);
	fprintf(versionfd, "  Install prefix: %s\n", VER_PREFIX);
	fprintf(versionfd, "  Thread system : %s\n", VER_THREAD_SYSTEM);
	fprintf(versionfd, "  CC            : %s\n", VER_CC);
	fprintf(versionfd, "  CFLAGS        : %s\n", VER_CFLAGS);
	// fprintf(versionfd, "  Libraries     : %s\n", VER_KAFFELIBS);
}


kaffe/kaffe/version.h:
/*
 * version.h
 *
 * Copyright (c) 2000  The University of Utah.  All rights Reserved.
 *
 * This file is distributed as is under the terms of the GNU General
 * Public License.
 */

#ifndef KAFFE_KAFFE_VERSION_H
#define KAFFE_KAFFE_VERSION_H

#define JAVA_VERSION_STRING	"1.1"
#define JAVA_VERSION_HEX 	0x00010001

/*
 * Print copyright notice and simple version info (Java version, 
 * engine type, etc).  Prints to stderr.
 */
void printShortVersion(void);

/*
 * In addition to the short version, print ludicrous amounts of
 * information about the compile environment, configuration 
 * options, etc.
 */
void printFullVersion(void);

#endif /* KAFFE_KAFFE_VERSION_H */


The patch:
Index: kaffe/kaffe/Makefile.am
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffe/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- kaffe/kaffe/Makefile.am	1999/02/08 10:44:38	1.5
+++ kaffe/kaffe/Makefile.am	2000/03/10 05:52:05
@@ -10,10 +10,32 @@
 
 INCLUDES = -I../kaffevm -I$(srcdir)/../kaffevm -I$(top_srcdir)/libltdl
 
-Kaffe_SOURCES = main.c
+Kaffe_SOURCES = main.c version.o
 
 LIBKAFFEVM = ../kaffevm/libkaffevm.la
 
 Kaffe_LDFLAGS = -export-dynamic
 Kaffe_LDADD = $(DLOPEN_JAVA_LIBS) $(LIBKAFFEVM) $(KAFFE_LIBS)
 Kaffe_DEPENDENCIES = $(LIBKAFFEVM) $(JAVA_LIBS)
+
+### Rules to generate the version-info header file
+
+version.d: version-info
+
+version.o: version-info
+
+version-info:   
+	rm -f version-info.h
+	echo "/* version-info.h is automagically generated by kaffe Makefile */" > version-info.h
+	echo '#define VER_COMPILE_DATE  "'`date`'" '            >> version-info.h
+	echo '#define VER_COMPILE_HOST  "'`hostname`'"'         >> version-info.h
+	echo '#define VER_CC            "$(CC)"'                >> version-info.h
+	echo '#define VER_KAFFELIBS     "$(Kaffe_LDADD)"'       >> version-info.h
+	echo '#define VER_CFLAGS        "$(AM_CFLAGS) $(CFLAGS)"'      >> version-info.h
+	echo '#define VER_CPPFLAGS      "$(AM_CPPFLAGS) $(CPPFLAGS)"'  >> version-info.h
+	echo '#define VER_DEFS          "$(DEFS)"'              >> version-info.h
+	echo '#define VER_PREFIX        "$(prefix)"'            >> version-info.h
+	echo '#define VER_THREAD_SYSTEM "$(THREAD_SYSTEM)"'     >> version-info.h
+
+# Make version-info phony because we always want it to be regenerated
+.PHONY: version-info
Index: kaffe/kaffe/main.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffe/main.c,v
retrieving revision 1.27
diff -u -r1.27 main.c
--- kaffe/kaffe/main.c	2000/01/28 23:21:46	1.27
+++ kaffe/kaffe/main.c	2000/03/10 05:52:05
@@ -22,13 +22,11 @@
 #include "system.h"
 #include "md.h"
 #include "ltdl.h"
+#include "version.h"
 
 #if defined(KAFFE_PROFILER)
 extern int profFlag;
 #endif
-extern char* engine_name;
-extern char* engine_version;
-static char* java_version;
 
 #include "jni.h"
 
@@ -63,8 +61,8 @@
 	/* Machine specific main first */
 	MAIN_MD;
 #endif
-	java_version = "1.1";
-	vmargs.version = 0x00010001;
+	vmargs.version = JAVA_VERSION_HEX;
+
 #if defined(KAFFE_PROFILER)
 	profFlag = 0;
 #endif
@@ -231,9 +229,11 @@
 			exit(0);
 		}
 		else if (strcmp(argv[i], "-version") == 0) {
-			fprintf(stderr, "Kaffe Virtual Machine\n");
-			fprintf(stderr, "Copyright (c) 1996-1999\nTransvirtual Technologies, Inc.  All rights reserved\n");
-			fprintf(stderr, "Engine: %s   Version: %s   Java Version: %s\n", engine_name, engine_version, java_version);
+			printShortVersion();
+			exit(0);
+		}
+		else if (strcmp(argv[i], "-fullversion") == 0) {
+			printFullVersion();
 			exit(0);
 		}
 		else if (strcmp(argv[i], "-classpath") == 0) {



More information about the kaffe mailing list