Whamcloud - gitweb
LU-9501 mke2fs: avoid inode number error with large FS
[tools/e2fsprogs.git] / configure.ac
index 78f71fd..47d02b2 100644 (file)
@@ -1,6 +1,6 @@
 AC_INIT
 AC_CONFIG_SRCDIR([version.h])
-AC_PREREQ([2.71])
+AC_PREREQ(2.59)
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_HEADERS([lib/config.h])
 AH_BOTTOM([#include <dirpaths.h>])
@@ -11,11 +11,9 @@ BINARY_TYPE=bin
 dnl
 dnl This is to figure out the version number and the date....
 dnl
-E2FSPROGS_VERSION=`grep E2FSPROGS_VERSION ${srcdir}/version.h  \
-       | awk '{print $3}' | tr \" " " | awk '{print $1}'`
-E2FSPROGS_DATE=`grep E2FSPROGS_DATE ${srcdir}/version.h | awk '{print $3}' \
-       | tr \" " " | awk '{print $1}'`
-E2FSPROGS_DAY=$(echo $E2FSPROGS_DATE | awk -F- '{print $1}' | sed -e '/^[[1-9]]$/s/^/0/')
+E2FSPROGS_VERSION=`awk -F\" '/E2FSPROGS_VERS/ { print $2 }' ${srcdir}/version.h`
+E2FSPROGS_DATE=`awk -F\" '/E2FSPROGS_DATE/ { print $2 }' ${srcdir}/version.h`
+E2FSPROGS_DAY=$(echo $E2FSPROGS_DATE | awk -F- '{ printf "%02d", $1 }')
 MONTH=`echo $E2FSPROGS_DATE | awk -F- '{print $2}'`
 YEAR=`echo $E2FSPROGS_DATE | awk -F- '{print $3}'`
 
@@ -43,27 +41,31 @@ Dec)        MONTH_NUM=12; E2FSPROGS_MONTH="December" ;;
 *)     AC_MSG_WARN([Unknown month $MONTH??]) ;;
 esac
 
-base_ver=`echo $E2FSPROGS_VERSION | \
-              sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'`
+base_ver=`echo $E2FSPROGS_VERSION | sed -e 's/pre-//' -e 's/-.*//'`
+base_rel=`echo $E2FSPROGS_VERSION | awk -F- '{ print $2 }'`
 
 date_spec=${E2FSPROGS_YEAR}.${MONTH_NUM}.${E2FSPROGS_DAY}
 
 case $E2FSPROGS_VERSION in
 *-WIP|pre-*)
-       E2FSPROGS_PKGVER="$base_ver~WIP.$date_spec"
+       E2FSPROGS_PKGVER="$base_ver"
+       E2FSPROGS_PKGREL="WIP.$date_spec"
        ;;
 *)
        E2FSPROGS_PKGVER="$base_ver"
+       E2FSPROGS_PKGREL="$base_rel"
        ;;
 esac
 
 unset DATE MONTH YEAR base_ver pre_vers date_spec
 AC_MSG_RESULT([Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION])
+AC_MSG_RESULT([Package version ${E2FSPROGS_PKGVER} release ${E2FSPROGS_PKGREL}])
 AC_MSG_RESULT([Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}])
 AC_SUBST(E2FSPROGS_YEAR)
 AC_SUBST(E2FSPROGS_MONTH)
 AC_SUBST(E2FSPROGS_DAY)
 AC_SUBST(E2FSPROGS_VERSION)
+AC_SUBST(E2FSPROGS_PKGREL)
 AC_SUBST(E2FSPROGS_PKGVER)
 AC_SUBST(E2FSPROGS_DATE)
 dnl
