-#
-# LB_PATH_SPL
-#
-# --with-spl - Enable spl support and attempt to autodetect the spl
-# --with-spl=yes headers in one of the following places in this order:
-# * ./spl
-# * /usr/src/spl-*/$LINUXRELEASE
-# * ../spl
-#
-# --with-spl=path - Enable spl support and use the spl headers in the
-# provided path. No autodetection is performed.
-#
-# --with-spl-obj - When spl support is enabled the object directory
-# will be based on the --with-spl directory. If this
-# is detected incorrectly it can be explicitly
-# specified using this option.
-#
-# NOTE: As with all external packages spl is expected to already be
-# configured and built. However, if the spl tree is located in-tree
-# (./spl) then it will be configured and built recursively as part of
-# the lustre build system.
-#
-AC_DEFUN([LB_PATH_SPL],
-[
-AC_ARG_WITH([spl],
- AC_HELP_STRING([--with-spl=path], [set path to spl sources]),
- [],[
- if test x$enable_server = xyes && test x$enable_dist = xno; then
- with_spl='yes'
- else
- with_spl='no'
- fi
+dnl #
+dnl # Supported configure options. When no options are specified support
+dnl # for ZFS OSDs will be autodetected assuming server support is enabled.
+dnl # If the ZFS OSD cannot be built support for it is disabled and a
+dnl # warning is issued but the configure process is allowed to continue.
+dnl #
+dnl # --without-zfs - Disable zfs support.
+dnl # --with-zfs=no
+dnl #
+dnl # --with-zfs - Enable zfs support and attempt to autodetect the zfs
+dnl # --with-zfs=yes headers in one of the following places. Because zfs
+dnl # support was explicitly required if the headers cannot
+dnl # be located it is treated as a fatal error.
+dnl #
+dnl # * /var/lib/dkms/zfs/${VERSION}/build
+dnl # * /usr/src/zfs-${VERSION}/${LINUXRELEASE}
+dnl # * /usr/src/zfs-${VERSION}
+dnl # * ../spl/
+dnl # * $LINUX
+dnl #
+dnl # --with-zfs-devel=path
+dnl # - User provided directory where zfs development headers
+dnl # are located. This option is typically used when user
+dnl # uses rpm2cpio to unpack src rpm.
+dnl #
+dnl # --with-zfs=path - Enable zfs support and use the zfs headers in the
+dnl # provided path. No autodetection is performed and
+dnl # if no headers are found this is a fatal error.
+dnl #
+dnl # --with-zfs-obj - When zfs support is enabled the object directory
+dnl # will be based on the --with-zfs directory. If this
+dnl # is detected incorrectly it can be explicitly
+dnl # specified using this option.
+dnl #
+dnl # --without-spl - Disable spl support.
+dnl # --with-spl=no
+dnl #
+dnl # --with-spl - Enable spl support and attempt to autodetect the spl
+dnl # --with-spl=yes headers in one of the following places in this order:
+dnl # * /var/lib/dkms/spl/${VERSION}/build
+dnl # * /usr/src/spl-${VERSION}/${LINUXRELEASE}
+dnl # * /usr/src/spl-${VERSION}
+dnl # * ../spl/
+dnl # * $LINUX
+dnl #
+dnl # --with-spl=path - Enable spl support and use the spl headers in the
+dnl # provided path. No autodetection is performed.
+dnl #
+dnl # --with-spl-obj - When spl support is enabled the object directory
+dnl # will be based on the --with-spl directory. If this
+dnl # is detected incorrectly it can be explicitly
+dnl # specified using this option.
+dnl #
+AC_DEFUN([LB_SPL], [
+ AC_ARG_WITH([spl],
+ AS_HELP_STRING([--with-spl=PATH],
+ [Path to spl source]),
+ [splsrc="$withval"])
+
+ AC_ARG_WITH([spl-obj],
+ AS_HELP_STRING([--with-spl-obj=PATH],
+ [Path to spl build objects]),
+ [splobj="$withval"])
+
+ dnl #
+ dnl # The existence of spl.release[.in] is used to identify a valid
+ dnl # source directory. In order of preference:
+ dnl #
+ splver=$(ls -1 /usr/src/ | grep -m1 spl | cut -f2 -d'-')
+ splsrc0="/var/lib/dkms/spl/${splver}/build"
+ splsrc1="/usr/src/spl-${splver}/${LINUXRELEASE}"
+ splsrc2="/usr/src/spl-${splver}"
+ splsrc3="../spl/"
+ splsrc4="$LINUX"
+
+ AC_MSG_CHECKING([spl source directory])
+ AS_IF([test -z "${splsrc}"], [
+ AS_IF([test -e "${splsrc0}/spl.release.in"], [
+ splsrc=${splsrc0}
+ ], [test -e "${splsrc1}/spl.release.in"], [
+ splsrc=${splsrc1}
+ ], [test -e "${splsrc2}/spl.release.in"], [
+ splsrc=${splsrc2}
+ ], [test -e "${splsrc3}/spl.release.in"], [
+ splsrc=$(readlink -f "${splsrc3}")
+ ], [test -e "${splsrc4}/spl.release.in"], [
+ splsrc=${splsrc4}
+ ], [
+ splsrc="[Not found]"
+ ])