homebrew-core/Formula/libgit2.rb
2016-10-04 03:19:00 -07:00

64 lines
2 KiB
Ruby

class Libgit2 < Formula
desc "C library of Git core methods that is re-entrant and linkable"
homepage "https://libgit2.github.com/"
url "https://github.com/libgit2/libgit2/archive/v0.24.2.tar.gz"
sha256 "00f0a7403143fba69601accc80cacf49becc568b890ba232f300c1b2a37475e6"
head "https://github.com/libgit2/libgit2.git"
bottle do
sha256 "a91f992a31d5514513ea465376a0674063719a84888f68be397ef6f08f021716" => :sierra
sha256 "2a012d6fe081d48f8a3b945d45d35e7d471412c1baf59c5da66b54500de3d807" => :el_capitan
sha256 "4ec737bb7521f49d7375ec10c0f492de4a647e90c21f122b44e309ad9a04c46d" => :yosemite
end
option :universal
depends_on "pkg-config" => :build
depends_on "cmake" => :build
depends_on "libssh2" => :recommended
depends_on "openssl" if MacOS.version <= :lion # Uses SecureTransport on >10.7
def install
args = std_cmake_args
args << "-DBUILD_EXAMPLES=YES"
args << "-DBUILD_CLAR=NO" # Don't build tests.
args << "-DUSE_SSH=NO" if build.without? "libssh2"
if build.universal?
ENV.universal_binary
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
end
mkdir "build" do
system "cmake", "..", *args
system "make", "install"
cd "examples" do
(pkgshare/"examples").install "add", "blame", "cat-file", "cgit2",
"describe", "diff", "for-each-ref",
"general", "init", "log", "remote",
"rev-list", "rev-parse", "showindex",
"status", "tag"
end
end
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <git2.h>
int main(int argc, char *argv[]) {
int options = git_libgit2_features();
return 0;
}
EOS
libssh2 = Formula["libssh2"]
flags = %W[
-I#{include}
-I#{libssh2.opt_include}
-L#{lib}
-lgit2
]
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end