Whamcloud - gitweb
e2fsck: clean up xattr checking code
[tools/e2fsprogs.git] / configure.ac
index 824a93d..963c7a0 100644 (file)
@@ -1,19 +1,19 @@
-AC_INIT(version.h)
-AC_PREREQ(2.69)
+AC_INIT
+AC_CONFIG_SRCDIR([version.h])
+AC_PREREQ(2.59)
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_HEADERS([lib/config.h])
 AH_BOTTOM([#include <dirpaths.h>])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_HEADERS([lib/config.h])
 AH_BOTTOM([#include <dirpaths.h>])
+AC_USE_SYSTEM_EXTENSIONS
 MCONFIG=./MCONFIG
 AC_SUBST_FILE(MCONFIG)
 BINARY_TYPE=bin
 dnl
 dnl This is to figure out the version number and the date....
 dnl
 MCONFIG=./MCONFIG
 AC_SUBST_FILE(MCONFIG)
 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_VER/ { 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}'`
 
 MONTH=`echo $E2FSPROGS_DATE | awk -F- '{print $2}'`
 YEAR=`echo $E2FSPROGS_DATE | awk -F- '{print $3}'`
 
@@ -41,28 +41,32 @@ Dec)        MONTH_NUM=12; E2FSPROGS_MONTH="December" ;;
 *)     AC_MSG_WARN([Unknown month $MONTH??]) ;;
 esac
 
 *)     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-*)
 
 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_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])
        ;;
 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_PKGVER)
 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_PKGVER)
+AC_SUBST(E2FSPROGS_PKGREL)
 AC_SUBST(E2FSPROGS_DATE)
 dnl
 dnl Use diet libc
 AC_SUBST(E2FSPROGS_DATE)
 dnl
 dnl Use diet libc
@@ -123,7 +127,6 @@ then
 else
     AC_MSG_RESULT([[(none)]])
 fi
 else
     AC_MSG_RESULT([[(none)]])
 fi
-AC_USE_SYSTEM_EXTENSIONS
 dnl
 dnl Set default values for library extensions.  Will be dealt with after
 dnl parsing configuration options, which may modify these
 dnl
 dnl Set default values for library extensions.  Will be dealt with after
 dnl parsing configuration options, which may modify these
@@ -844,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]),
 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])
 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])
 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=""
        AC_DEFINE(CONFIG_TDB, 1)
        TDB_CMT=""
        TDB_MAN_COMMENT=""
+else
+       TDB_CMT="#"
+       TDB_MAN_COMMENT='.\"'
 fi
 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
 AC_SUBST(TDB_CMT)
 AC_SUBST(TDB_MAN_COMMENT)
 dnl
@@ -1005,6 +1024,7 @@ AC_CHECK_HEADERS(m4_flatten([
        sys/mman.h
        sys/mount.h
        sys/prctl.h
        sys/mman.h
        sys/mount.h
        sys/prctl.h
+       sys/random.h
        sys/resource.h
        sys/select.h
        sys/socket.h
        sys/resource.h
        sys/select.h
        sys/socket.h
@@ -1018,6 +1038,17 @@ AC_CHECK_HEADERS(m4_flatten([
        sys/wait.h
        sys/xattr.h
 ]))
        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])
 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])
@@ -1137,18 +1168,12 @@ dnl flags somewhat portably.  Also check for the analogous setter, chflags().
 dnl
 AC_MSG_CHECKING(whether struct stat has a st_flags field)
 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
 dnl
 AC_MSG_CHECKING(whether struct stat has a st_flags field)
 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
-       AC_TRY_COMPILE([#include <sys/stat.h>],
-               [struct stat stat; stat.st_flags = 0;],
-               [e2fsprogs_cv_struct_st_flags=yes],
-               [e2fsprogs_cv_struct_st_flags=no]))
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat stat; stat.st_flags = 0;]])],[e2fsprogs_cv_struct_st_flags=yes],[e2fsprogs_cv_struct_st_flags=no]))
 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
   AC_MSG_CHECKING(whether st_flags field is useful)
   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
   AC_MSG_CHECKING(whether st_flags field is useful)
   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
