-# TODO: Remove after smartmontools 6.5
-AC_ARG_WITH(docdir,
- [AS_HELP_STRING([--with-docdir=DIR], [(removed, use --docdir=DIR instead)])],
- [AC_MSG_ERROR([--with-docdir is no longer supported, use --docdir instead])])
-AC_ARG_ENABLE(drivedb,
- [AS_HELP_STRING([--disable-drivedb], [(removed, use --without-drivedbdir instead)])])
-AC_ARG_ENABLE(savestates,
- [AS_HELP_STRING([--enable-savestates], [(removed, use --with-savestates@<:@=yes@:>@ instead)])])
-AC_ARG_ENABLE(attributelog,
- [AS_HELP_STRING([--enable-attributelog], [(removed, use --with-attributelog@<:@=yes@:>@ instead)])])
-if test -n "${enable_drivedb+set}${enable_savestates+set}${enable_attributelog+set}"; then
- AC_MSG_ERROR([Options --disable-drivedb, --enable-savestates, --enable-attributelog are no longer supported.
-Use --without-drivedbdir, --with-savestates, --with-attributelog instead.])
-fi
+AC_ARG_WITH(cxx11-option,
+ [AS_HELP_STRING([--with-cxx11-option@<:@=OPTION|auto|no@:>@],
+ [Compiler option to enable C++11 support for future versions of smartmontools, 'no' if unsupported [auto]])],
+ [], [with_cxx11_option=auto])
+
+check_cxx11_support()
+{
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS=$1
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #if __cplusplus < 201103L
+ #error false
+ #endif
+ // use some C++11 features (and return v * 42 :-)
+ auto cxx11(long v) noexcept -> decltype(v) {
+ typedef decltype(v) t; t r = v;
+ static const t a[] = { -7, -1, 1, 2, 3 };
+ static_assert(sizeof(r) == sizeof(a[0]), "fail");
+ auto f = [](t x, t y){ return x * y; };
+ for (const auto & e : a) r = f(r, e);
+ return r;
+ }]])],
+ [CXXFLAGS=$save_CXXFLAGS; return 0], [CXXFLAGS=$save_CXXFLAGS; return 1])
+}
+
+case "$with_cxx11_option" in
+ no) ;;
+ auto)
+ AC_MSG_CHECKING([for $CXX option to accept C++11])
+ with_cxx11_option=unknown
+ for option in "" "-std=gnu++11" "-std=gnu++0x" "-std=c++11" "-std=c++0x"; do
+ if check_cxx11_support "$option"; then with_cxx11_option=$option; break; fi
+ done
+ AC_MSG_RESULT([${with_cxx11_option:-none needed}])
+ test "$with_cxx11_option" != "unknown" || AC_MSG_ERROR([
+This version of smartmontools does not use C++11 features, but future
+versions possibly will.
+This script was unable to determine a compiler option to enable C++11.
+Use option '--with-cxx11-option=OPTION' to specify the compiler option
+(it will be checked, but not used in the actual build).
+Use option '--without-cxx11-option' to suppress this error message if the
+compiler lacks C++11 support.
+In both cases, please send info about compiler and platform to
+$PACKAGE_BUGREPORT - Thanks!])
+ ;;
+ *)
+ AC_MSG_CHECKING([whether $CXX $with_cxx11_option accepts C++11])
+ res=no; check_cxx11_support "$with_cxx11_option" && res=yes
+ AC_MSG_RESULT([$res])
+ test "$res" = "yes" || AC_MSG_ERROR([$CXX $with_cxx11_option does not accept C++11])
+ ;;
+esac