homebrew-core/Formula/mbedtls.rb

47 lines
1.9 KiB
Ruby

class Mbedtls < Formula
desc "Cryptographic & SSL/TLS library"
homepage "https://tls.mbed.org/"
url "https://tls.mbed.org/download/mbedtls-2.4.2-apache.tgz"
sha256 "17dd98af7478aadacc480c7e4159e447353b5b2037c1b6d48ed4fd157fb1b018"
head "https://github.com/ARMmbed/mbedtls.git", :branch => "development"
bottle do
cellar :any
sha256 "b1f05011d97553b6255ffd5cf51ca0f4ae1394c7f3661165e009180916e5411e" => :sierra
sha256 "6757969434945c4b0fdf18835e4289b4564f935114a2cc8abebb695919f94881" => :el_capitan
sha256 "2e1fb7fcceb78de514711c4ebae95d1ce0af92681569b13dd292fe4c604a2332" => :yosemite
end
depends_on "cmake" => :build
def install
inreplace "include/mbedtls/config.h" do |s|
# disable support for SSL 3.0
s.gsub! "#define MBEDTLS_SSL_PROTO_SSL3", "//#define MBEDTLS_SSL_PROTO_SSL3"
# 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