class Mbedtls < Formula desc "Cryptographic & SSL/TLS library" homepage "https://tls.mbed.org/" url "https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz" sha256 "a6834fcd7b7e64b83dfaaa6ee695198cb5019a929b2806cb0162e049f98206a4" head "https://github.com/ARMmbed/mbedtls.git", :branch => "development" bottle do cellar :any sha256 "c1a4f23c7cf7c9e2491e0b340718c401732de2b4df86c5c2a92b2b8ba1fe868c" => :catalina sha256 "5e0fb460a0f30997819de1a56ed4a22d409e375d04571703d85e02f86458bb08" => :mojave sha256 "d8993453addc7f19eb38a939c1c7df757f64f08554636f52513a57333e3af44c" => :high_sierra sha256 "f25d70bfcc69413cb817b4a0f5cc26eed2e130c8b19004cbdca424cee2785d4a" => :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