Merge branch '2991_label_redraw'
[midnight-commander.git] / m4.include / vfs / mc-vfs-undelfs.m4
blob43f12ee901e71d1d97f7c59ee8f76f791037d47f
1 dnl MC_UNDELFS_CHECKS
2 dnl    Check for ext2fs undel support.
3 dnl    Set shell variable ext2fs_undel to "yes" if we have it,
4 dnl    "no" otherwise.  May define ENABLE_VFS_UNDELFS for cpp.
5 dnl    Will set EXT2FS_UNDEL_LIBS to required libraries.
7 AC_DEFUN([MC_UNDELFS_CHECKS], [
8   ext2fs_undel=no
9   EXT2FS_UNDEL_LIBS=
10   AC_CHECK_HEADERS([ext2fs/ext2_fs.h linux/ext2_fs.h], [ext2_fs_h=yes; break])
11   if test x"$ext2_fs_h" = xyes; then
12     AC_CHECK_HEADERS([ext2fs/ext2fs.h], [ext2fs_ext2fs_h=yes], ,
13                      [
14 #include <stdio.h>
15 #ifdef HAVE_EXT2FS_EXT2_FS_H
16 #include <ext2fs/ext2_fs.h>
17 #else
18 #undef umode_t
19 #include <linux/ext2_fs.h>
20 #endif
21                      ])
22     if test x"$ext2fs_ext2fs_h" = xyes; then
23       ext2fs_undel=yes
24       EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
25       AC_CHECK_TYPE([ext2_ino_t], ,
26                     [AC_DEFINE_UNQUOTED([ext2_ino_t], [ino_t],
27                                [Define to ino_t if undefined.])],
28                     [
29 #include <errno.h>
30 #include <stdio.h>
31 #include <fcntl.h>
32 #include <stdlib.h>
33 #ifdef HAVE_EXT2FS_EXT2_FS_H
34 #include <ext2fs/ext2_fs.h>
35 #else
36 #undef umode_t
37 #include <linux/ext2_fs.h>
38 #endif
39 #include <ext2fs/ext2fs.h>
40                     ])
41     fi
42   fi
45 dnl
46 dnl Ext2fs undelete support
47 dnl
48 AC_DEFUN([AC_MC_VFS_UNDELFS],
50     AC_ARG_ENABLE([vfs-undelfs],
51         AS_HELP_STRING([--enable-vfs-undelfs], [Support for ext2 undelete filesystem @<:@no@:>@]),
52         [
53             if test "x$enableval" = "xno"; then
54                 enable_vfs_undelfs=no
55             else
56                 enable_vfs_undelfs=yes
57             fi
58         ],
59         [enable_vfs_undelfs="no"])
61     if test x"$enable_vfs" = x"yes" -a x"$enable_vfs_undelfs" != x"no"; then
62         MC_UNDELFS_CHECKS
64         if test x"$ext2fs_undel" = x"yes"; then
65             enable_vfs_undelfs="yes"
66             AC_MC_VFS_ADDNAME([undelfs])
67             AC_DEFINE(ENABLE_VFS_UNDELFS, [1], [Support for ext2 undelfs])
68             AC_MSG_NOTICE([using ext2fs file recovery code])
69             MCLIBS="$MCLIBS $EXT2FS_UNDEL_LIBS"
70         else
71             AC_ERROR([Ext2 libraries not found])
72         fi
73     fi
74     AM_CONDITIONAL(ENABLE_VFS_UNDELFS, [test "$enable_vfs" = "yes" -a x"$enable_vfs_undelfs" = x"yes"])