Whamcloud - gitweb
LU-7304 ldiskfs: fix bug when bigalloc is enabled
[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}/build
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}/build
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         splsrc0="/var/lib/dkms/spl/${splver}/build"
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 "${splsrc0}/spl.release.in"], [
84                         splsrc=${splsrc0}
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 -e "${splsrc}/${LINUXRELEASE}/spl_config.h"], [
113                         splobj="${splsrc}/${LINUXRELEASE}"
114                 ], [test -e "${splsrc}/spl_config.h"], [
115                         splobj="${splsrc}"
116                 ], [
117                         splobj="[Not found]"
118                 ])
119         ])
120         AC_MSG_RESULT([$splobj])
121
122         AS_IF([test ! -e "$splobj/spl_config.h"], [
123                 enable_zfs=no
124         ])
125
126         dnl #
127         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
128         dnl #
129         AS_IF([test x$enable_zfs = xyes], [
130                 AC_MSG_CHECKING([spl source version])
131                 AS_IF([fgrep -q SPL_META_VERSION $splobj/spl_config.h], [
132                         splver=$((echo "#include <spl_config.h>";
133                             echo "splver=SPL_META_VERSION-SPL_META_RELEASE") |
134                             cpp -I $splobj |
135                             grep "^splver=" | tr -d \" | cut -d= -f2)
136                 ], [
137                         splver="[Not found]"
138                         enable_zfs=no
139                 ])
140                 AC_MSG_RESULT([$splver])
141         ])
142
143         dnl #
144         dnl # Verify the modules systems exist by the expect name.
145         dnl #
146         AS_IF([test x$enable_zfs = xyes], [
147                 AC_MSG_CHECKING([spl file name for module symbols])
148                 AS_IF([test -r $splobj/$SYMVERFILE], [
149                         splsym=$SYMVERFILE
150                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/$SYMVERFILE"
151                 ], [test -r $splobj/module/$SYMVERFILE], [
152                         splsym=$SYMVERFILE
153                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/module/$SYMVERFILE"
154                 ], [
155                         splsym="[Not found]"
156                         enable_zfs=no
157                 ])
158                 AC_MSG_RESULT([$splsym])
159         ])
160
161         SPL=${splsrc}
162         SPL_OBJ=${splobj}
163         SPL_VERSION=${splver}
164
165         AC_SUBST(SPL)
166         AC_SUBST(SPL_OBJ)
167         AC_SUBST(SPL_VERSION)
168         AC_SUBST(EXTRA_SYMBOLS)
169 ])
170
171 AC_DEFUN([LB_ZFS], [
172         AC_ARG_WITH([zfs-obj],
173                 AS_HELP_STRING([--with-zfs-obj=PATH],
174                 [Path to zfs build objects]),
175                 [zfsobj="$withval"])
176
177         dnl #
178         dnl # The existence of zfs.release[.in] is used to identify a valid
179         dnl # source directory.  In order of preference:
180         dnl #
181         zfsver=$(ls -1 /usr/src/ | grep -m1 zfs | cut -f2 -d'-')
182         zfssrc0="/var/lib/dkms/zfs/${zfsver}/build"
183         zfssrc1="/usr/src/zfs-${zfsver}/${LINUXRELEASE}"
184         zfssrc2="/usr/src/zfs-${zfsver}"
185         zfssrc3="../zfs/"
186         zfssrc4="$LINUX"
187
188         AC_MSG_CHECKING([zfs source directory])
189         AS_IF([test -z "${zfssrc}"], [
190                 AS_IF([test -e "${zfssrc0}/zfs.release.in"], [
191                         zfssrc=${zfssrc0}
192                 ], [test -e "${zfssrc1}/zfs.release.in"], [
193                         zfssrc=${zfssrc1}
194                 ], [test -e "${zfssrc2}/zfs.release.in"], [
195                         zfssrc=${zfssrc2}
196                 ], [test -e "${zfssrc3}/zfs.release.in"], [
197                         zfssrc=$(readlink -f "${zfssrc3}")
198                 ], [test -e "${zfssrc4}/zfs.release.in"], [
199                         zfssrc=${zfssrc4}
200                 ], [
201                         zfssrc="[Not found]"
202                 ])
203         ])
204         AC_MSG_RESULT([$zfssrc])
205
206         AS_IF([test ! -e "$zfssrc/zfs.release.in" &&
207             test ! -e "$zfssrc/zfs.release"], [
208                 enable_zfs=no
209         ])
210
211         dnl #
212         dnl # The existence of the zfs_config.h is used to identify a valid
213         dnl # zfs object directory.  In many cases the object and source
214         dnl # directory are the same, however the objects may also reside
215         dnl # is a subdirectory named after the kernel version.
216         dnl #
217         AC_MSG_CHECKING([zfs build directory])
218         AS_IF([test -z "$zfsobj"], [
219                 AS_IF([test -e "${zfssrc}/${LINUXRELEASE}/zfs_config.h"], [
220                         zfsobj="${zfssrc}/${LINUXRELEASE}"
221                 ], [test -e "${zfssrc}/zfs_config.h"], [
222                         zfsobj="${zfssrc}"
223                 ], [
224                         zfsobj="[Not found]"
225                 ])
226         ])
227
228         AC_MSG_RESULT([$zfsobj])
229         AS_IF([test ! -e "$zfsobj/zfs_config.h"], [
230                 enable_zfs=no
231         ])
232
233         dnl #
234         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
235         dnl #
236         AS_IF([test x$enable_zfs = xyes], [
237                 AC_MSG_CHECKING([zfs source version])
238                 AS_IF([fgrep -q ZFS_META_VERSION $zfsobj/zfs_config.h], [
239                         zfsver=$((echo "#include <zfs_config.h>";
240                             echo "zfsver=ZFS_META_VERSION-ZFS_META_RELEASE") |
241                             cpp -I $zfsobj |
242                             grep "^zfsver=" | tr -d \" | cut -d= -f2)
243                 ],[
244                         zfsver="[Not found]"
245                         enable_zfs=no
246                 ])
247                 AC_MSG_RESULT([$zfsver])
248         ])
249
250         dnl #
251         dnl # Verify the modules systems exist by the expect name.
252         dnl #
253         AS_IF([test x$enable_zfs = xyes], [
254                 AC_MSG_CHECKING([zfs file name for module symbols])
255                 AS_IF([test -r $zfsobj/$SYMVERFILE], [
256                         zfssym=$SYMVERFILE
257                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/$SYMVERFILE"
258                 ], [test -r $zfsobj/module/$SYMVERFILE], [
259                         zfssym=$SYMVERFILE
260                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/module/$SYMVERFILE"
261                 ], [
262                         zfssym="[Not found]"
263                         enable_zfs=no
264                 ])
265                 AC_MSG_RESULT([$zfssym])
266         ])
267
268         ZFS=${zfssrc}
269         ZFS_OBJ=${zfsobj}
270         ZFS_VERSION=${zfsver}
271
272         AC_SUBST(ZFS)
273         AC_SUBST(ZFS_OBJ)
274         AC_SUBST(ZFS_VERSION)
275         AC_SUBST(EXTRA_SYMBOLS)
276 ])
277
278 AC_DEFUN([LB_ZFS_DEVEL], [
279         AC_ARG_WITH([zfs-devel],
280                 [AS_HELP_STRING([--with-zfs-devel=PATH],
281                 [Path to zfs development headers])],
282                 [zfsdevel="$withval"])
283
284         AC_MSG_CHECKING([user provided zfs devel headers])
285         AS_IF([test ! -z "${zfsdevel}"], [
286                 AS_IF([test -d "${zfsdevel}/usr/include/libspl" && test -d "${zfsdevel}/usr/include/libzfs"], [
287                         zfsinc="-I $zfsdevel/usr/include/libspl -I $zfsdevel/usr/include/libzfs"
288                         zfslib="-L$zfsdevel/usr/lib64 -L$zfsdevel/usr/lib -L$zfsdevel/lib64 -L$zfsdevel/lib"
289                 ], [
290                         AC_MSG_ERROR([Path to development headers directory does not exist])
291                 ])
292         ])
293         AC_MSG_RESULT([$zfsinc])
294 ])
295
296 AC_DEFUN([LB_ZFS_USER], [
297         dnl #
298         dnl # Detect user space zfs development headers.
299         dnl #
300         AC_MSG_CHECKING([zfs devel headers])
301         AS_IF([test -z "${zfsinc}"], [
302                 AS_IF([test -e "${zfssrc}/include/libzfs.h" && test -e "${zfssrc}/lib/libspl/include"], [
303                         zfsinc="-I $zfssrc/lib/libspl/include -I $zfssrc/include"
304                         zfslib="-L$zfssrc/lib/libzfs/.libs/"
305                 ], [test -d /usr/include/libzfs && test -d /usr/include/libspl], [
306                         zfsinc="-I/usr/include/libspl -I /usr/include/libzfs"
307                         zfslib=""
308                 ], [
309                         zfsinc="[Not Found]"
310                         zfslib=""
311                         enable_zfs=no
312                 ])
313         ])
314         AC_MSG_RESULT([$zfsinc])
315
316         ZFS_LIBZFS_INCLUDE=${zfsinc}
317         ZFS_LIBZFS_LDFLAGS="-lzfs ${zfslib}"
318         AC_SUBST(ZFS_LIBZFS_INCLUDE)
319         AC_SUBST(ZFS_LIBZFS_LDFLAGS)
320 ])
321
322 AC_DEFUN([LB_CONFIG_ZFS], [
323         AC_ARG_WITH([zfs],
324                 [AS_HELP_STRING([--with-zfs=PATH], [Path to zfs source])],
325                 [
326                         AS_IF([test x$withval = xno], [
327                                 enable_zfs=no
328                                 require_zfs=no
329                         ], [test x$withval = xyes], [
330                                 enable_zfs=yes
331                                 require_zfs=yes
332                         ], [
333                                 enable_zfs=yes
334                                 require_zfs=yes
335                                 zfssrc="$withval"
336                         ])
337                 ], [
338                         AS_IF([test x$enable_server != xno], [
339                                 require_zfs=no
340                                 enable_zfs=yes
341                         ], [
342                                 require_zfs=no
343                                 enable_zfs=no
344                         ])
345                 ])
346
347         AC_MSG_CHECKING([whether to enable zfs])
348         AC_MSG_RESULT([$enable_zfs])
349
350         AS_IF([test x$enable_zfs = xyes], [
351                 AS_IF([test x$enable_modules = xyes], [
352                         LB_SPL
353                         LB_ZFS
354                 ])
355                 LB_ZFS_DEVEL
356                 LB_ZFS_USER
357
358                 dnl #
359                 dnl # enable_zfs will be set to no in LB_SPL or LB_ZFS if
360                 dnl # one of more of the build requirements is not met.
361                 dnl #
362                 AS_IF([test x$enable_zfs = xyes], [
363                         AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)
364                 ],[
365                         AS_IF([test x$require_zfs = xyes], [
366                                 AC_MSG_ERROR([
367
368 Required zfs osd cannot be built due to missing zfs development headers.
369
370 Support for zfs can be enabled by downloading the required packages for your
371 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
372 your distribution.
373                                 ])
374                         ], [
375                                 AC_MSG_WARN([
376
377 Disabling optional zfs osd due to missing development headers.
378
379 Support for zfs can be enabled by downloading the required packages for your
380 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
381 your distribution.
382                                 ])
383                         ])
384                 ])
385         ])
386
387         AS_IF([test "x$enable_zfs" = xyes], [
388                 LB_CHECK_COMPILE([if zfs defines dsl_pool_config_enter/exit],
389                 dsl_pool_config_enter, [
390                         #include <sys/dsl_pool.h>
391                 ],[
392                         dsl_pool_config_enter(NULL, FTAG);
393                 ],[
394                         AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1,
395                                 [Have dsl_pool_config_enter/exit in ZFS])
396                 ])
397                 LB_CHECK_COMPILE([if zfs defines dsl_sync_task_do_nowait],
398                 dsl_sync_task_do_nowait, [
399                         #include <sys/dsl_synctask.h>
400                 ],[
401                         dsl_sync_task_do_nowait(NULL, NULL, NULL, NULL, NULL, 0, NULL);
402                 ],[
403                         AC_DEFINE(HAVE_DSL_SYNC_TASK_DO_NOWAIT, 1,
404                                 [Have dsl_sync_task_do_nowait in ZFS])
405                 ])
406                 LB_CHECK_COMPILE([if zfs defines sa_spill_alloc],
407                 sa_spill_alloc, [
408                         #include <sys/kmem.h>
409                         #include <sys/sa.h>
410                 ],[
411                         void *ptr;
412
413                         ptr = sa_spill_alloc(KM_SLEEP);
414                         sa_spill_free(ptr);
415                 ],[
416                         AC_DEFINE(HAVE_SA_SPILL_ALLOC, 1,
417                                 [Have sa_spill_alloc in ZFS])
418                 ])
419                 LB_CHECK_COMPILE([if zfs defines spa_maxblocksize],
420                 spa_maxblocksize, [
421                         #include <sys/spa.h>
422                 ],[
423                         spa_t *spa = NULL;
424                         int size;
425
426                         size = spa_maxblocksize(spa);
427                 ],[
428                         AC_DEFINE(HAVE_SPA_MAXBLOCKSIZE, 1,
429                                 [Have spa_maxblocksize in ZFS])
430                 ])
431         ])
432
433         AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
434 ])