diff --git a/Formula/lib/libnghttp2.rb b/Formula/lib/libnghttp2.rb new file mode 100644 index 00000000000..e26286924c0 --- /dev/null +++ b/Formula/lib/libnghttp2.rb @@ -0,0 +1,62 @@ +class Libnghttp2 < Formula + desc "HTTP/2 C Library" + homepage "https://nghttp2.org/" + url "https://github.com/nghttp2/nghttp2/releases/download/v1.63.0/nghttp2-1.63.0.tar.gz" + mirror "http://fresh-center.net/linux/www/nghttp2-1.63.0.tar.gz" + mirror "http://fresh-center.net/linux/www/legacy/nghttp2-1.63.0.tar.gz" + # this legacy mirror is for user to install from the source when https not working for them + # see discussions in here, https://github.com/Homebrew/homebrew-core/pull/133078#discussion_r1221941917 + sha256 "9318a2cc00238f5dd6546212109fb833f977661321a2087f03034e25444d3dbb" + license "MIT" + + livecheck do + formula "nghttp2" + end + + bottle do + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/libnghttp2-1.63.0" + sha256 cellar: :any_skip_relocation, aarch64_linux: "e3de4a2cc008999def7b3159edb2f02a63f73f1246d33cf9f8999964ed5192bd" + end + + head do + url "https://github.com/nghttp2/nghttp2.git", branch: "master" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "libtool" => :build + end + + depends_on "pkg-config" => :build + + # These used to live in `nghttp2`. + link_overwrite "include/nghttp2" + link_overwrite "lib/libnghttp2.a" + link_overwrite "lib/libnghttp2.dylib" + link_overwrite "lib/libnghttp2.14.dylib" + link_overwrite "lib/libnghttp2.so" + link_overwrite "lib/libnghttp2.so.14" + link_overwrite "lib/pkgconfig/libnghttp2.pc" + + def install + system "autoreconf", "-ivf" if build.head? + system "./configure", *std_configure_args, "--enable-lib-only" + system "make", "-C", "lib" + system "make", "-C", "lib", "install" + end + + test do + (testpath/"test.c").write <<~EOS + #include + #include + + int main() { + nghttp2_info *info = nghttp2_version(0); + printf("%s", info->version_str); + return 0; + } + EOS + + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lnghttp2", "-o", "test" + assert_equal version.to_s, shell_output("./test") + end +end