class Nettle < Formula desc "Low-level cryptographic library" homepage "https://www.lysator.liu.se/~nisse/nettle/" url "https://ftp.gnu.org/gnu/nettle/nettle-3.6.tar.gz" mirror "https://ftpmirror.gnu.org/nettle/nettle-3.6.tar.gz" sha256 "d24c0d0f2abffbc8f4f34dcf114b0f131ec3774895f3555922fe2f40f3d5e3f1" # license ["GPL-2.0", "GPL-3.0", "LGPL-3.0"] - pending https://github.com/Homebrew/brew/pull/7953 license "GPL-2.0" livecheck do url :stable end bottle do cellar :any sha256 "7ac7677ba653dbef81dd83ed8cde3dfcb7b464d04442886c396179932f4f9faa" => :catalina sha256 "d378b026725d8d449ca6497ce2158b93c991a0e0326921a5f914bc4847da3a92" => :mojave sha256 "07c65cb4d172b05065dcceb702b41ca3408b31b6154690c7a4cfa430b2de074d" => :high_sierra end depends_on "gmp" uses_from_macos "m4" => :build def install # The LLVM shipped with Xcode/CLT 10+ compiles binaries/libraries with # ___chkstk_darwin, which upsets nettle's expected symbol check. # https://github.com/Homebrew/homebrew-core/issues/28817#issuecomment-396762855 # https://lists.lysator.liu.se/pipermail/nettle-bugs/2018/007300.html if DevelopmentTools.clang_build_version >= 1000 inreplace "testsuite/symbols-test", "get_pc_thunk", "get_pc_thunk|(_*chkstk_darwin)" end args = [] args << "--build=aarch64-apple-darwin#{OS.kernel_version}" if Hardware::CPU.arm? system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}", "--enable-shared", *args system "make" system "make", "install" system "make", "check" end test do (testpath/"test.c").write <<~EOS #include #include int main() { struct sha1_ctx ctx; uint8_t digest[SHA1_DIGEST_SIZE]; unsigned i; sha1_init(&ctx); sha1_update(&ctx, 4, "test"); sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest); printf("SHA1(test)="); for (i = 0; i