Whamcloud - gitweb
7d906a3c9d27810d02bd80e7a00f3ec2a36edfae
[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         84)     LDISKFS_SERIES="4.18-rhel8.4.series"    ;;
17         83)     LDISKFS_SERIES="4.18-rhel8.3.series"    ;;
18         82)     LDISKFS_SERIES="4.18-rhel8.2.series"    ;;
19         81)     LDISKFS_SERIES="4.18-rhel8.1.series"    ;;
20         80)     LDISKFS_SERIES="4.18-rhel8.series"      ;;
21         79)     LDISKFS_SERIES="3.10-rhel7.9.series"    ;;
22         78)     LDISKFS_SERIES="3.10-rhel7.8.series"    ;;
23         77)     LDISKFS_SERIES="3.10-rhel7.7.series"    ;;
24         76)     LDISKFS_SERIES="3.10-rhel7.6.series"    ;;
25         esac
26 ], [test x$SUSE_KERNEL = xyes], [
27         AS_VERSION_COMPARE([$LINUXRELEASE],[5.3.18],[
28         AS_VERSION_COMPARE([$LINUXRELEASE],[4.12.14],[], [], [
29                 suse_conf=$LINUX_OBJ/include/generated/uapi/linux/suse_version.h
30                 suse_vers=$(awk '[$]2 == "SUSE_VERSION" {print [$]3 }' $suse_conf)
31                 suse_patchlevel=$(awk '[$]2 == "SUSE_PATCHLEVEL" {print [$]3 }' $suse_conf)
32                 echo "$suse_conf $suse_vers $suse_patchlevel  ${suse_vers}sp$suse_patchlevel" >> /tmp/log-nb
33                 case ${suse_vers}sp$suse_patchlevel in # (
34                 15sp0 ) LDISKFS_SERIES="4.12-sles15.series"
35                         if test ! -f $LINUX/arch/x86/kernel/cpu/hygon.c ; then
36                                 # This file was added shortly after -150.22 so
37                                 # this must be 150.22 or earlier
38                                 LDISKFS_SERIES="4.12-sles15-22.series"
39                         fi
40                         ;; # (
41                 15sp1 ) LDISKFS_SERIES="4.12-sles15sp1.series"
42                         if test ! -f $LINUX/arch/x86/kernel/cpu/umwait.c ; then
43                                 # This file was added after -197.7 so
44                                 # this must be -197.7 or earlier
45                                 LDISKFS_SERIES="4.12-sles15sp1-7.series"
46                         fi
47                         ;;
48                 esac
49         ]
50         )], [LDISKFS_SERIES="5.4.21-ml.series"],
51             [LDISKFS_SERIES="5.4.21-ml.series"])
52 ], [test x$UBUNTU_KERNEL = xyes], [
53         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[
54         AS_VERSION_COMPARE([$LINUXRELEASE],[5.0.0],[
55         AS_VERSION_COMPARE([$LINUXRELEASE],[4.15.0],[
56         AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0], [],
57         [
58                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
59                 AS_IF(
60                         [test -z "$KPLEV"], [
61                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
62                                 LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"
63                         ],
64                         [test $KPLEV -ge 73], [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"],
65                         [test $KPLEV -ge 62], [LDISKFS_SERIES="4.4.0-62-ubuntu14+16.series"],
66                         [test $KPLEV -ge 49], [LDISKFS_SERIES="4.4.0-49-ubuntu14+16.series"],
67                         [LDISKFS_SERIES="4.4.0-45-ubuntu14+16.series"]
68                 )
69         ],
70         [LDISKFS_SERIES="4.4.0-73-ubuntu14+16.series"])],
71         [
72                 KPLEV=$(echo $LINUXRELEASE | sed -n 's/.*-\([0-9]\+\).*/\1/p')
73                 AS_IF(
74                         [test -z "$KPLEV"], [
75                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
76                                 LDISKFS_SERIES="4.15.0-24-ubuntu18.series"
77                         ],
78                         [test $KPLEV -ge 24], [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"],
79                         [test $KPLEV -ge 20], [LDISKFS_SERIES="4.15.0-20-ubuntu18.series"]
80                 )
81         ],
82         [LDISKFS_SERIES="4.15.0-24-ubuntu18.series"])],
83         [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"],
84         [LDISKFS_SERIES="5.0.0-13-ubuntu19.series"])],
85         [LDISKFS_SERIES="5.4.0-42-ubuntu20.series"],
86         [
87                 KPLEV=$(echo $LINUXRELEASE | cut -d'-' -f2)
88                 AS_IF(
89                         [test -z "$KPLEV"], [
90                                 AC_MSG_WARN([Failed to determine Kernel patch level. Assume latest.])
91                                 LDISKFS_SERIES="5.4.0-66-ubuntu20.series"
92                         ],
93                         [test $KPLEV -eq 1007], [LDISKFS_SERIES="5.4.0-42-ubuntu20.series"],
94                         [test $KPLEV -ge 66], [LDISKFS_SERIES="5.4.0-66-ubuntu20.series"],
95                         [LDISKFS_SERIES="5.4.0-42-ubuntu20.series"]
96                 )
97         ],
98         [LDISKFS_SERIES="5.4.0-ml.series"])
99 ])
100 ])
101 # Not RHEL/SLES or Ubuntu .. probably mainline
102 AS_IF([test -z "$LDISKFS_SERIES"],
103         [
104         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.0],[],
105         [LDISKFS_SERIES="5.4.0-ml.series"],[
106         AS_VERSION_COMPARE([$LINUXRELEASE],[5.4.21],
107           [LDISKFS_SERIES="5.4.0-ml.series"],  # lt
108           [LDISKFS_SERIES="5.4.21-ml.series"], # eq
109           [AS_VERSION_COMPARE([$LINUXRELEASE],[5.8.0],
110             [LDISKFS_SERIES="5.4.21-ml.series"], # lt
111             [LDISKFS_SERIES="5.8.0-ml.series"],  # eq
112             [LDISKFS_SERIES="5.8.0-ml.series"],  # gt
113           )]
114                 )])
115         ],
116 [])
117 AS_IF([test -z "$LDISKFS_SERIES"],
118         [AC_MSG_RESULT([failed to identify series])],
119         [AC_MSG_RESULT([$LDISKFS_SERIES for $LINUXRELEASE])])
120 AC_SUBST(LDISKFS_SERIES)
121 ]) # LDISKFS_LINUX_SERIES
122
123 #
124 # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
125 #
126 # 2.6.32-rc7 ext4_free_blocks requires struct buffer_head
127 # Note that RHEL6 is pre 2.6.32-rc7 so this check is still needed.
128 #
129 AC_DEFUN([LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD], [
130 LB_CHECK_COMPILE([if 'ext4_free_blocks' needs 'struct buffer_head'],
131 ext4_free_blocks_with_buffer_head, [
132         #include <linux/fs.h>
133         #include "$EXT4_SRC_DIR/ext4.h"
134 ],[
135         ext4_free_blocks(NULL, NULL, NULL, 0, 0, 0);
136 ],[
137         AC_DEFINE(HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD, 1,
138                 [ext4_free_blocks do not require struct buffer_head])
139 ])
140 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
141
142 #
143 # LB_EXT4_JOURNAL_START_3ARGS
144 #
145 # 3.9 added a type argument to ext4_journal_start and friends
146 #
147 AC_DEFUN([LB_EXT4_JOURNAL_START_3ARGS], [
148 LB_CHECK_COMPILE([if ext4_journal_start takes 3 arguments],
149 ext4_journal_start, [
150         #include <linux/fs.h>
151         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
152 ],[
153         ext4_journal_start(NULL, 0, 0);
154 ],[
155         AC_DEFINE(JOURNAL_START_HAS_3ARGS, 1, [ext4_journal_start takes 3 arguments])
156 ])
157 ]) # LB_EXT4_JOURNAL_START_3ARGS
158
159 #
160 # LB_EXT4_BREAD_4ARGS
161 #
162 # 3.18 ext4_bread has 4 arguments
163 # NOTE: It may not be exported for modules, use a positive compiler test here.
164 #
165 AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
166 LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
167 ext4_bread, [
168         #include <linux/fs.h>
169         #include "$EXT4_SRC_DIR/ext4.h"
170
171         struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
172                                        ext4_lblk_t block, int map_flags)
173         {
174                 struct buffer_head *bh = NULL;
175                 (void)handle;
176                 (void)inode;
177                 (void)block;
178                 (void)map_flags;
179                 return bh;
180         }
181 ],[
182         ext4_bread(NULL, NULL, 0, 0);
183 ],[
184         AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
185 ])
186 ]) # LB_EXT4_BREAD_4ARGS
187
188 #
189 # LB_EXT4_HAVE_INFO_DQUOT
190 #
191 # in linux 4.4 i_dqout is in ext4_inode_info, not in struct inode
192 #
193 AC_DEFUN([LB_EXT4_HAVE_INFO_DQUOT], [
194 LB_CHECK_COMPILE([if i_dquot is in ext4_inode_info],
195 ext4_info_dquot, [
196         #include <linux/fs.h>
197         #include <linux/quota.h>
198         #include "$EXT4_SRC_DIR/ext4.h"
199 ],[
200         struct ext4_inode_info in;
201         struct dquot *dq;
202
203         dq = in.i_dquot[0];
204 ],[
205         AC_DEFINE(HAVE_EXT4_INFO_DQUOT, 1, [i_dquot is in ext4_inode_info])
206 ])
207 ]) # LB_EXT4_HAVE_INFO_DQUOT
208
209 #
210 # LB_EXT4_HAVE_I_CRYPT_INFO
211 #
212 # in linux 4.8 i_crypt_info moved from ext4_inode_info to struct inode
213 #
214 # Determine if we need to enable CONFIG_LDISKFS_FS_ENCRYPTION.
215 # If we have i_crypt_info in ext4_inode_info, the config option
216 # should be enabled to make the ldiskfs module compilation happy.
217 # Otherwise i_crypy_info is in struct inode, we need to check kernel
218 # config option to determine that.
219 #
220 AC_DEFUN([LB_EXT4_HAVE_I_CRYPT_INFO], [
221 LB_CHECK_COMPILE([if i_crypt_info is in ext4_inode_info],
222 ext4_i_crypt_info, [
223         #define CONFIG_EXT4_FS_ENCRYPTION 1
224         #include <linux/fs.h>
225         #include "$EXT4_SRC_DIR/ext4.h"
226 ],[
227         struct ext4_inode_info in;
228
229         in.i_crypt_info = NULL;
230 ],[
231         AC_DEFINE(
232                 CONFIG_LDISKFS_FS_ENCRYPTION, 1,
233                 [enable encryption for ldiskfs]
234         )
235 ],[
236         LB_CHECK_CONFIG([EXT4_FS_ENCRYPTION],[
237                 AC_DEFINE(
238                         CONFIG_LDISKFS_FS_ENCRYPTION, 1,
239                         [enable encryption for ldiskfs]
240                 )
241         ])
242 ])
243 ]) # LB_EXT4_HAVE_I_CRYPT_INFO
244
245 #
246 # LB_LDISKFS_JOURNAL_ENSURE_CREDITS
247 #
248 # kernel 4.18.0-240.1.1.el8 and
249 # kernel 5.4 commit a413036791d040e33badcc634453a4d0c0705499
250 #
251 # ext4_journal_ensure_credits was introduced to ensure given handle
252 # has at least requested amount of credits available, and possibly
253 # restarting transaction if needed.
254 #
255 AC_DEFUN([LB_LDISKFS_JOURNAL_ENSURE_CREDITS], [
256 tmp_flags="$EXTRA_KCFLAGS"
257 EXTRA_KCFLAGS="-Werror"
258 LB_CHECK_COMPILE([if 'ext4_journal_ensure_credits' exists],
259 ext4_journal_ensure_credits, [
260         #include "$EXT4_SRC_DIR/ext4_jbd2.h"
261         int __ext4_journal_ensure_credits(handle_t *handle, int check_cred,
262                 int extend_cred, int revoke_cred) { return 0; }
263 ],[
264         ext4_journal_ensure_credits(NULL, 0, 0);
265 ],[
266         AC_DEFINE(HAVE_LDISKFS_JOURNAL_ENSURE_CREDITS, 1,
267                 ['ext4_journal_ensure_credits' exists])
268 ])
269 EXTRA_KCFLAGS="$tmp_flags"
270 ]) # LB_LDISKFS_JOURNAL_ENSURE_CREDITS
271
272 #
273 # LB_LDISKFS_IGET_HAS_FLAGS_ARG
274 #
275 # kernel 4.19 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
276 # ext4_iget changed to a macro with 3 args was function with 2 args
277 #
278 AC_DEFUN([LB_LDISKFS_IGET_HAS_FLAGS_ARG], [
279 tmp_flags="$EXTRA_KCFLAGS"
280 EXTRA_KCFLAGS="-Werror"
281 LB_CHECK_COMPILE([if ldiskfs_iget takes a flags argument],
282 ext4_iget_3args, [
283         #include <linux/fs.h>
284         #include "$EXT4_SRC_DIR/ext4.h"
285 ],[
286         int f = EXT4_IGET_SPECIAL;
287         (void)f;
288 ],[
289         AC_DEFINE(HAVE_LDISKFS_IGET_WITH_FLAGS, 1,
290                 [if ldiskfs_iget takes a flags argument])
291 ])
292 EXTRA_KCFLAGS="$tmp_flags"
293 ]) # LB_LDISKFS_IGET_HAS_FLAGS_ARG
294
295 #
296 # LDISKFS_AC_PATCH_PROGRAM
297 #
298 # Determine which program should be used to apply the patches to
299 # the ext4 source code to produce the ldiskfs source code.
300 #
301 AC_DEFUN([LDISKFS_AC_PATCH_PROGRAM], [
302         AC_ARG_ENABLE([quilt],
303                 [AC_HELP_STRING([--disable-quilt],
304                         [disable use of quilt for ldiskfs])],
305                 [AS_IF([test "x$enableval" = xno],
306                         [use_quilt=no],
307                         [use_quilt=maybe])],
308                 [use_quilt=maybe]
309         )
310
311         AS_IF([test x$use_quilt = xmaybe], [
312                 AC_PATH_PROG([quilt_avail], [quilt], [no])
313                 AS_IF([test x$quilt_avail = xno], [
314                         use_quilt=no
315                 ], [
316                         use_quilt=yes
317                 ])
318         ])
319
320         AS_IF([test x$use_quilt = xno], [
321                 AC_PATH_PROG([patch_avail], [patch], [no])
322                 AS_IF([test x$patch_avail = xno], [
323                         AC_MSG_ERROR([*** Need "quilt" or "patch" command])
324                 ])
325         ])
326 ]) # LDISKFS_AC_PATCH_PROGRAM
327
328 #
329 # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
330 #
331 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
332 # ext4: avoid declaring fs inconsistent due to invalid file handles
333 # __ext4_find_entry became a helper function for ext4_find_entry
334 # conflicting with previous ldiskfs patches.
335 # ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
336 # avoid conflicting with __ext4_find_entry
337 #
338 # When the following check succeeds __ext4_find_entry helper is not
339 # used.
340 #
341 AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
342 tmp_flags="$EXTRA_KCFLAGS"
343 EXTRA_KCFLAGS="-Werror"
344 LB_CHECK_COMPILE([if __ldiskfs_find_entry is available],
345 ldiskfs_find_entry_locked, [
346         #include <linux/fs.h>
347         #include "$EXT4_SRC_DIR/ext4.h"
348         #include "$EXT4_SRC_DIR/namei.c"
349
350         static int __ext4_find_entry(void) { return 0; }
351 ],[
352         int x = __ext4_find_entry();
353         (void)x;
354 ],[
355         AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
356                 [if __ldiskfs_find_entry is available])
357 ])
358 EXTRA_KCFLAGS="$tmp_flags"
359 ]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
360
361 #
362 # LB_LDISKFSFS_DIRHASH_WANTS_DIR
363 #
364 # kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
365 # ext4fs_dirhash UNICODE support
366 #
367 AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
368 tmp_flags="$EXTRA_KCFLAGS"
369 EXTRA_KCFLAGS="-Werror"
370 LB_CHECK_COMPILE([if ldiskfsfs_dirhash takes an inode argument],
371 ext4fs_dirhash, [
372         #include <linux/fs.h>
373         #include "$EXT4_SRC_DIR/ext4.h"
374
375         int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
376                           struct dx_hash_info *hinfo)
377         {
378                 (void)dir;
379                 (void)name;
380                 (void)len;
381                 (void)hinfo;
382                 return 0;
383         }
384 ],[
385         int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
386         (void)f;
387 ],[
388         AC_DEFINE(HAVE_LDISKFSFS_GETHASH_INODE_ARG, 1,
389                 [ldiskfsfs_dirhash takes an inode argument])
390 ])
391 EXTRA_KCFLAGS="$tmp_flags"
392 ]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
393
394 #
395 # LB_JBD2_H_TOTAL_CREDITS
396 #
397 # kernel 5.5 commit 933f1c1e0b75bbc29730eef07c9e196c6dfd37e5
398 # jbd2: Reserve space for revoke descriptor blocks
399 #
400 AC_DEFUN([LB_JBD2_H_TOTAL_CREDITS], [
401 tmp_flags="$EXTRA_KCFLAGS"
402 EXTRA_KCFLAGS="-Werror"
403 LB_CHECK_COMPILE([if struct jbd2_journal_handle has h_total_credits member],
404 handle_t_h_revoke_credits, [
405         #include <linux/jbd2.h>
406 ],[
407         int x = offsetof(struct jbd2_journal_handle, h_total_credits);
408         (void)x;
409 ],[
410         AC_DEFINE(HAVE_JOURNAL_TOTAL_CREDITS, 1,
411                 [struct jbd2_journal_handle has h_total_credits member])
412 ])
413 EXTRA_KCFLAGS="$tmp_flags"
414 ]) # LB_JBD2_H_TOTAL_CREDITS
415
416 #
417 # LB_CONFIG_LDISKFS
418 #
419 AC_DEFUN([LB_CONFIG_LDISKFS], [
420 # --with-ldiskfs is deprecated now that ldiskfs is fully merged with lustre.
421 # However we continue to support this option through Lustre 2.5.
422 AC_ARG_WITH([ldiskfs],
423         [],
424         [AC_MSG_WARN([--with-ldiskfs is deprecated, please use --enable-ldiskfs])
425         AS_IF([test x$withval != xyes -a x$withval != xno],
426                 [AC_MSG_ERROR([
427
428 The ldiskfs option is deprecated,
429 and no longer supports paths to external ldiskfs source
430 ])])
431 ])
432
433 AC_ARG_ENABLE([ldiskfs],
434         [AS_HELP_STRING([--disable-ldiskfs],
435                 [disable ldiskfs osd (default is enable)])],
436         [AS_IF([test x$enable_ldiskfs != xyes -a x$enable_ldiskfs != xno],
437                 [AC_MSG_ERROR([ldiskfs valid options are "yes" or "no"])])],
438         [AS_IF([test "${with_ldiskfs+set}" = set],
439                 [enable_ldiskfs=$with_ldiskfs],
440                 [enable_ldiskfs=maybe])
441 ])
442
443 AS_IF([test x$enable_server = xno],
444         [AS_CASE([$enable_ldiskfs],
445                 [maybe], [enable_ldiskfs=no],
446                 [yes], [AC_MSG_ERROR([cannot build ldiskfs when servers are disabled])]
447         )])
448
449 AS_IF([test x$enable_ldiskfs != xno],[
450         # In the future, we chould change enable_ldiskfs from maybe to
451         # either yes or no based on additional tests, e.g.  whether a patch
452         # set is available for the detected kernel.  For now, we just always
453         # set it to "yes".
454         AS_IF([test x$enable_ldiskfs = xmaybe], [enable_ldiskfs=yes])
455         AC_SUBST(ENABLE_LDISKFS, yes)
456
457         LDISKFS_LINUX_SERIES
458         LDISKFS_AC_PATCH_PROGRAM
459         LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
460         LB_EXT4_JOURNAL_START_3ARGS
461         LB_EXT4_BREAD_4ARGS
462         LB_EXT4_HAVE_INFO_DQUOT
463         LB_EXT4_HAVE_I_CRYPT_INFO
464         LB_LDISKFS_JOURNAL_ENSURE_CREDITS
465         LB_LDISKFS_IGET_HAS_FLAGS_ARG
466         LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
467         LB_LDISKFSFS_DIRHASH_WANTS_DIR
468         LB_JBD2_H_TOTAL_CREDITS
469         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
470         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
471         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
472         AC_DEFINE(CONFIG_LDISKFS_FS_RW, 1, [enable rw access for ldiskfs])
473         AC_SUBST(LDISKFS_SUBDIR, ldiskfs)
474         AC_DEFINE(HAVE_LDISKFS_OSD, 1, Enable ldiskfs osd)
475 ], [
476         AC_SUBST(ENABLE_LDISKFS, no)
477 ])
478
479 AC_MSG_CHECKING([whether to build ldiskfs])
480 AC_MSG_RESULT([$enable_ldiskfs])
481
482 AM_CONDITIONAL([LDISKFS_ENABLED], [test x$enable_ldiskfs = xyes])
483 ]) # LB_CONFIG_LDISKFS
484
485
486 AC_DEFUN([LB_EXT4_SRC_DIR_SRC], [])
487 AC_DEFUN([LB_EXT4_SRC_DIR_RESULTS], [])
488
489 #
490 # LB_VALIDATE_EXT4_SRC_DIR
491 #
492 # Spot check the existence of several source files common to ext4.
493 # Detecting this at configure time allows us to avoid a potential build
494 # failure and provide a useful error message to explain what is wrong.
495 #
496 AC_DEFUN([LB_VALIDATE_EXT4_SRC_DIR], [
497 enable_ldiskfs_build="no"
498 AS_IF([test -n "$EXT4_SRC_DIR"], [
499         enable_ldiskfs_build="yes"
500         LB_CHECK_FILE([$EXT4_SRC_DIR/dir.c], [], [
501                 enable_ldiskfs_build="no"
502                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
503         ])
504         LB_CHECK_FILE([$EXT4_SRC_DIR/file.c], [], [
505                 enable_ldiskfs_build="no"
506                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
507         ])
508         LB_CHECK_FILE([$EXT4_SRC_DIR/inode.c], [], [
509                 enable_ldiskfs_build="no"
510                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
511         ])
512         LB_CHECK_FILE([$EXT4_SRC_DIR/super.c], [], [
513                 enable_ldiskfs_build="no"
514                 AC_MSG_WARN([ext4 must exist for ldiskfs build])
515         ])
516 ])
517
518 AS_IF([test "x$enable_ldiskfs_build" = xno], [
519         enable_ldiskfs="no"
520
521         AC_MSG_WARN([
522
523 Disabling ldiskfs support because complete ext4 source does not exist.
524
525 If you are building using kernel-devel packages and require ldiskfs
526 server support then ensure that the matching kernel-debuginfo-common
527 and kernel-debuginfo-common-<arch> packages are installed.
528 ])
529 ])
530 ]) # LB_VALIDATE_EXT4_SRC_DIR
531
532 #
533 # LB_EXT4_SRC_DIR
534 #
535 # Determine the location of the ext4 source code.  It it required
536 # for several configure tests and to build ldiskfs.
537 #
538 AC_DEFUN([LB_EXT4_SRC_DIR], [
539 AC_MSG_CHECKING([ext4 source directory])
540 # Kernel ext source located with devel headers
541 linux_src=$LINUX
542 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
543         EXT4_SRC_DIR="$linux_src/fs/ext4"
544 ], [
545         # Kernel ext source provided by kernel-debuginfo-common package
546         # that extracted to $LINUX
547         linux_src=$(ls -1d $linux_src/../../debug/*/linux-${LINUXRELEASE%.*}* \
548                 2>/dev/null | tail -1)
549         AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
550                 EXT4_SRC_DIR="$linux_src/fs/ext4"
551         ], [
552                 # Kernel ext source provided by kernel-debuginfo-common package
553                 linux_src=$(ls -1d /usr/src/debug/*/linux-${LINUXRELEASE%.*}* \
554                         2>/dev/null | tail -1)
555                 AS_IF([test -e "$linux_src/fs/ext4/super.c"], [
556                         EXT4_SRC_DIR="$linux_src/fs/ext4"
557                 ], [
558                         EXT4_SRC_DIR=""
559                 ])
560         ])
561 ])
562 AC_MSG_RESULT([$EXT4_SRC_DIR])
563 AC_SUBST(EXT4_SRC_DIR)
564
565 LB_VALIDATE_EXT4_SRC_DIR
566 ]) # LB_EXT4_SRC_DIR
567
568 #
569 # LB_DEFINE_E2FSPROGS_NAMES
570 #
571 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
572 #
573 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], [
574 AC_MSG_CHECKING([whether to use alternate names for e2fsprogs])
575 AC_ARG_WITH([ldiskfsprogs],
576         AC_HELP_STRING([--with-ldiskfsprogs],
577                 [use alternate names for ldiskfs-enabled e2fsprogs]),
578         [], [withval="no"])
579
580 AS_IF([test "x$withval" = xyes], [
581         AC_MSG_RESULT([enabled])
582         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
583         E2FSPROGS="ldiskfsprogs"
584         MKE2FS="mkfs.ldiskfs"
585         DEBUGFS="debugfs.ldiskfs"
586         TUNE2FS="tunefs.ldiskfs"
587         E2LABEL="label.ldiskfs"
588         DUMPE2FS="dumpfs.ldiskfs"
589         E2FSCK="fsck.ldiskfs"
590         PFSCK="pfsck.ldiskfs"
591 ], [
592         AC_MSG_RESULT([disabled])
593         E2FSPROGS="e2fsprogs"
594         MKE2FS="mke2fs"
595         DEBUGFS="debugfs"
596         TUNE2FS="tune2fs"
597         E2LABEL="e2label"
598         DUMPE2FS="dumpe2fs"
599         E2FSCK="e2fsck"
600         PFSCK="fsck"
601 ])
602
603 AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
604 AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
605 AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
606 AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
607 AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
608 AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
609 AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
610 AC_DEFINE_UNQUOTED(PFSCK, "$PFSCK", [name of parallel fsck program])
611
612 AC_SUBST([E2FSPROGS], [$E2FSPROGS])
613 AC_SUBST([MKE2FS], [$MKE2FS])
614 AC_SUBST([DEBUGFS], [$DEBUGFS])
615 AC_SUBST([TUNE2FS], [$TUNE2FS])
616 AC_SUBST([E2LABEL], [$E2LABEL])
617 AC_SUBST([DUMPE2FS], [$DUMPE2FS])
618 AC_SUBST([E2FSCK], [$E2FSCK])
619 AC_SUBST([PFSCK], [$PFSCK])
620 ]) # LB_DEFINE_E2FSPROGS_NAMES