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