--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ DAV_CHECK_NEON
 # Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h iconv.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h syslog.h termios.h unistd.h utime.h])
+AC_CHECK_HEADERS([error.h fcntl.h iconv.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h syslog.h termios.h unistd.h utime.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
--- a/src/cache.c
+++ b/src/cache.c
@@ -19,12 +19,12 @@
 
 
 #include "config.h"
+#include "compat.h"
 
 #ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #endif
 #include <errno.h>
-#include <error.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
--- /dev/null
+++ b/src/compat.h
@@ -0,0 +1,39 @@
+#ifndef _COMPAT_H
+#define _COMPAT_H
+
+#ifdef HAVE_ERROR_H
+# include <error.h>
+#else
+# include <stdio.h>
+# include <stdarg.h>
+# include <stdlib.h>
+# include <string.h>
+static void error_at_line(int status, int errnum, const char *filename,
+                          unsigned int linenum, const char *format, ...)
+{
+	va_list ap;
+
+	fflush(stdout);
+
+	if (filename != NULL)
+		fprintf(stderr, "%s:%u: ", filename, linenum);
+
+	va_start(ap, format);
+	vfprintf(stderr, format, ap);
+	va_end(ap);
+
+	if (errnum != 0)
+		fprintf(stderr, ": %s", strerror(errnum));
+
+	fprintf(stderr, "\n");
+
+	if (status != 0)
+		exit(status);
+}
+
+#define error(status, errnum, format...) \
+	error_at_line(status, errnum, NULL, 0, format)
+
+#endif /* HAVE_ERROR_H */
+
+#endif /* _COMPAT_H */
--- a/src/kernel_interface.c
+++ b/src/kernel_interface.c
@@ -19,9 +19,9 @@
 
 
 #include "config.h"
+#include "compat.h"
 
 #include <errno.h>
-#include <error.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
--- a/src/mount_davfs.c
+++ b/src/mount_davfs.c
@@ -19,10 +19,10 @@
 
 
 #include "config.h"
+#include "compat.h"
 
 #include <ctype.h>
 #include <errno.h>
-#include <error.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
--- a/src/umount_davfs.c
+++ b/src/umount_davfs.c
@@ -19,8 +19,8 @@
 
 
 #include "config.h"
+#include "compat.h"
 
-#include <error.h>
 #include <errno.h>
 #include <getopt.h>
 #ifdef HAVE_LIBINTL_H
--- a/src/webdav.c
+++ b/src/webdav.c
@@ -19,9 +19,9 @@
 
 
 #include "config.h"
+#include "compat.h"
 
 #include <errno.h>
-#include <error.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
