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.27.7.tar.gz" sha256 "1a5435a483759b1cd96feb12b11abb5231b0688016db506ce5947178f6ba2531" head "https://github.com/libgit2/libgit2.git" bottle do cellar :any rebuild 1 sha256 "d9c0bb9fc757af21ca690e0262edb2fdfac710cfd4897399fa4a8f52debacbcd" => :mojave sha256 "15fe42707016a29881b1093ef9f6e6bebf4388ad0395d63ba4dd2da73cef6d4f" => :high_sierra sha256 "feb602bd610351dc95ed7532f74a3ca5fb5946159bd4e2f81d2df03752128398" => :sierra end depends_on "cmake" => :build depends_on "pkg-config" => :build depends_on "libssh2" 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. 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 system "make", "clean" system "cmake", "..", "-DBUILD_SHARED_LIBS=OFF", *args system "make" lib.install "libgit2.a" end end test do (testpath/"test.c").write <<~EOS #include 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