Make '--version' flag work.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 10 Jun 2008 14:46:28 +0000 (15:46 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 10 Jun 2008 14:46:28 +0000 (15:46 +0100)
.hgignore
MANIFEST
configure.ac
lib/.depend
lib/Makefile.in
lib/virt_mem.ml
lib/virt_mem_version.ml.in [new file with mode: 0644]

index 3948230..1116084 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -20,6 +20,7 @@ configure
 gmon.out
 virt-mem-*.tar.gz
 lib/virt_mem_gettext.ml
+lib/virt_mem_version.ml
 uname/virt-uname
 dmesg/virt-dmesg
 samples
\ No newline at end of file
index 2ee847c..2874f23 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,5 @@
 aclocal.m4
+ChangeLog
 configure.ac
 COPYING
 dmesg/.depend
@@ -13,6 +14,7 @@ lib/virt_mem.mli
 lib/virt_mem_mmap.ml
 lib/virt_mem_mmap.mli
 lib/virt_mem_utils.ml
+lib/virt_mem_version.ml.in
 Makefile.in
 Make.rules.in
 MANIFEST
index c56ae27..e0e64a3 100644 (file)
@@ -135,6 +135,7 @@ AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile
        Make.rules
        lib/Makefile
+       lib/virt_mem_version.ml
        uname/Makefile
        dmesg/Makefile
        po/Makefile
index 180057e..3e083d2 100644 (file)
@@ -1,9 +1,9 @@
 virt_mem.cmi: virt_mem_utils.cmo virt_mem_mmap.cmi 
 virt_mem_mmap.cmi: virt_mem_utils.cmo /usr/lib64/ocaml/bitmatch/bitmatch.cmi 
-virt_mem.cmo: virt_mem_utils.cmo virt_mem_mmap.cmi virt_mem_gettext.cmo \
-    /usr/lib64/ocaml/bitmatch/bitmatch.cmi virt_mem.cmi 
-virt_mem.cmx: virt_mem_utils.cmx virt_mem_mmap.cmx virt_mem_gettext.cmx \
-    /usr/lib64/ocaml/bitmatch/bitmatch.cmi virt_mem.cmi 
+virt_mem.cmo: virt_mem_version.cmo virt_mem_utils.cmo virt_mem_mmap.cmi \
+    virt_mem_gettext.cmo /usr/lib64/ocaml/bitmatch/bitmatch.cmi virt_mem.cmi 
+virt_mem.cmx: virt_mem_version.cmx virt_mem_utils.cmx virt_mem_mmap.cmx \
+    virt_mem_gettext.cmx /usr/lib64/ocaml/bitmatch/bitmatch.cmi virt_mem.cmi 
 virt_mem_mmap.cmo: virt_mem_utils.cmo /usr/lib64/ocaml/bitmatch/bitmatch.cmi \
     virt_mem_mmap.cmi 
 virt_mem_mmap.cmx: virt_mem_utils.cmx /usr/lib64/ocaml/bitmatch/bitmatch.cmi \
index bc3cce8..c520552 100644 (file)
@@ -44,13 +44,11 @@ OCAMLDEPFLAGS       = $(SYNTAX)
 TARGETS                = virt_mem.cma virt_mem.cmxa
 
 OBJS           = virt_mem_gettext.cmo \
+                 virt_mem_version.cmo \
                  virt_mem_utils.cmo \
                  virt_mem_mmap.cmo \
                  virt_mem.cmo
-XOBJS          = virt_mem_gettext.cmx \
-                 virt_mem_utils.cmx \
-                 virt_mem_mmap.cmx \
-                 virt_mem.cmx
+XOBJS          = $(OBJS:%.cmo=%.cmx)
 
 all:   $(TARGETS)
 
index 3a42448..9a00ead 100644 (file)
@@ -101,6 +101,16 @@ let start usage_msg =
     :: !images
   in
 
+  let version () =
+    printf "virt-mem %s\n" Virt_mem_version.version;
+
+    let major, minor, release =
+      let v, _ = Libvirt.get_version () in
+      v / 1_000_000, (v / 1_000) mod 1_000, v mod 1_000 in
+    printf "libvirt %d.%d.%d\n" major minor release;
+    exit 0
+  in
+
   let argspec = Arg.align [
     "-A", Arg.String set_architecture,
       "arch " ^ s_"Set kernel architecture, endianness and word size";
@@ -118,6 +128,8 @@ let start usage_msg =
       " " ^ s_"Debug mode (default: false)";
     "-t", Arg.String memory_image,
       "image " ^ s_"Use saved kernel memory image";
+    "--version", Arg.Unit version,
+      " " ^ s_"Display version and exit";
   ] in
 
   let anon_fun str =
diff --git a/lib/virt_mem_version.ml.in b/lib/virt_mem_version.ml.in
new file mode 100644 (file)
index 0000000..b55eb45
--- /dev/null
@@ -0,0 +1,20 @@
+(* Memory info for virtual domains.
+   (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
+   http://libvirt.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *)
+
+let version = "@PACKAGE_VERSION@"