aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-02-23 15:21:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-02-23 15:21:15 +0200
commit90b0c577bc2f368b62e05211062af72d15f0d5c4 (patch)
tree4247adb3bac79901894114574a579a87cff2cac3
parent7dbc1fda18fef05d3c5a8008c54ee5cd871633b8 (diff)
Add support for detecting C++ standard
-rwxr-xr-xbuild/cxx/gnu/configure13
-rwxr-xr-xbuild/cxx/intel/configure13
-rw-r--r--build/cxx/standard.make34
3 files changed, 60 insertions, 0 deletions
diff --git a/build/cxx/gnu/configure b/build/cxx/gnu/configure
index 81848f7..c551713 100755
--- a/build/cxx/gnu/configure
+++ b/build/cxx/gnu/configure
@@ -29,6 +29,18 @@ $echo
cxx_gnu=`read_path --command g++`
+# Determine the C++ standard.
+#
+cxx_gnu_standard=`echo "$3" | sed -e 's/.*-std=\([^ ]*\).*/\1/' -e t -e d`
+
+if [ -z "$cxx_gnu_standard" ]; then
+ cxx_gnu_standard="gnu++98"
+elif [ "$cxx_gnu_standard" = "c++0x" ]; then
+ cxx_gnu_standard="c++11"
+elif [ "$cxx_gnu_standard" = "gnu++0x" ]; then
+ cxx_gnu_standard="gnu++11"
+fi
+
# Pass cxx_extra_options and cxx_ld_extra_options since those
# can affect the search paths (e.g., -m32) and target.
#
@@ -76,6 +88,7 @@ if [ "$2" == "y" ]; then
fi
echo "cxx_gnu := $cxx_gnu" > $1
+echo "cxx_gnu_standard := $cxx_gnu_standard" >> $1
echo "cxx_gnu_libraries := $cxx_gnu_libraries" >> $1
echo "cxx_gnu_optimization_options := $optimization" >> $1
echo "cxx_gnu_target := $cxx_gnu_target" >> $1
diff --git a/build/cxx/intel/configure b/build/cxx/intel/configure
index d044cab..7f79dd8 100755
--- a/build/cxx/intel/configure
+++ b/build/cxx/intel/configure
@@ -29,6 +29,19 @@ $echo
cxx_intel=`read_path --command icpc`
+# Determine the C++ standard. Intel C++ on GNU/Linux appears to use the
+# same option and values as GCC.
+#
+cxx_intel_standard=`echo "$3" | sed -e 's/.*-std=\([^ ]*\).*/\1/' -e t -e d`
+
+if [ -z "$cxx_intel_standard" ]; then
+ cxx_intel_standard="gnu++98"
+elif [ "$cxx_intel_standard" = "c++0x" ]; then
+ cxx_intel_standard="c++11"
+elif [ "$cxx_intel_standard" = "gnu++0x" ]; then
+ cxx_intel_standard="gnu++11"
+fi
+
# Pass cxx_extra_options and cxx_ld_extra_options since those
# can affect the search paths (e.g., -m32).
#
diff --git a/build/cxx/standard.make b/build/cxx/standard.make
new file mode 100644
index 0000000..fcc33e4
--- /dev/null
+++ b/build/cxx/standard.make
@@ -0,0 +1,34 @@
+# file : build/cxx/standard.make
+# copyright : Copyright (c) 2004-2012 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+# Set the cxx_standard variable to either c++98 or c++11.
+#
+$(call include,$(bld_root)/cxx/configuration.make) # cxx_id
+
+cxx_standard :=
+
+ifdef cxx_id
+ $(call include,$(bld_root)/cxx/$(cxx_id)/configuration.make) # cxx_*_standard
+ ifeq ($(cxx_id),gnu)
+ ifdef cxx_gnu
+ ifneq ($(filter $(cxx_gnu_standard),c++11 gnu++11),)
+ cxx_standard := c++11
+ else
+ cxx_standard := c++98
+ endif
+ endif
+ else ifeq ($(cxx_id),intel)
+ ifdef cxx_intel
+ ifneq ($(filter $(cxx_intel_standard),c++11 gnu++11),)
+ cxx_standard := c++11
+ else
+ cxx_standard := c++98
+ endif
+ endif
+ else ifeq ($(cxx_id),generic)
+ cxx_standard := c++98
+ else
+ $(error unknown C++ compiler $(cxx_id))
+ endif
+endif