@@ -363,10 +365,10 @@ CFLAGS_STLIB="${CFLAGS_STLIB:-$CFLAGS}"
 LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
 LDFLAGS_STATIC=${LDFLAGS_STATIC:-$LDFLAGS}
 AC_ARG_ENABLE([hardening],
-AS_HELP_STRING([--enable-hardening],[build for coverage testing using gcov]),
+AS_HELP_STRING([--enable-hardening],[build with hardening flags such as fortify]),
 if test "$enableval" = "yes"
 then
-       HARDEN_CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
+       HARDEN_CFLAGS="-D_FORTIFY_SOURCE=3 -fstack-protector-strong"
        HARDEN_LDFLAGS=["-Wl,-z,relro -Wl,-z,now"]
        CFLAGS="$CFLAGS $HARDEN_CFLAGS -fPIE"
        CFLAGS_SHLIB="$CFLAGS_SHLIB $HARDEN_CFLAGS"
@@ -845,23 +847,39 @@ dnl
 AH_TEMPLATE([CONFIG_TDB], [Define to 1 to enable tdb support])
 AC_ARG_ENABLE([tdb],
 AS_HELP_STRING([--disable-tdb],[disable tdb support]),
+[
 if test "$enableval" = "no"
 then
        AC_MSG_RESULT([Disabling tdb support])
-       TDB_CMT="#"
-       TDB_MAN_COMMENT='.\"'
+       CONFIG_TDB=0
 else
        AC_MSG_RESULT([Enabling tdb support])
+       CONFIG_TDB=1
+fi
+]
+,
+[
+case "$host_os" in
+mingw*)
+       AC_MSG_RESULT([Disabling tdb support by default])
+       CONFIG_TDB=0
+       ;;
+*)
+       AC_MSG_RESULT([Enabling tdb support by default])
+       CONFIG_TDB=1
+       ;;
+esac
+]
+)
+if test "$CONFIG_TDB" = "1"
+then
        AC_DEFINE(CONFIG_TDB, 1)
        TDB_CMT=""
        TDB_MAN_COMMENT=""
+else
+       TDB_CMT="#"
+       TDB_MAN_COMMENT='.\"'
 fi
-,
-AC_MSG_RESULT([Enabling mmp support by default])
-AC_DEFINE(CONFIG_TDB, 1)
-TDB_CMT=""
-TDB_MAN_COMMENT=""
-)
 AC_SUBST(TDB_CMT)
 AC_SUBST(TDB_MAN_COMMENT)
 dnl
