Version 1.15.10.
[libguestfs.git] / configure.ac
index 835f1c7..ea0aec4 100644 (file)
 #
 # 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.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-# major/minor/release must be numbers
+# The major, minor, and release fields MUST be numbers.  Packagers can
+# add extra information using --with-extra="..." which may be any
+# freeform string.
 m4_define([libguestfs_major],   [1])
-m4_define([libguestfs_minor],   [13])
-m4_define([libguestfs_release], [3])
-# extra can be any string
-m4_define([libguestfs_extra],   [])
+m4_define([libguestfs_minor],   [15])
+m4_define([libguestfs_release], [10])
 
 AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release)
 AC_CONFIG_AUX_DIR([build-aux])
@@ -31,12 +31,6 @@ AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
 
 AC_CONFIG_MACRO_DIR([m4])
 
-dnl Split up the version string.
-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([PACKAGE_VERSION_EXTRA],["libguestfs_extra"],[Extra version string])
-
 dnl Stable or unstable version?
 AC_MSG_CHECKING([if this is a stable or unstable branch of libguestfs])
 AS_IF([test "$((libguestfs_minor % 2))" -eq 0 ],[
@@ -53,12 +47,30 @@ please see the section "LIBGUESTFS VERSION NUMBERS" in guestfs(3).
 ***])
        ])
 
+dnl Extra string, a freeform string defined by packagers.
+AC_ARG_WITH([extra],
+  [AS_HELP_STRING([--with-extra],
+                  [extra version string (for use by packagers)])],
+  [libguestfs_extra="$withval"],
+  [libguestfs_extra=]
+)
+
+AC_MSG_NOTICE([libguestfs version libguestfs_major.libguestfs_minor.libguestfs_release$libguestfs_extra])
+
+dnl Split up the version string.
+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])
+
 dnl Early gnulib initialization.
 gl_EARLY
 gl_INIT
 
 AC_PROG_LIBTOOL
 
+AC_PROG_SED
+
 dnl Check for basic C environment.
 AC_PROG_CC_STDC
 AC_PROG_INSTALL
@@ -109,6 +121,9 @@ if test "$gl_gcc_warnings" = yes; then
                                     # failures (seen on Ubuntu).
   nw="$nw -Wmissing-noreturn"       # Don't warn about missed noreturn funcs
                                     # (seen on Ubuntu).
+  nw="$nw -Wsuggest-attribute=pure" # Don't suggest pure functions.
+  nw="$nw -Wsuggest-attribute=const" # Don't suggest const functions.
+  nw="$nw -Wunsuffixed-float-constants" # Don't care about these.
 
   gl_MANYWARN_ALL_GCC([ws])
   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
@@ -300,22 +315,19 @@ AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
         AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
         ])
 
-dnl Check for Augeas (now optional).
-AC_CHECK_LIB([augeas],[aug_match],[
-        have_augeas=yes
-        AUGEAS_LIB="-laugeas"
-
-        old_LIBS="$LIBS"
-        LIBS="$LIBS $AUGEAS_LIB"
-        dnl Check for functions not available in earlier versions of Augeas.
-        AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
-        LIBS="$old_LIBS"
-
-        ],[have_augeas=no])
-if test "x$have_augeas" = "xyes"; then
-        AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
-fi
-AC_SUBST([AUGEAS_LIB])
+dnl Check for Augeas (optional).
+PKG_CHECK_MODULES([AUGEAS], [augeas],
+        [AC_SUBST([AUGEAS_CFLAGS])
+         AC_SUBST([AUGEAS_LIBS])
+         AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
+
+         old_LIBS="$LIBS"
+         LIBS="$LIBS $AUGEAS_LIBS"
+         dnl Check for functions not available in earlier versions of Augeas.
+         AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
+         LIBS="$old_LIBS"
+        ],
+        [AC_MSG_WARN([augeas not found, some core features will be disabled])])
 
 dnl Check for libselinux (optional).
 AC_CHECK_HEADERS([selinux/selinux.h])
@@ -334,6 +346,11 @@ if test "x$have_libselinux" = "xyes"; then
 fi
 AC_SUBST([SELINUX_LIB])
 
+dnl Check for systemtap/DTrace userspace probes (optional).
+dnl http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps
+AC_CHECK_HEADERS([sys/sdt.h])
+dnl AC_CHECK_PROG([DTRACE],[dtrace],[dtrace],[no])
+
 dnl Check for cpio which isn't in the default Pardus install amazingly.
 AC_CHECK_PROG([CPIO],[cpio],[cpio],[no])
 test "x$CPIO" = "xno" &&
