class Mbedtls < Formula desc "Cryptographic & SSL/TLS library" homepage "https://tls.mbed.org/" url "https://tls.mbed.org/download/mbedtls-2.13.0-apache.tgz" sha256 "593b4e4d2e1629fc407ab4750d69fa309a0ddb66565dc3deb5b60eddbdeb06da" head "https://github.com/ARMmbed/mbedtls.git", :branch => "development" bottle do cellar :any sha256 "feccdb1c6eddee9925758aee4a1ffbab89d4ac43cd4c290feab8cec3f3f88197" => :mojave sha256 "3f923b072ceb1f9a08321a333336bcfb45a5cac718f79a5533f8580735063838" => :high_sierra sha256 "1ed5d87a59cff97897698d96e4bc99e59128d67b837aedff69c0dee1034e224a" => :sierra sha256 "178b322e81d96190b004a71984be2ecd9af4daa1e35b7c4e2a8f9c0137374dc3" => :el_capitan 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