--- subversion/bindings/swig/perl/native/Makefile.PL.in.orig	2014-01-17 08:54:43.000000000 +0400
+++ subversion/bindings/swig/perl/native/Makefile.PL.in	2015-10-15 01:31:03.842306478 +0300
@@ -19,7 +19,8 @@
 # under the License.
 #
 #
-
+#!/usr/local/bin/perl -w
+use strict;
 use ExtUtils::MakeMaker;
 use Config;
 use Cwd 'abs_path';
@@ -36,6 +37,11 @@
 my $swig_srcdir = "${svnlib_srcdir}/bindings/swig";
 my $swig_builddir = "${svnlib_builddir}/bindings/swig";
 
+my $top_builddir = '../../../../..';
+my $top_srcdir = '@top_srcdir@';
+my $svnlib_srcdir = "${top_srcdir}/subversion";
+my $swig_srcdir = "${svnlib_srcdir}/bindings/swig";
+
 my @modules = qw/client delta fs ra repos wc/;
 my @ldpaths = (abs_path($swig_builddir) . "/perl/libsvn_swig_perl/.libs",
                map { abs_path($svnlib_builddir) . "/libsvn_$_/.libs" }
@@ -86,10 +92,9 @@
                  " -I$svnlib_builddir",
                  " -I$swig_srcdir -g"),
     OBJECT => q/$(O_FILES)/,
-    LIBS => [join(' ', $apr_ldflags,
+    LIBS => [join(' ', $ENV{'LDFLAGS'}, $apr_ldflags,
                   (map {"-L$_"} @ldpaths),
-                  @ldmodules, '-lsvn_swig_perl-1',
-                  `$swig -perl -ldflags`)],
+                  @ldmodules, '-lsvn_swig_perl')],
     test => { TESTS => "$swig_srcdir/perl/native/t/*.t" }
 );
 
@@ -104,6 +109,7 @@
                       "\$(INST_LIBDIR)/$_.pm") }
          map { perlish $_ }
          ('base', 'core', @modules)},
+        LDFROM => '$(O_FILES) '."../libsvn_swig_perl/.libs/libsvn_swig_perl.a",
         MAN3PODS => {map { ("$swig_srcdir/perl/native/$_.pm" =>
                             "\$(INST_MAN3DIR)/SVN::$_.\$(MAN3EXT)") }
          map { perlish $_ }