@@ -429,8 +446,53 @@ working.
 ])
     fi
 
+    dnl qemu 0.15 was released with broken support for '-machine',
+    dnl requiring you to add the machine type: '-machine pc,[...]'.
+    dnl The problem is that 'pc' is only applicable for PC-like
+    dnl hardware, so we cannot do this as a general solution.  Since
+    dnl qemu 0.15, this problem has been fixed so now the default
+    dnl machine type is chosen (qemu commit 2645c6dcaf6ea2a51a).
+    dnl
+    dnl We need to work out if this qemu is the broken version, so we
+    dnl can add 'pc' just for this broken version.
+    dnl
+    dnl Note that old qemu didn't support the '-machine' option at all.
+    dnl
+    dnl We use the -kernel option for testing this, because this option
+    dnl is processed very late, after qemu has set up the machine.
+    AC_MSG_CHECKING([for broken '-machine accel=tcg' option in $QEMU])
+    LC_ALL=C $QEMU -nographic -machine accel=tcg -kernel /NO_SUCH_FILE \
+             > config1.tmp 2>&1
+    LC_ALL=C $QEMU -nographic -machine pc,accel=tcg -kernel /NO_SUCH_FILE \
+             > config2.tmp 2>&1
+    if cmp -s config1.tmp config2.tmp; then
+        AC_MSG_RESULT([no])
+    else
+        AC_MSG_RESULT([yes])
+        AC_DEFINE([QEMU_MACHINE_TYPE_IS_BROKEN],[1],[qemu -machine accel=tcg option is broken (in qemu 0.15 only)])
+    fi
+    rm config1.tmp config2.tmp
+
+    dnl See if the '-machine [pc,]accel=tcg' option is required in
+    dnl order to run the virtio-serial test below.  This happens when
+    dnl we run qemu-kvm inside a VM without forcing TCG:
+    dnl
+    dnl   Could not access KVM kernel module: No such file or directory
+    dnl   failed to initialize KVM: No such file or directory
+    dnl   No accelerator found!
+    AC_MSG_CHECKING([if -machine @<:@pc,@:>@accel=tcg option is required to test virtio-serial feature])
+    if $QEMU -nographic -device \? >/dev/null 2>&1; then
+        :
+    elif $QEMU -machine accel=tcg -nographic -device \? >/dev/null 2>&1; then
+        QEMU_EXTRA_OPTIONS_FOR_TEST="-machine accel=tcg"
+    elif $QEMU -machine pc,accel=tcg -nographic -device \? >/dev/null 2>&1; then
+        QEMU_EXTRA_OPTIONS_FOR_TEST="-machine pc,accel=tcg"
+    # else nothing ... it'll fail below.
+    fi
+    AC_MSG_RESULT([$QEMU_EXTRA_OPTIONS_FOR_TEST])
+
     AC_MSG_CHECKING([for virtio-serial support in $QEMU])
-    if $QEMU -nographic -device \? 2>&1 | grep -sq virtio-serial; then
+    if $QEMU $QEMU_EXTRA_OPTIONS_FOR_TEST -nographic -device \? 2>&1 | grep -sq virtio-serial; then
         AC_MSG_RESULT([yes])
     else
         AC_MSG_RESULT([no])
