homebrew-core/Formula/libbpf.rb

41 lines
1.1 KiB
Ruby

class Libbpf < Formula
desc "Berkeley Packet Filter library"
homepage "https://github.com/libbpf/libbpf"
url "https://github.com/libbpf/libbpf/archive/refs/tags/v1.1.0.tar.gz"
sha256 "5da826c968fdb8a2f714701cfef7a4b7078be030cf58b56143b245816301cbb8"
license "BSD-2-Clause"
bottle do
sha256 cellar: :any_skip_relocation, x86_64_linux: "7fbd0ecc7a0aa866326c68f548a99169ab7d7b5a88f0e867c31df764956372a8"
end
depends_on "pkg-config" => :build
depends_on "linux-headers@5.16" => :test
depends_on "elfutils"
depends_on :linux
uses_from_macos "zlib"
def install
chdir "src" do
system "make"
system "make", "install", "PREFIX=#{prefix}", "LIBDIR=#{lib}"
end
end
test do
(testpath/"test.c").write <<~EOS
#include "bpf/libbpf.h"
#include <stdio.h>
int main() {
printf("%s", libbpf_version_string());
return(0);
}
EOS
system ENV.cc, "test.c", "-I#{Formula["linux-headers@5.16"].opt_include}", "-I#{include}", "-L#{lib}",
"-lbpf", "-o", "test"
system "./test"
end
end