+dnl Usage: LYX_PROG_CLANG: set CLANG to yes if the compiler is clang.
+AC_DEFUN([LYX_PROG_CLANG],
+[AC_CACHE_CHECK([whether the compiler is clang],
+ [lyx_cv_prog_clang],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+#ifndef __clang__
+ this is not clang
+#endif
+]])],[lyx_cv_prog_clang=yes ; CLANG=yes],[lyx_cv_prog_clang=no ; CLANG=no])])
+if test $CLANG = yes ; then
+ AC_CACHE_CHECK([for clang version],
+ [lyx_cv_clang_version],
+ [clang_noversion=no
+ AC_COMPUTE_INT(clang_major,__clang_major__,,[clang_noversion_=yes])
+ AC_COMPUTE_INT(clang_minor,__clang_minor__,,[clang_noversion_=yes])
+ AC_COMPUTE_INT(clang_patchlevel,__clang_patchlevel__,,[clang_noversion_=yes])
+ if test $clang_noversion = yes ; then
+ clang_version=unknown
+ else
+ clang_version=$clang_major.$clang_minor.$clang_patchlevel
+ fi
+ lyx_cv_clang_version=$clang_version])
+fi
+])
+
+
+dnl Usage: LYX_CXX_CXX11_FLAGS(VERSION): add to AM_CXXFLAGS the best flag that
+dnl selects C++11 mode; gives an error when C++11 mode is not found.
+dnl VERSION is a list of years to try (e.g. 11 or {14,11}).
+AC_DEFUN([LYX_CXX_CXX11_FLAGS],
+[AC_CACHE_CHECK([for a good C++ mode], [lyx_cv_cxx11_flags],
+ [lyx_cv_cxx11_flags=none
+ for flag in `eval echo -std=c++$1 default -std=gnu++$1` ; do
+ if test $flag = default ; then
+ flag=
+ fi
+ save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$flag $AM_CXXFLAGS $CXXFLAGS"
+ dnl sample openmp source code to test
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ class TestDeleted
+ {
+ public:
+ TestDeleted() = delete;
+ };
+
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);
+
+ auto d = a;]], [[]])],[lyx_cv_cxx11_flags=$flag; break],[])
+ CXXFLAGS=$save_CXXFLAGS
+ CPPFLAGS=$save_CPPFLAGS
+ done])
+ if test x$lyx_cv_cxx11_flags = xnone ; then
+ AC_MSG_ERROR([Cannot find suitable mode for compiler $CXX])
+ fi
+ AM_CXXFLAGS="$lyx_cv_cxx11_flags $AM_CXXFLAGS"
+])
+
+
+dnl Usage: LYX_CXX_USE_CALL_ONCE
+dnl check whether we can use std::call_once and set the
+dnl LYX_USE_STD_CALL_ONCE macro and conditional accordingly.
+AC_DEFUN([LYX_CXX_USE_CALL_ONCE],
+[AC_MSG_CHECKING([for std::call_once availability])
+ save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ #include <mutex>
+ static std::once_flag flag;
+ ]], [[
+ std::call_once(flag, [](){ return; });
+ ]])],[lyx_std_call_once=yes],[lyx_std_call_once=no])
+ CXXFLAGS=$save_CXXFLAGS
+ CPPFLAGS=$save_CPPFLAGS
+ AC_MSG_RESULT([$lyx_std_call_once])
+
+ if test $lyx_std_call_once = yes ; then
+ AC_DEFINE([LYX_USE_STD_CALL_ONCE], 1, [define to 1 if std::call_once is supported by the compiler])
+ fi
+ AM_CONDITIONAL([LYX_USE_STD_CALL_ONCE], test $lyx_std_call_once = yes)
+])
+
+
+dnl Usage: LYX_LIB_STDCXX: set lyx_cv_lib_stdcxx to yes if the STL library is libstdc++.
+AC_DEFUN([LYX_LIB_STDCXX],
+[AC_CACHE_CHECK([whether STL is libstdc++],
+ [lyx_cv_lib_stdcxx],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<vector>]], [[
+#if ! defined(__GLIBCXX__) && ! defined(__GLIBCPP__)
+ this is not libstdc++
+#endif
+]])],[lyx_cv_lib_stdcxx=yes],[lyx_cv_lib_stdcxx=no])])
+])
+
+
+dnl Usage: LYX_LIB_STDCXX_CXX11_ABI: set lyx_cv_lib_stdcxx_cxx11_abi to yes
+dnl if the STL library is GNU libstdc++ and the C++11 ABI is used.
+AC_DEFUN([LYX_LIB_STDCXX_CXX11_ABI],
+[AC_CACHE_CHECK([whether STL is libstdc++ using the C++11 ABI],
+ [lyx_cv_lib_stdcxx_cxx11_abi],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<vector>]], [[
+#if ! defined(_GLIBCXX_USE_CXX11_ABI) || ! _GLIBCXX_USE_CXX11_ABI
+ this is not libstdc++ using the C++11 ABI
+#endif
+]])],[lyx_cv_lib_stdcxx_cxx11_abi=yes],[lyx_cv_lib_stdcxx_cxx11_abi=no])])