Whamcloud - gitweb
LU-4442 tests: update version number in replay-vbr test 7g
[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 #
26 dnl # --with-zfs=path - Enable zfs support and use the zfs headers in the
27 dnl #                   provided path.  No autodetection is performed and
28 dnl #                   if no headers are found this is a fatal error.
29 dnl #
30 dnl # --with-zfs-obj  - When zfs support is enabled the object directory
31 dnl #                   will be based on the --with-zfs directory.  If this
32 dnl #                   is detected incorrectly it can be explicitly
33 dnl #                   specified using this option.
34 dnl #
35 dnl # --without-spl   - Disable spl support.
36 dnl # --with-spl=no
37 dnl #
38 dnl # --with-spl      - Enable spl support and attempt to autodetect the spl
39 dnl # --with-spl=yes    headers in one of the following places in this order:
40 dnl #                   * /var/lib/dkms/spl/${VERSION}/build
41 dnl #                   * /usr/src/spl-${VERSION}/${LINUXRELEASE}
42 dnl #                   * /usr/src/spl-${VERSION}
43 dnl #                   * ../spl/
44 dnl #                   * $LINUX
45 dnl #
46 dnl # --with-spl=path - Enable spl support and use the spl headers in the
47 dnl #                   provided path.  No autodetection is performed.
48 dnl #
49 dnl # --with-spl-obj  - When spl support is enabled the object directory
50 dnl #                   will be based on the --with-spl directory.  If this
51 dnl #                   is detected incorrectly it can be explicitly
52 dnl #                   specified using this option.
53 dnl #
54 AC_DEFUN([LB_SPL], [
55         AC_ARG_WITH([spl],
56                 AS_HELP_STRING([--with-spl=PATH],
57                 [Path to spl source]),
58                 [splsrc="$withval"])
59
60         AC_ARG_WITH([spl-obj],
61                 AS_HELP_STRING([--with-spl-obj=PATH],
62                 [Path to spl build objects]),
63                 [splobj="$withval"])
64
65         dnl #
66         dnl # The existence of spl.release[.in] is used to identify a valid
67         dnl # source directory.  In order of preference:
68         dnl #
69         splver=$(ls -1 /usr/src/ | grep -m1 spl | cut -f2 -d'-')
70         splsrc0="/var/lib/dkms/spl/${splver}/build"
71         splsrc1="/usr/src/spl-${splver}/${LINUXRELEASE}"
72         splsrc2="/usr/src/spl-${splver}"
73         splsrc3="../spl/"
74         splsrc4="$LINUX"
75
76         AC_MSG_CHECKING([spl source directory])
77         AS_IF([test -z "${splsrc}"], [
78                 AS_IF([test -e "${splsrc0}/spl.release.in"], [
79                         splsrc=${splsrc0}
80                 ], [test -e "${splsrc1}/spl.release.in"], [
81                         splsrc=${splsrc1}
82                 ], [test -e "${splsrc2}/spl.release.in"], [
83                         splsrc=${splsrc2}
84                 ], [test -e "${splsrc3}/spl.release.in"], [
85                         splsrc=$(readlink -f "${splsrc3}")
86                 ], [test -e "${splsrc4}/spl.release.in"], [
87                         splsrc=${splsrc4}
88                 ], [
89                         splsrc="[Not found]"
90                 ])
91         ])
92         AC_MSG_RESULT([$splsrc])
93
94         AS_IF([test ! -e "$splsrc/spl.release" &&
95             test ! -e "$splsrc/spl.release.in"], [
96                 enable_zfs=no
97         ])
98
99         dnl #
100         dnl # The existence of the spl_config.h is used to identify a valid
101         dnl # spl object directory.  In many cases the object and source
102         dnl # directory are the same, however the objects may also reside
103         dnl # is a subdirectory named after the kernel version.
104         dnl #
105         AC_MSG_CHECKING([spl build directory])
106         AS_IF([test -z "$splobj"], [
107                 AS_IF([test -e "${splsrc}/${LINUXRELEASE}/spl_config.h"], [
108                         splobj="${splsrc}/${LINUXRELEASE}"
109                 ], [test -e "${splsrc}/spl_config.h"], [
110                         splobj="${splsrc}"
111                 ], [
112                         splobj="[Not found]"
113                 ])
114         ])
115         AC_MSG_RESULT([$splobj])
116
117         AS_IF([test ! -e "$splobj/spl_config.h"], [
118                 enable_zfs=no
119         ])
120
121         dnl #
122         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
123         dnl #
124         AS_IF([test x$enable_zfs = xyes], [
125                 AC_MSG_CHECKING([spl source version])
126                 AS_IF([fgrep -q SPL_META_VERSION $splobj/spl_config.h], [
127                         splver=$((echo "#include <spl_config.h>";
128                             echo "splver=SPL_META_VERSION-SPL_META_RELEASE") |
129                             cpp -I $splobj |
130                             grep "^splver=" | tr -d \" | cut -d= -f2)
131                 ], [
132                         splver="[Not found]"
133                         enable_zfs=no
134                 ])
135                 AC_MSG_RESULT([$splver])
136         ])
137
138         dnl #
139         dnl # Verify the modules systems exist by the expect name.
140         dnl #
141         AS_IF([test x$enable_zfs = xyes], [
142                 AC_MSG_CHECKING([spl file name for module symbols])
143                 AS_IF([test -r $splobj/$SYMVERFILE], [
144                         splsym=$SYMVERFILE
145                 ], [test -r $splobj/module/$SYMVERFILE], [
146                         splsym=$SYMVERFILE
147                 ], [
148                         splsym="[Not found]"
149                         enable_zfs=no
150                 ])
151                 AC_MSG_RESULT([$splsym])
152         ])
153
154         SPL=${splsrc}
155         SPL_OBJ=${splobj}
156         SPL_VERSION=${splver}
157         SPL_SYMBOLS=${splsym}
158
159         AC_SUBST(SPL)
160         AC_SUBST(SPL_OBJ)
161         AC_SUBST(SPL_VERSION)
162         AC_SUBST(SPL_SYMBOLS)
163 ])
164
165 AC_DEFUN([LB_ZFS], [
166         AC_ARG_WITH([zfs-obj],
167                 AS_HELP_STRING([--with-zfs-obj=PATH],
168                 [Path to zfs build objects]),
169                 [zfsobj="$withval"])
170
171         dnl #
172         dnl # The existence of zfs.release[.in] is used to identify a valid
173         dnl # source directory.  In order of preference:
174         dnl #
175         zfsver=$(ls -1 /usr/src/ | grep -m1 zfs | cut -f2 -d'-')
176         zfssrc0="/var/lib/dkms/zfs/${zfsver}/build"
177         zfssrc1="/usr/src/zfs-${zfsver}/${LINUXRELEASE}"
178         zfssrc2="/usr/src/zfs-${zfsver}"
179         zfssrc3="../zfs/"
180         zfssrc4="$LINUX"
181
182         AC_MSG_CHECKING([zfs source directory])
183         AS_IF([test -z "${zfssrc}"], [
184                 AS_IF([test -e "${zfssrc0}/zfs.release.in"], [
185                         zfssrc=${zfssrc0}
186                 ], [test -e "${zfssrc1}/zfs.release.in"], [
187                         zfssrc=${zfssrc1}
188                 ], [test -e "${zfssrc2}/zfs.release.in"], [
189                         zfssrc=${zfssrc2}
190                 ], [test -e "${zfssrc3}/zfs.release.in"], [
191                         zfssrc=$(readlink -f "${zfssrc3}")
192                 ], [test -e "${zfssrc4}/zfs.release.in"], [
193                         zfssrc=${zfssrc4}
194                 ], [
195                         zfssrc="[Not found]"
196                 ])
197         ])
198         AC_MSG_RESULT([$zfssrc])
199
200         AS_IF([test ! -e "$zfssrc/zfs.release.in" &&
201             test ! -e "$zfssrc/zfs.release"], [
202                 enable_zfs=no
203         ])
204
205         dnl #
206         dnl # The existence of the zfs_config.h is used to identify a valid
207         dnl # zfs object directory.  In many cases the object and source
208         dnl # directory are the same, however the objects may also reside
209         dnl # is a subdirectory named after the kernel version.
210         dnl #
211         AC_MSG_CHECKING([zfs build directory])
212         AS_IF([test -z "$zfsobj"], [
213                 AS_IF([test -e "${zfssrc}/${LINUXRELEASE}/zfs_config.h"], [
214                         zfsobj="${zfssrc}/${LINUXRELEASE}"
215                 ], [test -e "${zfssrc}/zfs_config.h"], [
216                         zfsobj="${zfssrc}"
217                 ], [
218                         zfsobj="[Not found]"
219                 ])
220         ])
221
222         AC_MSG_RESULT([$zfsobj])
223         AS_IF([test ! -e "$zfsobj/zfs_config.h"], [
224                 enable_zfs=no
225         ])
226
227         dnl #
228         dnl # Verify the source version using SPL_META_VERSION in spl_config.h
229         dnl #
230         AS_IF([test x$enable_zfs = xyes], [
231                 AC_MSG_CHECKING([zfs source version])
232                 AS_IF([fgrep -q ZFS_META_VERSION $zfsobj/zfs_config.h], [
233                         zfsver=$((echo "#include <zfs_config.h>";
234                             echo "zfsver=ZFS_META_VERSION-ZFS_META_RELEASE") |
235                             cpp -I $zfsobj |
236                             grep "^zfsver=" | tr -d \" | cut -d= -f2)
237                 ],[
238                         zfsver="[Not found]"
239                         enable_zfs=no
240                 ])
241                 AC_MSG_RESULT([$zfsver])
242         ])
243
244         dnl #
245         dnl # Verify the modules systems exist by the expect name.
246         dnl #
247         AS_IF([test x$enable_zfs = xyes], [
248                 AC_MSG_CHECKING([zfs file name for module symbols])
249                 AS_IF([test -r $zfsobj/$SYMVERFILE], [
250                         zfssym=$SYMVERFILE
251                 ], [test -r $zfsobj/module/$SYMVERFILE], [
252                         zfssym=$SYMVERFILE
253                 ], [
254                         zfssym="[Not found]"
255                         enable_zfs=no
256                 ])
257                 AC_MSG_RESULT([$zfssym])
258         ])
259
260         ZFS=${zfssrc}
261         ZFS_OBJ=${zfsobj}
262         ZFS_VERSION=${zfsver}
263         ZFS_SYMBOLS=${zfssym}
264
265         AC_SUBST(ZFS)
266         AC_SUBST(ZFS_OBJ)
267         AC_SUBST(ZFS_VERSION)
268         AC_SUBST(ZFS_SYMBOLS)
269 ])
270
271 AC_DEFUN([LB_ZFS_DEVEL], [
272         AC_ARG_WITH([zfs-devel],
273                 [AS_HELP_STRING([--with-zfs-devel=PATH],
274                 [Path to zfs development headers])],
275                 [zfsdevel="$withval"])
276
277         AC_MSG_CHECKING([user provided zfs devel headers])
278         AS_IF([test ! -z "${zfsdevel}"], [
279                 AS_IF([test -d "${zfsdevel}/usr/include/libspl" && test -d "${zfsdevel}/usr/include/libzfs"], [
280                         zfslib="-I $zfsdevel/usr/include/libspl -I $zfsdevel/usr/include/libzfs"
281                 ], [
282                         AC_MSG_ERROR([Path to development headers directory does not exist])
283                 ])
284         ])
285         AC_MSG_RESULT([$zfslib])
286 ])
287
288 AC_DEFUN([LB_ZFS_USER], [
289         dnl #
290         dnl # Detect user space zfs development headers.
291         dnl #
292         AC_MSG_CHECKING([zfs devel headers])
293         AS_IF([test -z "${zfslib}"], [
294                 AS_IF([test -e "${zfssrc}/include/libzfs.h" && test -e "${zfssrc}/lib/libspl/include"], [
295                         zfslib="-I $zfssrc/lib/libspl/include -I $zfssrc/include"
296                 ], [test -d /usr/include/libzfs && test -d /usr/include/libspl], [
297                         zfslib="-I /usr/include/libspl -I /usr/include/libzfs"
298                 ], [
299                         zfslib="[Not Found]"
300                         enable_zfs=no
301                 ])
302         ])
303         AC_MSG_RESULT([$zfslib])
304
305         ZFS_LIBZFS_INCLUDE=${zfslib}
306         AC_SUBST(ZFS_LIBZFS_INCLUDE)
307 ])
308
309 AC_DEFUN([LB_CONFIG_ZFS], [
310         AC_ARG_WITH([zfs],
311                 [AS_HELP_STRING([--with-zfs=PATH], [Path to zfs source])],
312                 [
313                         AS_IF([test x$withval = xno], [
314                                 enable_zfs=no
315                                 require_zfs=no
316                         ], [test x$withval = xyes], [
317                                 enable_zfs=yes
318                                 require_zfs=yes
319                         ], [
320                                 enable_zfs=yes
321                                 require_zfs=yes
322                                 zfssrc="$withval"
323                         ])
324                 ], [
325                         AS_IF([test x$enable_server != xno], [
326                                 require_zfs=no
327                                 enable_zfs=yes
328                         ], [
329                                 require_zfs=no
330                                 enable_zfs=no
331                         ])
332                 ])
333
334         AC_MSG_CHECKING([whether to enable zfs])
335         AC_MSG_RESULT([$enable_zfs])
336
337         AS_IF([test x$enable_zfs = xyes], [
338                 AS_IF([test x$enable_modules = xyes], [
339                         LB_SPL
340                         LB_ZFS
341                 ])
342                 LB_ZFS_DEVEL
343                 LB_ZFS_USER
344
345                 dnl #
346                 dnl # enable_zfs will be set to no in LB_SPL or LB_ZFS if
347                 dnl # one of more of the build requirements is not met.
348                 dnl #
349                 AS_IF([test x$enable_zfs = xyes], [
350                         AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)
351                 ],[
352                         AS_IF([test x$require_zfs = xyes], [
353                                 AC_MSG_ERROR([
354
355 Required zfs osd cannot be built due to missing zfs development headers.
356
357 Support for zfs can be enabled by downloading the required packages for your
358 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
359 your distribution.
360                                 ])
361                         ], [
362                                 AC_MSG_WARN([
363
364 Disabling optional zfs osd due to missing development headers.
365
366 Support for zfs can be enabled by downloading the required packages for your
367 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
368 your distribution.
369                                 ])
370                         ])
371                 ])
372         ])
373
374         AS_IF([test "x$enable_zfs" = xyes], [
375                 LB_CHECK_COMPILE([if zfs defines dsl_pool_config_enter/exit],
376                 dsl_pool_config_enter, [
377                         #include <sys/dsl_pool.h>
378                 ],[
379                         dsl_pool_config_enter(NULL, FTAG);
380                 ],[
381                         AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1,
382                                 [Have dsl_pool_config_enter/exit in ZFS])
383                 ])
384         ])
385
386         AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
387 ])