homebrew-core/Formula/igraph.rb

75 lines
3.2 KiB
Ruby

class Igraph < Formula
desc "Network analysis package"
homepage "https://igraph.org/"
url "https://github.com/igraph/igraph/releases/download/0.9.6/igraph-0.9.6.tar.gz"
sha256 "7c299ec54eecfe413758c332a42c4cb71d02d2951b2ac232584d317c5792f387"
license "GPL-2.0-or-later"
bottle do
sha256 cellar: :any, arm64_monterey: "bf18add8549fe2af4fbab150c8ad18d77d0186dbe8b646173e3cdb85ee218ca8"
sha256 cellar: :any, arm64_big_sur: "d42a9c19e8b446d02648515ca4193c0e456d355e2e419984e2f16a6d558e5d1e"
sha256 cellar: :any, monterey: "9aa5f5c22c06c39b5eee34734c4d59b0d8074441a2359f306e0309d6123fa449"
sha256 cellar: :any, big_sur: "374b57ecf003139a94fecc7e7e4dc24e13194451d4e66199343b05028e33b2c3"
sha256 cellar: :any, catalina: "36f2a4a74d1042ef9cbb624f3bf2fb3eaad9dac45334571ef8c3dcdd886c0558"
sha256 cellar: :any_skip_relocation, x86_64_linux: "fac228845b3bd3853b2941f022f36741e64cc2e5316c4248a9a585203f383c9e"
end
depends_on "cmake" => :build
depends_on "arpack"
depends_on "glpk"
depends_on "gmp"
depends_on "openblas"
depends_on "suite-sparse"
uses_from_macos "libxml2"
def install
mkdir "build" do
# explanation of extra options:
# * we want a shared library, not a static one
# * link-time optimization should be enabled if the compiler supports it
# * thread-local storage of global variables is enabled
# * force the usage of external dependencies from Homebrew where possible
# * GraphML support should be compiled in (needs libxml2)
# * BLAS and LAPACK should come from OpenBLAS
# * prevent the usage of ccache even if it is installed to ensure that we
# have a clean build
system "cmake", "-G", "Unix Makefiles",
"-DBUILD_SHARED_LIBS=ON",
"-DIGRAPH_ENABLE_LTO=AUTO",
"-DIGRAPH_ENABLE_TLS=ON",
"-DIGRAPH_GLPK_SUPPORT=ON",
"-DIGRAPH_GRAPHML_SUPPORT=ON",
"-DIGRAPH_USE_INTERNAL_ARPACK=OFF",
"-DIGRAPH_USE_INTERNAL_BLAS=OFF",
"-DIGRAPH_USE_INTERNAL_CXSPARSE=OFF",
"-DIGRAPH_USE_INTERNAL_GLPK=OFF",
"-DIGRAPH_USE_INTERNAL_GMP=OFF",
"-DIGRAPH_USE_INTERNAL_LAPACK=OFF",
"-DBLA_VENDOR=OpenBLAS",
"-DUSE_CCACHE=OFF",
"..", *std_cmake_args
system "make"
system "make", "install"
end
end
test do
(testpath/"test.c").write <<~EOS
#include <igraph.h>
int main(void) {
igraph_real_t diameter;
igraph_t graph;
igraph_rng_seed(igraph_rng_default(), 42);
igraph_erdos_renyi_game(&graph, IGRAPH_ERDOS_RENYI_GNP, 1000, 5.0/1000, IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
igraph_diameter(&graph, &diameter, 0, 0, 0, IGRAPH_UNDIRECTED, 1);
printf("Diameter = %f\\n", (double) diameter);
igraph_destroy(&graph);
}
EOS
system ENV.cc, "test.c", "-I#{include}/igraph", "-L#{lib}",
"-ligraph", "-lm", "-o", "test"
assert_match "Diameter = 9", shell_output("./test")
end
end