configure: Check for presence of Python 3.
[cascardo/ovs.git] / m4 / openvswitch.m4
index 98e5ce9..fa85d3f 100644 (file)
@@ -109,11 +109,11 @@ AC_DEFUN([OVS_CHECK_WIN32],
             fi
             if test "$cl_cv_x64" = yes; then
                 PTHREAD_WIN32_DIR=$withval/lib/x64
-                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x64
+                PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x64
                 PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x64
             else
                 PTHREAD_WIN32_DIR=$withval/lib/x86
-                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x86
+                PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x86
                 PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x86
             fi
             PTHREAD_INCLUDES=-I$withval/include
@@ -186,6 +186,42 @@ AC_DEFUN([OVS_CHECK_NETLINK],
                 [Define to 1 if Netlink protocol is available.])
    fi])
 
+dnl Checks for libcap-ng.
+AC_DEFUN([OVS_CHECK_LIBCAPNG],
+  [AC_ARG_ENABLE(
+     [libcapng],
+     [AC_HELP_STRING([--disable-libcapng], [Disable Linux capability support])],
+     [case "${enableval}" in
+        (yes) libcapng=true ;;
+        (no)  libcapng=false ;;
+        (*) AC_MSG_ERROR([bad value ${enableval} for --enable-libcapng]) ;;
+      esac],
+     [libcapng=check])
+
+   if test "$libcapng" != false; then
+       AC_CHECK_LIB([cap-ng], [capng_clear], [HAVE_LIBCAPNG=yes])
+
+       if test "$HAVE_LIBCAPNG" != yes; then
+           if test "$libcapng" = true ; then
+                AC_MSG_ERROR([libcap-ng support requested, but not found])
+           fi
+           if test "$libcapng" = check ; then
+                 AC_MSG_WARN([cannot find libcap-ng.
+--user option will not be supported on Linux.
+(you may use --disable-libcapng to suppress this warning). ])
+           fi
+       fi
+   fi
+
+   AC_SUBST([HAVE_LIBCAPNG])
+   AM_CONDITIONAL([HAVE_LIBCAPNG], [test "$HAVE_LIBCAPNG" = yes])
+   if test "$HAVE_LIBCAPNG" = yes; then
+      AC_DEFINE([HAVE_LIBCAPNG], [1],
+                [Define to 1 if libcap-ng is available.])
+      CAPNG_LDADD="-lcap-ng"
+      AC_SUBST([CAPNG_LDADD])
+   fi])
+
 dnl Checks for OpenSSL.
 AC_DEFUN([OVS_CHECK_OPENSSL],
   [AC_ARG_ENABLE(
@@ -305,6 +341,12 @@ else:
             fi
           done
         done
+        if test $ovs_cv_python != no; then
+          if test -x "$ovs_cv_python" && ! "$ovs_cv_python" -c 'import six' >/dev/null 2>&1; then
+            ovs_cv_python=no
+            AC_MSG_WARN([Missing Python six library.])
+          fi
+        fi
       fi])
    AC_SUBST([HAVE_PYTHON])
    AM_MISSING_PROG([PYTHON], [python])
@@ -316,6 +358,60 @@ else:
    fi
    AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
 
+dnl Checks for Python 3.x, x >= 4.
+AC_DEFUN([OVS_CHECK_PYTHON3],
+  [AC_CACHE_CHECK(
+     [for Python 3.x for x >= 4],
+     [ovs_cv_python3],
+     [if test -n "$PYTHON3"; then
+        ovs_cv_python3=$PYTHON3
+      else
+        ovs_cv_python3=no
+        for binary in python3 python3.4; do
+          ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+          for dir in $PATH; do
+            IFS=$ovs_save_IFS
+            test -z "$dir" && dir=.
+            if test -x "$dir"/"$binary" && "$dir"/"$binary" -c 'import sys
+if sys.hexversion >= 0x03040000 and sys.hexversion < 0x04000000:
+    sys.exit(0)
+else:
+    sys.exit(1)'; then
+              ovs_cv_python3=$dir/$binary
+              break 2
+            fi
+          done
+        done
+        if test $ovs_cv_python != no; then
+          if test -x "$ovs_cv_python" && ! "$ovs_cv_python" -c 'import six' >/dev/null 2>&1; then
+            ovs_cv_python=no
+            AC_MSG_WARN([Missing Python six library.])
+          fi
+        fi
+      fi])
+   AC_SUBST([HAVE_PYTHON3])
+   AM_MISSING_PROG([PYTHON3], [python3])
+   if test $ovs_cv_python3 != no; then
+     PYTHON3=$ovs_cv_python3
+     HAVE_PYTHON3=yes
+   else
+     HAVE_PYTHON3=no
+   fi
+   AM_CONDITIONAL([HAVE_PYTHON3], [test "$HAVE_PYTHON3" = yes])])
+
+
+dnl Checks for dot.
+AC_DEFUN([OVS_CHECK_FLAKE8],
+  [AC_CACHE_CHECK(
+    [for flake8],
+    [ovs_cv_flake8],
+    [if flake8 --version >/dev/null 2>&1; then
+       ovs_cv_flake8=yes
+     else
+       ovs_cv_flake8=no
+     fi])
+   AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])])
+
 dnl Checks for dot.
 AC_DEFUN([OVS_CHECK_DOT],
   [AC_CACHE_CHECK(