2 dnl # Check for ZFS support in libblkid. This test needs to check
3 dnl # more than if the library exists because we expect there are
4 dnl # at least 3 flavors of the library out in the wild:
6 dnl # 1) blkid which has no ZFS support
7 dnl # 2) blkid with ZFS support and a flawed method of probing
8 dnl # 3) blkid with ZFS support and a working method of probing
10 dnl # To handle this the check first validates that there is a version
11 dnl # of the library installed. If there is it creates a simulated
12 dnl # ZFS filesystem and then links a small test app which attempts
13 dnl # to detect the simualated filesystem type. If it correctly
14 dnl # identifies the filesystem as ZFS we can safely assume case 3).
15 dnl # Otherwise we disable blkid support and resort to manual probing.
17 AC_DEFUN([ZFS_AC_CONFIG_USER_LIBBLKID], [
19 [AS_HELP_STRING([--with-blkid],
20 [support blkid caching @<:@default=check@:>@])],
25 AS_IF([test "x$with_blkid" != xno],
27 AC_CHECK_LIB([blkid], [blkid_get_cache],
29 AC_MSG_CHECKING([for blkid zfs support])
32 dd if=/dev/zero of=$ZFS_DEV bs=1024k count=8 \
33 >/dev/null 2>/dev/null
34 echo -en "\x0c\xb1\xba\0\0\0\0\0" | \
35 dd of=$ZFS_DEV bs=1k count=8 \
36 seek=132 conv=notrunc &>/dev/null \
37 >/dev/null 2>/dev/null
39 saved_LDFLAGS="$LDFLAGS"
42 AC_RUN_IFELSE(AC_LANG_PROGRAM(
45 #include <blkid/blkid.h>
51 if (blkid_get_cache(&cache, NULL) < 0)
54 value = blkid_get_tag_value(cache, "TYPE",
57 blkid_put_cache(cache);
61 if (strcmp(value, "zfs")) {
63 blkid_put_cache(cache);
68 blkid_put_cache(cache);
73 AC_SUBST([LIBBLKID], ["-lblkid"])
74 AC_DEFINE([HAVE_LIBBLKID], 1,
75 [Define if you have libblkid])
80 AS_IF([test "x$with_blkid" != xcheck],
82 [--with-blkid given but unavailable])])
85 LDFLAGS="$saved_LDFLAGS"
88 AS_IF([test "x$with_blkid" != xcheck],
90 [--with-blkid given but unavailable])])