homebrew-core/Formula/dwarfutils.rb

57 lines
1.6 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-20200114.tar.gz"
sha256 "cffd8d600ca3181a5194324c38d50f94deb197249b2dea92d18969a7eadd2c34"
bottle do
cellar :any_skip_relocation
sha256 "7a752aaf0ef830de3bef1041516ecb1efc505e577b67deb690c9d38b99fbaeeb" => :catalina
sha256 "12c22459b32e39867a9943b958de8fecdc311a233f1b80722ecebca44fb5ce50" => :mojave
sha256 "7e815620405e86d932cba7502cbf8ee63fd786fb18258a0318d4ca9680f8912e" => :high_sierra
end
depends_on "libelf" => :build
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, "-L#{lib}", "-I#{include}", "-ldwarf", "test.c", "-o", "test"
system "./test"
end
end