Index: openssl-1.1.1d/Configurations/unix-Makefile.tmpl
===================================================================
--- openssl-1.1.1d.orig/Configurations/unix-Makefile.tmpl
+++ openssl-1.1.1d/Configurations/unix-Makefile.tmpl
@@ -191,7 +191,8 @@ LIBDIR={- our $libdir = $config{libdir};
 # $(libdir) is chosen to be compatible with the GNU coding standards
 libdir={- file_name_is_absolute($libdir)
           ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
-ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
+ENGINESDIR={- use File::Spec::Functions;
+              $config{enginesdir} -}
 
 # Convenience variable for those who want to set the rpath in shared
 # libraries and applications
Index: openssl-1.1.1d/Configure
===================================================================
--- openssl-1.1.1d.orig/Configure
+++ openssl-1.1.1d/Configure
@@ -290,6 +290,7 @@ $config{perl_archname} = $Config{archnam
 
 $config{prefix}="";
 $config{openssldir}="";
+$config{enginesdir}="";
 $config{processor}="";
 $config{libdir}="";
 my $auto_threads=1;    # enable threads automatically? true by default
@@ -796,6 +797,10 @@ while (@argvcopy)
                         {
                         $config{openssldir}=$1;
                         }
+		elsif (/^--enginesdir=(.*)$/)
+			{
+			$config{enginesdir}=$1;
+			}
                 elsif (/^--with-zlib-lib=(.*)$/)
                         {
                         $withargs{zlib_lib}=$1;
