1 use ExtUtils::MakeMaker;
6 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
7 # the contents of the Makefile that is written.
9 %MakeParams = InitMakeParams();
11 WriteMakefile(%MakeParams);
19 dist => { SUFFIX => "gz", COMPRESS => "gzip -9f"},
20 MAN3PODS => { 'SNMP.pm' => '$(INST_MAN3DIR)/SNMP.3' },
21 XSPROTOARG => '-noprototypes', # XXX remove later?
22 VERSION_FROM => 'SNMP.pm',
23 realclean => { FILES => 'host' },
26 my ($snmp_lib, $snmp_llib, $sep);
27 if ($Config{'osname'} eq 'MSWin32') {
28 $snmp_lib = 'libnetsnmp.lib';
29 $snmp_link_lib = 'libnetsnmp';
33 $opts = NetSNMPGetOpts();
34 if (!$ENV{'NETSNMP_LIBS'}) {
35 $Params{'LIBS'} = `$opts->{'nsconfig'} --libs`;
36 chomp($Params{'LIBS'});
38 $Params{'LIBS'} = $ENV{'NETSNMP_LIBS'};
40 if (!$ENV{'NETSNMP_CCFLAGS'}) {
41 $Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
42 chomp($Params{'CCFLAGS'});
43 $Params{'CCFLAGS'} .= " " . $Config{'ccflags'};
45 $Params{'CCFLAGS'} = $ENV{'NETSNMP_CCFLAGS'};
47 if ($opts->{'insource'} eq "true") {
48 $Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ " . $Params{'LIBS'};
49 $Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
51 # $Params{'PREREQ_PM'} = { 'NetSNMP::default_store' => 0.01 };
53 $Params{'CCFLAGS'} =~ s/ -W[-\w]+//g; # ignore developer warnings
54 if (!$ENV{'NETSNMP_PREFIX'}) {
55 $prefix = `$opts->{'nsconfig'} --prefix`;
59 $prefix = $ENV{'NETSNMP_PREFIX'};
61 if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
62 die "You need to install net-snmp first (I can't find net-snmp-config)";
72 my ($dir,$found,$file);
76 $found++ if -f "$dir/$file";
85 my $sep = ($^O =~ /win32/i ? '\\' : '/');
86 my $info_file = "t${sep}snmptest.cmd";
87 my $snmpd_path1 = "${prefix}${sep}sbin";
88 my $snmpd_path2 = "${sep}usr${sep}sbin";
89 my $snmpd_path3 = "${sep}usr${sep}bin";
90 open(H, ">$info_file") || die "Error: could not open file '$info_file'($!)";
93 my $mibdir = "${prefix}${sep}share${sep}snmp${sep}mibs";
95 ==================================================================
96 You are using Windows 32. The testing of Perl/SNMP API here would
97 require you to start an snmpd agent and a trap receiver using the
98 config file provided ( t\\snmptest.conf) manually.The
99 test scripts will not do this(as in unix testing). So, please
100 run those agents and enter the following information.If the data
101 about host, agent_port and trap_port are already present in your
102 snmptest.cmd file, make test will use those data for testing.
103 =================================================================
107 $host = prompt("Please enter the host IP address/host name: ", "localhost");
108 print H "HOST => $host\n";
109 $agent_port = prompt("Please enter the agent port number: ", 161);
110 print H "AGENT_PORT => $agent_port\n";
111 $trap_port = prompt("Please enter the trap port number: ", 162);
112 print H "TRAP_PORT => $trap_port\n";
113 $mibdir = prompt("Please enter the MIB directory: ", "/usr/mibs");
114 print H "MIBDIR => $mibdir\n";
117 my ($mibdir, $snmpd, $snmptrapd);
118 if ($opts->{'insource'} eq "true") {
119 $mibdir = "../../mibs";
120 $snmpd = "../../agent/snmpd";
121 $snmptrapd = "../../apps/snmptrapd";
123 $mibdir = "${prefix}${sep}share${sep}snmp${sep}mibs";
124 $snmpd = find_files(["snmpd"], [$snmpd_path1, $snmpd_path2]);
125 $snmptrapd = find_files(["snmptrapd"], [$snmpd_path1, $snmpd_path2]);
127 $mibdir = find_files(["NET-SNMP-MIB.txt"],[$mibdir]);
129 $mibdir ||= prompt("Unable to locate the MIBs, Please enter the path: ",
131 $snmpd ||= prompt("Unable to locate \"snmpd\". Please enter the path: ",
134 prompt("Unable to locate \"snmptrapd\". Please enter the path: ",
137 $snmpd =~ s/($sep)?(snmpd)?$/${sep}snmpd/;
138 $snmptrapd =~ s/($sep)?(snmptrapd)?$/${sep}snmptrapd/;
140 print H "SNMPD => $snmpd\n";
141 print H "SNMPTRAPD => $snmptrapd\n";
142 print H "MIBDIR => $mibdir\n";
144 if (!$opts->{'insource'}) {
145 if (-e $snmpd and -r $snmpd) {
147 warn("Error: $snmpd not executable. 'make test' will not work.\n");
150 warn("Error: $snmpd does not exist or is unreadable. 'make test' will not work.\n");
153 if (-e $snmptrapd and -r $snmptrapd) {
154 if (not -x $snmptrapd) {
155 warn("Error: $snmptrapd not executable. 'make test' will not work.\n");
158 warn("Error: $snmptrapd does not exist or is unreadable. 'make test' will not work.\n");
167 my $config_header = shift;
169 unless (open(C,"<$config_header")) {
170 warn("Unable to open $config_header, assuming no SSL\n");
174 $has_ssl++, last if /^\s*#define\s+USE_OPENSSL/;
179 # common subroutines -- DO NOT EDIT.
180 # They are imported from the Makefile.subs.pl file
183 my $rootpath = shift;
184 $rootpath = "../" if (!$rootpath);
185 $rootpath .= '/' if ($rootpath !~ /\/$/);
187 if ($ENV{'NET-SNMP-CONFIG'} &&
188 $ENV{'NET-SNMP-IN-SOURCE'}) {
189 # have env vars, pull from there
190 $ret{'nsconfig'} = $ENV{'NET-SNMP-CONFIG'};
191 $ret{'insource'} = $ENV{'NET-SNMP-IN-SOURCE'};
193 # don't have env vars, pull from command line and put there
194 GetOptions("NET-SNMP-CONFIG=s" => \$ret{'nsconfig'},
195 "NET-SNMP-IN-SOURCE=s" => \$ret{'insource'});
197 if ($ret{'insource'} eq "true" && $ret{'nsconfig'} eq "") {
198 $ret{'nsconfig'}="sh ROOTPATH../net-snmp-config";
199 } elsif ($ret{'nsconfig'} eq "") {
200 $ret{'nsconfig'}="net-snmp-config";
203 $ENV{'NET-SNMP-CONFIG'} = $ret{'nsconfig'};
204 $ENV{'NET-SNMP-IN-SOURCE'} = $ret{'insource'};
207 $ret{'nsconfig'} =~ s/ROOTPATH/$rootpath/;
209 $ret{'rootpath'} = $rootpath;