summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGert Wollny <[email protected]>2017-10-18 17:05:25 +0200
committerEmil Velikov <[email protected]>2017-11-08 16:03:34 +0000
commit09ad2576ece2f813e5be9dda60fdb0b9598d0d23 (patch)
tree99d19fba1cb98bf7e057817e7942d87cd590ab45
parent6dd56fafe2d6d55c8804a27de3b52fb53a4c98b0 (diff)
configure: check for -std=c++11 support and enable st/mesa test accordingly
Add a check that tests whether the c++ compiler supports c++11, either by default, by adding the compiler flag -std=c++11, or by adding a compiler flag that the user has specified via the environment variable CXX11_CXXFLAGS. The test only does a very shallow check of c++11 support, i.e. it tests whether the define __cplusplus >= 201103L to confirm language support by the compiler, and it checks whether the header <tuple> is available to test the availability of the c++11 standard library. A make file conditional HAVE_STD_CXX11 is provided that is used in this patch to enable the test in st/mesa if C++11 support is available. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102665 Acked-by: Emil Velikov <[email protected]>
-rw-r--r--configure.ac56
-rw-r--r--src/mesa/state_tracker/tests/Makefile.am4
2 files changed, 59 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index c69c7d6b0c9..14236c9dc99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,10 @@ dnl Check for progs
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CXX
+dnl add this here, so the help for this environmnet variable is close to
+dnl other CC/CXX flags related help
+AC_ARG_VAR([CXX11_CXXFLAGS], [Compiler flag to enable C++11 support (only needed if not
+ enabled by default and different from -std=c++11)])
AM_PROG_CC_C_O
AM_PROG_AS
AX_CHECK_GNU_MAKE
@@ -120,6 +124,7 @@ AC_PROG_MKDIR_P
AC_SYS_LARGEFILE
+
LT_PREREQ([2.2])
LT_INIT([disable-static])
@@ -327,6 +332,56 @@ if test "x$GCC" = xyes; then
fi
fi
+dnl
+dnl Check whether C++11 is supported, if the environment variable
+dnl CXX11_CXXFLAGS is set it takes precedence.
+dnl
+
+AC_LANG_PUSH([C++])
+
+check_cxx11_available() {
+ output_support=$1
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([
+ #if !(__cplusplus >= 201103L)
+ #error
+ #endif
+ #include <tuple>
+ ])
+ ], [
+ AC_MSG_RESULT(yes)
+ cxx11_support=yes
+ ], AC_MSG_RESULT(no))
+ eval "$output_support=\$cxx11_support"
+}
+
+HAVE_CXX11=no
+save_CXXFLAGS="$CXXFLAGS"
+
+dnl If the user provides a flag to enable c++11, then we test only this
+if test "x$CXX11_CXXFLAGS" != "x"; then
+ CXXFLAGS="$CXXFLAGS $CXX11_CXXFLAGS"
+ AC_MSG_CHECKING(whether c++11 is enabled by via $CXX11_CXXFLAGS)
+ check_cxx11_available HAVE_CXX11
+else
+ dnl test whether c++11 is enabled by default
+ AC_MSG_CHECKING(whether c++11 is enabled by default)
+ check_cxx11_available HAVE_CXX11
+
+ dnl C++11 not enabled by default, test whether -std=c++11 does the job
+ if test "x$HAVE_CXX11" != "xyes"; then
+ CXX11_CXXFLAGS=-std=c++11
+ CXXFLAGS="$CXXFLAGS $CXX11_CXXFLAGS"
+ AC_MSG_CHECKING(whether c++11 is enabled by via $CXX11_CXXFLAGS)
+ check_cxx11_available HAVE_CXX11
+ fi
+fi
+
+CXXFLAGS="$save_CXXFLAGS"
+AM_CONDITIONAL(HAVE_STD_CXX11, test "x$HAVE_CXX11" = "xyes")
+AC_SUBST(CXX11_CXXFLAGS)
+AC_LANG_POP([C++])
+
dnl even if the compiler appears to support it, using visibility attributes isn't
dnl going to do anything useful currently on cygwin apart from emit lots of warnings
case "$host_os" in
@@ -3114,6 +3169,7 @@ defines=`echo $DEFINES | $SED 's/^ *//;s/ */ /;s/ *$//'`
echo ""
echo " CFLAGS: $cflags"
echo " CXXFLAGS: $cxxflags"
+echo " CXX11_CXXFLAGS: $CXX11_CXXFLAGS"
echo " LDFLAGS: $ldflags"
echo " Macros: $defines"
echo ""
diff --git a/src/mesa/state_tracker/tests/Makefile.am b/src/mesa/state_tracker/tests/Makefile.am
index f32957608e7..6c58d367694 100644
--- a/src/mesa/state_tracker/tests/Makefile.am
+++ b/src/mesa/state_tracker/tests/Makefile.am
@@ -5,7 +5,7 @@ AM_CFLAGS = \
AM_CXXFLAGS = \
$(GALLIUM_DRIVER_CXXFLAGS) \
- -std=c++11
+ $(CXX11_CXXFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir)/src/gtest/include \
@@ -15,8 +15,10 @@ AM_CPPFLAGS = \
-I$(top_builddir)/src/compiler/glsl \
$(DEFINES)
+if HAVE_STD_CXX11
TESTS = st-renumerate-test
check_PROGRAMS = st-renumerate-test
+endif
st_renumerate_test_SOURCES = \
test_glsl_to_tgsi_lifetime.cpp