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.3.tar.gz" sha256 "0a24e6a51dbf3beecb0ebcd2cafb1e09b1212e910be6477b5de03c84a5586754" head "https://github.com/libgit2/libgit2.git" bottle do sha256 "8beb1cb03a4c3da66753054cce18f80939e2b0a15934345622657e9f77133010" => :sierra sha256 "c24adf3a7f04ea099e07f869518196c2c6e1ba63aab3c4ae5b5a8ca7a32682a3" => :el_capitan sha256 "b5bb829ea74f54219b131c59c53fd441145ba8507529bfd8c17003320dfa005b" => :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