aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorXiyue Deng2013-10-07 00:40:32 -0700
committerXiyue Deng2013-10-26 22:17:04 -0700
commitf2132c47bd26484e8a9961ad6056bbbb17a2d108 (patch)
tree5d0e8d5b9dbe0629a20a31347222dc3cb50cd9d9 /Library/Homebrew/extend
parent0e6df1c3bf1c5f5d23bcfa5c668d26cf48dffd20 (diff)
downloadbrew-f2132c47bd26484e8a9961ad6056bbbb17a2d108.tar.bz2
C++11 support.
* Add options and ENV method to specify building in C++11 mode. - Set C++ compiler flags to enable C++11 mode. - To add options to support C++11 mode, a formula can now use option :cxx11 to provide "--c++11" option, and detect and enable C++11 support in install method using ENV.cxx11 if build.cxx11? Closes Homebrew/homebrew#22453.
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/ENV/std.rb11
-rw-r--r--Library/Homebrew/extend/ENV/super.rb13
2 files changed, 24 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index bca0df041..0d5613256 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -322,6 +322,17 @@ module Stdenv
end
end
+ def cxx11
+ if compiler == :clang
+ append 'CXX', '-std=c++11'
+ append 'CXX', '-stdlib=libc++'
+ elsif compiler =~ /gcc-4\.(8|9)/
+ append 'CXX', '-std=c++11'
+ else
+ raise "The selected compiler doesn't support C++11: #{compiler}"
+ end
+ end
+
def replace_in_cflags before, after
CC_FLAG_VARS.each do |key|
self[key] = self[key].sub(before, after) if has_key?(key)
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index e3f9ed923..2be8a62d4 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -97,6 +97,8 @@ module Superenv
# A - Installing from a bottle on PPC with Altivec
# O - Enables argument refurbishing. Only active under the
# make/bsdmake wrappers currently.
+ # x - Enable C++11 mode.
+ # g - Enable "-stdlib=libc++" for clang.
#
# On 10.8 and newer, these flags will also be present:
# s - apply fix for sed's Unicode support
@@ -110,6 +112,17 @@ module Superenv
append 'HOMEBREW_CCCFG', "u", ''
end
+ def cxx11
+ if self['HOMEBREW_CC'] == 'clang'
+ append 'HOMEBREW_CCCFG', "x", ''
+ append 'HOMEBREW_CCCFG', "g", ''
+ elsif self['HOMEBREW_CC'] =~ /gcc-4\.(8|9)/
+ append 'HOMEBREW_CCCFG', "x", ''
+ else
+ raise "The selected compiler doesn't support C++11: #{self['HOMEBREW_CC']}"
+ end
+ end
+
# m32 on superenv does not add any CC flags. It prevents "-m32" from being erased.
def m32
append 'HOMEBREW_CCCFG', "3", ''