Skip to content

Instantly share code, notes, and snippets.

@dpo
Created April 7, 2014 16:30
Show Gist options
  • Select an option

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

Select an option

Save dpo/10023652 to your computer and use it in GitHub Desktop.
require "formula"
class Colamd < Formula
homepage "http://www.cise.ufl.edu/research/sparse/colamd/"
url "http://www.cise.ufl.edu/research/sparse/colamd/COLAMD-2.8.0.tar.gz"
sha1 "007bc46337dd27102fece0d4e81a9bc9db0d0a67"
depends_on "suite-sparse-config"
def suite_sparse_config_options
Tab.for_formula(Formula["suite-sparse-config"]).used_options
end
def install
make_args = ["INSTALL_LIB=#{lib}", "INSTALL_INCLUDE=#{include}"]
suite_sparse_config_options.each do |opt|
make_args << opt.to_s
end
ln_s Formula["suite-sparse-config"].libexec, "../SuiteSparse_config"
system "make", "all", *make_args
system "make", "demos", *make_args
lib.mkpath
include.mkpath
system "make", "install", *make_args
(share / name / "demo").install Dir["Demo/*[^.o]"]
end
test do
system "#{share}/#{name}/demo/colamd_example > #{share}/#{name}/demo/my_colamd_example.out"
test1 = %x(diff #{share}/#{name}/demo/my_colamd_example.out #{share}/#{name}/demo/colamd_example.out).empty? ? true : false
system "#{share}/#{name}/demo/colamd_l_example > #{share}/#{name}/demo/my_colamd_l_example.out"
test2 = %x(diff #{share}/#{name}/demo/my_colamd_l_example.out #{share}/#{name}/demo/colamd_l_example.out).empty? ? true : false
test1 and test2
end
end
require 'formula'
class SuiteSparseConfig < Formula
homepage 'http://www.cise.ufl.edu/research/sparse/SuiteSparse'
url 'http://www.cise.ufl.edu/research/sparse/SuiteSparse_config/SuiteSparse_config-4.2.1.tar.gz'
sha1 '1d6f70ec7ecdb7b60e6a76c59f1f98fb94e7e4d3'
depends_on "tbb" => :recommended
depends_on "openblas" => :optional
depends_on "metis4" => :optional
def install
# Switch to the Mac base config, per SuiteSparse README.txt
system "mv SuiteSparse_config.mk SuiteSparse_config_orig.mk"
system "mv SuiteSparse_config_Mac.mk SuiteSparse_config.mk"
make_args = ["INSTALL_LIB=#{libexec}", "INSTALL_INCLUDE=#{libexec}"]
make_args << "BLAS=" + ((build.with? 'openblas') ? "-L#{Formula['openblas'].lib} -lopenblas" : "-framework Accelerate")
make_args << "LAPACK=$(BLAS)"
make_args += ["SPQR_CONFIG=-DHAVE_TBB", "TBB=-L#{Formula['tbb'].lib} -ltbb"] if build.with? "tbb"
make_args += ["METIS_PATH=", "METIS=-L#{Formula['metis'].lib} -lmetis"] if build.with? "metis4"
system "make", "all", *make_args
libexec.mkpath
lib.mkpath
include.mkpath
system "make", "install", *make_args
libexec.install "SuiteSparse_config.mk"
include.install_symlink libexec / "SuiteSparse_config.h"
lib.install_symlink libexec / "libsuitesparseconfig.a"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment