-AC_MSG_CHECKING([whether to include assertions])
-AC_ARG_ENABLE([assertions],
- AS_HELP_STRING([--disable-assertions], [do not include assertions]),
- [ENABLE_ASSERTIONS=$enableval],
- [ENABLE_ASSERTIONS=yes]
- )
-AC_MSG_RESULT([$ENABLE_ASSERTIONS])
-if test "x$ENABLE_ASSERTIONS" = "xyes"; then
- AC_DEFINE([ENABLE_ASSERTIONS], [1], [Define to 1 if including assertions.])
+AC_PROG_CC
+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"
+ # -D__MINGW_USE_VC2005_COMPAT: make time_t 64-bit on 32-bit Windows.
+ PLATFORM_CPPFLAGS="-D_POSIX -D_POSIX_THREAD_SAFE_FUNCTIONS -DUNICODE -D_UNICODE -D_CRT_NON_CONFORMING_SWPRINTFS -D__MINGW_USE_VC2005_COMPAT -D_WIN32_WINNT=0x0600"
+ 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 getopt_long_only])
+
+# 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>])
+
+###############################################################################
+# Required libraries #
+###############################################################################
+
+# ------------------------------ pthreads -------------------------------------
+if test "$WINDOWS_NATIVE_BUILD" != "yes"; then
+ AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])