Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / perl / agent / Makefile.PL
1 use ExtUtils::MakeMaker;
2 require 5;
3 use Config;
4 use Getopt::Long;
5
6 %MakeParams = InitMakeParams();
7
8 WriteMakefile(%MakeParams);
9
10 sub InitMakeParams {
11     my $opts;
12     my %Params = (
13                   'NAME'                => 'NetSNMP::agent',
14                   'VERSION_FROM'        => 'agent.pm', # finds $VERSION
15                   'XSPROTOARG'          => '-prototypes',
16                   'PM'                => { 
17                       'agent.pm' => '$(INST_LIBDIR)/agent.pm',
18                       'netsnmp_request_infoPtr.pm' =>
19                           '$(INST_LIBDIR)/agent/netsnmp_request_infoPtr.pm'
20                   },
21                   'PREREQ_PM'           => {},
22                   );
23
24     my ($snmp_lib, $snmp_llib, $sep);
25     if ($Config{'osname'} eq 'MSWin32') {
26         $snmp_lib = 'libnetsnmp.lib';
27         $snmp_link_lib = 'libnetsnmp';
28         # XXX fix me
29     } else {
30         $opts = NetSNMPGetOpts();
31         $Params{'LIBS'}    = `$opts->{'nsconfig'} --agent-libs`;
32         chomp($Params{'LIBS'});
33         $Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
34         chomp($Params{'CCFLAGS'});
35         $Params{'CCFLAGS'} .= " " . $Config{'ccflags'};
36         if ($opts->{'insource'} eq "true") {
37             $Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ -L../../agent/.libs -L../../agent/ -L../../agent/helpers/.libs -L../../agent/helpers/ " . $Params{'LIBS'};
38             $Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
39 #       } else {
40 #           $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'};
41         }
42         $Params{'CCFLAGS'} =~ s/ -W[-\w]+//g; # ignore developer warnings
43         if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
44             die "You need to install net-snmp first (I can't find net-snmp-config)";
45         }
46     }
47
48     return(%Params);
49 }
50 # common subroutines -- DO NOT EDIT.
51 # They are imported from the Makefile.subs.pl file
52 sub NetSNMPGetOpts {
53     my %ret;
54     my $rootpath = shift;
55     $rootpath = "../" if (!$rootpath);
56     $rootpath .= '/' if ($rootpath !~ /\/$/);
57
58     if ($ENV{'NET-SNMP-CONFIG'} && 
59         $ENV{'NET-SNMP-IN-SOURCE'}) {
60         # have env vars, pull from there
61         $ret{'nsconfig'} = $ENV{'NET-SNMP-CONFIG'};
62         $ret{'insource'} = $ENV{'NET-SNMP-IN-SOURCE'};
63     } else {
64         # don't have env vars, pull from command line and put there
65         GetOptions("NET-SNMP-CONFIG=s" => \$ret{'nsconfig'},
66                    "NET-SNMP-IN-SOURCE=s" => \$ret{'insource'});
67
68         if ($ret{'insource'} eq "true" && $ret{'nsconfig'} eq "") {
69             $ret{'nsconfig'}="sh ROOTPATH../net-snmp-config";
70         } elsif ($ret{'nsconfig'} eq "") {
71             $ret{'nsconfig'}="net-snmp-config";
72         }
73
74         $ENV{'NET-SNMP-CONFIG'}    = $ret{'nsconfig'};
75         $ENV{'NET-SNMP-IN-SOURCE'} = $ret{'insource'};
76     }   
77     
78     $ret{'nsconfig'} =~ s/ROOTPATH/$rootpath/;
79
80     $ret{'rootpath'} = $rootpath;
81
82     \%ret;
83 }