aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements/mpi_dependency.rb
diff options
context:
space:
mode:
authorJack Nagel2013-04-02 15:33:35 -0500
committerJack Nagel2013-04-02 15:33:35 -0500
commit5372719246afcfd942cb2e8bd47dc62747715a61 (patch)
treef96d0267d2925576815d3bc8c484cd0ee4f533aa /Library/Homebrew/requirements/mpi_dependency.rb
parent56d5735b094953a0ad38f919ed38eb5a6ee97c0a (diff)
downloadhomebrew-5372719246afcfd942cb2e8bd47dc62747715a61.tar.bz2
Shrink requirements.rb
Diffstat (limited to 'Library/Homebrew/requirements/mpi_dependency.rb')
-rw-r--r--Library/Homebrew/requirements/mpi_dependency.rb82
1 files changed, 82 insertions, 0 deletions
diff --git a/Library/Homebrew/requirements/mpi_dependency.rb b/Library/Homebrew/requirements/mpi_dependency.rb
new file mode 100644
index 000000000..b51efc303
--- /dev/null
+++ b/Library/Homebrew/requirements/mpi_dependency.rb
@@ -0,0 +1,82 @@
+require 'requirement'
+
+# There are multiple implementations of MPI-2 available.
+# http://www.mpi-forum.org/
+# This requirement is used to find an appropriate one.
+class MPIDependency < Requirement
+
+ attr_reader :lang_list
+
+ fatal true
+
+ env :userpaths
+
+ def initialize *lang_list
+ @lang_list = lang_list
+ @non_functional = []
+ @unknown_langs = []
+ super()
+ end
+
+ def mpi_wrapper_works? compiler
+ compiler = which compiler
+ return false if compiler.nil? or not compiler.executable?
+
+ # Some wrappers are non-functional and will return a non-zero exit code
+ # when invoked for version info.
+ #
+ # NOTE: A better test may be to do a small test compilation a la autotools.
+ quiet_system compiler, '--version'
+ end
+
+ satisfy do
+ @lang_list.each do |lang|
+ case lang
+ when :cc, :cxx, :f90, :f77
+ compiler = 'mpi' + lang.to_s
+ @non_functional << compiler unless mpi_wrapper_works? compiler
+ else
+ @unknown_langs << lang.to_s
+ end
+ end
+ @unknown_langs.empty? and @non_functional.empty?
+ end
+
+ env do
+ # Set environment variables to help configure scripts find MPI compilers.
+ # Variable names taken from:
+ # http://www.gnu.org/software/autoconf-archive/ax_mpi.html
+ @lang_list.each do |lang|
+ compiler = 'mpi' + lang.to_s
+ mpi_path = which compiler
+
+ # Fortran 90 environment var has a different name
+ compiler = 'MPIFC' if lang == :f90
+ ENV[compiler.upcase] = mpi_path
+ end
+ end
+
+ def message
+ if not @unknown_langs.empty?
+ <<-EOS.undent
+ There is no MPI compiler wrapper for:
+ #{@unknown_langs.join ', '}
+
+ The following values are valid arguments to `MPIDependency.new`:
+ :cc, :cxx, :f90, :f77
+ EOS
+ else
+ <<-EOS.undent
+ Homebrew could not locate working copies of the following MPI compiler
+ wrappers:
+ #{@non_functional.join ', '}
+
+ If you have a MPI installation, please ensure the bin folder is on your
+ PATH and that all the wrappers are functional. Otherwise, a MPI
+ installation can be obtained from homebrew by *picking one* of the
+ following formulae:
+ open-mpi, mpich2
+ EOS
+ end
+ end
+end