diff --git a/Formula/secp256k1.rb b/Formula/secp256k1.rb new file mode 100644 index 00000000000..8e8abf2be37 --- /dev/null +++ b/Formula/secp256k1.rb @@ -0,0 +1,38 @@ +class Secp256k1 < Formula + desc "Optimized C library for EC operations on curve secp256k1" + homepage "https://github.com/bitcoin-core/secp256k1" + url "https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v0.2.0.tar.gz" + sha256 "6cb0fd596e6b1a671f96e9ed7e65a047960def73de024e7b39f45a78ab4fc8df" + license "MIT" + + bottle do + root_url "https://github.com/gromgit/homebrew-core-mojave/releases/download/secp256k1" + sha256 cellar: :any, mojave: "821b26fb610770b0ffec28cf51866976a215cc76f82064159d4a629d9c332845" + end + + depends_on "autoconf" => [:build] + depends_on "automake" => [:build] + depends_on "libtool" => [:build] + + def install + system "./autogen.sh" + system "./configure", *std_configure_args, "--disable-silent-rules" + system "make" + system "make", "install" + end + + test do + (testpath/"test.c").write <<~EOS + #include + int main() { + secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE); + secp256k1_context_destroy(ctx); + return 0; + } + EOS + system ENV.cc, "test.c", + "-L#{lib}", "-lsecp256k1", + "-o", "test" + system "./test" + end +end