Whamcloud - gitweb
LU-3216 kernel: Kernel update [RHEL6.4 2.6.32-358.6.1.el6]
[fs/lustre-release.git] / config / lustre-build-zfs.m4
1 #
2 # LB_PATH_SPL
3 #
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:
6 #                   * ./spl
7 #                   * /usr/src/spl-*/$LINUXRELEASE
8 #                   * ../spl
9 #
10 # --with-spl=path - Enable spl support and use the spl headers in the
11 #                   provided path.  No autodetection is performed.
12 #
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.
17 #
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.
22 #
23 AC_DEFUN([LB_PATH_SPL],
24 [
25 AC_ARG_WITH([spl],
26         AC_HELP_STRING([--with-spl=path], [set path to spl sources]),
27         [],[
28                 if test x$enable_server = xyes && test x$enable_dist = xno; then
29                         with_spl='yes'
30                 else
31                         with_spl='no'
32                 fi
33         ])
34
35 case x$with_spl in
36         xno)
37                 AC_MSG_ERROR([spl must be enabled when building zfs.])
38                 ;;
39         xyes)
40                 SPL_DIR=
41
42                 # Check ./spl
43                 spl_src=$PWD/spl
44                 if test -e "$spl_src"; then
45                         SPL_DIR=$(readlink -f $spl_src)
46                 else
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)
52                         else
53                                 # Check ../spl
54                                 spl_src=$PWD/../spl
55                                 if test -e "$spl_src"; then
56                                         SPL_DIR=$(readlink -f $spl_src)
57                                 else
58                                         # Fatal spl required for zfs builds
59                                         AC_MSG_ERROR([Could not locate spl.])
60                                 fi
61                         fi
62                 fi
63
64                 ;;
65         *)
66                 SPL_DIR=$(readlink -f $with_spl)
67                 with_spl='yes'
68                 ;;
69 esac
70
71 AC_ARG_WITH([spl-obj],
72         AC_HELP_STRING([--with-spl-obj=path], [set path to spl objects]),
73         [
74                 if test x$with_spl = xyes; then
75                         SPL_OBJ="$withval"
76                 fi
77         ],[
78                 if test x$with_spl = xyes; then
79                         SPL_OBJ=$SPL_DIR
80                 fi
81         ])
82
83 AC_MSG_CHECKING([spl source directory])
84 AC_MSG_RESULT([$SPL_DIR])
85 AC_SUBST(SPL_DIR)
86
87 AC_MSG_CHECKING([spl object directory])
88 AC_MSG_RESULT([$SPL_OBJ])
89 AC_SUBST(SPL_OBJ)
90
91 LB_SPL_SYMVERS
92 LB_SPL_RELEASE
93 ])
94
95 #
96 # LB_SPL_BUILD
97 #
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.
103 #
104 AC_DEFUN([LB_SPL_BUILD],
105 [
106 AC_ARG_ENABLE([spl-build],
107         AC_HELP_STRING([--enable-spl-build], [enable spl configure/make]),
108         [], [
109                 SPL_DIR_INTREE=$(readlink -f $PWD/spl)
110                 if test x$SPL_DIR = x$SPL_DIR_INTREE; then
111                         enable_spl_build='yes'
112                 else
113                         enable_spl_build='no'
114                 fi
115         ])
116
117 AC_MSG_CHECKING([whether to build spl])
118 if test x$enable_spl_build = xyes; then
119         AC_MSG_RESULT([$enable_spl_build])
120
121         LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c], [], [
122                 AC_MSG_ERROR([Complete spl source must exist when building.])])
123
124         LB_CHECK_FILE([$SPL_DIR/configure], [], [
125                 AC_MSG_ERROR([Complete spl source must exist when building.])])
126
127         SPL_SUBDIR="$SPL_DIR"
128         AC_SUBST(SPL_SUBDIR)
129         AC_CONFIG_SUBDIRS("spl")
130 else
131         enable_spl_build='no'
132         AC_MSG_RESULT([$enable_spl_build])
133 fi
134 ])
135
136 #
137 # LB_SPL_SYMVERS
138 #
139 AC_DEFUN([LB_SPL_SYMVERS],
140 [
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
150 else
151         SPL_SYMBOLS=$SYMVERFILE
152 fi
153
154 AC_MSG_RESULT([$SPL_SYMBOLS])
155 AC_SUBST(SPL_SYMBOLS)
156 ])
157
158 #
159 # LB_SPL_RELEASE
160 #
161 AC_DEFUN([LB_SPL_RELEASE],
162 [
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"
167         LB_LINUX_TRY_MAKE([
168                 #include <$SPL_OBJ/spl_config.h>
169         ],[
170                 char *SPL_RELEASE;
171                 SPL_RELEASE=SPL_META_VERSION;
172         ],[
173                 $makerule LUSTRE_KERNEL_TEST=conftest.i
174         ],[
175                 test -s build/conftest.i
176         ],[
177                 eval $(grep "SPL_RELEASE=" build/conftest.i)
178         ],[
179                 AC_MSG_RESULT([unknown])
180                 AC_MSG_ERROR([Could not preprocess test program.])
181         ])
182         EXTRA_KCFLAGS="$tmp_flags"
183         rm build/conftest.i
184 elif test -r $SPL_DIR/META; then
185         SPL_RELEASE=$(awk '/Version/ { print [$]2 }' $SPL_DIR/META)
186 else
187         AC_MSG_RESULT([unknown])
188         AC_MSG_ERROR([Could not locate spl_config.h or META to check release.])
189 fi
190
191 if test x$SPL_RELEASE = x; then
192         AC_MSG_RESULT([unknown])
193         AC_MSG_ERROR([Could not determine spl release.])
194 fi
195
196 AC_MSG_RESULT([$SPL_RELEASE])
197 AC_SUBST(SPL_RELEASE)
198 ])
199
200
201 #
202 # LB_PATH_ZFS
203 #
204 # --without-zfs   - Disable zfs support.
205 # --with-zfs=no
206 #
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:
209 #                   * ./zfs
210 #                   * /usr/src/zfs-*/$LINUXRELEASE
211 #                   * ../zfs
212 #
213 # --with-zfs=path - Enable zfs support and use the zfs headers in the
214 #                   provided path.  No autodetection is performed.
215 #
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.
220 #
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.
225 #
226 AC_DEFUN([LB_PATH_ZFS],
227 [
228 AC_ARG_WITH([zfs],
229         AC_HELP_STRING([--with-zfs=path], [set path to zfs sources]),
230         [],[
231                 if test x$enable_server = xyes && test x$enable_dist = xno; then
232                         with_zfs='yes'
233                 else
234                         with_zfs='no'
235                 fi
236         ])
237
238 case x$with_zfs in
239         xno)
240                 ZFS_DIR=
241                 ;;
242         xyes)
243                 ZFS_DIR=
244
245                 # Check ./zfs
246                 zfs_src=$PWD/zfs
247                 if test -e "$zfs_src"; then
248                         ZFS_DIR=$(readlink -f $zfs_src)
249                 else
250                         # Check /usr/src/zfs-*/$LINUXRELEASE
251                         zfs_src=$(ls -1d /usr/src/zfs-*/$LINUXRELEASE \
252                                 2>/dev/null|tail -1)
253                         if test -e "$zfs_src"; then
254                                 ZFS_DIR=$(readlink -f $zfs_src)
255                         else
256                                 # Check ../zfs
257                                 zfs_src=$PWD/../zfs
258                                 if test -e "$zfs_src"; then
259                                         ZFS_DIR=$(readlink -f $zfs_src)
260                                 else
261                                         # Disable zfs failed to detect sources
262                                         with_zfs='no'
263                                 fi
264                         fi
265                 fi
266                 ;;
267         *)
268                 ZFS_DIR=$(readlink -f $with_zfs)
269                 with_zfs='yes'
270                 ;;
271 esac
272
273 AC_MSG_CHECKING([whether to enable zfs])
274 AC_MSG_RESULT([$with_zfs])
275
276 if test x$with_zfs = xyes; then
277         AC_MSG_CHECKING([for location of zfs library headers])
278         if test -e "$ZFS_DIR/include/libzfs.h"; then
279                 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/lib/libspl/include -I $ZFS_DIR/include"
280                 AC_MSG_RESULT([$ZFS_DIR])
281         elif test -e "$ZFS_DIR/libzfs/libzfs.h"; then
282                 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/libspl -I $ZFS_DIR/libzfs"
283                 AC_MSG_RESULT([$ZFS_DIR])
284         elif test -e "/usr/include/libzfs/libzfs.h"; then
285                 AC_MSG_RESULT([/usr/include])
286                 EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I /usr/include/libspl -I /usr/include/libzfs"
287         else
288                 AC_MSG_RESULT([unknown])
289                 AC_MSG_ERROR([Could not locate zfs library headers.])
290         fi
291         AC_SUBST(EXTRA_LIBZFS_INCLUDE)
292 fi
293
294 AC_ARG_WITH([zfs-obj],
295         AC_HELP_STRING([--with-zfs-obj=path], [set path to zfs objects]),
296         [
297                 if test x$with_zfs = xyes; then
298                         ZFS_OBJ="$withval"
299                 fi
300         ],[
301                 if test x$with_zfs = xyes; then
302                         ZFS_OBJ=$ZFS_DIR
303                 fi
304         ])
305
306 if test x$with_zfs = xyes; then
307         LB_ZFS_DEFINE_OPTIONS
308
309         AC_MSG_CHECKING([zfs source directory])
310         AC_MSG_RESULT([$ZFS_DIR])
311         AC_SUBST(ZFS_DIR)
312
313         AC_MSG_CHECKING([zfs object directory])
314         AC_MSG_RESULT([$ZFS_OBJ])
315         AC_SUBST(ZFS_OBJ)
316
317         LB_ZFS_SYMVERS
318         LB_ZFS_RELEASE
319
320         LB_PATH_SPL
321
322         LB_SPL_BUILD
323         LB_ZFS_BUILD
324 fi
325
326 AM_CONDITIONAL(SPL_BUILD, test x$enable_spl_build = xyes)
327 AM_CONDITIONAL(ZFS_BUILD, test x$enable_zfs_build = xyes)
328 AM_CONDITIONAL(ZFS_ENABLED, test x$with_zfs = xyes)
329 ])
330
331 #
332 # LB_ZFS_BUILD
333 #
334 # Optionally configure/make the zfs sources.  If the sources are
335 # determined to reside in-tree this feature will automatically be
336 # enabled.  If the sources are not in-tree it will be disabled.
337 # Use --enable-zfs-build or --disable-zfs-build if you need to
338 # override this behavior.
339 #
340 AC_DEFUN([LB_ZFS_BUILD],
341 [
342 AC_ARG_ENABLE([zfs-build],
343         AC_HELP_STRING([--enable-zfs-build], [enable zfs configure/make]),
344         [], [
345                 ZFS_DIR_INTREE=$(readlink -f $PWD/zfs)
346                 if test x$ZFS_DIR = x$ZFS_DIR_INTREE; then
347                         enable_zfs_build='yes'
348                 else
349                         enable_zfs_build='no'
350                 fi
351         ])
352
353 AC_MSG_CHECKING([whether to build zfs])
354 if test x$enable_zfs_build = xyes; then
355         AC_MSG_RESULT([$enable_zfs_build])
356
357         LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c], [], [
358                 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
359
360         LB_CHECK_FILE([$ZFS_DIR/configure], [], [
361                 AC_MSG_ERROR([Complete zfs sources must exist when building.])])
362
363         ZFS_SUBDIR="$ZFS_DIR"
364         AC_SUBST(ZFS_SUBDIR)
365         AC_CONFIG_SUBDIRS("zfs")
366
367         ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
368         ac_configure_args="$ac_configure_args --with-spl-obj=$SPL_OBJ"
369 else
370         enable_zfs_build='no'
371         AC_MSG_RESULT([$enable_zfs_build])
372 fi
373 ])
374
375 #
376 # LB_ZFS_SYMVERS
377 #
378 AC_DEFUN([LB_ZFS_SYMVERS],
379 [
380 AC_MSG_CHECKING([zfs module symbols])
381 if test -r $ZFS_OBJ/Module.symvers; then
382         ZFS_SYMBOLS=Module.symvers
383 elif test -r $ZFS_OBJ/Modules.symvers; then
384         ZFS_SYMBOLS=Modules.symvers
385 elif test -r $ZFS_OBJ/module/Module.symvers; then
386         ZFS_SYMBOLS=Module.symvers
387 elif test -r $ZFS_OBJ/module/Modules.symvers; then
388         ZFS_SYMBOLS=Modules.symvers
389 else
390         ZFS_SYMBOLS=$SYMVERFILE
391 fi
392
393 AC_MSG_RESULT([$ZFS_SYMBOLS])
394 AC_SUBST(ZFS_SYMBOLS)
395 ])
396
397 #
398 # LB_ZFS_RELEASE
399 #
400 AC_DEFUN([LB_ZFS_RELEASE],
401 [
402 AC_MSG_CHECKING([zfs source release])
403 if test -r $ZFS_OBJ/zfs_config.h; then
404         tmp_flags="$EXTRA_KCFLAGS"
405         EXTRA_KCFLAGS="-I$ZFS_OBJ $EXTRA_KCFLAGS"
406         LB_LINUX_TRY_MAKE([
407                 #include <$ZFS_OBJ/zfs_config.h>
408         ],[
409                 char *ZFS_RELEASE;
410                 ZFS_RELEASE=ZFS_META_VERSION;
411         ],[
412                 $makerule LUSTRE_KERNEL_TEST=conftest.i
413         ],[
414                 test -s build/conftest.i
415         ],[
416                 eval $(grep "ZFS_RELEASE=" build/conftest.i)
417         ],[
418                 AC_MSG_RESULT([unknown])
419                 AC_MSG_ERROR([Could not preprocess test program.])
420         ])
421         EXTRA_KCFLAGS="$tmp_flags"
422         rm build/conftest.i
423 elif test -r $ZFS_DIR/META; then
424         ZFS_RELEASE=$(awk '/Version/ { print [$]2 }' $ZFS_DIR/META)
425 else
426         AC_MSG_RESULT([unknown])
427         AC_MSG_ERROR([Could not locate zfs_config.h or META to check release.])
428 fi
429
430 if test x$ZFS_RELEASE = x; then
431         AC_MSG_RESULT([unknown])
432         AC_MSG_ERROR([Could not determine zfs release.])
433 fi
434
435 AC_MSG_RESULT([$ZFS_RELEASE])
436 AC_SUBST(ZFS_RELEASE)
437 ])
438
439 #
440 # LB_ZFS_DEFINE_OPTIONS
441 #
442 AC_DEFUN([LB_ZFS_DEFINE_OPTIONS],
443 [
444 AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)
445 ])