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