| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use ExtUtils::MakeMaker; |
| 4 |
require 5; |
| 5 |
use Config; |
| 6 |
use MakefileSubs; |
| 7 |
|
| 8 |
my $lib_version; |
| 9 |
|
| 10 |
WriteMakefile(AgentInitMakeParams()); |
| 11 |
|
| 12 |
Check_Version($lib_version); |
| 13 |
|
| 14 |
sub AgentInitMakeParams { |
| 15 |
my $opts; |
| 16 |
my %Params = ( |
| 17 |
'NAME' => 'NetSNMP::agent', |
| 18 |
'VERSION_FROM' => 'agent.pm', # finds $VERSION |
| 19 |
'XSPROTOARG' => '-prototypes', |
| 20 |
'PM' => { |
| 21 |
'agent.pm' => '$(INST_LIBDIR)/agent.pm', |
| 22 |
'netsnmp_request_infoPtr.pm' => |
| 23 |
'$(INST_LIBDIR)/agent/netsnmp_request_infoPtr.pm' |
| 24 |
}, |
| 25 |
'PREREQ_PM' => {}, |
| 26 |
); |
| 27 |
|
| 28 |
AddCommonParams(\%Params); |
| 29 |
|
| 30 |
my ($snmp_lib, $snmp_llib, $sep); |
| 31 |
|
| 32 |
$opts = NetSNMPGetOpts(); |
| 33 |
|
| 34 |
if ($Config{'osname'} eq 'MSWin32' && !defined($ENV{'OSTYPE'})) { |
| 35 |
$sep = '\\'; |
| 36 |
my $snmp_lib_file = 'netsnmp.lib'; |
| 37 |
my $snmp_link_lib = 'netsnmp'; |
| 38 |
my $lib_dir; |
| 39 |
my $agent_link_lib = 'netsnmpagent'; |
| 40 |
my $mibs_link_lib = 'netsnmpmibs'; |
| 41 |
|
| 42 |
if (lc($opts->{'debug'}) eq "true") { |
| 43 |
$lib_dir = 'lib\\debug'; |
| 44 |
} |
| 45 |
else { |
| 46 |
$lib_dir = 'lib\\release'; |
| 47 |
} |
| 48 |
|
| 49 |
if (lc($opts->{'insource'}) eq "true") { |
| 50 |
$Params{'LIBS'} = "-L" . $MakefileSubs::basedir . "\\win32\\$lib_dir\\ -l$snmp_link_lib -l$agent_link_lib " . |
| 51 |
"-l$mibs_link_lib"; |
| 52 |
} |
| 53 |
else { |
| 54 |
my @LibDirs = split($Config{path_sep}, $ENV{LIB}); |
| 55 |
my $LibDir; |
| 56 |
if ($opts->{'prefix'}) { |
| 57 |
push (@LibDirs,"$ENV{'NET-SNMP-PATH'}${sep}lib"); |
| 58 |
} |
| 59 |
my $noLibDir = 1; |
| 60 |
while ($noLibDir) { |
| 61 |
$LibDir = find_files(["$snmp_lib_file"],\@LibDirs); |
| 62 |
if ($LibDir ne '') { |
| 63 |
$noLibDir = 0; |
| 64 |
# Put quotes around LibDir to allow spaces in paths |
| 65 |
$LibDir = '"' . $LibDir . '"'; |
| 66 |
} |
| 67 |
else |
| 68 |
{ |
| 69 |
@LibDirs = (); |
| 70 |
$LibDirs[0] = prompt("The Net-SNMP library ($snmp_lib_file) could not be found.\nPlease enter the directory where it is located:"); |
| 71 |
$LibDirs[0] =~ s/\\$//; |
| 72 |
} |
| 73 |
} |
| 74 |
$Params{LIBS} = "-L$LibDir -l$snmp_link_lib -l$agent_link_lib -l$mibs_link_lib"; |
| 75 |
} |
| 76 |
} |
| 77 |
else { |
| 78 |
$Params{'LIBS'} = `$opts->{'nsconfig'} --base-agent-libs` or |
| 79 |
die "net-snmp-config failed\n"; |
| 80 |
chomp($Params{'LIBS'}); |
| 81 |
$lib_version = `$opts->{'nsconfig'} --version` or |
| 82 |
die "net-snmp-config failed\n"; |
| 83 |
if (lc($opts->{'insource'}) eq "true") { |
| 84 |
$Params{'LIBS'} = |
| 85 |
"-L" . abs_path("../../snmplib/.libs") . |
| 86 |
" -L" . abs_path("../../snmplib") . |
| 87 |
" -L" . abs_path("../../agent/.libs") . |
| 88 |
" -L" . abs_path("../../agent") . |
| 89 |
" " . $Params{'LIBS'}; |
| 90 |
# } else { |
| 91 |
$Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . $Params{'LIBS'}; |
| 92 |
# $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'}; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
return(%Params); |
| 97 |
} |