configure: check for socat and its escape feature
authorGuido Trotter <ultrotter@google.com>
Sat, 31 Oct 2009 21:38:08 +0000 (17:38 -0400)
committerGuido Trotter <ultrotter@google.com>
Tue, 3 Nov 2009 13:14:17 +0000 (08:14 -0500)
Currently we use a static value for the socat path, or we trust the
user-provided one. With this patch we still trust any user provided
value, but if none is passed we check for socat on the machine we're
being configured on. This allows us also to check if we can or cannot
use the escape= feature in socat.

If the user has forced the path in, he can also pass --with-socat-escape
in order to force the escape functionality to be used, even if a check
is not done.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

Makefile.am
configure.ac

index cbfa69c..87af4e6 100644 (file)
@@ -411,6 +411,7 @@ lib/_autoconf.py: Makefile stamp-directories
          echo "KVM_PATH = '$(KVM_PATH)'"; \
          echo "KVM_MIGRATION_PORT = '$(KVM_MIGRATION_PORT)'"; \
          echo "SOCAT_PATH = '$(SOCAT_PATH)'"; \
+         echo "SOCAT_ESCAPE = '$(SOCAT_ESCAPE)'"; \
          echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
          echo "TOOLSDIR = '$(toolsdir)'"; \
          echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
index 3ba28cd..c681e03 100644 (file)
@@ -122,11 +122,16 @@ AC_SUBST(KVM_MIGRATION_PORT, $kvm_migration_port)
 AC_ARG_WITH([socat-path],
   [AS_HELP_STRING([--with-socat-path=PATH],
     [absolute path to the socat binary]
-    [ (default is /usr/bin/socat)]
+    [ (default is to let configure search for it)]
   )],
-  [socat_path="$withval"],
-  [socat_path="/usr/bin/socat"])
-AC_SUBST(SOCAT_PATH, $socat_path)
+  [SOCAT="$withval"],
+  [])
+
+AC_ARG_WITH([socat-escape],
+  [AS_HELP_STRING([--with-socat-escape],
+    [enable escape functionality found in newer socat])],
+  [],
+  [check_socat_escape=yes])
 
 # ---with-lvm-stripecount=...
 AC_ARG_WITH([lvm-stripecount],
@@ -173,6 +178,32 @@ then
   AC_MSG_WARN([dot (from the graphviz suite) not found, documentation rebuild not possible])
 fi
 
+if test -z "$SOCAT" -a -n "$check_socat_escape"
+then
+AC_CACHE_CHECK([for socat with the escape feature], [ac_cv_path_SOCAT],
+  [AC_PATH_PROGS_FEATURE_CHECK(SOCAT, [socat],
+            [[$ac_path_SOCAT -hh | grep -q escape \
+              && ac_cv_path_SOCAT=$ac_path_SOCAT \
+                 SOCAT=$ac_cv_path_SOCAT \
+                 with_socat_escape=yes ac_path_SOCAT_found=:]],
+            [AC_MSG_WARN([no escape feature found])])])
+fi
+
+if test -z "$SOCAT"
+then
+AC_CACHE_CHECK([for socat], [ac_cv_path_SOCAT],
+  [AC_PATH_PROGS_FEATURE_CHECK(SOCAT, [socat],
+            [[ac_cv_path_SOCAT=$ac_path_SOCAT \
+              SOCAT=$ac_cv_path_SOCAT ac_path_SOCAT_found=:]],
+            [AC_MSG_ERROR([socat not found])])])
+fi
+
+AC_SUBST([SOCAT_PATH], [$SOCAT])
+if test "x$with_socat_escape" = xyes
+then
+  AC_SUBST([SOCAT_ESCAPE], [1])
+fi
+
 # Check for Python
 AM_PATH_PYTHON(2.4)