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