Debian Codegraph @

perl/ASN/Makefile.PL

raw
1 use strict;
2 use warnings;
3 use Config;
4 use Cwd 'abs_path';
5 use ExtUtils::MakeMaker;
6 use File::Basename;
7 require 5;
8 use Config;
9 use MakefileSubs;
10
11 my $lib_version;
12
13 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
14 # the contents of the Makefile that is written.
15
16 WriteMakefile(AsnInitMakeParams());
17
18 Check_Version($lib_version);
19
20 sub AsnInitMakeParams {
21 my $opts;
22 my %Params = (
23 'NAME' => 'NetSNMP::ASN',
24 'VERSION_FROM' => 'ASN.pm', # finds $VERSION
25 'XSPROTOARG' => '-prototypes',
26 'PREREQ_PM' => {},
27 );
28
29 AddCommonParams(\%Params);
30
31 my ($snmp_lib, $snmp_llib, $sep);
32
33 $opts = NetSNMPGetOpts();
34
35 if ($Config{'osname'} eq 'MSWin32' && !defined($ENV{'OSTYPE'})) {
36 $sep = '\\';
37 my $snmp_lib_file = 'netsnmp.lib';
38 my $snmp_link_lib = 'netsnmp';
39 my $lib_dir;
40
41 if (lc($opts->{'debug'}) eq "true") {
42 $lib_dir = 'lib\\debug';
43 }
44 else {
45 $lib_dir = 'lib\\release';
46 }
47
48 if (lc($opts->{'insource'}) eq "true") {
49 $Params{'LIBS'} = "-L" . $MakefileSubs::basedir . "\\win32\\$lib_dir\\ -l$snmp_link_lib";
50 }
51 else {
52 my @LibDirs = split($Config{path_sep}, $ENV{LIB});
53 my $LibDir;
54 if ($opts->{'prefix'}) {
55 push (@LibDirs,"$ENV{'NET-SNMP-PATH'}${sep}lib");
56 }
57 my $noLibDir = 1;
58 while ($noLibDir) {
59 $LibDir = find_files(["$snmp_lib_file"],\@LibDirs);
60 if ($LibDir ne '') {
61 $noLibDir = 0;
62 # Put quotes around LibDir to allow spaces in paths
63 $LibDir = '"' . $LibDir . '"';
64 }
65 else
66 {
67 @LibDirs = ();
68 $LibDirs[0] = prompt("The Net-SNMP library ($snmp_lib_file) could not be found.\nPlease enter the directory where it is located:");
69 $LibDirs[0] =~ s/\\$//;
70 }
71 }
72 $Params{LIBS} = "-L$LibDir -l$snmp_link_lib";
73 }
74 }
75 else
76 {
77 $Params{'LIBS'} = `$opts->{'nsconfig'} --libs` or
78 die "net-snmp-config failed\n";
79 chomp($Params{'LIBS'});
80 $lib_version = `$opts->{'nsconfig'} --version` or
81 die "net-snmp-config failed\n";
82
83 if (lc($opts->{'insource'}) eq "true") {
84 $Params{'LIBS'} =
85 "-L" . abs_path("../../snmplib/.libs") .
86 " -L" . abs_path("../../snmplib") .
87 " " . $Params{'LIBS'};
88 }
89 }
90 return (%Params);
91 }