Skip to content

Instantly share code, notes, and snippets.

@dpo
Created October 30, 2014 18:18
Show Gist options
  • Select an option

  • Save dpo/edaded26558f4a82ed7c to your computer and use it in GitHub Desktop.

Select an option

Save dpo/edaded26558f4a82ed7c to your computer and use it in GitHub Desktop.
require "formula"
class Petsc < Formula
homepage "http://www.mcs.anl.gov/petsc/index.html"
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.5.2.tar.gz"
sha1 "d60d1735762f2e398774514451e137580bb2c7bb"
head "https://bitbucket.org/petsc/petsc", :using => :git
option "without-check", "Skip build-time tests (not recommended)"
option "complex", "Build complex-valued version of PETSc"
version ((build.include? "complex") ? "3.5.2-complex" : "3.5.2-real")
depends_on :mpi => :cc
depends_on :fortran
depends_on :x11 => :optional
depends_on "cmake" => :build
depends_on "superlu_dist" => :recommended
depends_on "metis" => :recommended
depends_on "parmetis" => :recommended
depends_on "scalapack" => :recommended
depends_on "mumps" => :recommended
depends_on "hypre" => :recommended unless build.include? "complex"
def install
ENV.deparallelize # PETSc compiles are automatically parallel
petsc_arch = "arch-darwin-c-opt"
args = %W[
--with-debugging=0
--with-shared-libraries=1
--prefix=#{prefix}/#{petsc_arch}
]
args << "--with-superlu_dist-include=#{Formula["superlu_dist"].include}/superlu_dist" << "--with-superlu_dist-lib=#{Formula["superlu_dist"].lib}/libsuperlu_dist.a" if build.with? "superlu_dist"
args << "--with-metis-dir=#{Formula["metis"].prefix}" if build.with? "metis"
args << "--with-parmetis-dir=#{Formula["parmetis"].prefix}" if build.with? "parmetis"
args << "--with-scalapack-dir=#{Formula["scalapack"].prefix}" if build.with? "scalapack"
args << "--with-mumps-dir=#{Formula["mumps"].prefix}" if build.with? "mumps"
args << "--with-scalar-type=" + ((build.with? "complex") ? "complex" : "real")
args << "--with-x=0" if build.without? "x11"
ENV["PETSC_DIR"] = Dir.getwd # configure fails if those vars are set differently.
ENV["PETSC_ARCH"] = petsc_arch
system "./configure", *args
system "make all"
system "make test" if build.with? "check"
system "make install"
# Link only what we want.
include.install_symlink Dir["#{prefix}/#{petsc_arch}/include/*h"], "#{prefix}/#{petsc_arch}/include/finclude", "#{prefix}/#{petsc_arch}/include/petsc-private"
prefix.install_symlink "#{prefix}/#{petsc_arch}/conf"
lib.install_symlink Dir["#{prefix}/#{petsc_arch}/lib/*.a"], Dir["#{prefix}/#{petsc_arch}/lib/*.dylib"]
share.install_symlink Dir["#{prefix}/#{petsc_arch}/share/*"]
end
def caveats; <<-EOS
Set PETSC_DIR to #{prefix}
and PETSC_ARCH to arch-darwin-c-opt.
Fortran module files are in #{prefix}/arch-darwin-c-opt/include.
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment