and added files
[bcm963xx.git] / userapps / opensource / net-snmp / perl / Makefile.subs.pl
1 sub NetSNMPGetOpts {
2     my %ret;
3     my $rootpath = shift;
4     $rootpath = "../" if (!$rootpath);
5     $rootpath .= '/' if ($rootpath !~ /\/$/);
6
7     if ($ENV{'NET-SNMP-CONFIG'} && 
8         $ENV{'NET-SNMP-IN-SOURCE'}) {
9         # have env vars, pull from there
10         $ret{'nsconfig'} = $ENV{'NET-SNMP-CONFIG'};
11         $ret{'insource'} = $ENV{'NET-SNMP-IN-SOURCE'};
12     } else {
13         # don't have env vars, pull from command line and put there
14         GetOptions("NET-SNMP-CONFIG=s" => \$ret{'nsconfig'},
15                    "NET-SNMP-IN-SOURCE=s" => \$ret{'insource'});
16
17         if ($ret{'insource'} eq "true" && $ret{'nsconfig'} eq "") {
18             $ret{'nsconfig'}="sh ROOTPATH../net-snmp-config";
19         } elsif ($ret{'nsconfig'} eq "") {
20             $ret{'nsconfig'}="net-snmp-config";
21         }
22
23         $ENV{'NET-SNMP-CONFIG'}    = $ret{'nsconfig'};
24         $ENV{'NET-SNMP-IN-SOURCE'} = $ret{'insource'};
25     }   
26     
27     $ret{'nsconfig'} =~ s/ROOTPATH/$rootpath/;
28
29     $ret{'rootpath'} = $rootpath;
30
31     \%ret;
32 }