class Mbedtls < Formula desc "Cryptographic & SSL/TLS library" homepage "https://tls.mbed.org/" url "https://tls.mbed.org/download/mbedtls-2.16.1-apache.tgz" sha256 "ebd06d1342cdc7af506835ae16b84f839a4807c36615ffb4bb558ac51e42ff23" head "https://github.com/ARMmbed/mbedtls.git", :branch => "development" bottle do cellar :any sha256 "85bdb8b7a5c0c682610703958d1a0ab6a68a4e9afd0bd90fbb02aa695002b32d" => :mojave sha256 "e2d5aefdf7d6a25da7a3db2091be4601471fe1d532a9b2a9c364ea62b251a513" => :high_sierra sha256 "09e8adebc8592be12638138f2cfaf1799e0688641163da274b04272f563f73ec" => :sierra end depends_on "cmake" => :build def install inreplace "include/mbedtls/config.h" do |s| # enable pthread mutexes s.gsub! "//#define MBEDTLS_THREADING_PTHREAD", "#define MBEDTLS_THREADING_PTHREAD" # allow use of mutexes within mbed TLS s.gsub! "//#define MBEDTLS_THREADING_C", "#define MBEDTLS_THREADING_C" end system "cmake", "-DUSE_SHARED_MBEDTLS_LIBRARY=On", *std_cmake_args system "make" system "make", "install" # Why does Mbedtls ship with a "Hello World" executable. Let's remove that. rm_f bin/"hello" # Rename benchmark & selftest, which are awfully generic names. mv bin/"benchmark", bin/"mbedtls-benchmark" mv bin/"selftest", bin/"mbedtls-selftest" # Demonstration files shouldn't be in the main bin libexec.install bin/"mpi_demo" end test do (testpath/"testfile.txt").write("This is a test file") # Don't remove the space between the checksum and filename. It will break. expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249 testfile.txt" assert_equal expected_checksum, shell_output("#{bin}/generic_sum SHA256 testfile.txt").strip end end