aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorCharlie Sharpsteen2011-03-10 11:23:42 -0800
committerAdam Vandenberg2011-03-12 13:29:58 -0800
commit8991d9bf15678fd236b2c70b5f7e5a825e122d7e (patch)
treee44606448b7c53f567b10dd9182d7e60ac792656 /Library/Homebrew
parentddb8d1cd95d8c0562ddb1a8df3f4701aa7e95ed1 (diff)
downloadbrew-8991d9bf15678fd236b2c70b5f7e5a825e122d7e.tar.bz2
Add Fortran configuration to ENV.rb
This provides a uniform way for formulae to indicate a Fortran compiler is required. Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/ENV.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index fc4dc96ae..e15f642eb 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -131,6 +131,54 @@ module HomebrewEnvExtension
self.O4
end
+ def fortran
+ 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'
+ self['FCFLAGS'] = self['CFLAGS'] unless self['FCFLAGS']
+ self['FFFLAGS'] = self['CFLAGS'] unless self['FFFLAGS']
+ elsif not self['FCFLAGS'] or self['FFLAGS']
+ opoo <<-EOS
+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
+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']
+
+ self['FCFLAGS'] = self['CFLAGS']
+ self['FFLAGS'] = self['CFLAGS']
+
+ 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 osx_10_4
self['MACOSX_DEPLOYMENT_TARGET']="10.4"
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)