Whamcloud - gitweb
LU-6684 lfsck: set the lfsck notify as interruptable
[fs/lustre-release.git] / config / lustre-build-zfs.m4
1 dnl #
2 dnl # Supported configure options.  When no options are specified support
3 dnl # for ZFS OSDs will be autodetected assuming server support is enabled.
4 dnl # If the ZFS OSD cannot be built support for it is disabled and a
5 dnl # warning is issued but the configure process is allowed to continue.
6 dnl #
7 dnl # --without-zfs   - Disable zfs support.
8 dnl # --with-zfs=no
9 dnl #
10 dnl # --with-zfs      - Enable zfs support and attempt to autodetect the zfs
11 dnl # --with-zfs=yes    headers in one of the following places.  Because zfs
12 dnl #                   support was explicitly required if the headers cannot
13 dnl #                   be located it is treated as a fatal error.
14 dnl #
15 dnl #                       * /var/lib/dkms/zfs/${VERSION}/source
16 dnl #                       * /usr/src/zfs-${VERSION}/${LINUXRELEASE}
17 dnl #                       * /usr/src/zfs-${VERSION}
18 dnl #                       * ../spl/
19 dnl #                       * $LINUX
20 dnl #
21 dnl # --with-zfs-devel=path
22 dnl #                 - User provided directory where zfs development headers
23 dnl #                   are located. This option is typically used when user
24 dnl #                   uses rpm2cpio to unpack src rpm.
25 dnl #                   Assumes layout of:
26 dnl #                     ${zfs-devel-path}/usr/include/libzfs
27 dnl #                     ${zfs-devel-path}/usr/include/libspl
28 dnl #                     ${zfs-devel-path}/lib64/libzfs.so.* or
29 dnl #                     ${zfs-devel-path}/lib/libzfs.so.*
30 dnl #
31 dnl # --with-zfs=path - Enable zfs support and use the zfs headers in the
32 dnl #                   provided path.  No autodetection is performed and
33 dnl #                   if no headers are found this is a fatal error.
34 dnl #
35 dnl # --with-zfs-obj  - When zfs support is enabled the object directory
36 dnl #                   will be based on the --with-zfs directory.  If this
37 dnl #                   is detected incorrectly it can be explicitly
38 dnl #                   specified using this option.
39 dnl #
40 dnl # --without-spl   - Disable spl support.
41 dnl # --with-spl=no
42 dnl #
43 dnl # --with-spl      - Enable spl support and attempt to autodetect the spl
44 dnl # --with-spl=yes    headers in one of the following places in this order:
45 dnl #                   * /var/lib/dkms/spl/${VERSION}/source
46 dnl #                   * /usr/src/spl-${VERSION}/${LINUXRELEASE}
47 dnl #                   * /usr/src/spl-${VERSION}
48 dnl #                   * ../spl/
49 dnl #                   * $LINUX
50 dnl #
51 dnl # --with-spl=path - Enable spl support and use the spl headers in the
52 dnl #                   provided path.  No autodetection is performed.
53 dnl #
54 dnl # --with-spl-obj  - When spl support is enabled the object directory
55 dnl #                   will be based on the --with-spl directory.  If this
56 dnl #                   is detected incorrectly it can be explicitly
57 dnl #                   specified using this option.
58 dnl #
59 AC_DEFUN([LB_SPL], [
60         AC_ARG_WITH([spl],
61                 AS_HELP_STRING([--with-spl=PATH],
62                 [Path to spl source]),
63                 [splsrc="$withval"])
64
65         AC_ARG_WITH([spl-obj],
66                 AS_HELP_STRING([--with-spl-obj=PATH],
67                 [Path to spl build objects]),
68                 [splobj="$withval"])
69
70         dnl #
71         dnl # The existence of spl.release[.in] is used to identify a valid
72         dnl # source directory.  In order of preference:
73         dnl #
74         splver=$(ls -1 /usr/src/ | grep -m1 spl | cut -f2 -d'-')
75         spldkms="/var/lib/dkms/spl/${splver}"
76         splsrc1="/usr/src/spl-${splver}/${LINUXRELEASE}"
77         splsrc2="/usr/src/spl-${splver}"
78         splsrc3="../spl/"
79         splsrc4="$LINUX"
80
81         AC_MSG_CHECKING([spl source directory])
82         AS_IF([test -z "${splsrc}"], [
83                 AS_IF([test -e "${spldkms}/source/spl.release.in"], [
84                         splsrc=${spldkms}/source
85                 ], [test -e "${splsrc1}/spl.release.in"], [
86                         splsrc=${splsrc1}
87                 ], [test -e "${splsrc2}/spl.release.in"], [
88                         splsrc=${splsrc2}
89                 ], [test -e "${splsrc3}/spl.release.in"], [
90                         splsrc=$(readlink -f "${splsrc3}")
91                 ], [test -e "${splsrc4}/spl.release.in"], [
92                         splsrc=${splsrc4}
93                 ], [
94                         splsrc="[Not found]"
95                 ])
96         ])
97         AC_MSG_RESULT([$splsrc])
98
99         AS_IF([test ! -e "$splsrc/spl.release" &&
100             test ! -e "$splsrc/spl.release.in"], [
101                 enable_zfs=no
102         ])
103
104         dnl #
105         dnl # The existence of the spl_config.h is used to identify a valid
106         dnl # spl object directory.  In many cases the object and source
107         dnl # directory are the same, however the objects may also reside
108         dnl # is a subdirectory named after the kernel version.
109         dnl #
110         AC_MSG_CHECKING([spl build directory])
111         AS_IF([test -z "$splobj"], [
112                 AS_IF([test "${splsrc}" = "${spldkms}/source"], [
113                         AS_IF([test -e "${spldkms}/${LINUXRELEASE}/${target_cpu}/spl_config.h"], [
114                                 splobj=${spldkms}/${LINUXRELEASE}/${target_cpu}
115                         ], [
116                                 splobj="[Not found]"
117                         ])
118                 ],[test -e "${splsrc}/${LINUXRELEASE}/spl_config.h"], [
119                         splobj="${splsrc}/${LINUXRELEASE}"
120                 ], [test -e "${splsrc}/spl_config.h"], [
121                         splobj="${splsrc}"
122                 ], [
123                         splobj="[Not found]"
124                 ])
125         ])
126         AC_MSG_RESULT([$splobj])
127
128         AS_IF([test ! -e "$splobj/spl_config.h"], [
129                 enable_zfs=no
130         ])
131
132         dnl #
133         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
134         dnl #
135         AS_IF([test x$enable_zfs = xyes], [
136                 AC_MSG_CHECKING([spl source version])
137                 AS_IF([fgrep -q SPL_META_VERSION $splobj/spl_config.h], [
138                         splver=$((echo "#include <spl_config.h>";
139                             echo "splver=SPL_META_VERSION-SPL_META_RELEASE") |
140                             cpp -I $splobj |
141                             grep "^splver=" | tr -d \" | cut -d= -f2)
142                 ], [
143                         splver="[Not found]"
144                         enable_zfs=no
145                 ])
146                 AC_MSG_RESULT([$splver])
147         ])
148
149         dnl #
150         dnl # Verify the modules systems exist by the expect name.
151         dnl #
152         AS_IF([test x$enable_zfs = xyes], [
153                 AC_MSG_CHECKING([spl file name for module symbols])
154                 AS_IF([test -r $splobj/$SYMVERFILE], [
155                         splsym=$SYMVERFILE
156                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/$SYMVERFILE"
157                 ], [test -r $splobj/module/$SYMVERFILE], [
158                         splsym=$SYMVERFILE
159                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/module/$SYMVERFILE"
160                 ], [
161                         splsym="[Not found]"
162                         enable_zfs=no
163                 ])
164                 AC_MSG_RESULT([$splsym])
165         ])
166
167         SPL=${splsrc}
168         SPL_OBJ=${splobj}
169         SPL_VERSION=${splver}
170
171         AC_SUBST(SPL)
172         AC_SUBST(SPL_OBJ)
173         AC_SUBST(SPL_VERSION)
174         AC_SUBST(EXTRA_SYMBOLS)
175 ])
176
177 AC_DEFUN([LB_ZFS], [
178         AC_ARG_WITH([zfs-obj],
179                 AS_HELP_STRING([--with-zfs-obj=PATH],
180                 [Path to zfs build objects]),
181                 [zfsobj="$withval"])
182
183         dnl #
184         dnl # The existence of zfs.release[.in] is used to identify a valid
185         dnl # source directory.  In order of preference:
186         dnl #
187         zfsver=$(ls -1 /usr/src/ | grep -m1 zfs | cut -f2 -d'-')
188         zfsdkms="/var/lib/dkms/zfs/${zfsver}"
189         zfssrc1="/usr/src/zfs-${zfsver}/${LINUXRELEASE}"
190         zfssrc2="/usr/src/zfs-${zfsver}"
191         zfssrc3="../zfs/"
192         zfssrc4="$LINUX"
193
194         AC_MSG_CHECKING([zfs source directory])
195         AS_IF([test -z "${zfssrc}"], [
196                 AS_IF([test -e "${zfsdkms}/source/zfs.release.in"], [
197                         zfssrc=${zfsdkms}/source
198                 ], [test -e "${zfssrc1}/zfs.release.in"], [
199                         zfssrc=${zfssrc1}
200                 ], [test -e "${zfssrc2}/zfs.release.in"], [
201                         zfssrc=${zfssrc2}
202                 ], [test -e "${zfssrc3}/zfs.release.in"], [
203                         zfssrc=$(readlink -f "${zfssrc3}")
204                 ], [test -e "${zfssrc4}/zfs.release.in"], [
205                         zfssrc=${zfssrc4}
206                 ], [
207                         zfssrc="[Not found]"
208                 ])
209         ])
210         AC_MSG_RESULT([$zfssrc])
211
212         AS_IF([test ! -e "$zfssrc/zfs.release.in" &&
213             test ! -e "$zfssrc/zfs.release"], [
214                 enable_zfs=no
215         ])
216
217         dnl #
218         dnl # The existence of the zfs_config.h is used to identify a valid
219         dnl # zfs object directory.  In many cases the object and source
220         dnl # directory are the same, however the objects may also reside
221         dnl # is a subdirectory named after the kernel version.
222         dnl #
223         AC_MSG_CHECKING([zfs build directory])
224         AS_IF([test -z "$zfsobj"], [
225                 AS_IF([test "${zfssrc}" = "${zfsdkms}/source"], [
226                         AS_IF([test -e "${zfsdkms}/${LINUXRELEASE}/${target_cpu}/zfs_config.h"], [
227                                 zfsobj=${zfsdkms}/${LINUXRELEASE}/${target_cpu}
228                         ], [
229                                 zfsobj="[Not found]"
230                         ])
231                 ], [test -e "${zfssrc}/${LINUXRELEASE}/zfs_config.h"], [
232                         zfsobj="${zfssrc}/${LINUXRELEASE}"
233                 ], [test -e "${zfssrc}/zfs_config.h"], [
234                         zfsobj="${zfssrc}"
235                 ], [
236                         zfsobj="[Not found]"
237                 ])
238         ])
239
240         AC_MSG_RESULT([$zfsobj])
241         AS_IF([test ! -e "$zfsobj/zfs_config.h"], [
242                 enable_zfs=no
243         ])
244
245         dnl #
246         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
247         dnl #
248         AS_IF([test x$enable_zfs = xyes], [
249                 AC_MSG_CHECKING([zfs source version])
250                 AS_IF([fgrep -q ZFS_META_VERSION $zfsobj/zfs_config.h], [
251                         zfsver=$((echo "#include <zfs_config.h>";
252                             echo "zfsver=ZFS_META_VERSION-ZFS_META_RELEASE") |
253                             cpp -I $zfsobj |
254                             grep "^zfsver=" | tr -d \" | cut -d= -f2)
255                 ],[
256                         zfsver="[Not found]"
257                         enable_zfs=no
258                 ])
259                 AC_MSG_RESULT([$zfsver])
260         ])
261
262         dnl #
263         dnl # Verify the modules systems exist by the expect name.
264         dnl #
265         AS_IF([test x$enable_zfs = xyes], [
266                 AC_MSG_CHECKING([zfs file name for module symbols])
267                 AS_IF([test -r $zfsobj/$SYMVERFILE], [
268                         zfssym=$SYMVERFILE
269                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/$SYMVERFILE"
270                 ], [test -r $zfsobj/module/$SYMVERFILE], [
271                         zfssym=$SYMVERFILE
272                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/module/$SYMVERFILE"
273                 ], [
274                         zfssym="[Not found]"
275                         enable_zfs=no
276                 ])
277                 AC_MSG_RESULT([$zfssym])
278         ])
279
280         ZFS=${zfssrc}
281         ZFS_OBJ=${zfsobj}
282         ZFS_VERSION=${zfsver}
283
284         AC_SUBST(ZFS)
285         AC_SUBST(ZFS_OBJ)
286         AC_SUBST(ZFS_VERSION)
287         AC_SUBST(EXTRA_SYMBOLS)
288 ])
289
290 AC_DEFUN([LB_ZFS_DEVEL], [
291         AC_ARG_WITH([zfs-devel],
292                 [AS_HELP_STRING([--with-zfs-devel=PATH],
293                 [Path to zfs development headers])],
294                 [zfsdevel="$withval"])
295
296         AC_MSG_CHECKING([user provided zfs devel headers])
297         AS_IF([test ! -z "${zfsdevel}"], [
298                 AS_IF([test -d "${zfsdevel}/usr/include/libspl" && test -d "${zfsdevel}/usr/include/libzfs"], [
299                         zfsinc="-I $zfsdevel/usr/include/libspl -I $zfsdevel/usr/include/libzfs"
300                         zfslib="-L$zfsdevel/usr/lib64 -L$zfsdevel/usr/lib -L$zfsdevel/lib64 -L$zfsdevel/lib"
301                 ], [
302                         AC_MSG_ERROR([Path to development headers directory does not exist])
303                 ])
304         ])
305         AC_MSG_RESULT([$zfsinc])
306 ])
307
308 AC_DEFUN([LB_ZFS_USER], [
309         dnl #
310         dnl # Detect user space zfs development headers.
311         dnl #
312         AC_MSG_CHECKING([zfs devel headers])
313         AS_IF([test -z "${zfsinc}"], [
314                 AS_IF([test -e "${zfssrc}/include/libzfs.h" && test -e "${zfssrc}/lib/libspl/include"], [
315                         zfsinc="-I $zfssrc/lib/libspl/include -I $zfssrc/include"
316                         zfslib="-L$zfssrc/lib/libzfs/.libs/"
317                 ], [test -d /usr/include/libzfs && test -d /usr/include/libspl], [
318                         zfsinc="-I/usr/include/libspl -I /usr/include/libzfs"
319                         zfslib=""
320                 ], [
321                         zfsinc="[Not Found]"
322                         zfslib=""
323                         enable_zfs=no
324                 ])
325         ])
326         AC_MSG_RESULT([$zfsinc])
327
328         ZFS_LIBZFS_INCLUDE=${zfsinc}
329         ZFS_LIBZFS_LDFLAGS="-lzfs ${zfslib}"
330         AC_SUBST(ZFS_LIBZFS_INCLUDE)
331         AC_SUBST(ZFS_LIBZFS_LDFLAGS)
332 ])
333
334 AC_DEFUN([LB_CONFIG_ZFS], [
335         AC_ARG_WITH([zfs],
336                 [AS_HELP_STRING([--with-zfs=PATH], [Path to zfs source])],
337                 [
338                         AS_IF([test x$withval = xno], [
339                                 enable_zfs=no
340                                 require_zfs=no
341                         ], [test x$withval = xyes], [
342                                 enable_zfs=yes
343                                 require_zfs=yes
344                         ], [
345                                 enable_zfs=yes
346                                 require_zfs=yes
347                                 zfssrc="$withval"
348                         ])
349                 ], [
350                         AS_IF([test x$enable_server != xno], [
351                                 require_zfs=no
352                                 enable_zfs=yes
353                         ], [
354                                 require_zfs=no
355                                 enable_zfs=no
356                         ])
357                 ])
358
359         AC_MSG_CHECKING([whether to enable zfs])
360         AC_MSG_RESULT([$enable_zfs])
361
362         AS_IF([test x$enable_zfs = xyes], [
363                 AS_IF([test x$enable_modules = xyes], [
364                         LB_SPL
365                         LB_ZFS
366                 ])
367                 LB_ZFS_DEVEL
368                 LB_ZFS_USER
369
370                 dnl #
371                 dnl # enable_zfs will be set to no in LB_SPL or LB_ZFS if
372                 dnl # one of more of the build requirements is not met.
373                 dnl #
374                 AS_IF([test x$enable_zfs = xyes], [
375                         AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)
376                 ],[
377                         AS_IF([test x$require_zfs = xyes], [
378                                 AC_MSG_ERROR([
379
380 Required zfs osd cannot be built due to missing zfs development headers.
381
382 Support for zfs can be enabled by downloading the required packages for your
383 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
384 your distribution.
385                                 ])
386                         ], [
387                                 AC_MSG_WARN([
388
389 Disabling optional zfs osd due to missing development headers.
390
391 Support for zfs can be enabled by downloading the required packages for your
392 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
393 your distribution.
394                                 ])
395                         ])
396                 ])
397         ])
398
399         AS_IF([test "x$enable_zfs" = xyes], [
400                 LB_CHECK_COMPILE([if zfs defines dsl_pool_config_enter/exit],
401                 dsl_pool_config_enter, [
402                         #include <sys/dsl_pool.h>
403                 ],[
404                         dsl_pool_config_enter(NULL, FTAG);
405                 ],[
406                         AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1,
407                                 [Have dsl_pool_config_enter/exit in ZFS])
408                 ])
409                 LB_CHECK_COMPILE([if zfs defines dsl_sync_task_do_nowait],
410                 dsl_sync_task_do_nowait, [
411                         #include <sys/dsl_synctask.h>
412                 ],[
413                         dsl_sync_task_do_nowait(NULL, NULL, NULL, NULL, NULL, 0, NULL);
414                 ],[
415                         AC_DEFINE(HAVE_DSL_SYNC_TASK_DO_NOWAIT, 1,
416                                 [Have dsl_sync_task_do_nowait in ZFS])
417                 ])
418                 LB_CHECK_COMPILE([if zfs defines sa_spill_alloc],
419                 sa_spill_alloc, [
420                         #include <sys/kmem.h>
421                         #include <sys/sa.h>
422                 ],[
423                         void *ptr;
424
425                         ptr = sa_spill_alloc(KM_SLEEP);
426                         sa_spill_free(ptr);
427                 ],[
428                         AC_DEFINE(HAVE_SA_SPILL_ALLOC, 1,
429                                 [Have sa_spill_alloc in ZFS])
430                 ])
431                 LB_CHECK_COMPILE([if zfs defines spa_maxblocksize],
432                 spa_maxblocksize, [
433                         #include <sys/spa.h>
434                 ],[
435                         spa_t *spa = NULL;
436                         int size;
437
438                         size = spa_maxblocksize(spa);
439                 ],[
440                         AC_DEFINE(HAVE_SPA_MAXBLOCKSIZE, 1,
441                                 [Have spa_maxblocksize in ZFS])
442                 ])
443         ])
444
445         AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
446 ])