Whamcloud - gitweb
LU-11881 utils: silence error message
[fs/lustre-release.git] / config / lustre-build-ldiskfs.m4
1 #
2 # LDISKFS_LINUX_SERIES
3 #
4 AC_DEFUN([LDISKFS_LINUX_SERIES], [
5 AC_MSG_CHECKING([which ldiskfs series to use])
6 case x$LDISKFS_SERIES in
7         x)                      # not set
8                 ;;
9         *.series)               # set externally
10                 ;;
11         *) LDISKFS_SERIES=
12 esac
13 AS_IF([test -z "$LDISKFS_SERIES"], [
14 AS_IF([test x$RHEL_KERNEL = xyes], [
15         case $RHEL_RELEASE_NO in
16         76)     LDISKFS_SERIES="3.10-rhel7.6.series"    ;;
17         75)     LDISKFS_SERIES="3.10-rhel7.5.series"    ;;
18         74)     LDISKFS_SERIES="3.10-rhel7.4.series"    ;;
19         73)     LDISKFS_SERIES="3.10-rhel7.3.series"    ;;
20         72)     LDISKFS_SERIES="3.10-rhel7.2.series"    ;;
21         71)     LDISKFS_SERIES="3.10-rhel7.series"      ;;
22         69)     LDISKFS_SERIES="2.6-rhel6.9.series"     ;;
23         68)     LDISKFS_SERIES="2.6-rhel6.8.series"     ;;
24         67)     LDISKFS_SERIES="2.6-rhel6.7.series"     ;;
25         66)     LDISKFS_SERIES="2.6-rhel6.6.series"     ;;
26         65)     LDISKFS_SERIES="2.6-rhel6.5.series"     ;;
27         64)     LDISKFS_SERIES="2.6-rhel6.4.series"     ;;
28         6[0-3]) LDISKFS_SERIES="2.6-rhel6.series"       ;;
29         esac
30 ], [test x$SUSE_KERNEL = xyes], [
31         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[
32         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[
33         AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[
34         AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[
35         AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32], [],
36         [LDISKFS_SERIES="2.6-sles11.series"],[LDISKFS_SERIES="2.6-sles11.series"])],
37         [LDISKFS_SERIES="3.0-sles11.series"],[
38                 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
39                 case $PLEV in
40                 2) LDISKFS_SERIES="3.0-sles11.series"
41                         ;;
42                 3) LDISKFS_SERIES="3.0-sles11sp3.series"
43                         ;;
44                 4) LDISKFS_SERIES="3.0-sles11sp4.series"
45                         ;;
46                 esac
47         ])],[LDISKFS_SERIES="3.12-sles12.series"],[
48                 PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
49                 case $PLEV in
50                 1) LDISKFS_SERIES="3.12-sles12sp1.series"
51                         ;;
52                 *) LDISKFS_SERIES="3.12-sles12.series"
53                         ;;
54                 esac
55         ])],[LDISKFS_SERIES="4.4-sles12sp2.series"],
56             [LDISKFS_SERIES="4.4-sles12sp2.series"]
57         )], [LDISKFS_SERIES="4.4-sles12sp3.series"],
58             [LDISKFS_SERIES="4.4-sles12sp3.series"])
59 ], [test x$UBUNTU_KERNEL = xyes], [
60         AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
61         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
62         [
63                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
64                 AS_IF(
65                         [test -z "$KPLEV"], [
66                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
67                                 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
68                         ],
69                         [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
70                         [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
71                         [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
72                         [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
73                 )
74         ],
75         [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
76         [
77                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
78                 AS_IF(
79                         [test -z "$KPLEV"], [
80                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
81                                 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
82                         ],
83                         [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
84                         [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
85                 )
86         ],
87         [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])
88 ])
89 ])
90 AS_IF([test -z "$LDISKFS_SERIES"],
91         [AC_MSG_RESULT([failed to identify series])],
92         [AC_MSG_RESULT([$LDISKFS_SERIES])])
93 AC_SUBST(LDISKFS_SERIES)
94 ]) # LDISKFS_LINUX_SERIES
95
96 #
97 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
98 #
99 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
100 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
101 #
102 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
103 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
104 ext4_free_blocks_with_buffer_head, [
105         #include <linux/fs.h>
106         #include "$EXT4_SRC_DIR/ext4.h"
107 ],[
108         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
109 ],[
110         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
111                 [ext4_free_blocks do not require struct buffer_head])
112 ])
113 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
114
115 #
116 # LB_EXT_PBLOCK
117 #
118 # 2.6.35 renamed ext_pblock to ext4_ext_pblock(ex)
119 #
120 AC_DEFUN([LB_EXT_PBLOCK], [
121 LB_CHECK_COMPILE([if Linux kernel has 'ext_pblock'],
122 ext_pblock, [
123         #include <linux/fs.h>
124         #include "$EXT4_SRC_DIR/ext4_extents.h"
125 ],[
126         ext_pblock(NULL);
127 ],[
128         AC_DEFINE(HAVE_EXT_PBLOCK, 1, [Linux kernel has ext_pblock])
129 ])
130 ]) # LB_EXT_PBLOCK
131
132 #
133 # LB_EXT4_JOURNAL_START_3ARGS
134 #
135 # 3.9 added a type argument to ext4_journal_start and friends
136 #
137 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
138 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
139 ext4_journal_start, [
140         #include <linux/fs.h>
141         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
142 ],[
143         ext4_journal_start(NULL, 0, 0);
144 ],[
145         AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
146 ])
147 ]) # LB_EXT4_JOURNAL_START_3ARGS
148
149 #
150 # LB_LDISKFS_MAP_BLOCKS
151 #
152 # Since 2.6.35 brought ext4_map_blocks() for IO.
153 # We just check this function whether existed.
154 # it must be exported by ldiskfs patches.
155 #
156 AC_DEFUN([LB_LDISKFS_MAP_BLOCKS], [
157 LB_CHECK_COMPILE([if kernel has ext4_map_blocks],
158 ext4_map_blocks, [
159         #include <linux/fs.h>
160         #include "$EXT4_SRC_DIR/ext4.h"
161 ],[
162         ext4_map_blocks(NULL, NULL, NULL, 0);
163 ],[
164         AC_DEFINE(HAVE_LDISKFS_MAP_BLOCKS, 1, [kernel has ext4_map_blocks])
165 ])
166 ])
167
168 #
169 # LB_EXT4_BREAD_4ARGS
170 #
171 # 3.18 ext4_bread has 4 arguments
172 #
173 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
174 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
175 ext4_bread, [
176         #include <linux/fs.h>
177         #include "$EXT4_SRC_DIR/ext4.h"
178 ],[
179         ext4_bread(NULL, NULL, 0, 0);
180 ],[
181         AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
182 ])
183 ]) # LB_EXT4_BREAD_4ARGS
184
185 #
186 # LB_EXT4_HAVE_INFO_DQUOT
187 #
188 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
189 #
190 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
191 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
192 ext4_info_dquot, [
193         #include <linux/fs.h>
194         #include <linux/quota.h>
195         #include "$EXT4_SRC_DIR/ext4.h"
196 ],[
197         struct ext4_inode_info in;
198         struct dquot *dq;
199
200         dq = in.i_dquot[0];
201 ],[
202         AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
203 ])
204 ]) # LB_EXT4_HAVE_INFO_DQUOT
205
206 #
207 # LDISKFS_AC_PATCH_PROGRAM
208 #
209 # Determine which program should be used to apply the patches to
210 # the ext4 source code to produce the ldiskfs source code.
211 #
212 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
213         AC_ARG_ENABLE([quilt],
214                 [AC_HELP_STRING([--disable-quilt],
215                         [disable use of quilt for ldiskfs])],
216                 [AS_IF([test "x$enableval" = xno],
217                         [use_quilt=no],
218                         [use_quilt=maybe])],
219                 [use_quilt=maybe]
220         )
221
222         AS_IF([test x$use_quilt = xmaybe], [
223                 AC_PATH_PROG([quilt_avail], [quilt], [no])
224                 AS_IF([test x$quilt_avail = xno], [
225                         use_quilt=no
226                 ], [
227                         use_quilt=yes
228                 ])
229         ])
230
231         AS_IF([test x$use_quilt = xno], [
232                 AC_PATH_PROG([patch_avail], [patch], [no])
233                 AS_IF([test x$patch_avail = xno], [
234                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
235                 ])
236         ])
237 ]) # LDISKFS_AC_PATCH_PROGRAM
238
239 #
240 # LB_CONFIG_LDISKFS
241 #
242 AC_DEFUN([LB_CONFIG_LDISKFS], [
243 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
244 # However we continue to support this option through Lustre 2.5.
245 AC_ARG_WITH([ldiskfs],
246         [],
247         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
248         AS_IF([test x$withval != xyes -a x$withval != xno],
249                 [AC_MSG_ERROR([
250
251 The ldiskfs option is deprecated,
252 and no longer supports paths to external ldiskfs source
253 ])])
254 ])
255
256 AC_ARG_ENABLE([ldiskfs],
257         [AS_HELP_STRING([--disable-ldiskfs],
258                 [disable ldiskfs osd (default is enable)])],
259         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
260                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
261         [AS_IF([test "${with_ldiskfs+set}" = set],
262                 [enable_ldiskfs=$with_ldiskfs],
263                 [enable_ldiskfs=maybe])
264 ])
265
266 AS_IF([test x$enable_server = xno],
267         [AS_CASE([$enable_ldiskfs],
268                 [maybe], [enable_ldiskfs=no],
269                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
270         )])
271
272 AS_IF([test x$enable_ldiskfs != xno],[
273         # In the future, we chould change enable_ldiskfs from maybe to
274         # either yes or no based on additional tests, e.g.  whether a patch
275         # set is available for the detected kernel.  For now, we just always
276         # set it to "yes".
277         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
278         AC_SUBST(ENABLE_LDISKFS, yes)
279
280         LDISKFS_LINUX_SERIES
281         LDISKFS_AC_PATCH_PROGRAM
282         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
283         LB_EXT_PBLOCK
284         LB_EXT4_JOURNAL_START_3ARGS
285         LB_LDISKFS_MAP_BLOCKS
286         LB_EXT4_BREAD_4ARGS
287         LB_EXT4_HAVE_INFO_DQUOT
288         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
289         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
290         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
291         AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
292         AC_DEFINE(CONFIG_LDISKFS_FS_ENCRYPTION, 1, [enable encryption for ldiskfs])
293         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
294         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
295 ], [
296         AC_SUBST(ENABLE_LDISKFS, no)
297 ])
298
299 AC_MSG_CHECKING([whether to build ldiskfs])
300 AC_MSG_RESULT([$enable_ldiskfs])
301
302 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
303 ]) # LB_CONFIG_LDISKFS
304
305 #
306 # LB_VALIDATE_EXT4_SRC_DIR
307 #
308 # Spot check the existence of several source files common to ext4.
309 # Detecting this at configure time allows us to avoid a potential build
310 # failure and provide a useful error message to explain what is wrong.
311 #
312 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
313 enable_ldiskfs_build="no"
314 AS_IF([test -n "$EXT4_SRC_DIR"], [
315         enable_ldiskfs_build="yes"
316         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
317                 enable_ldiskfs_build="no"
318                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
319         ])
320         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
321                 enable_ldiskfs_build="no"
322                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
323         ])
324         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
325                 enable_ldiskfs_build="no"
326                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
327         ])
328         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
329                 enable_ldiskfs_build="no"
330                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
331         ])
332 ])
333
334 AS_IF([test "x$enable_ldiskfs_build" = xno], [
335         enable_ldiskfs="no"
336
337         AC_MSG_WARN([
338
339 Disabling ldiskfs support because complete ext4 source does not exist.
340
341 If you are building using kernel-devel packages and require ldiskfs
342 server support then ensure that the matching kernel-debuginfo-common
343 and kernel-debuginfo-common-<arch> packages are installed.
344 ])
345 ])
346 ]) # LB_VALIDATE_EXT4_SRC_DIR
347
348 #
349 # LB_EXT4_SRC_DIR
350 #
351 # Determine the location of the ext4 source code.  It it required
352 # for several configure tests and to build ldiskfs.
353 #
354 AC_DEFUN([LB_EXT4_SRC_DIR], [
355 AC_MSG_CHECKING([ext4 source directory])
356 # Kernel ext source located with devel headers
357 linux_src=$LINUX
358 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
359         EXT4_SRC_DIR="$linux_src/fs/ext4"
360 ], [
361         # Kernel ext source provided by kernel-debuginfo-common package
362         # that extracted to $LINUX
363         linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
364                 2>/dev/null | tail -1)
365         AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
366                 EXT4_SRC_DIR="$linux_src/fs/ext4"
367         ], [
368                 # Kernel ext source provided by kernel-debuginfo-common package
369                 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
370                         2>/dev/null | tail -1)
371                 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
372                         EXT4_SRC_DIR="$linux_src/fs/ext4"
373                 ], [
374                         EXT4_SRC_DIR=""
375                 ])
376         ])
377 ])
378 AC_MSG_RESULT([$EXT4_SRC_DIR])
379 AC_SUBST(EXT4_SRC_DIR)
380
381 LB_VALIDATE_EXT4_SRC_DIR
382 ]) # LB_EXT4_SRC_DIR
383
384 #
385 # LB_DEFINE_E2FSPROGS_NAMES
386 #
387 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
388 #
389 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
390 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
391 AC_ARG_WITH([ldiskfsprogs],
392         AC_HELP_STRING([--with-ldiskfsprogs],
393                 [use alternate names for ldiskfs-enabled e2fsprogs]),
394         [], [withval="no"])
395
396 AS_IF([test "x$withval" = xyes], [
397         AC_MSG_RESULT([enabled])
398         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
399         E2FSPROGS="ldiskfsprogs"
400         MKE2FS="mkfs.ldiskfs"
401         DEBUGFS="debugfs.ldiskfs"
402         TUNE2FS="tunefs.ldiskfs"
403         E2LABEL="label.ldiskfs"
404         DUMPE2FS="dumpfs.ldiskfs"
405         E2FSCK="fsck.ldiskfs"
406         PFSCK="pfsck.ldiskfs"
407 ], [
408         AC_MSG_RESULT([disabled])
409         E2FSPROGS="e2fsprogs"
410         MKE2FS="mke2fs"
411         DEBUGFS="debugfs"
412         TUNE2FS="tune2fs"
413         E2LABEL="e2label"
414         DUMPE2FS="dumpe2fs"
415         E2FSCK="e2fsck"
416         PFSCK="fsck"
417 ])
418
419 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
420 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
421 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
422 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
423 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
424 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
425 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
426 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
427
428 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
429 AC_SUBST([MKE2FS], [$MKE2FS])
430 AC_SUBST([DEBUGFS], [$DEBUGFS])
431 AC_SUBST([TUNE2FS], [$TUNE2FS])
432 AC_SUBST([E2LABEL], [$E2LABEL])
433 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
434 AC_SUBST([E2FSCK], [$E2FSCK])
435 AC_SUBST([PFSCK], [$PFSCK])
436 ]) # LB_DEFINE_E2FSPROGS_NAMES