diff options
| author | Max Howell | 2012-08-11 12:30:51 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-29 12:41:34 -0400 |
| commit | 65d195dcaaa4304e127e0a264cf97ad7b6a7fd83 (patch) | |
| tree | 7b8a04d1bdb8676e5e8b978da9824365edac9bae /Library/Homebrew/extend | |
| parent | 57df15afd009d11e8d683353a74287e0a22ba57b (diff) | |
| download | brew-65d195dcaaa4304e127e0a264cf97ad7b6a7fd83.tar.bz2 | |
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 121 |
1 files changed, 55 insertions, 66 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 90ff517b1..69947879e 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -178,6 +178,8 @@ module HomebrewEnvExtension end def fortran + fc_flag_vars = %w{FCFLAGS FFLAGS} + if self['FC'] ohai "Building with an alternative Fortran compiler. This is unsupported." self['F77'] = self['FC'] unless self['F77'] @@ -333,28 +335,6 @@ Please take one of the following actions: remove_from_cflags '-Qunused-arguments' end - # Snow Leopard defines an NCURSES value the opposite of most distros - # See: http://bugs.python.org/issue6848 - def ncurses_define - append 'CPPFLAGS', "-DNCURSES_OPAQUE=0" - end - - # Shortcuts for reading common flags - def cc; self['CC'] or "gcc"; end - def cxx; self['CXX'] or "g++"; end - def cflags; self['CFLAGS']; end - def cxxflags;self['CXXFLAGS']; end - def cppflags;self['CPPFLAGS']; end - def ldflags; self['LDFLAGS']; end - - # Shortcuts for lists of common flags - def cc_flag_vars - %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS} - end - def fc_flag_vars - %w{FCFLAGS FFLAGS} - end - def m64 append_to_cflags '-m64' append 'LDFLAGS', '-arch x86_64' @@ -376,49 +356,6 @@ Please take one of the following actions: end end - def prepend key, value, separator = ' ' - # Value should be a string, but if it is a pathname then coerce it. - value = value.to_s - - [*key].each do |key| - unless self[key].to_s.empty? - self[key] = value + separator + self[key] - else - self[key] = value - end - end - end - - def append key, value, separator = ' ' - # Value should be a string, but if it is a pathname then coerce it. - value = value.to_s - - [*key].each do |key| - unless self[key].to_s.empty? - self[key] = self[key] + separator + value - else - self[key] = value - end - end - end - - def append_to_cflags f - append cc_flag_vars, f - end - - def remove key, value - [*key].each do |key| - next if self[key].nil? - self[key] = self[key].sub value, '' # can't use sub! on ENV - self[key] = self[key].gsub /\s+/, ' ' # compact whitespace - self[key] = nil if self[key].empty? # keep things clean - end - end - - def remove_from_cflags f - remove cc_flag_vars, f - end - def replace_in_cflags before, after cc_flag_vars.each do |key| self[key] = self[key].sub before, after if self[key] @@ -491,13 +428,65 @@ Please take one of the following actions: Hardware.processor_count end end +end +class << ENV def remove_cc_etc keys = %w{CC CXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS} removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten] keys.each do |key| - self[key] = nil + delete(key) end removed end + def cc_flag_vars + %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS} + end + def append_to_cflags newflags + append(cc_flag_vars, newflags) + end + def remove_from_cflags f + remove cc_flag_vars, f + end + def append key, value, separator = ' ' + value = value.to_s + [*key].each do |key| + unless self[key].to_s.empty? + self[key] = self[key] + separator + value.to_s + else + self[key] = value.to_s + end + end + end + def prepend key, value, separator = ' ' + [*key].each do |key| + unless self[key].to_s.empty? + self[key] = value.to_s + separator + self[key] + else + self[key] = value.to_s + end + end + end + def prepend_path key, path + prepend key, path, ':' if File.directory? path + end + def remove key, value + [*key].each do |key| + next unless self[key] + self[key] = self[key].sub(value, '') + delete(key) if self[key].to_s.empty? + end if value + end + def cc; self['CC'] or "cc"; end + def cxx; self['CXX'] or "c++"; end + def cflags; self['CFLAGS']; end + def cxxflags;self['CXXFLAGS']; end + def cppflags;self['CPPFLAGS']; end + def ldflags; self['LDFLAGS']; end + + # Snow Leopard defines an NCURSES value the opposite of most distros + # See: http://bugs.python.org/issue6848 + def ncurses_define + append 'CPPFLAGS', "-DNCURSES_OPAQUE=0" + end end |
