homebrew-core/Formula/libmd.rb

44 lines
1.2 KiB
Ruby

class Libmd < Formula
desc "BSD Message Digest library"
homepage "https://www.hadrons.org/software/libmd/"
url "https://libbsd.freedesktop.org/releases/libmd-1.0.3.tar.xz"
sha256 "5a02097f95cc250a3f1001865e4dbba5f1d15554120f95693c0541923c52af4a"
license "BSD-3-Clause"
depends_on :linux
def install
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <md5.h>
int main() {
MD5_CTX ctx;
uint8_t results[MD5_DIGEST_LENGTH];
char *buf;
buf = "abc";
int n;
n = strlen(buf);
MD5Init(&ctx);
MD5Update(&ctx, (uint8_t *)buf, n);
MD5Final(results, &ctx);
for (n = 0; n < MD5_DIGEST_LENGTH; n++)
printf("%02x", results[n]);
putchar('\\n');
return EXIT_SUCCESS;
}
EOS
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lmd", "-o", "test"
assert_equal "900150983cd24fb0d6963f7d28e17f72", shell_output("./test").chomp
end
end