mbedtls: fix build for Darwin (#20940)

mbedtls: fix build for darwin
This commit is contained in:
Alexei Boronine 2016-12-11 00:29:50 +08:00 committed by Daiderd Jordan
parent 9074d9859e
commit 9243703c5c

View File

@ -10,6 +10,13 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ perl ];
patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace library/Makefile --replace "-soname" "-install_name"
substituteInPlace tests/scripts/run-test-suites.pl --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
# Necessary for install_name_tool below
echo "LOCAL_LDFLAGS += -headerpad_max_install_names" >> programs/Makefile
'';
postPatch = ''
patchShebangs .
'';
@ -22,6 +29,18 @@ stdenv.mkDerivation rec {
"DESTDIR=\${out}"
];
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $out/lib/libmbedtls.so.10
install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $out/lib/libmbedx509.so.0
install_name_tool -change libmbedx509.so.0 $out/lib/libmbedx509.so.0 $out/lib/libmbedtls.so.10
for exe in $out/bin/*; do
install_name_tool -change libmbedtls.so.10 $out/lib/libmbedtls.so.10 $exe
install_name_tool -change libmbedx509.so.0 $out/lib/libmbedx509.so.0 $exe
install_name_tool -change libmbedcrypto.so.0 $out/lib/libmbedcrypto.so.0 $exe
done
'';
doCheck = true;
meta = with stdenv.lib; {