-       AC_TRY_COMPILE([#include <sys/stat.h>],
-               [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
-               [e2fsprogs_cv_struct_st_flags_immut=yes],
-               [e2fsprogs_cv_struct_st_flags_immut=no]))
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat stat; stat.st_flags |= UF_IMMUTABLE;]])],[e2fsprogs_cv_struct_st_flags_immut=yes],[e2fsprogs_cv_struct_st_flags_immut=no]))
   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
          AC_DEFINE(HAVE_STAT_FLAGS, 1,
   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
          AC_DEFINE(HAVE_STAT_FLAGS, 1,
@@ -1200,9 +1225,11 @@ AC_CHECK_FUNCS(m4_flatten([
        futimes
        getcwd
        getdtablesize
        futimes
        getcwd
        getdtablesize
+       getentropy
        gethostname
        getmntinfo
        getpwuid_r
        gethostname
        getmntinfo
        getpwuid_r
+       getrandom
        getrlimit
        getrusage
        jrand48
        getrlimit
        getrusage
        jrand48
@@ -1211,6 +1238,7 @@ AC_CHECK_FUNCS(m4_flatten([
        llseek
        lseek64
        mallinfo
        llseek
        lseek64
        mallinfo
+       mallinfo2
        mbstowcs
        memalign
        mempcpy
        mbstowcs
        memalign
        mempcpy
@@ -1227,6 +1255,7 @@ AC_CHECK_FUNCS(m4_flatten([
        pwrite
        pread64
        pwrite64
        pwrite
        pread64
        pwrite64
+       qsort_r
        secure_getenv
        setmntent
        setresgid
        secure_getenv
        setmntent
        setresgid
@@ -1352,6 +1381,33 @@ then
 fi
 AC_SUBST(SEM_INIT_LIB)
 dnl
 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)
 dnl Check for unified diff
 dnl
 AC_MSG_CHECKING(for unified diff option)
@@ -1496,6 +1552,45 @@ if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then
        AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.])
 fi
 dnl
        AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.])
 fi
 dnl
+dnl Enable the fuzzer sanitizer for all packages
+dnl
+FUZZING_CMT="#"
+AC_ARG_ENABLE([fuzzing],
+AS_HELP_STRING([--enable-fuzzing],[enable fuzzing sanitizer]),,
+enable_fuzzing=no)
+if test "$enable_fuzzing" = "yes" || test "$enable_fuzzing" = "probe"; then
+       AC_PROG_CXX
+       AC_MSG_CHECKING([if C compiler supports fuzzing sanitizer])
+       AC_LANG_PUSH([C++])
+       OLD_CXXFLAGS="$CXXFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       FUZZER_FLAGS="-fsanitize=fuzzer"
+       CXXFLAGS="$CXXFLAGS $FUZZER_FLAGS"
+       LDFLAGS="$LDFLAGS $FUZZER_FLAGS"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+               #include <stddef.h>
+               #include <stdint.h>
+               ]],
+               [ return 0; ])],
+               [AC_MSG_RESULT([yes])]
+               [fuzzer_cflags=$FUZZER_FLAGS]
+               [fuzzer_ldflags=$FUZZER_FLAGS]
+               [FUZZING_CMT=]
+               [have_fuzzer=yes],
+               [AC_MSG_RESULT([no])]
+               [AC_MSG_ERROR([fuzzing requested but not available])])
+       CXXFLAGS="${OLD_CXXFLAGS}"
+       LDFLAGS="${OLD_LDFLAGS}"
+       AC_LANG_POP([C++])
+       AC_SUBST(have_fuzzer)
+       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
 dnl
 LINUX_CMT="#"
 dnl OS-specific uncomment control
 dnl
 LINUX_CMT="#"
@@ -1603,8 +1698,7 @@ dnl
 AC_MSG_CHECKING([whether we can link with -static])
 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS_STATIC -static"
 AC_MSG_CHECKING([whether we can link with -static])
 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS_STATIC -static"
-AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
- ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(stdout);]])],[ac_cv_e2fsprogs_use_static=yes],[ac_cv_e2fsprogs_use_static=no])
 LDFLAGS=$SAVE_LDFLAGS])
 dnl
 dnl Regardless of how the test turns out, Solaris doesn't handle -static
 LDFLAGS=$SAVE_LDFLAGS])
 dnl
 dnl Regardless of how the test turns out, Solaris doesn't handle -static
@@ -1657,6 +1751,11 @@ fi
 if test -n "$WITH_DIET_LIBC" ; then
        INCLUDES="$INCLUDES -D_REENTRANT"
 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
 AC_SUBST(INCLUDES)
 dnl
 dnl Build CFLAGS
@@ -1789,7 +1888,7 @@ dnl Adjust the compiled files if we are on windows vs everywhere else
 dnl
 OS_IO_FILE=""
 [case "$host_os" in
 dnl
 OS_IO_FILE=""
 [case "$host_os" in
-  cigwin*|mingw*|msys*)
+  mingw*)
     OS_IO_FILE=windows_io
   ;;
   *)
     OS_IO_FILE=windows_io
   ;;
   *)
@@ -1797,6 +1896,9 @@ OS_IO_FILE=""
   ;;
 esac]
 AC_SUBST(OS_IO_FILE)
   ;;
 esac]
 AC_SUBST(OS_IO_FILE)
+
+AC_SYS_LARGEFILE
+
 dnl
 dnl Make our output files, being sure that we create the some miscellaneous 
 dnl directories
 dnl
 dnl Make our output files, being sure that we create the some miscellaneous 
 dnl directories
@@ -1814,6 +1916,9 @@ if test -z "$BLKID_CMT" ; then
                lib/blkid/blkid_types.h"
 fi
 for i in MCONFIG Makefile \
                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 \
        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 \
@@ -1821,10 +1926,12 @@ for i in MCONFIG Makefile \
        lib/ss/ss.pc lib/et/com_err.pc lib/e2p/e2p.pc lib/ext2fs/ext2fs.pc \
        misc/Makefile ext2ed/Makefile e2fsck/Makefile \
        debugfs/Makefile tests/Makefile tests/progs/Makefile \
        lib/ss/ss.pc lib/et/com_err.pc lib/e2p/e2p.pc lib/ext2fs/ext2fs.pc \
        misc/Makefile ext2ed/Makefile e2fsck/Makefile \
        debugfs/Makefile tests/Makefile tests/progs/Makefile \
-       resize/Makefile doc/Makefile po/Makefile.in scrub/Makefile; do
+       tests/fuzz/Makefile resize/Makefile doc/Makefile \
+       po/Makefile.in scrub/Makefile; do
        if test -d `dirname ${srcdir}/$i` ; then
                outlist="$outlist $i"
        fi
 done
        if test -d `dirname ${srcdir}/$i` ; then
                outlist="$outlist $i"
        fi
 done
-AC_OUTPUT($outlist)
+AC_CONFIG_FILES([$outlist])
+AC_OUTPUT
 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi
 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi