From 3ec40c062e5b3bdfebc5cbfb36a5766d1d0905d6 Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Thu, 24 Oct 2013 00:26:09 -0700 Subject: Clang standard library selection. * Add new ENV function for selecting stdlib for Clang. - The selection is no-op for non-system-clang compilers. - Both superenv and stdenv are handled. * Add new HOMEBREW_CCCFG flag and ccwrapper handling. --- Library/Homebrew/extend/ENV/std.rb | 12 ++++++++++++ Library/Homebrew/extend/ENV/super.rb | 13 +++++++++++++ 2 files changed, 25 insertions(+) (limited to 'Library/Homebrew') diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 0d5613256..92bdfd794 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -333,6 +333,18 @@ module Stdenv end end + def libcxx + if compiler == :clang + append 'CXX', '-stdlib=libc++' + end + end + + def libstdcxx + if compiler == :clang + append 'CXX', '-stdlib=libstdc++' + 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 2be8a62d4..169a4200c 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -99,6 +99,7 @@ module Superenv # make/bsdmake wrappers currently. # x - Enable C++11 mode. # g - Enable "-stdlib=libc++" for clang. + # h - Enable "-stdlib=libstdc++" for clang. # # On 10.8 and newer, these flags will also be present: # s - apply fix for sed's Unicode support @@ -123,6 +124,18 @@ module Superenv end end + def libcxx + if self['HOMEBREW_CC'] == 'clang' + append 'HOMEBREW_CCCFG', "g", '' + end + end + + def libstdcxx + if self['HOMEBREW_CC'] == 'clang' + append 'HOMEBREW_CCCFG', "h", '' + end + end + # m32 on superenv does not add any CC flags. It prevents "-m32" from being erased. def m32 append 'HOMEBREW_CCCFG', "3", '' -- cgit v1.2.3