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