@@ -969,6 +987,7 @@ else
   AC_CHECK_PROGS(BUILD_CC, gcc cc)
 fi
 AC_CHECK_HEADERS(m4_flatten([
+       attr/xattr.h
        dirent.h
        errno.h
        execinfo.h
@@ -1020,6 +1039,17 @@ AC_CHECK_HEADERS(m4_flatten([
        sys/wait.h
        sys/xattr.h
 ]))
+case "$host_os" in
+mingw*)
+       # The above checks only detect system headers, not the headers in
+       # ./include/mingw/, so explicitly define them to be available.
+       AC_DEFINE(HAVE_LINUX_TYPES_H, 1)
+       AC_DEFINE(HAVE_SYS_STAT_H, 1)
+       AC_DEFINE(HAVE_SYS_SYSMACROS_H, 1)
+       AC_DEFINE(HAVE_SYS_TYPES_H, 1)
+       AC_DEFINE(HAVE_UNISTD_H, 1)
+       ;;
+esac
 dnl Check where to find a dd(1) that supports iflag=fullblock
 dnl and oflag=append
 AC_MSG_CHECKING([for a dd(1) program that supports iflag=fullblock])
@@ -1080,9 +1110,16 @@ AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
                [#define _LARGEFILE_SOURCE
                 #define _LARGEFILE64_SOURCE
                 #include <unistd.h>])
+
+dnl The Android NDK has <linux/fsmap.h>, but it is missing the inline functions
+dnl fsmap_sizeof() and fsmap_advance().  Check whether this is the case.
+AC_CHECK_DECL(fsmap_sizeof,[AC_DEFINE(HAVE_FSMAP_SIZEOF, 1,
+                           [Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h])],,
+               [#include <linux/fsmap.h>])
 dnl
 dnl Word sizes...
 dnl
+AC_SYS_LARGEFILE
 AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
@@ -1226,6 +1263,7 @@ AC_CHECK_FUNCS(m4_flatten([
        pwrite
        pread64
        pwrite64
+       qsort_r
        secure_getenv
        setmntent
        setresgid
@@ -1262,12 +1300,50 @@ if test "$ac_cv_func_dlopen" = yes ; then
 fi
 AC_SUBST(MAGIC_LIB)
 dnl
+dnl libarchive
+dnl
+AC_ARG_WITH([libarchive],
+AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
+[if test "$withval" = "no"
+then
+       try_libarchive=""
+       AC_MSG_RESULT([Disabling libarchive support])
+elif test "$withval" = "direct"
+then
+       try_libarchive="direct"
+       AC_MSG_RESULT([Testing for libarchive support (forced direct link)])
+else
+       try_libarchive="yes"
+       AC_MSG_RESULT([Testing for libarchive support (with dlopen)])
+fi]
+,
+try_libarchive="yes"
+AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default])
+)
+ARCHIVE_LIB=
+if test -n "$try_libarchive"
+then
+    AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
+    AC_CHECK_HEADERS([archive.h])])
+    if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
+        ARCHIVE_LIB=$DLOPEN_LIB
+       AC_DEFINE(CONFIG_DLOPEN_LIBARCHIVE, 1,
+               [Define to 1 if using dlopen to access libarchive])
+
+    fi
+    if test "$ac_cv_header_archive_h" != "yes"
+    then
+        ARCHIVE_LIB=
+    fi
+fi
+AC_SUBST(ARCHIVE_LIB)
+dnl
 dnl Check to see if librt is required for clock_gettime() (glibc < 2.17)
 dnl
 AC_CHECK_LIB(rt, clock_gettime, [CLOCK_GETTIME_LIB=-lrt])
 AC_SUBST(CLOCK_GETTIME_LIB)
 dnl
-dnl Check to see if the FUSE library is -lfuse or -losxfuse
+dnl Check to see if the FUSE library is -lfuse3, -losxfuse, or -lfuse
 dnl
 FUSE_CMT=
 FUSE_LIB=
@@ -1279,27 +1355,35 @@ then
        FUSE_CMT="#"
        AC_MSG_RESULT([Disabling fuse2fs])
 else
-       AC_CHECK_HEADERS([pthread.h fuse.h], [],
-[AC_MSG_FAILURE([Cannot find fuse2fs headers.])],
-[#define _FILE_OFFSET_BITS     64
-#define FUSE_USE_VERSION 29])
-
        AC_PREPROC_IFELSE(
-[AC_LANG_PROGRAM([[#define FUSE_USE_VERSION 29
-#ifdef __linux__
+[AC_LANG_PROGRAM([[#ifdef __linux__
 #include <linux/fs.h>
 #include <linux/falloc.h>
 #include <linux/xattr.h>
 #endif
 ]], [])], [], [AC_MSG_FAILURE([Cannot find fuse2fs Linux headers.])])
 
-       AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
-               [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
-                             [AC_MSG_FAILURE([Cannot find fuse library.])])])
+       PKG_CHECK_MODULES([fuse3], [fuse3],
+         [
+               FUSE_LIB=-lfuse3
+         ], [
+               AC_CHECK_HEADERS([pthread.h fuse.h], [],
+                       [AC_MSG_FAILURE([Cannot find fuse2fs headers.])],
+[#define _FILE_OFFSET_BITS     64
+#define FUSE_USE_VERSION 29])
+
+               AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
+                       [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
+                               [AC_MSG_FAILURE([Cannot find fuse library.])])])
+         ])
        AC_MSG_RESULT([Enabling fuse2fs])
 fi
 ,
-AC_CHECK_HEADERS([pthread.h fuse.h], [], [FUSE_CMT="#"],
+PKG_CHECK_MODULES([fuse3], [fuse3],
+  [
+       FUSE_LIB=-lfuse3
+  ], [
+       AC_CHECK_HEADERS([pthread.h fuse.h], [], [FUSE_CMT="#"], 
 [#define _FILE_OFFSET_BITS     64
 #define FUSE_USE_VERSION 29
 #ifdef __linux__
@@ -1307,11 +1391,13 @@ AC_CHECK_HEADERS([pthread.h fuse.h], [], [FUSE_CMT="#"],
 # include <linux/falloc.h>
 # include <linux/xattr.h>
 #endif])
-if test -z "$FUSE_CMT"
-then
-       AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
-[AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse], [FUSE_CMT="#"])])
-fi
+       if test -z "$FUSE_CMT"
+       then
+               AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
+                       [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
+                               [FUSE_CMT="#"])])
+       fi
+  ])
 if test -z "$FUSE_CMT"
 then
        AC_MSG_RESULT([Enabling fuse2fs by default.])
@@ -1319,6 +1405,29 @@ fi
 )
 AC_SUBST(FUSE_LIB)
 AC_SUBST(FUSE_CMT)
+if test "$FUSE_LIB" = "-lfuse3"
+then
+       FUSE_USE_VERSION=35
+       CFLAGS="$CFLAGS $fuse3_CFLAGS"
+       LDFLAGS="$LDFLAGS $fuse3_LDFLAGS"
+       AC_CHECK_HEADERS([pthread.h fuse.h], [],
+               [AC_MSG_FAILURE([Cannot find fuse3 fuse2fs headers.])],
+[#define _FILE_OFFSET_BITS     64
+#define FUSE_USE_VERSION 35
+#ifdef __linux__
+#include <linux/fs.h>
+#include <linux/falloc.h>
+#include <linux/xattr.h>
+#endif])
+elif test -n "$FUSE_LIB"
+then
+       FUSE_USE_VERSION=29
+fi
+if test -n "$FUSE_USE_VERSION"
+then
+       AC_DEFINE_UNQUOTED(FUSE_USE_VERSION, $FUSE_USE_VERSION,
+               [Define to the version of FUSE to use])
+fi
 dnl
 dnl See if optreset exists
 dnl
@@ -1351,6 +1460,33 @@ then
 fi
 AC_SUBST(SEM_INIT_LIB)
 dnl
+dnl qsort_r detection
+dnl
+AS_IF([test "$ac_cv_func_qsort_r" != no], [
+  AC_CACHE_CHECK(whether qsort_r is GNU version, e2_cv_gnu_qsort_r,
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+@%:@include <stdlib.h>
+void (qsort_r)(void *base, size_t nmemb, size_t size,
+           int (*compar)(const void *, const void *, void *),
+           void *arg);
+]], [[ ]])],[e2_cv_gnu_qsort_r=yes],[e2_cv_gnu_qsort_r=no])
+  ])
+  AC_CACHE_CHECK(whether qsort_r is BSD version, e2_cv_bsd_qsort_r,
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+@%:@include <stdlib.h>
+void (qsort_r)(void *base, size_t nmemb, size_t size,
+            void *arg, int (*compar)(void *, const void *, const void *));
+]], [[ ]])],[e2_cv_bsd_qsort_r=yes],[e2_cv_bsd_qsort_r=no])
+  ])
+  AS_CASE("$e2_cv_gnu_qsort_r:$e2_cv_bsd_qsort_r",
+  [yes:no], [
+    AC_DEFINE(HAVE_GNU_QSORT_R, 1, [ Define to 1 if you have the GNU-style 'qsort_r' function.])
+  ],
+  [no:yes], [
+    AC_DEFINE(HAVE_BSD_QSORT_R, 1, [ Define to 1 if you have the BSD-style 'qsort_r' function.])
+  ])
+])
+dnl
 dnl Check for unified diff
 dnl
 AC_MSG_CHECKING(for unified diff option)
