aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/build_options.rb7
-rw-r--r--Library/Homebrew/extend/ENV/std.rb11
-rw-r--r--Library/Homebrew/extend/ENV/super.rb13
-rw-r--r--Library/Homebrew/software_spec.rb1
4 files changed, 32 insertions, 0 deletions
diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb
index ff2e099fc..83afe362e 100644
--- a/Library/Homebrew/build_options.rb
+++ b/Library/Homebrew/build_options.rb
@@ -7,6 +7,7 @@ class BuildOptions
attr_accessor :args
attr_accessor :universal
+ attr_accessor :cxx11
attr_reader :options
protected :options
@@ -25,6 +26,7 @@ class BuildOptions
description ||= case name.to_s
when "universal" then "Build a universal binary"
when "32-bit" then "Build 32-bit only"
+ when "c++11" then "Build using C++11 mode"
end.to_s
@options << Option.new(name, description)
@@ -94,6 +96,11 @@ class BuildOptions
universal || args.include?('--universal') && has_option?('universal')
end
+ # True if the user requested to enable C++11 mode.
+ def cxx11?
+ cxx11 || args.include?('--c++11') && has_option?('c++11')
+ end
+
# Request a 32-bit only build.
# This is needed for some use-cases though we prefer to build Universal
# when a 32-bit version is needed.
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", ''
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 80f92a7c9..3d0664b7d 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -50,6 +50,7 @@ class SoftwareSpec
end
def option name, description=nil
+ name = 'c++11' if name == :cxx11
name = name.to_s if Symbol === name
raise "Option name is required." if name.empty?
raise "Options should not start with dashes." if name[0, 1] == "-"