build: Use AC_HEADER_MAJOR to find device macros

Depending on the OS/libc, device macros are defined in different
headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may
change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html
This commit is contained in:
Mike Gilbert 2016-04-19 14:27:22 -04:00 committed by Andrei Borzenkov
parent abf9beb7d6
commit 7a5b301e3a
5 changed files with 22 additions and 2 deletions

View file

@ -388,7 +388,8 @@ fi
# Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
AC_HEADER_MAJOR
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
#include <sys/param.h>

View file

@ -40,6 +40,12 @@
#include <limits.h>
#endif
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#include <libdevmapper.h>
#include <grub/types.h>

View file

@ -24,6 +24,11 @@
#include <errno.h>
#include <limits.h>
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#ifdef HAVE_DEVICE_MAPPER
# include <libdevmapper.h>

View file

@ -35,6 +35,12 @@
#include <limits.h>
#endif
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#include <grub/types.h>
#include <sys/ioctl.h> /* ioctl */
#include <sys/mount.h>

View file

@ -51,8 +51,10 @@
#endif
#include <sys/types.h>
#if defined(HAVE_SYS_MKDEV_H)
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)