Debian Codegraph @

perl/agent/Support/Makefile.PL

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