homebrew-core/Formula/dwarfutils.rb

64 lines
1.8 KiB
Ruby

class Dwarfutils < Formula
desc "Dump and produce DWARF debug information in ELF objects"
homepage "https://www.prevanders.net/dwarf.html"
url "https://www.prevanders.net/libdwarf-20201201.tar.gz"
sha256 "62db1028dfd8fd877d01ae75873ac1fe311437012ef48a0ac4157189e1e9b2c9"
license all_of: ["BSD-2-Clause", "LGPL-2.1-or-later", "GPL-2.0-or-later"]
livecheck do
url :homepage
regex(%r{href=(?:["']?|.*?/)libdwarf[._-]v?(\d{6,8})\.t}i)
end
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "4b7bb9ec7ab16bc1f7621484fb36af441cb9fd9e749cda79996915cf7bc22372"
sha256 cellar: :any_skip_relocation, catalina: "5e63608b1a3ac55a066255d09d57d07105c7adcecbcddfe65fb45738f4480460"
sha256 cellar: :any_skip_relocation, mojave: "a511dac8825fed2348399e8390170b53e7232b19247f42f59c5bd67ae24af5b4"
end
depends_on "libelf" => :build
uses_from_macos "zlib"
def install
system "./configure"
system "make"
bin.install "dwarfdump/dwarfdump"
man1.install "dwarfdump/dwarfdump.1"
lib.install "libdwarf/.libs/libdwarf.a"
include.install "libdwarf/dwarf.h"
include.install "libdwarf/libdwarf.h"
end
test do
system "#{bin}/dwarfdump", "-V"
(testpath/"test.c").write <<~EOS
#include <dwarf.h>
#include <libdwarf.h>
#include <stdio.h>
#include <string.h>
int main(void) {
const char *out = NULL;
int res = dwarf_get_children_name(0, &out);
if (res != DW_DLV_OK) {
printf("Getting name failed\\n");
return 1;
}
if (strcmp(out, "DW_children_no") != 0) {
printf("Name did not match: %s\\n", out);
return 1;
}
return 0;
}
EOS
system ENV.cc, "-I#{include}", "test.c", "-L#{lib}", "-ldwarf", "-o", "test"
system "./test"
end
end