@@ -590,14 +652,9 @@ AS_IF([test "x$enable_ocaml" != "xno"],
          OCAMLFIND=
          AC_PROG_OCAML
          AC_PROG_FINDLIB
-
-         AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"],
-               [AC_CHECK_OCAML_PKG([pcre])])
         ])
 AM_CONDITIONAL([HAVE_OCAML],
                [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"])
-AM_CONDITIONAL([HAVE_OCAML_PCRE],
-               [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_pcre" != "xno"])
 AM_CONDITIONAL([HAVE_OCAMLDOC],
                [test "x$OCAMLDOC" != "xno"])
 
@@ -647,11 +704,13 @@ AS_IF([test "x$enable_python" != "xno"],
 
         if test "x$PYTHON" != "xno"; then
            AC_MSG_CHECKING([Python prefix])
-            PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
+            PYTHON_PREFIX=`$PYTHON -c "import sys; print (sys.prefix)"`
            AC_MSG_RESULT([$PYTHON_PREFIX])
 
            AC_MSG_CHECKING([Python version])
-            PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
+            PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
+            PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
+            PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
            AC_MSG_RESULT([$PYTHON_VERSION])
 
             AC_MSG_CHECKING([for Python include path])
@@ -679,9 +738,19 @@ AS_IF([test "x$enable_python" != "xno"],
                 AC_MSG_RESULT([$PYTHON_INSTALLDIR])
             fi
 
+            dnl Look for libpython and some optional symbols in it.
             old_LIBS="$LIBS"
-            LIBS="$LIBS -lpython$PYTHON_VERSION"
-            AC_CHECK_FUNCS([PyCapsule_New])
+            if test "x$PYTHON_VERSION_MAJOR" = "x3"; then
+                dnl libpython3 is called "libpython3.Xmu.so"
+                LIBPYTHON="python${PYTHON_VERSION}mu"
+            else
+                LIBPYTHON="python$PYTHON_VERSION"
+            fi
+            AC_CHECK_LIB([$LIBPYTHON], [PyList_Size], [],
+                         [AC_MSG_FAILURE([$LIBPYTHON is not installed])])
+
+            AC_CHECK_FUNCS([PyCapsule_New \
+                            PyString_AsString])
             LIBS="$old_LIBS"
         fi
 
@@ -874,6 +943,25 @@ AS_IF([test "x$enable_php" != "xno"],
         ])
 AM_CONDITIONAL([HAVE_PHP], [test "x$PHP" != "xno" && test "x$PHPIZE" != "xno"])
 
+dnl Erlang
+ERLANG=no
+AC_ARG_ENABLE([erlang],
+    AS_HELP_STRING([--disable-erlang], [Disable Erlang language bindings]),
+         [],
+         [enable_erlang=yes])
+# NB: Don't use AS_IF here: it doesn't work.
+if test "x$enable_erlang" != "xno"; then
+        ERLANG=
+        AC_ERLANG_PATH_ERLC([no])
+
+        if test "x$ERLC" != "xno"; then
+            AC_ERLANG_CHECK_LIB([erl_interface], [],
+                                [AC_MSG_FAILURE([Erlang erl_interface library not installed.  Use --disable-erlang to disable.])])
+            AC_ERLANG_SUBST_LIB_DIR
+        fi
+fi
+AM_CONDITIONAL([HAVE_ERLANG], [test "x$ERLANG" != "xno" && test "x$ERLC" != "xno"])
+
 dnl Check for Perl modules needed by Perl virt tools (virt-df, etc.)
 AS_IF([test "x$PERL" != "xno"],
         [
@@ -907,19 +995,28 @@ AC_SUBST([LIBTOOL])
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
 dnl http://www.mail-archive.com/automake@gnu.org/msg10204.html
+AC_CONFIG_FILES([clone/virt-sysprep],
+                [chmod +x clone/virt-sysprep])
 AC_CONFIG_FILES([podwrapper.sh],
                 [chmod +x podwrapper.sh])
+AC_CONFIG_FILES([run],
+                [chmod +x run])
 AC_CONFIG_FILES([Makefile
+                 align/Makefile
                  appliance/Makefile
                  capitests/Makefile
                  cat/Makefile
                  caution/Makefile
+                 clone/Makefile
                  csharp/Makefile
                  daemon/Makefile
                  debian/changelog
                  df/Makefile
                  edit/Makefile
+                 erlang/Makefile
+                 erlang/examples/Makefile
                  examples/Makefile
+                 extratests/Makefile
                  fish/Makefile
                  fuse/Makefile
                  generator/Makefile
@@ -950,6 +1047,7 @@ AC_CONFIG_FILES([Makefile
                  ruby/Makefile
                  ruby/Rakefile
                  ruby/examples/Makefile
+                 sparsify/Makefile
                  src/Makefile
                  test-tool/Makefile
                  tools/Makefile])
@@ -980,11 +1078,13 @@ echo -n "Haskell bindings .................... "
 if test "x$HAVE_HASKELL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
 echo -n "PHP bindings ........................ "
 if test "x$HAVE_PHP_TRUE" = "x"; then echo "yes"; else echo "no"; fi
+echo -n "Erlang bindings ..................... "
+if test "x$HAVE_ERLANG_TRUE" = "x"; then echo "yes"; else echo "no"; fi
 echo    "guestfish and C virt tools .......... yes"
 echo -n "Perl virt tools ..................... "
 if test "x$HAVE_TOOLS_TRUE" = "x"; then echo "yes"; else echo "no"; fi
 echo -n "virt-resize ......................... "
-if test "x$HAVE_OCAML_TRUE" = "x" && test "x$HAVE_OCAML_PCRE_TRUE" = "x"; then echo "yes"; else echo "no"; fi
+if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
 echo "FUSE filesystem ..................... $enable_fuse"
 echo
 echo "If any optional component is configured 'no' when you expected 'yes'"