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