@@ -1529,9 +1665,6 @@ if test "$enable_fuzzing" = "yes" || test "$enable_fuzzing" = "probe"; then
        AC_SUBST(fuzzer_cflags)
        AC_SUBST(fuzzer_ldflags)
 fi
-if test "$enable_fuzzer" = "yes" && test "$have_fuzzer" != "yes"; then
-       AC_MSG_ERROR([Fuzzing not supported by compiler.])
-fi
 AC_SUBST(FUZZING_CMT)
 dnl
 dnl OS-specific uncomment control
@@ -1694,6 +1827,11 @@ fi
 if test -n "$WITH_DIET_LIBC" ; then
        INCLUDES="$INCLUDES -D_REENTRANT"
 fi
+case "$host_os" in
+mingw*)
+       INCLUDES=$INCLUDES' -I$(top_srcdir)/include/mingw'
+       ;;
+esac
 AC_SUBST(INCLUDES)
 dnl
 dnl Build CFLAGS
@@ -1826,7 +1964,7 @@ dnl Adjust the compiled files if we are on windows vs everywhere else
 dnl
 OS_IO_FILE=""
 [case "$host_os" in
-  cigwin*|mingw*|msys*)
+  mingw*)
     OS_IO_FILE=windows_io
   ;;
   *)
@@ -1834,6 +1972,7 @@ OS_IO_FILE=""
   ;;
 esac]
 AC_SUBST(OS_IO_FILE)
+
 dnl
 dnl Make our output files, being sure that we create the some miscellaneous 
 dnl directories
@@ -1851,6 +1990,9 @@ if test -z "$BLKID_CMT" ; then
                lib/blkid/blkid_types.h"
 fi
 for i in MCONFIG Makefile \
+       e2fsprogs-RHEL-6.spec \
+       e2fsprogs-SUSE_LINUX-11+.spec \
+       e2fsprogs-RHEL-7+.spec \
        util/Makefile util/subst.conf util/gen-tarball util/install-symlink \
        lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
        lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \