+have_asciidoc_xmlto=no
+warn_prebuilt_man_pages=no
+
+AC_PATH_PROG([ASCIIDOC], [asciidoc], [no])
+AC_PATH_PROG([XMLTO], [xmlto], [no])
+
+AS_IF([test "x$enable_man_pages" = "xyes"], [
+ AS_IF([test "x$ASCIIDOC" = "xno" || test "x$XMLTO" = "xno"], [
+ AS_IF([test "x$in_git_repo" = "xyes"], [
+ # this is an error because we're in the Git repo, which
+ # means the man pages are not already generated for us,
+ # thus asciixmlto are required because we were asked
+ # to build the man pages
+ AC_MSG_ERROR([
+You need asciidoc and xmlto to build the Babeltrace man pages. Use
+--disable-man-pages to disable building the man pages, in which case
+they will not be installed.
+ ])
+ ], [
+ # only warn here: since we're in the tarball, the man
+ # pages should already be generated at this point, thus
+ # asciidoc/xmlto are not strictly required
+ warn_prebuilt_man_pages=yes
+ ])
+ ], [
+ have_asciidoc_xmlto=yes
+ ])
+])
+
+# export AsciiDoc and xmlto existence
+AM_CONDITIONAL([HAVE_ASCIIDOC_XMLTO], [test "x$have_asciidoc_xmlto" = "xyes"])
+
+# a wonderful hack that seems necessary because $libdir is
+# literally `${exec_prefix}/lib`, and $exec_prefix is set to `NONE`
+# by autoconf when it's not specified by the user
+AS_IF([test "x$exec_prefix" = xNONE], [
+ AS_IF([test "x$prefix" = xNONE], [
+ PREFIX="$ac_default_prefix"
+ ], [
+ PREFIX="$prefix"
+ ])
+
+ LIBDIR="$PREFIX/lib"
+], [
+ LIBDIR="$libdir"
+])
+
+AC_SUBST(LIBDIR)
+