Note this requires either the following fix in autoconf:
http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98
OR gnulib sys_types module plus gnulib
commit a512e041120e9012e69afa2f5c3adc196ec4999a (any gnulib more
recent than Sep 2016) which corrects the AC_HEADER_MAJOR macro in a
similar way.
---
bootstrap | 1 +
cat/ls.c | 7 +++++++
daemon/mknod.c | 6 ++++++
diff/diff.c | 7 +++++++
lib/fuse.c | 6 ++++++
m4/guestfs_libraries.m4 | 3 +++
mllib/unix_utils-c.c | 8 +++++++-
p2v/main.c | 6 ++++++
8 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/bootstrap b/bootstrap
index 037d07e..faa10a3 100755
--- a/bootstrap
+++ b/bootstrap
@@ -92,6 +92,7 @@ strerror
strndup
symlinkat
sys_select
+sys_types
sys_wait
vasprintf
vc-list-files
diff --git a/cat/ls.c b/cat/ls.c
index e0b5ff8..7568a5f 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -31,7 +31,14 @@
#include <assert.h>
#include <time.h>
#include <libintl.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
+#else
+#include <sys/types.h>
+#endif
#include "human.h"
#include "getprogname.h"
diff --git a/daemon/mknod.c b/daemon/mknod.c
index f8640ea..35dad15 100644
--- a/daemon/mknod.c
+++ b/daemon/mknod.c
@@ -25,7 +25,13 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
#include "guestfs_protocol.h"
#include "daemon.h"
diff --git a/diff/diff.c b/diff/diff.c
index fc31ad3..8c045ad 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -32,7 +32,14 @@
#include <time.h>
#include <libintl.h>
#include <sys/wait.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
+#else
+#include <sys/types.h>
+#endif
#include "c-ctype.h"
#include "human.h"
diff --git a/lib/fuse.c b/lib/fuse.c
index 98bbc8d..7f80c49 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -26,7 +26,13 @@
#include <sys/wait.h>
#include <string.h>
#include <libintl.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
#if HAVE_FUSE
/* See <attr/xattr.h> */
diff --git a/m4/guestfs_libraries.m4 b/m4/guestfs_libraries.m4
index 0882d27..c265b29 100644
--- a/m4/guestfs_libraries.m4
+++ b/m4/guestfs_libraries.m4
@@ -82,6 +82,9 @@ AC_CHECK_FUNCS([\
statvfs \
sync])
+dnl Which header file defines major, minor, makedev.
+AC_HEADER_MAJOR
+
dnl Check for UNIX_PATH_MAX, creating a custom one if not available.
AC_MSG_CHECKING([for UNIX_PATH_MAX])
AC_COMPILE_IFELSE([
diff --git a/mllib/unix_utils-c.c b/mllib/unix_utils-c.c
index 1a4c3d7..f5aaaf6 100644
--- a/mllib/unix_utils-c.c
+++ b/mllib/unix_utils-c.c
@@ -27,9 +27,15 @@
#include <fnmatch.h>
#include <errno.h>
#include <sys/types.h>
-#include <sys/sysmacros.h>
#include <sys/statvfs.h>
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
+#include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
+
#include <caml/alloc.h>
#include <caml/fail.h>
#include <caml/memory.h>
diff --git a/p2v/main.c b/p2v/main.c
index 42d3bbb..af14240 100644
--- a/p2v/main.c
+++ b/p2v/main.c
@@ -32,7 +32,13 @@
#include <libintl.h>
#include <sys/types.h>
#include <sys/stat.h>
+
+#if MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
+/* else it's in sys/types.h, included above */
+#endif
/* errors in <gtk.h> */
#pragma GCC diagnostic push
--
2.9.3