+dnl
+dnl Check for ext2fs_read_inode_full
+dnl
+AC_CHECK_LIB(ext2fs, ext2fs_read_inode_full, [rif=yes], [rif=no], [-lcom_err])
+if test "$rif" = yes; then
+ AC_DEFINE([HAVE_EXT2FS_READ_INODE_FULL],1,[Define this if your ext2fs libs have the ext2fs_read_inode_full function.])
+fi
+
+dnl
+dnl Try to use ext2_fs.h header from libext2fs instead of from the kernel
+dnl
+AC_CHECK_HEADERS(ext2fs/ext2_fs.h, [], [], [-])
+
+dnl
+dnl Check for ext2_ino_t type
+dnl
+AC_MSG_CHECKING(for ext2_ino_t type in libext2fs headers)
+AC_TRY_COMPILE([#include <stdio.h>
+#ifdef HAVE_EXT2FS_EXT2_FS_H
+#include <ext2fs/ext2_fs.h>
+#else
+#include <linux/ext2_fs.h>
+#endif
+#include <ext2fs/ext2fs.h>],
+[ext2_ino_t ino = 0;],
+[AC_DEFINE([HAVE_EXT2_INO_T],1,[Define if we have the ext2_ino_t type (from e2fsprogs 1.20+).])
+ AC_MSG_RESULT(yes)],
+AC_MSG_RESULT(no))
+
+dnl
+dnl Check for s_journal_inum field in ext2_super_block struct
+dnl
+AC_MSG_CHECKING(for s_journal_inum field in ext2_super_block struct)
+AC_TRY_COMPILE([#include <stdio.h>
+#ifdef HAVE_EXT2FS_EXT2_FS_H
+#include <ext2fs/ext2_fs.h>
+#else
+#include <linux/ext2_fs.h>
+#endif
+#include <ext2fs/ext2fs.h>],
+[struct ext2_super_block es; es.s_journal_inum = 0;],
+[AC_DEFINE([HAVE_EXT2_JOURNAL_INUM],1,[Define if we have the s_journal_inum field in struct ext2_super_block.])
+ AC_MSG_RESULT(yes)],
+AC_MSG_RESULT(no))
+
+dnl
+dnl Check for blkid headers libraries
+dnl
+AC_CHECK_HEADER(blkid/blkid.h, [blkid_h=yes], [blkid_h=no], [-])
+AC_CHECK_LIB(blkid, blkid_get_devname, [blkid_lib=yes], [blkid_lib=no], [-luuid])
+if test "$blkid_h" = yes -a "$blkid_lib" = yes; then
+ AC_DEFINE([HAVE_BLKID],1,[Define this if you have the blkid library.])
+ BLKID="-lblkid -luuid -ldevmapper -lselinux -lsepol"
+fi
+AC_SUBST(BLKID)
+
+dnl
+dnl Check for ncurses or termcap libraries
+dnl
+AC_CHECK_LIB(ncurses, tgetent, [ncurses_lib=yes], [ncurses_lib=no])
+AC_CHECK_LIB(termcap, tgetent, [termcap_lib=yes], [termcap_lib=no])
+AC_CHECK_LIB(tinfo, tgetent, [tinfo_lib=yes], [tinfo_lib=no])
+
+if test "$ncurses_lib" = no -a "$termcap_lib" = no -a "$tinfo_lib" = no; then
+ if test "$READLINE" = "yes"; then
+ AC_MSG_ERROR(You need to install the ncurses or termcap library or configure without --enable-readline)
+ fi
+fi
+if test "$tinfo_lib" = yes; then
+ rdllib="-ltinfo"
+elif test "$ncurses_lib" = yes; then
+ rdllib="-lncurses"
+elif test "$termcap_lib" = yes; then
+ rdllib="-ltermcap"
+fi
+
+dnl
+dnl Check for readline headers and libraries
+dnl
+AC_CHECK_HEADER(readline/readline.h, [readline_h=yes], [readline_h=no], [-])
+AC_CHECK_LIB(readline, readline, [readline_lib=yes], [readline_lib=no], $rdllib)
+if test "$readline_h" = no -o "$readline_lib" = no; then
+ if test "$READLINE" = "yes"; then
+ AC_MSG_ERROR(You need to install the GNU readline library or configure without --enable-readline)
+ fi
+fi
+if test "$READLINE" = yes; then
+ READLINE="-lreadline $rdllib"
+fi
+AC_SUBST(READLINE)
+
+dnl
+dnl Check for rl_completion_matches
+dnl
+AC_CHECK_LIB(readline, rl_completion_matches, [rlcm=yes], [rlcm=no], "-ltermcap")
+if test "$rlcm" = yes; then
+ AC_DEFINE([HAVE_READLINE_RLCM],1,[Define this if your readline libs have the rl_completion_matches library.])
+fi
+
+dnl
+dnl Check for rl_completion_append_character
+dnl
+AC_CHECK_LIB(readline, rl_completion_append_character, [rcac=yes], [rcac=no], "-ltermcap")
+if test "$rcac" = yes; then
+ AC_DEFINE([HAVE_READLINE_CAC],1,[Define this if your readline libs have the rl_completion_append_character variable.])
+fi
+
+dnl
+dnl Check for zlib headers and libraries
+dnl
+AC_CHECK_HEADER(zlib.h, [zlib_h=yes], [zlib_h=no], [-])
+AC_CHECK_LIB(z, compress2, [zlib_lib=yes], [zlib_lib=no])
+if test "$zlib_h" = yes -a "$zlib_lib" = yes; then
+ if test "$STATICZ" = yes; then
+ ZLIB="-Wl,-Bstatic -lz -Wl,-Bdynamic"
+ else
+ ZLIB="-lz"
+ fi
+ AC_DEFINE([HAVE_ZLIB],1,[Define this if you have zlib compression library.])
+else
+ ZLIB=""
+fi
+AC_SUBST(ZLIB)
+
+dnl
+dnl Check for bzlib headers and libraries
+dnl
+AC_CHECK_HEADER(bzlib.h, [bzlib_h=yes], [bzlib_h=no], [-])
+AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress, [bzlib_lib=yes], [bzlib_lib=no])
+if test "$bzlib_h" = yes -a "$bzlib_lib" = yes; then
+ if test "$STATICZ" = yes; then
+ BZLIB="-Wl,-Bstatic -lbz2 -Wl,-Bdynamic"
+ else
+ BZLIB="-lbz2"
+ fi
+ AC_DEFINE([HAVE_BZLIB],1,[Define this if you have bzlib compression library.])
+else
+ BZLIB=""
+fi
+AC_SUBST(BZLIB)
+