From 90b0c577bc2f368b62e05211062af72d15f0d5c4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 23 Feb 2012 15:21:15 +0200 Subject: Add support for detecting C++ standard --- build/cxx/gnu/configure | 13 +++++++++++++ build/cxx/intel/configure | 13 +++++++++++++ build/cxx/standard.make | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 build/cxx/standard.make (limited to 'build/cxx') 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 -- cgit v1.1