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.25.0.tar.gz" sha256 "10c66211a3346644e55af9651d5f89966f9c4fa2f92972fca4e8560d0d3c837a" head "https://github.com/libgit2/libgit2.git" bottle do sha256 "027ae50d1c614cf9f0d697b113cbada73fab7887a4d6b78abcfc27875c7bd371" => :sierra sha256 "2eaf23eac55551484d155c1bc71ca1fe483429aeef47ec926f5be3d02689c548" => :el_capitan sha256 "b901857627a46aaf8428e83f3fbf283f98dca5dd1ae948b77404d3af969aad4e" => :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 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