and added files
[bcm963xx.git] / userapps / opensource / net-snmp / perl / 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
11 sub InitMakeParams {
12     my $opts;
13     my %Params = (
14                   'NAME'                => 'NetSNMP::default_store',
15                   'VERSION_FROM'        => 'default_store.pm', # finds $VERSION
16                   'XSPROTOARG'          => '-prototypes',
17                   );
18
19     my ($snmp_lib, $snmp_llib, $sep);
20     if ($Config{'osname'} eq 'MSWin32') {
21         $snmp_lib = 'libnetsnmp.lib';
22         $snmp_link_lib = 'libnetsnmp';
23         $sep = '\\';
24         # XXX fix me
25     } else {
26         $opts = NetSNMPGetOpts();
27         $Params{'LIBS'}    = `$opts->{'nsconfig'} --libs`;
28         chomp($Params{'LIBS'});
29         $Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
30         chomp($Params{'CCFLAGS'});
31         $Params{'CCFLAGS'} .= " " . $Config{'ccflags'};
32         if ($opts->{'insource'} eq "true") {
33             $Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ " . $Params{'LIBS'};
34             $Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
35         }
36         $Params{'CCFLAGS'} =~ s/ -W[-\w]+//g; # ignore developer warnings
37         if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
38             die "You need to install net-snmp first (I can't find net-snmp-config)";
39         }
40     }
41
42     return(%Params);
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 }