4 # --with-spl - Enable spl support and attempt to autodetect the spl
5 # --with-spl=yes headers in one of the following places in this order:
7 # * /usr/src/spl-*/$LINUXRELEASE
10 # --with-spl=path - Enable spl support and use the spl headers in the
11 # provided path. No autodetection is performed.
13 # --with-spl-obj - When spl support is enabled the object directory
14 # will be based on the --with-spl directory. If this
15 # is detected incorrectly it can be explicitly
16 # specified using this option.
18 # NOTE: As with all external packages spl is expected to already be
19 # configured and built. However, if the spl tree is located in-tree
20 # (./spl) then it will be configured and built recursively as part of
21 # the lustre build system.
23 AC_DEFUN([LB_PATH_SPL],
26 AC_HELP_STRING([--with-spl=path], [set path to spl sources]),
28 if test x$enable_server = xyes && test x$enable_dist = xno; then
37 AC_MSG_ERROR([spl must be enabled when building zfs.])
44 if test -e "$spl_src"; then
45 SPL_DIR=$(readlink -f $spl_src)
47 # Check /usr/src/spl-*/$LINUXRELEASE
48 spl_src=$(ls -1d /usr/src/spl-*/$LINUXRELEASE \
49 2>/dev/null | tail -1)
50 if test -e "$spl_src"; then
51 SPL_DIR=$(readlink -f $spl_src)
55 if test -e "$spl_src"; then
56 SPL_DIR=$(readlink -f $spl_src)
58 # Fatal spl required for zfs builds
59 AC_MSG_ERROR([Could not locate spl.])
66 SPL_DIR=$(readlink -f $with_spl)
71 AC_ARG_WITH([spl-obj],
72 AC_HELP_STRING([--with-spl-obj=path], [set path to spl objects]),
74 if test x$with_spl = xyes; then
78 if test x$with_spl = xyes; then
83 AC_MSG_CHECKING([spl source directory])
84 AC_MSG_RESULT([$SPL_DIR])
87 AC_MSG_CHECKING([spl object directory])
88 AC_MSG_RESULT([$SPL_OBJ])
98 # Optionally configure/make the spl sources. If the sources are
99 # determined to reside in-tree this feature will automatically be
100 # enabled. If the sources are not in-tree it will be disabled.
101 # Use --enable-spl-build or --disable-spl-build if you need to
102 # override this behavior.
104 AC_DEFUN([LB_SPL_BUILD],
106 AC_ARG_ENABLE([spl-build],
107 AC_HELP_STRING([--enable-spl-build], [enable spl configure/make]),
109 SPL_DIR_INTREE=$(readlink -f $PWD/spl)
110 if test x$SPL_DIR = x$SPL_DIR_INTREE; then
111 enable_spl_build='yes'
113 enable_spl_build='no'
117 AC_MSG_CHECKING([whether to build spl])
118 if test x$enable_spl_build = xyes; then
119 AC_MSG_RESULT([$enable_spl_build])
121 LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c], [], [
122 AC_MSG_ERROR([Complete spl source must exist when building.])])
124 LB_CHECK_FILE([$SPL_DIR/configure], [], [
125 AC_MSG_ERROR([Complete spl source must exist when building.])])
127 SPL_SUBDIR="$SPL_DIR"
129 AC_CONFIG_SUBDIRS("spl")
131 enable_spl_build='no'
132 AC_MSG_RESULT([$enable_spl_build])
139 AC_DEFUN([LB_SPL_SYMVERS],
141 AC_MSG_CHECKING([spl module symbols])
142 if test -r $SPL_OBJ/Module.symvers; then
143 SPL_SYMBOLS=Module.symvers
144 elif test -r $SPL_OBJ/Modules.symvers; then
145 SPL_SYMBOLS=Modules.symvers
146 elif test -r $SPL_OBJ/module/Module.symvers; then
147 SPL_SYMBOLS=Module.symvers
148 elif test -r $SPL_OBJ/module/Modules.symvers; then
149 SPL_SYMBOLS=Modules.symvers
151 SPL_SYMBOLS=$SYMVERFILE
154 AC_MSG_RESULT([$SPL_SYMBOLS])
155 AC_SUBST(SPL_SYMBOLS)
161 AC_DEFUN([LB_SPL_RELEASE],
163 AC_MSG_CHECKING([spl source release])
164 if test -r $SPL_OBJ/spl_config.h; then
165 tmp_flags="$EXTRA_KCFLAGS"
166 EXTRA_KCFLAGS="-I$SPL_DIR $EXTRA_KCFLAGS"
168 #include <$SPL_OBJ/spl_config.h>
171 SPL_RELEASE=SPL_META_VERSION;
173 $makerule LUSTRE_KERNEL_TEST=conftest.i
175 test -s build/conftest.i
177 eval $(grep "SPL_RELEASE=" build/conftest.i)
179 AC_MSG_RESULT([unknown])
180 AC_MSG_ERROR([Could not preprocess test program.])
182 EXTRA_KCFLAGS="$tmp_flags"
184 elif test -r $SPL_DIR/META; then
185 SPL_RELEASE=$(awk '/Version/ { print [$]2 }' $SPL_DIR/META)
187 AC_MSG_RESULT([unknown])
188 AC_MSG_ERROR([Could not locate spl_config.h or META to check release.])
191 if test x$SPL_RELEASE = x; then
192 AC_MSG_RESULT([unknown])
193 AC_MSG_ERROR([Could not determine spl release.])
196 AC_MSG_RESULT([$SPL_RELEASE])
197 AC_SUBST(SPL_RELEASE)
204 # --without-zfs - Disable zfs support.
207 # --with-zfs - Enable zfs support and attempt to autodetect the zfs
208 # --with-zfs=yes headers in one of the following places in this order:
210 # * /usr/src/zfs-*/$LINUXRELEASE
213 # --with-zfs=path - Enable zfs support and use the zfs headers in the
214 # provided path. No autodetection is performed.
216 # --with-zfs-obj - When zfs support is enabled the object directory
217 # will be based on the --with-zfs directory. If this
218 # is detected incorrectly it can be explicitly
219 # specified using this option.
221 # NOTE: As with all external packages zfs is expected to already be
222 # configured and built. However, if the zfs tree is located in-tree
223 # (./zfs) then it will be configured and built recursively as part of
224 # the lustre build system.
226 AC_DEFUN([LB_PATH_ZFS],
229 AC_HELP_STRING([--with-zfs=path], [set path to zfs sources]),
231 if test x$enable_server = xyes && test x$enable_dist = xno; then
247 if test -e "$zfs_src"; then
248 ZFS_DIR=$(readlink -f $zfs_src)
250 # Check /usr/src/zfs-*/$LINUXRELEASE
251 zfs_src=$(ls -1d /usr/src/zfs-*/$LINUXRELEASE \
253 if test -e "$zfs_src"; then
254 ZFS_DIR=$(readlink -f $zfs_src)
258 if test -e "$zfs_src"; then
259 ZFS_DIR=$(readlink -f $zfs_src)
261 # Disable zfs failed to detect sources
268 ZFS_DIR=$(readlink -f $with_zfs)
273 AC_MSG_CHECKING([whether to enable zfs])
274 AC_MSG_RESULT([$with_zfs])
276 if test x$with_zfs = xyes; then
277 AC_MSG_CHECKING([for location of zfs library headers])
278 if test -e "$ZFS_DIR/include/libzfs.h"; then
279 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/lib/libspl/include -I $ZFS_DIR/include"
280 AC_MSG_RESULT([$ZFS_DIR])
281 elif test -e "$ZFS_DIR/libzfs/libzfs.h"; then
282 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/libspl -I $ZFS_DIR/libzfs"
283 AC_MSG_RESULT([$ZFS_DIR])
284 elif test -e "/usr/include/libzfs/libzfs.h"; then
285 AC_MSG_RESULT([/usr/include])
286 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I /usr/include/libspl -I /usr/include/libzfs"
288 AC_MSG_RESULT([unknown])
289 AC_MSG_ERROR([Could not locate zfs library headers.])
291 AC_SUBST(EXTRA_LIBZFS_INCLUDE)
294 AC_ARG_WITH([zfs-obj],
295 AC_HELP_STRING([--with-zfs-obj=path], [set path to zfs objects]),
297 if test x$with_zfs = xyes; then
301 if test x$with_zfs = xyes; then
306 if test x$with_zfs = xyes; then
307 LB_ZFS_DEFINE_OPTIONS
309 AC_MSG_CHECKING([zfs source directory])
310 AC_MSG_RESULT([$ZFS_DIR])
313 AC_MSG_CHECKING([zfs object directory])
314 AC_MSG_RESULT([$ZFS_OBJ])
326 AM_CONDITIONAL(SPL_BUILD, test x$enable_spl_build = xyes)
327 AM_CONDITIONAL(ZFS_BUILD, test x$enable_zfs_build = xyes)
328 AM_CONDITIONAL(ZFS_ENABLED, test x$with_zfs = xyes)
334 # Optionally configure/make the zfs sources. If the sources are
335 # determined to reside in-tree this feature will automatically be
336 # enabled. If the sources are not in-tree it will be disabled.
337 # Use --enable-zfs-build or --disable-zfs-build if you need to
338 # override this behavior.
340 AC_DEFUN([LB_ZFS_BUILD],
342 AC_ARG_ENABLE([zfs-build],
343 AC_HELP_STRING([--enable-zfs-build], [enable zfs configure/make]),
345 ZFS_DIR_INTREE=$(readlink -f $PWD/zfs)
346 if test x$ZFS_DIR = x$ZFS_DIR_INTREE; then
347 enable_zfs_build='yes'
349 enable_zfs_build='no'
353 AC_MSG_CHECKING([whether to build zfs])
354 if test x$enable_zfs_build = xyes; then
355 AC_MSG_RESULT([$enable_zfs_build])
357 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c], [], [
358 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
360 LB_CHECK_FILE([$ZFS_DIR/configure], [], [
361 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
363 ZFS_SUBDIR="$ZFS_DIR"
365 AC_CONFIG_SUBDIRS("zfs")
367 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
368 ac_configure_args="$ac_configure_args --with-spl-obj=$SPL_OBJ"
370 enable_zfs_build='no'
371 AC_MSG_RESULT([$enable_zfs_build])
378 AC_DEFUN([LB_ZFS_SYMVERS],
380 AC_MSG_CHECKING([zfs module symbols])
381 if test -r $ZFS_OBJ/Module.symvers; then
382 ZFS_SYMBOLS=Module.symvers
383 elif test -r $ZFS_OBJ/Modules.symvers; then
384 ZFS_SYMBOLS=Modules.symvers
385 elif test -r $ZFS_OBJ/module/Module.symvers; then
386 ZFS_SYMBOLS=Module.symvers
387 elif test -r $ZFS_OBJ/module/Modules.symvers; then
388 ZFS_SYMBOLS=Modules.symvers
390 ZFS_SYMBOLS=$SYMVERFILE
393 AC_MSG_RESULT([$ZFS_SYMBOLS])
394 AC_SUBST(ZFS_SYMBOLS)
400 AC_DEFUN([LB_ZFS_RELEASE],
402 AC_MSG_CHECKING([zfs source release])
403 if test -r $ZFS_OBJ/zfs_config.h; then
404 tmp_flags="$EXTRA_KCFLAGS"
405 EXTRA_KCFLAGS="-I$ZFS_OBJ $EXTRA_KCFLAGS"
407 #include <$ZFS_OBJ/zfs_config.h>
410 ZFS_RELEASE=ZFS_META_VERSION;
412 $makerule LUSTRE_KERNEL_TEST=conftest.i
414 test -s build/conftest.i
416 eval $(grep "ZFS_RELEASE=" build/conftest.i)
418 AC_MSG_RESULT([unknown])
419 AC_MSG_ERROR([Could not preprocess test program.])
421 EXTRA_KCFLAGS="$tmp_flags"
423 elif test -r $ZFS_DIR/META; then
424 ZFS_RELEASE=$(awk '/Version/ { print [$]2 }' $ZFS_DIR/META)
426 AC_MSG_RESULT([unknown])
427 AC_MSG_ERROR([Could not locate zfs_config.h or META to check release.])
430 if test x$ZFS_RELEASE = x; then
431 AC_MSG_RESULT([unknown])
432 AC_MSG_ERROR([Could not determine zfs release.])
435 AC_MSG_RESULT([$ZFS_RELEASE])
436 AC_SUBST(ZFS_RELEASE)
440 # LB_ZFS_DEFINE_OPTIONS
442 AC_DEFUN([LB_ZFS_DEFINE_OPTIONS],
444 AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)