Fix order of -L flags to link with the newly-built library, even if a
different version of the library is already installed.
--- perl/ASN/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/ASN/Makefile.PL	2020-12-18 16:33:01.000000000 +0900
@@ -81,10 +81,10 @@
           die "net-snmp-config failed\n";
       
       if (lc($opts->{'insource'}) eq "true") {
-	$Params{'LIBS'} =
+	$Params{'LDDLFLAGS'} =
             "-L" . abs_path("../../snmplib/.libs") .
             " -L" . abs_path("../../snmplib") .
-            " " . $Params{'LIBS'};
+            " " . $Params{'LDDLFLAGS'};
       }
     }
     return (%Params);
--- perl/OID/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/OID/Makefile.PL	2020-12-18 16:50:33.000000000 +0900
@@ -76,11 +76,11 @@
         $lib_version = `$opts->{'nsconfig'} --version` or
 	    die "net-snmp-config failed\n";
 	if (lc($opts->{'insource'}) eq "true") {
-	    $Params{'LIBS'} =
+	    $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../snmplib/.libs") .
                 " -L" . abs_path("../../snmplib") .
-                " " . $Params{'LIBS'};
-#	} else {
+                " " . $Params{'LDDLFLAGS'};
+	} else {
 #	    $Params{'PREREQ_PM'} = {'SNMP' => '5.0'};
 	}
     }
--- perl/SNMP/Makefile.PL.orig	2021-05-25 17:19:35.000000000 -0500
+++ perl/SNMP/Makefile.PL	2021-06-27 04:01:44.000000000 -0500
@@ -88,10 +88,10 @@
         $lib_version = `$opts->{'nsconfig'} --version` or
 	    die "net-snmp-config failed\n";
 	if (lc($opts->{'insource'}) eq "true") {
-	    $Params{'LIBS'} =
+	    $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../snmplib/.libs") .
                 " -L" . abs_path("../../snmplib") .
-                " " . $Params{'LIBS'};
+                " " . $Params{'LDDLFLAGS'};
 #	} else {
 #	    $Params{'PREREQ_PM'} = { 'NetSNMP::default_store' => 0.01 };
 	}
--- perl/TrapReceiver/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/TrapReceiver/Makefile.PL	2020-12-18 16:37:07.000000000 +0900
@@ -108,14 +108,14 @@
 	chomp($Params{'LIBS'});
 
 	if (lc($opts->{'insource'}) eq "true") {
-            $Params{'LIBS'} =
+            $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../apps/.libs") .
                 " -L" . abs_path("../../apps") .
                 " -L" . abs_path("../../agent/.libs") .
                 " -L" . abs_path("../../agent") .
                 " -L" . abs_path("../../snmplib/.libs") .
                 " -L" . abs_path("../../snmplib") .
-                " " . $Params{'LIBS'};
+                " " . $Params{'LDDLFLAGS'};
 	} else {
             $Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . " $Params{'LIBS'}";
         }
--- perl/agent/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/agent/Makefile.PL	2020-12-18 16:38:46.000000000 +0900
@@ -81,14 +81,14 @@
         $lib_version = `$opts->{'nsconfig'} --version` or
 	    die "net-snmp-config failed\n";
 	if (lc($opts->{'insource'}) eq "true") {
-	    $Params{'LIBS'} =
+	    $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../snmplib/.libs") .
                 " -L" . abs_path("../../snmplib") .
                 " -L" . abs_path("../../agent/.libs") .
                 " -L" . abs_path("../../agent") .
-                " " . $Params{'LIBS'};
-#	} else {
-	    $Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . $Params{'LIBS'};
+                " " . $Params{'LDDLFLAGS'};
+	} else {
+	    $Params{'LDDLFLAGS'} = `$opts->{'nsconfig'} --libdir` . $Params{'LDDLFLAGS'};
 #	    $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'};
 	}
     }
--- perl/agent/Support/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/agent/Support/Makefile.PL	2020-12-18 16:47:49.000000000 +0900
@@ -28,6 +28,7 @@
     my ($snmp_lib, $snmp_llib, $sep);
 
     $opts = NetSNMPGetOpts();
+    $Params{'LDDLFLAGS'} = "$Config{lddlflags} " . `$opts->{'nsconfig'} --ldflags`;
 
     if ($Config{'osname'} eq 'MSWin32' && !defined($ENV{'OSTYPE'})) {
       $sep = '\\';
@@ -78,10 +79,10 @@
           die "net-snmp-config failed\n";
       
       if (lc($opts->{'insource'}) eq "true") {
-	$Params{'LIBS'} =
+	$Params{'LDDLFLAGS'} =
             "-L" . abs_path("../../../snmplib/.libs") .
             " -L" . abs_path("../../../snmplib") .
-            " " . $Params{'LIBS'};
+            " " . $Params{'LDDLFLAGS'};
       }
     }
     return (%Params);
--- perl/agent/default_store/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/agent/default_store/Makefile.PL	2020-12-18 16:47:04.000000000 +0900
@@ -24,6 +24,7 @@
     my ($snmp_lib, $snmp_llib, $sep);
 
     $opts = NetSNMPGetOpts();
+    $Params{'LDDLFLAGS'} = "$Config{lddlflags} " . `$opts->{'nsconfig'} --ldflags`;
 
     if ($Config{'osname'} eq 'MSWin32' && !defined($ENV{'OSTYPE'})) {
       $sep = '\\';
@@ -72,10 +73,10 @@
         $lib_version = `$opts->{'nsconfig'} --version` or
 	    die "net-snmp-config failed\n";
 	if ($opts->{'insource'} eq "true") {
-	    $Params{'LIBS'} =
+	    $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../../snmplib/.libs") .
                 " -L" . abs_path("../../../snmplib") .
-                " " . $Params{'LIBS'};
+                " " . $Params{'LDDLFLAGS'};
 	}
     }
 
--- perl/default_store/Makefile.PL.orig	2018-07-16 09:33:40.000000000 -0500
+++ perl/default_store/Makefile.PL	2020-12-18 16:48:43.000000000 +0900
@@ -71,10 +71,10 @@
         $lib_version = `$opts->{'nsconfig'} --version` or
 	    die "net-snmp-config failed\n";
 	if (lc($opts->{'insource'}) eq "true") {
-	    $Params{'LIBS'} =
+	    $Params{'LDDLFLAGS'} =
                 "-L" . abs_path("../../snmplib/.libs") .
                 " -L" . abs_path("../../snmplib") .
-                " " . $Params{'LIBS'};
+                " " . $Params{'LDDLFLAGS'};
 	}
     }
 
