diff options
| author | Max Howell | 2012-08-29 14:36:30 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-29 14:45:04 -0400 |
| commit | 95164a5d460213ea864c0f7c953d02c719518fc0 (patch) | |
| tree | de63e8aa83bd2ba496636e5ea4a33ca8eaf86e34 /Library | |
| parent | 4feb8e1cb4cf20df93e18c7642d68fe4a4bba6c7 (diff) | |
| download | brew-95164a5d460213ea864c0f7c953d02c719518fc0.tar.bz2 | |
Use fortran from std-env in superenv
Fixes Homebrew/homebrew#14524.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 115 | ||||
| -rw-r--r-- | Library/Homebrew/superenv.rb | 3 |
2 files changed, 60 insertions, 58 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 69947879e..cbed27746 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -177,63 +177,6 @@ module HomebrewEnvExtension @compiler = :clang 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'] - - if ARGV.include? '--default-fortran-flags' - flags_to_set = [] - flags_to_set << 'FCFLAGS' unless self['FCFLAGS'] - flags_to_set << 'FFLAGS' unless self['FFLAGS'] - - flags_to_set.each {|key| self[key] = cflags} - - # Ensure we use architecture optimizations for GCC 4.2.x - set_cpu_flags flags_to_set, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic' - elsif not self['FCFLAGS'] or self['FFLAGS'] - opoo <<-EOS.undent - No Fortran optimization information was provided. You may want to consider - setting FCFLAGS and FFLAGS or pass the `--default-fortran-flags` option to - `brew install` if your compiler is compatible with GCC. - - If you like the default optimization level of your compiler, ignore this - warning. - EOS - end - - elsif `/usr/bin/which gfortran`.chomp.size > 0 - ohai <<-EOS.undent - Using Homebrew-provided fortran compiler. - This may be changed by setting the FC environment variable. - EOS - self['FC'] = `/usr/bin/which gfortran`.chomp - self['F77'] = self['FC'] - - fc_flag_vars.each {|key| self[key] = cflags} - # Ensure we use architecture optimizations for GCC 4.2.x - set_cpu_flags fc_flag_vars, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic' - - else - onoe <<-EOS -This formula requires a fortran compiler, but we could not find one by -looking at the FC environment variable or searching your PATH for `gfortran`. -Please take one of the following actions: - - - Decide to use the build of gfortran 4.2.x provided by Homebrew using - `brew install gfortran` - - - Choose another Fortran compiler by setting the FC environment variable: - export FC=/path/to/some/fortran/compiler - Using an alternative compiler may produce more efficient code, but we will - not be able to provide support for build errors. - EOS - exit 1 - end - end - def remove_macosxsdk v=MacOS.version # Clear all lib and include dirs from CFLAGS, CPPFLAGS, LDFLAGS that were # previously added by macosxsdk @@ -489,4 +432,62 @@ class << ENV def ncurses_define append 'CPPFLAGS', "-DNCURSES_OPAQUE=0" 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'] + + if ARGV.include? '--default-fortran-flags' + flags_to_set = [] + flags_to_set << 'FCFLAGS' unless self['FCFLAGS'] + flags_to_set << 'FFLAGS' unless self['FFLAGS'] + + flags_to_set.each {|key| self[key] = cflags} + + # Ensure we use architecture optimizations for GCC 4.2.x + set_cpu_flags flags_to_set, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic' + elsif not self['FCFLAGS'] or self['FFLAGS'] + opoo <<-EOS.undent + No Fortran optimization information was provided. You may want to consider + setting FCFLAGS and FFLAGS or pass the `--default-fortran-flags` option to + `brew install` if your compiler is compatible with GCC. + + If you like the default optimization level of your compiler, ignore this + warning. + EOS + end + + elsif `/usr/bin/which gfortran`.chomp.size > 0 + ohai <<-EOS.undent + Using Homebrew-provided fortran compiler. + This may be changed by setting the FC environment variable. + EOS + self['FC'] = `/usr/bin/which gfortran`.chomp + self['F77'] = self['FC'] + + fc_flag_vars.each {|key| self[key] = cflags} + # Ensure we use architecture optimizations for GCC 4.2.x + set_cpu_flags fc_flag_vars, 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott', :bottle => 'generic' + + else + onoe <<-EOS +This formula requires a fortran compiler, but we could not find one by +looking at the FC environment variable or searching your PATH for `gfortran`. +Please take one of the following actions: + + - Decide to use the build of gfortran 4.2.x provided by Homebrew using + `brew install gfortran` + + - Choose another Fortran compiler by setting the FC environment variable: + export FC=/path/to/some/fortran/compiler + Using an alternative compiler may produce more efficient code, but we will + not be able to provide support for build errors. + EOS + exit 1 + end + end + end diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb index 5bf815dcb..ba42a5604 100644 --- a/Library/Homebrew/superenv.rb +++ b/Library/Homebrew/superenv.rb @@ -165,7 +165,8 @@ class << ENV ### NO LONGER NECESSARY OR NO LONGER SUPPORTED def noop(*args); end %w[m64 m32 gcc_4_0_1 fast O4 O3 O2 Os Og O1 libxml2 minimal_optimization - no_optimization enable_warnings fortran x11 + no_optimization enable_warnings x11 + set_cpu_flags macosxsdk remove_macosxsdk].each{|s| alias_method s, :noop } ### DEPRECATE THESE |
