homebrew-core/Formula/libbitcoin-network.rb
2019-06-09 22:18:35 +02:00

48 lines
1.7 KiB
Ruby

class LibbitcoinNetwork < Formula
desc "Bitcoin P2P Network Library"
homepage "https://github.com/libbitcoin/libbitcoin-network"
url "https://github.com/libbitcoin/libbitcoin-network/archive/v3.5.0.tar.gz"
sha256 "e065bd95f64ad5d7b0f882e8759f6b0f81a5fb08f7e971d80f3592a1b5aa8db4"
revision 3
bottle do
cellar :any
sha256 "f789c7974c37496e7d2775d90b857b27fd8c533d210f2e3143cb4abbee2e7f9b" => :mojave
sha256 "1321fa1d375f5a4cabdcd8a54202d0d0c20221d675697ae8e04041fdb5cc5765" => :high_sierra
sha256 "10409f4b0ad84135cbdd8a7d52223f9465da42af66bbb1dc6ee6d08d31bff29b" => :sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "libbitcoin"
def install
ENV.prepend_path "PKG_CONFIG_PATH", Formula["libbitcoin"].opt_libexec/"lib/pkgconfig"
system "./autogen.sh"
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <bitcoin/network.hpp>
int main() {
const bc::network::settings configuration;
bc::network::p2p network(configuration);
assert(network.top_block().height() == 0);
assert(network.top_block().hash() == bc::null_hash);
return 0;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-o", "test",
"-L#{Formula["libbitcoin"].opt_lib}", "-lbitcoin",
"-L#{lib}", "-lbitcoin-network",
"-L#{Formula["boost"].opt_lib}", "-lboost_system"
system "./test"
end
end