+if test "$enable_htools" != "no"; then
+
+# Check for qemu-img
+AC_ARG_VAR(QEMUIMG_PATH, [qemu-img path])
+AC_PATH_PROG(QEMUIMG_PATH, [qemu-img], [])
+if test -z "$QEMUIMG_PATH"
+then
+ AC_MSG_WARN([qemu-img not found, using ovfconverter will not be possible])
+fi
+
+# Check for ghc
+AC_ARG_VAR(GHC, [ghc path])
+AC_PATH_PROG(GHC, [ghc], [])
+if test -z "$GHC"; then
+ if test "$enable_htools" != "check"; then
+ AC_MSG_FAILURE([ghc not found, htools compilation will not possible])
+ fi
+fi
+
+# Check for ghc-pkg
+HTOOLS_MODULES=
+AC_ARG_VAR(GHC_PKG, [ghc-pkg path])
+AC_PATH_PROG(GHC_PKG, [ghc-pkg], [])
+if test -z "$GHC_PKG"; then
+ if test "$enable_htools" != "check"; then
+ AC_MSG_FAILURE([ghc-pkg not found, htools compilation will not be possible])
+ fi
+else
+ # check for modules
+ AC_MSG_NOTICE([checking for required haskell modules])
+ HTOOLS_NOCURL=-DNO_CURL
+ if test "$enable_htools_rapi" != "no"; then
+ AC_MSG_CHECKING([curl])
+ GHC_PKG_CURL=$($GHC_PKG latest curl)
+ if test -z "$GHC_PKG_CURL"; then
+ if test "$enable_htools_rapi" = "check"; then
+ AC_MSG_WARN(m4_normalize([The curl library not found, htools will be
+ compiled without RAPI support]))
+ else
+ AC_MSG_FAILURE(m4_normalize([The curl library was not found, but it has
+ been requested]))
+ fi
+ else
+ HTOOLS_NOCURL=
+ fi
+ AC_MSG_RESULT($GHC_PKG_CURL)
+ fi
+ AC_SUBST(GHC_PKG_CURL)
+ AC_SUBST(HTOOLS_NOCURL)
+ AC_MSG_CHECKING([parallel])
+ GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-3.*')
+ if test -n "$GHC_PKG_PARALLEL"
+ then
+ HTOOLS_PARALLEL3=-DPARALLEL3
+ else
+ GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-2.*')
+ fi
+ if test -z "$GHC_PKG_PARALLEL"
+ then
+ GHC_PKG_PARALLEL=$($GHC_PKG --simple-output list 'parallel-1.*')
+ fi
+ AC_SUBST(GHC_PKG_PARALLEL)
+ AC_SUBST(HTOOLS_PARALLEL3)
+ AC_MSG_RESULT($GHC_PKG_PARALLEL)
+ AC_MSG_CHECKING([json])
+ GHC_PKG_JSON=$($GHC_PKG latest json)
+ AC_MSG_RESULT($GHC_PKG_JSON)
+ AC_MSG_CHECKING([network])
+ GHC_PKG_NETWORK=$($GHC_PKG latest network)
+ AC_MSG_RESULT($GHC_PKG_NETWORK)
+ AC_MSG_CHECKING([QuickCheck 2.x])
+ GHC_PKG_QUICKCHECK=$($GHC_PKG --simple-output list 'QuickCheck-2.*')
+ AC_MSG_RESULT($GHC_PKG_QUICKCHECK)
+ if test -z "$GHC_PKG_PARALLEL" || test -z "$GHC_PKG_JSON" || \
+ test -z "$GHC_PKG_NETWORK"; then
+ if test "$enable_htools" != "check"; then
+ AC_MSG_FAILURE(m4_normalize([Required Haskell modules not found, htools
+ compilation disabled]))
+ fi
+ else
+ # we leave the other modules to be auto-selected
+ HTOOLS_MODULES="-package $GHC_PKG_PARALLEL"
+ fi
+ if test -z "$GHC_PKG_QUICKCHECK"; then
+ AC_MSG_WARN(m4_normalize([The QuickCheck 2.x module was not found,
+ you won't be able to run Haskell unittests]))
+ fi
+fi
+AC_SUBST(HTOOLS_MODULES)
+AC_SUBST(GHC_PKG_QUICKCHECK)
+
+if test "$enable_htools" != "no"; then
+ if test -z "$GHC" || test -z "$HTOOLS_MODULES"; then
+ AC_MSG_WARN(m4_normalize([Haskell compiler/required libraries not found,
+ htools compilation disabled]))
+ else
+ HTOOLS=yes
+ fi
+fi
+AC_SUBST(HTOOLS)
+
+# Check for HsColour
+HTOOLS_APIDOC=no
+AC_ARG_VAR(HSCOLOUR, [HsColour path])
+AC_PATH_PROG(HSCOLOUR, [HsColour], [])
+if test -z "$HSCOLOUR"; then
+ AC_MSG_WARN(m4_normalize([HsColour not found, htools API documentation will
+ not be generated]))
+fi
+
+# Check for haddock
+AC_ARG_VAR(HADDOCK, [haddock path])
+AC_PATH_PROG(HADDOCK, [haddock], [])
+if test -z "$HADDOCK"; then
+ AC_MSG_WARN(m4_normalize([haddock not found, htools API documentation will
+ not be generated]))
+fi
+if test "$HADDOCK" && test "$HSCOLOUR"; then
+ HTOOLS_APIDOC=yes
+fi
+AC_SUBST(HTOOLS_APIDOC)
+
+fi # end if enable_htools, define automake conditions
+
+AM_CONDITIONAL([WANT_HTOOLS], [test x$HTOOLS = xyes])
+AM_CONDITIONAL([WANT_HTOOLSTESTS], [test "x$GHC_PKG_QUICKCHECK" != x])
+AM_CONDITIONAL([WANT_HTOOLSAPIDOC], [test x$HTOOLS_APIDOC = xyes])
+
+# Check for fakeroot
+AC_ARG_VAR(FAKEROOT_PATH, [fakeroot path])
+AC_PATH_PROG(FAKEROOT_PATH, [fakeroot], [])
+if test -z "$FAKEROOT_PATH"; then
+ AC_MSG_WARN(m4_normalize([fakeroot not found, tests that must run as root
+ will not be executed]))
+fi
+AM_CONDITIONAL([HAS_FAKEROOT], [test "x$FAKEROOT_PATH" != x])
+