diff --git a/Formula/z/zlib.rb b/Formula/z/zlib.rb new file mode 100644 index 00000000000..942c51d786e --- /dev/null +++ b/Formula/z/zlib.rb @@ -0,0 +1,47 @@ +class Zlib < Formula + desc "General-purpose lossless data-compression library" + homepage "https://zlib.net/" + url "https://zlib.net/zlib-1.3.1.tar.gz" + mirror "https://downloads.sourceforge.net/project/libpng/zlib/1.3.1/zlib-1.3.1.tar.gz" + mirror "http://fresh-center.net/linux/misc/zlib-1.3.1.tar.gz" + mirror "http://fresh-center.net/linux/misc/legacy/zlib-1.3.1.tar.gz" + sha256 "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23" + license "Zlib" + head "https://github.com/madler/zlib.git", branch: "develop" + + livecheck do + url :homepage + regex(/href=.*?zlib[._-]v?(\d+(?:\.\d+)+)\.t/i) + end + + bottle do + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/zlib-1.3.1" + sha256 cellar: :any_skip_relocation, aarch64_linux: "343b667a2d94c71bcc0d5aaa610c685cdefdb0be7d874f6d3cfbd664f9d35b46" + end + + keg_only :provided_by_macos + + # https://zlib.net/zlib_how.html + resource "test_artifact" do + url "https://zlib.net/zpipe.c" + version "20051211" + sha256 "68140a82582ede938159630bca0fb13a93b4bf1cb2e85b08943c26242cf8f3a6" + end + + def install + system "./configure", "--prefix=#{prefix}" + system "make", "install" + + # Avoid rebuilds of dependents that hardcode this path. + inreplace lib/"pkgconfig/zlib.pc", prefix, opt_prefix + end + + test do + testpath.install resource("test_artifact") + system ENV.cc, "zpipe.c", "-I#{include}", "-L#{lib}", "-lz", "-o", "zpipe" + + text = "Hello, Homebrew!" + compressed = pipe_output("./zpipe", text) + assert_equal text, pipe_output("./zpipe -d", compressed) + end +end