+AM_PROG_CC_C_O
+AC_CANONICAL_HOST
+
+WINDOWS_NATIVE_BUILD="no"
+PLATFORM_CPPFLAGS=""
+PLATFORM_CFLAGS="-fvisibility=hidden"
+PLATFORM_LDFLAGS=""
+
+case "$host_os" in
+mingw*)
+ # Native Windows
+ WINDOWS_NATIVE_BUILD="yes"
+ PLATFORM_CPPFLAGS="-D_POSIX -D_POSIX_THREAD_SAFE_FUNCTIONS -DUNICODE -D_UNICODE -D_CRT_NON_CONFORMING_SWPRINTFS"
+ PLATFORM_CFLAGS="-municode -mno-ms-bitfields"
+ PLATFORM_LDFLAGS="-no-undefined"
+ WITH_NTFS_3G_DEFAULT="no"
+ WITH_FUSE_DEFAULT="no"
+ ;;
+linux*)
+ # Linux
+ WITH_NTFS_3G_DEFAULT="yes"
+ WITH_FUSE_DEFAULT="yes"
+ ;;
+*)
+ # Other UNIX
+ WITH_NTFS_3G_DEFAULT="yes"
+ WITH_FUSE_DEFAULT="no"
+ ;;
+esac
+
+AC_SUBST([PLATFORM_CPPFLAGS], [$PLATFORM_CPPFLAGS])
+AC_SUBST([PLATFORM_CFLAGS], [$PLATFORM_CFLAGS])
+AC_SUBST([PLATFORM_LDFLAGS], [$PLATFORM_LDFLAGS])
+AM_CONDITIONAL([WINDOWS_NATIVE_BUILD], [test "$WINDOWS_NATIVE_BUILD" = "yes"])
+
+# Useful functions which we can do without.
+AC_CHECK_FUNCS([futimens utimensat flock mempcpy \
+ openat fstatat readlinkat fdopendir posix_fallocate \
+ llistxattr lgetxattr fsetxattr lsetxattr])
+
+# Header checks, most of which are only here to satisfy conditional includes
+# made by the libntfs-3g headers.
+AC_CHECK_HEADERS([alloca.h \
+ byteswap.h \
+ endian.h \
+ errno.h \
+ glob.h \
+ machine/endian.h \
+ stdarg.h \
+ stddef.h \
+ stdlib.h \
+ sys/byteorder.h \
+ sys/endian.h \
+ sys/file.h \
+ sys/syscall.h \
+ sys/sysctl.h \
+ sys/times.h \
+ sys/xattr.h \
+ time.h \
+ utime.h])
+
+# Does stat() support nanosecond-precision timestamps? (This is relevant on
+# UNIX but not on Windows.)
+AC_CHECK_MEMBER([struct stat.st_mtim],
+ [AC_DEFINE([HAVE_STAT_NANOSECOND_PRECISION], [1],
+ [Define to 1 if stat() supports nanosecond precision
+ timestamps])],
+ [],
+ [#include <sys/stat.h>])
+
+# Check for possible support for the Linux getrandom() system call
+AC_CHECK_DECL([__NR_getrandom],
+ [AC_DEFINE([HAVE_NR_GETRANDOM], [1], [Define to 1 if the system
+ headers define a system call number for getrandom()])],
+ [],
+ [#include <sys/syscall.h>])
+
+###############################################################################
+# Required libraries #
+###############################################################################
+
+# ------------------------------ pthreads -------------------------------------
+AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
+
+# ------------------------------ libxml2 --------------------------------------
+PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
+PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libxml-2.0"