class Jemalloc < Formula desc "malloc implementation emphasizing fragmentation avoidance" homepage "http://jemalloc.net/" url "https://github.com/jemalloc/jemalloc/releases/download/5.2.0/jemalloc-5.2.0.tar.bz2" sha256 "74be9f44a60d2a99398e706baa921e4efde82bf8fd16e5c0643c375c5851e3b4" bottle do cellar :any sha256 "65f360353caa81de08b1b1882de13e8423d0f72d92a67bb3a8cfd7ce71f39c71" => :mojave sha256 "9c0d0531d6da443ae28a585f23b6f959383c6c92e37c7db9287ba59c6b91bfc9" => :high_sierra sha256 "6713d3ff6d14a6c924bde3f05e41cb290c90f0a435b2fb5df07be5b466e8475e" => :sierra end head do url "https://github.com/jemalloc/jemalloc.git", :branch => "dev" depends_on "autoconf" => :build depends_on "docbook-xsl" => :build end def install args = %W[ --disable-debug --prefix=#{prefix} --with-jemalloc-prefix= ] if build.head? args << "--with-xslroot=#{Formula["docbook-xsl"].opt_prefix}/docbook-xsl" system "./autogen.sh", *args system "make", "dist" else system "./configure", *args end system "make" system "make", "check" system "make", "install" end test do (testpath/"test.c").write <<~EOS #include #include int main(void) { for (size_t i = 0; i < 1000; i++) { // Leak some memory malloc(i * 100); } // Dump allocator statistics to stderr malloc_stats_print(NULL, NULL, NULL); } EOS system ENV.cc, "test.c", "-L#{lib}", "-ljemalloc", "-o", "test" system "./test" end end