|
| 1 | +class Libnghttp2 < Formula |
| 2 | + desc "HTTP/2 C Library" |
| 3 | + homepage "https://nghttp2.org/" |
| 4 | + url "https://github.com/nghttp2/nghttp2/releases/download/v1.63.0/nghttp2-1.63.0.tar.gz" |
| 5 | + mirror "http://fresh-center.net/linux/www/nghttp2-1.63.0.tar.gz" |
| 6 | + mirror "http://fresh-center.net/linux/www/legacy/nghttp2-1.63.0.tar.gz" |
| 7 | + # this legacy mirror is for user to install from the source when https not working for them |
| 8 | + # see discussions in here, https://github.com/Homebrew/homebrew-core/pull/133078#discussion_r1221941917 |
| 9 | + sha256 "9318a2cc00238f5dd6546212109fb833f977661321a2087f03034e25444d3dbb" |
| 10 | + license "MIT" |
| 11 | + |
| 12 | + livecheck do |
| 13 | + formula "nghttp2" |
| 14 | + end |
| 15 | + |
| 16 | + bottle do |
| 17 | + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/libnghttp2-1.63.0" |
| 18 | + sha256 cellar: :any_skip_relocation, aarch64_linux: "e3de4a2cc008999def7b3159edb2f02a63f73f1246d33cf9f8999964ed5192bd" |
| 19 | + end |
| 20 | + |
| 21 | + head do |
| 22 | + url "https://github.com/nghttp2/nghttp2.git", branch: "master" |
| 23 | + |
| 24 | + depends_on "autoconf" => :build |
| 25 | + depends_on "automake" => :build |
| 26 | + depends_on "libtool" => :build |
| 27 | + end |
| 28 | + |
| 29 | + depends_on "pkg-config" => :build |
| 30 | + |
| 31 | + # These used to live in `nghttp2`. |
| 32 | + link_overwrite "include/nghttp2" |
| 33 | + link_overwrite "lib/libnghttp2.a" |
| 34 | + link_overwrite "lib/libnghttp2.dylib" |
| 35 | + link_overwrite "lib/libnghttp2.14.dylib" |
| 36 | + link_overwrite "lib/libnghttp2.so" |
| 37 | + link_overwrite "lib/libnghttp2.so.14" |
| 38 | + link_overwrite "lib/pkgconfig/libnghttp2.pc" |
| 39 | + |
| 40 | + def install |
| 41 | + system "autoreconf", "-ivf" if build.head? |
| 42 | + system "./configure", *std_configure_args, "--enable-lib-only" |
| 43 | + system "make", "-C", "lib" |
| 44 | + system "make", "-C", "lib", "install" |
| 45 | + end |
| 46 | + |
| 47 | + test do |
| 48 | + (testpath/"test.c").write <<~EOS |
| 49 | + #include <nghttp2/nghttp2.h> |
| 50 | + #include <stdio.h> |
| 51 | +
|
| 52 | + int main() { |
| 53 | + nghttp2_info *info = nghttp2_version(0); |
| 54 | + printf("%s", info->version_str); |
| 55 | + return 0; |
| 56 | + } |
| 57 | + EOS |
| 58 | + |
| 59 | + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lnghttp2", "-o", "test" |
| 60 | + assert_equal version.to_s, shell_output("./test") |
| 61 | + end |
| 62 | +end |
0 commit comments