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
269 ZFS_DIR=$(readlink -f $with_zfs)
274 AC_MSG_CHECKING([whether to enable zfs])
275 AC_MSG_RESULT([$with_zfs])
277 AC_ARG_WITH([zfs-obj],
278 AC_HELP_STRING([--with-zfs-obj=path], [set path to zfs objects]),
280 if test x$with_zfs = xyes; then
284 if test x$with_zfs = xyes; then
289 if test x$with_zfs = xyes; then
290 LB_ZFS_DEFINE_OPTIONS
292 AC_MSG_CHECKING([zfs source directory])
293 AC_MSG_RESULT([$ZFS_DIR])
296 AC_MSG_CHECKING([zfs object directory])
297 AC_MSG_RESULT([$ZFS_OBJ])
310 AM_CONDITIONAL(SPL_BUILD, test x$enable_spl_build = xyes)
311 AM_CONDITIONAL(ZFS_BUILD, test x$enable_zfs_build = xyes)
312 AM_CONDITIONAL(ZFS_ENABLED, test x$with_zfs = xyes)
318 # Optionally configure/make the zfs sources. If the sources are
319 # determined to reside in-tree this feature will automatically be
320 # enabled. If the sources are not in-tree it will be disabled.
321 # Use --enable-zfs-build or --disable-zfs-build if you need to
322 # override this behavior.
324 AC_DEFUN([LB_ZFS_BUILD],
326 AC_ARG_ENABLE([zfs-build],
327 AC_HELP_STRING([--enable-zfs-build], [enable zfs configure/make]),
329 ZFS_DIR_INTREE=$(readlink -f $PWD/zfs)
330 if test x$ZFS_DIR = x$ZFS_DIR_INTREE; then
331 enable_zfs_build='yes'
333 enable_zfs_build='no'
337 AC_MSG_CHECKING([whether to build zfs])
338 if test x$enable_zfs_build = xyes; then
339 AC_MSG_RESULT([$enable_zfs_build])
341 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c], [], [
342 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
344 LB_CHECK_FILE([$ZFS_DIR/configure], [], [
345 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
347 ZFS_SUBDIR="$ZFS_DIR"
349 AC_CONFIG_SUBDIRS("zfs")
351 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
352 ac_configure_args="$ac_configure_args --with-spl-obj=$SPL_OBJ"
354 enable_zfs_build='no'
355 AC_MSG_RESULT([$enable_zfs_build])
362 AC_DEFUN([LB_ZFS_SYMVERS],
364 AC_MSG_CHECKING([zfs module symbols])
365 if test -r $ZFS_OBJ/Module.symvers; then
366 ZFS_SYMBOLS=Module.symvers
367 elif test -r $ZFS_OBJ/Modules.symvers; then
368 ZFS_SYMBOLS=Modules.symvers
369 elif test -r $ZFS_OBJ/module/Module.symvers; then
370 ZFS_SYMBOLS=Module.symvers
371 elif test -r $ZFS_OBJ/module/Modules.symvers; then
372 ZFS_SYMBOLS=Modules.symvers
374 ZFS_SYMBOLS=$SYMVERFILE
377 AC_MSG_RESULT([$ZFS_SYMBOLS])
378 AC_SUBST(ZFS_SYMBOLS)
384 AC_DEFUN([LB_ZFS_RELEASE],
386 AC_MSG_CHECKING([zfs source release])
387 if test -r $ZFS_OBJ/zfs_config.h; then
388 tmp_flags="$EXTRA_KCFLAGS"
389 EXTRA_KCFLAGS="-I$ZFS_DIR $EXTRA_KCFLAGS"
391 #include <$ZFS_OBJ/zfs_config.h>
394 ZFS_RELEASE=ZFS_META_VERSION;
396 $makerule LUSTRE_KERNEL_TEST=conftest.i
398 test -s build/conftest.i
400 eval $(grep "ZFS_RELEASE=" build/conftest.i)
402 AC_MSG_RESULT([unknown])
403 AC_MSG_ERROR([Could not preprocess test program.])
405 EXTRA_KCFLAGS="$tmp_flags"
407 elif test -r $ZFS_DIR/META; then
408 ZFS_RELEASE=$(awk '/Version/ { print [$]2 }' $ZFS_DIR/META)
410 AC_MSG_RESULT([unknown])
411 AC_MSG_ERROR([Could not locate zfs_config.h or META to check release.])
414 if test x$ZFS_RELEASE = x; then
415 AC_MSG_RESULT([unknown])
416 AC_MSG_ERROR([Could not determine zfs release.])
419 AC_MSG_RESULT([$ZFS_RELEASE])
420 AC_SUBST(ZFS_RELEASE)
424 # LB_ZFS_DEFINE_OPTIONS
426 AC_DEFUN([LB_ZFS_DEFINE_OPTIONS],
428 AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)