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