From 8991d9bf15678fd236b2c70b5f7e5a825e122d7e Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Thu, 10 Mar 2011 11:23:42 -0800 Subject: [PATCH] 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 --- Library/Homebrew/extend/ENV.rb | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index fc4dc96aef..e15f642ebc 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/)