From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Tue, 10 Jun 2008 14:46:28 +0000 (+0100) Subject: Make '--version' flag work. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=eb9dbe2bc7656aed41ed207016746c983fcba4ef;p=virt-mem.git Make '--version' flag work. --- diff --git a/.hgignore b/.hgignore index 3948230..1116084 100644 --- 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 diff --git a/MANIFEST b/MANIFEST index 2ee847c..2874f23 100644 --- 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 diff --git a/configure.ac b/configure.ac index c56ae27..e0e64a3 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/.depend b/lib/.depend index 180057e..3e083d2 100644 --- a/lib/.depend +++ b/lib/.depend @@ -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 \ diff --git a/lib/Makefile.in b/lib/Makefile.in index bc3cce8..c520552 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -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) diff --git a/lib/virt_mem.ml b/lib/virt_mem.ml index 3a42448..9a00ead 100644 --- a/lib/virt_mem.ml +++ b/lib/virt_mem.ml @@ -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 index 0000000..b55eb45 --- /dev/null +++ b/lib/virt_mem_version.ml.in @@ -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@"