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.9/igraph-0.9.9.tar.gz"
sha256 "ee358d9bd13e3b491533e3eda5cda934bc5238aa756a68c2defaab4e33ee57ab"
license "GPL-2.0-or-later"
bottle do
sha256 cellar: :any, arm64_monterey: "e15cb7768159d6d7f594b3de0f138e4a91025becf80da695e0574b0bf3d28087"
sha256 cellar: :any, arm64_big_sur: "6c94c4386e52de46be152738b0bc9a7caee7c391c24cfb90e7358d4a8cf122a4"
sha256 cellar: :any, monterey: "1ab05d252442e9e1d484cfb3c4963c08119ac4b9c348df856013ae97531ac2cd"
sha256 cellar: :any, big_sur: "6e2cd9721a12de6c906cacee147986f080f2487dc8102ee8b2873b8f21e6708b"
sha256 cellar: :any, catalina: "ba97ac84c0b50b6348ef9a45ff0de21b5e302243fd2aee99a005024d13a3ddbd"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f318390f78d86e791868ca3c9ee20db98fb3ce74607c9e6c219efd6810d7a798"
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