1
use ExtUtils::MakeMaker;
7
%MakeParams = InitMakeParams();
9
WriteMakefile(%MakeParams);
14
'NAME' => 'NetSNMP::agent',
15
'VERSION_FROM' => 'agent.pm', # finds $VERSION
16
'XSPROTOARG' => '-prototypes',
18
'agent.pm' => '$(INST_LIBDIR)/agent.pm',
19
'netsnmp_request_infoPtr.pm' =>
20
'$(INST_LIBDIR)/agent/netsnmp_request_infoPtr.pm'
25
if ($ENV{'OSTYPE'} eq 'msys') {
26
$Params{'DEFINE'} = "-DMINGW_PERL";
29
my ($snmp_lib, $snmp_llib, $sep);
30
if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} ne 'msys')) {
31
$opts = NetSNMPGetOpts();
32
$Params{'DEFINE'} = "-DMSVC_PERL";
34
$snmp_lib_file = 'netsnmp.lib';
35
$snmp_link_lib = 'netsnmp';
36
$agent_link_lib = 'netsnmpagent';
37
$helpers_link_lib = 'netsnmphelpers';
38
$mibs_link_lib = 'netsnmpmibs';
40
if (lc($opts->{'debug'}) eq "true") {
41
$lib_dir = 'lib\\debug';
44
$lib_dir = 'lib\\release';
47
if (lc($opts->{'insource'}) eq "true") {
48
$Params{'LIBS'} = "-L$basedir\\win32\\$lib_dir\\ -l$snmp_link_lib -l$agent_link_lib -l$helpers_link_lib " .
52
my @LibDirs = split (';',$ENV{LIB});
54
if ($opts->{'prefix'}) {
55
push (@LibDirs,"$ENV{'NET-SNMP-PATH'}${sep}lib");
59
$LibDir = find_files(["$snmp_lib_file"],\@LibDirs);
62
# Put quotes around LibDir to allow spaces in paths
63
$LibDir = '"' . $LibDir . '"';
68
@LibDirs[0] = prompt("The Net-SNMP library ($snmp_lib_file) could not be found.\nPlease enter the directory where it is located:");
69
@LibDirs[0] =~ s/\\$//;
72
$Params{LIBS} = "-L$LibDir -l$snmp_link_lib -l$agent_link_lib -l$helpers_link_lib -l$mibs_link_lib";
75
$Params{'INC'} = "-I$basedir\\include\\ -I$basedir\\include\\net-snmp\\ -I$basedir\\win32\\ ";
78
$opts = NetSNMPGetOpts();
79
$Params{'LIBS'} = `$opts->{'nsconfig'} --agent-libs`;
80
chomp($Params{'LIBS'});
81
$Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
82
chomp($Params{'CCFLAGS'});
83
$Params{'CCFLAGS'} .= " " . $Config{'ccflags'};
84
if (lc($opts->{'insource'}) eq "true") {
85
$Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ -L../../agent/.libs -L../../agent/ -L../../agent/helpers/.libs -L../../agent/helpers/ " . $Params{'LIBS'};
86
$Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
88
# $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'};
90
$Params{'CCFLAGS'} =~ s/ -W[-\w]+//g; # ignore developer warnings
91
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
92
die "You need to install net-snmp first (I can't find net-snmp-config)";
98
# common subroutines -- DO NOT EDIT.
99
# They are imported from the Makefile.subs.pl file
102
my $rootpath = shift;
103
$rootpath = "../" if (!$rootpath);
104
$rootpath .= '/' if ($rootpath !~ /\/$/);
106
if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} ne 'msys')) {
108
# Grab command line options first. Only used if environment variables are not set
109
GetOptions("NET-SNMP-IN-SOURCE=s" => \$ret{'insource'},
110
"NET-SNMP-PATH=s" => \$ret{'prefix'},
111
"NET-SNMP-DEBUG=s" => \$ret{'debug'});
113
if ($ENV{'NET-SNMP-IN-SOURCE'})
115
$ret{'insource'} = $ENV{'NET-SNMP-IN-SOURCE'};
116
undef ($ret{'prefix'});
118
elsif ($ENV{'NET-SNMP-PATH'})
120
$ret{'prefix'} = $ENV{'NET-SNMP-PATH'};
123
if ($ENV{'NET-SNMP-DEBUG'})
125
$ret{'debug'} = $ENV{'NET-SNMP-DEBUG'};
128
# Update environment variables in case they are needed
129
$ENV{'NET-SNMP-IN-SOURCE'} = $ret{'insource'};
130
$ENV{'NET-SNMP-PATH'} = $ret{'prefix'};
131
$ENV{'NET-SNMP-DEBUG'} = $ret{'debug'};
133
$basedir = `%COMSPEC% /c cd`;
135
$basedir =~ /(.*?)\\perl.*/;
137
print "Net-SNMP base directory: $basedir\n";
142
if ($ENV{'NET-SNMP-CONFIG'} &&
143
$ENV{'NET-SNMP-IN-SOURCE'}) {
144
# have env vars, pull from there
145
$ret{'nsconfig'} = $ENV{'NET-SNMP-CONFIG'};
146
$ret{'insource'} = $ENV{'NET-SNMP-IN-SOURCE'};
148
# don't have env vars, pull from command line and put there
149
GetOptions("NET-SNMP-CONFIG=s" => \$ret{'nsconfig'},
150
"NET-SNMP-IN-SOURCE=s" => \$ret{'insource'});
152
if (lc($ret{'insource'}) eq "true" && $ret{'nsconfig'} eq "") {
153
$ret{'nsconfig'}="sh ROOTPATH../net-snmp-config";
154
} elsif ($ret{'nsconfig'} eq "") {
155
$ret{'nsconfig'}="net-snmp-config";
158
$ENV{'NET-SNMP-CONFIG'} = $ret{'nsconfig'};
159
$ENV{'NET-SNMP-IN-SOURCE'} = $ret{'insource'};
163
$ret{'nsconfig'} =~ s/ROOTPATH/$rootpath/;
165
$ret{'rootpath'} = $rootpath;
172
my ($dir,$found,$file);
176
$found++ if -f "$dir/$file";