[Libguestfs] [PATCH 5/9] build: isolate the libdb tools search in an own autoconf macro

Pino Toscano ptoscano at redhat.com
Tue Nov 4 15:35:28 UTC 2014


Create an autoconf macro to deal with the possible combinations of names
and versions of the libdb tools. This also eases the addition of a libdb
version, or a new pattern for the names of tools.

There is no functional change.
---
 configure.ac               |  6 ++----
 m4/guestfs-find-db-tool.m4 | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 4 deletions(-)
 create mode 100644 m4/guestfs-find-db-tool.m4

diff --git a/configure.ac b/configure.ac
index 5f3828d..87e066c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -682,10 +682,8 @@ AC_CHECK_PROG([PO4A],[po4a],[po4a],[no])
 AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
 
 dnl Check for db_dump, db_load (optional).
-AC_PATH_PROGS([DB_DUMP],
-              [db_dump db5.1_dump db4_dump db4.8_dump db4.7_dump db4.6_dump],[no])
-AC_PATH_PROGS([DB_LOAD],
-              [db_load db5.1_load db4_load db4.8_load db4.7_load db4.6_load],[no])
+GUESTFS_FIND_DB_TOOL([DB_DUMP], [dump])
+GUESTFS_FIND_DB_TOOL([DB_LOAD], [load])
 if test "x$DB_DUMP" != "xno"; then
     AC_DEFINE_UNQUOTED([DB_DUMP],["$DB_DUMP"],[Name of db_dump program.])
 fi
diff --git a/m4/guestfs-find-db-tool.m4 b/m4/guestfs-find-db-tool.m4
new file mode 100644
index 0000000..0cbbd13
--- /dev/null
+++ b/m4/guestfs-find-db-tool.m4
@@ -0,0 +1,42 @@
+# libguestfs
+# Copyright (C) 2014 Red Hat Inc.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+AC_DEFUN([GUESTFS_FIND_DB_TOOL],[
+    pushdef([VARIABLE],$1)
+    TOOL=$2
+
+    db_tool_name="db_$TOOL"
+    db_versions="5.1 4.8 4.7 4.6"
+    db_tool_patterns="db_$TOOL dbX_$TOOL dbX.Y_$TOOL"
+
+    AC_ARG_VAR(VARIABLE, [Absolute path to $db_tool_name executable])
+
+    AS_IF(test -z "$VARIABLE", [
+        exe_list=""
+        for ver in $db_versions ; do
+            ver_maj=`echo $ver | cut -d. -f1`
+            ver_min=`echo $ver | cut -d. -f2`
+            for pattern in $db_tool_patterns ; do
+                exe=`echo "$pattern" | sed -e "s/X/$ver_maj/g;s/Y/$ver_min/g"`
+                exe_list="$exe_list $exe"
+            done
+        done
+        AC_PATH_PROGS([]VARIABLE[], [$exe_list], [no])
+    ])
+
+    popdef([VARIABLE])
+])
-- 
1.9.3




More information about the Libguestfs mailing list