Use fortran from std-env in superenv

Fixes Homebrew/homebrew#14524.
This commit is contained in:
Max Howell 2012-08-29 14:36:30 -04:00
parent 4feb8e1cb4
commit 95164a5d46
2 changed files with 60 additions and 58 deletions

View File

@ -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

View File

@ -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