- # Their cmd invocation only works on msys. On cygwin it starts
- # a cmd interactive shell. The replacement works in both environments.
- mv libffi/build/ltmain.sh libffi/build/ltmain.sh.orig
- sed 's#cmd //c echo "\$$1"#cmd /c "echo $$1"#' < libffi/build/ltmain.sh.orig > libffi/build/ltmain.sh
+ # We attempt to specify the installation directory below with --libdir,
+ # but libffi installs into 'toolexeclibdir' instead, which may differ
+ # on systems where gcc has multilib support. Force libffi to use libdir.
+ # (https://sourceware.org/ml/libffi-discuss/2014/msg00016.html)
+ mv libffi/build/Makefile.in libffi/build/Makefile.in.orig
+ sed 's:@toolexeclibdir@:$$(libdir):g' < libffi/build/Makefile.in.orig > libffi/build/Makefile.in
+
+ # install-sh is used when /usr/bin/install is missing; ensure its
+ # path in libffi's Makefile is correct. See GHC #11109.
+ mv libffi/build/Makefile.in libffi/build/Makefile.in.orig
+ sed 's|@INSTALL@|$$(subst ../install-sh,$(TOP)/install-sh,@INSTALL@)|g' < libffi/build/Makefile.in.orig > libffi/build/Makefile.in