Create a version string that includes the "extra" string as well, and
make use of it in print_version_and_exit (which can avoid creating a new
Guestfs handle).
Folloup of commit 478a552ab431762dd2a724ade0c3fd84a21b7cab.
---
configure.ac | 2 ++
mllib/common_utils.ml | 6 +-----
mllib/config.ml.in | 1 +
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index eeb61ea..98e8605 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,8 @@ AC_DEFINE([PACKAGE_VERSION_MAJOR],[libguestfs_major],[Major version
number.])
AC_DEFINE([PACKAGE_VERSION_MINOR],[libguestfs_minor],[Minor version number.])
AC_DEFINE([PACKAGE_VERSION_RELEASE],[libguestfs_release],[Release number.])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_EXTRA],["$libguestfs_extra"],[Extra version
string.])
+PACKAGE_VERSION_FULL="libguestfs_major.libguestfs_minor.libguestfs_release${libguestfs_extra}"
+AC_SUBST([PACKAGE_VERSION_FULL])
# Define $(SED).
m4_ifdef([AC_PROG_SED],[
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 0d6a4a6..652a412 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -344,11 +344,7 @@ let run_main_and_handle_errors ~prog main =
* the OCaml tools.
*)
let print_version_and_exit ~prog () =
- let g = G.create () in
- let { G.major = major; minor = minor;
- release = release; extra = extra } = G.version g in
- G.close g;
- printf "%s %Ld.%Ld.%Ld%s\n%!" prog major minor release extra;
+ printf "%s %s\n%!" prog Config.package_version_full;
exit 0
let read_whole_file path =
diff --git a/mllib/config.ml.in b/mllib/config.ml.in
index 793a35a..fe7850b 100644
--- a/mllib/config.ml.in
+++ b/mllib/config.ml.in
@@ -19,6 +19,7 @@
let package_name = "@PACKAGE_NAME@"
let package_version = "@PACKAGE_VERSION@"
+let package_version_full = "@PACKAGE_VERSION_FULL@"
let prefix = "@prefix@"
let datadir = prefix ^ "/share"
let host_cpu = "@host_cpu@"
--
2.1.0