~ubuntu-branches/ubuntu/intrepid/net-snmp/intrepid-updates

« back to all changes in this revision

Viewing changes to perl/OID/Makefile.PL

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2006-11-28 12:29:34 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128122934-82xxzy2zcvypnvy7
Tags: 5.2.3-4ubuntu1
* Merge from debian unstable, remaining changes:
  - remove stop links from rc0 and rc6

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
require 5;
6
6
use Config;
7
7
use Getopt::Long;
 
8
my $lib_version;
8
9
my %MakeParams = ();
9
10
 
10
11
%MakeParams = InitMakeParams();
11
12
 
12
13
WriteMakefile(%MakeParams);
13
14
 
 
15
Check_Version();
 
16
 
14
17
sub InitMakeParams {
15
18
    my $opts;
16
19
    my %Params = (
75
78
        $Params{'CCFLAGS'} = `$opts->{'nsconfig'} --cflags`;
76
79
        chomp($Params{'CCFLAGS'});
77
80
        $Params{'CCFLAGS'} .= " " . $Config{'ccflags'};
 
81
        $lib_version = `$opts->{'nsconfig'} --version`;
78
82
        if (lc($opts->{'insource'}) eq "true") {
79
83
            $Params{'LIBS'} = "-L../../snmplib/.libs -L../../snmplib/ " . $Params{'LIBS'};
80
84
            $Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
81
85
#       } else {
82
86
#           $Params{'PREREQ_PM'} = {'SNMP' => '5.0'};
83
87
        }
84
 
        $Params{'CCFLAGS'} =~ s/ -W[-\w]+//g; # ignore developer warnings
 
88
        $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
85
89
        if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
86
90
            die "You need to install net-snmp first (I can't find net-snmp-config)";
87
91
        }
178
182
    }
179
183
}
180
184
 
 
185
 
 
186
sub Check_Version {
 
187
  if (($Config{'osname'} ne 'MSWin32' || $ENV{'OSTYPE'} eq 'msys')) {
 
188
    my $foundversion = 0;
 
189
    return if ($ENV{'NETSNMP_DONT_CHECK_VERSION'});
 
190
    open(I,"<Makefile");
 
191
    while (<I>) {
 
192
        if (/^VERSION = (.*)/) {
 
193
            my $perlver = $1;
 
194
            my $srcver = $lib_version;
 
195
            chomp($srcver);
 
196
            my $srcfloat = floatize_version($srcver);
 
197
            $perlver =~ s/pre/0./;
 
198
            if ($srcfloat ne $perlver) {
 
199
                if (!$foundversion) {
 
200
                    print STDERR "ERROR:
 
201
Net-SNMP installed version: $srcver => $srcfloat
 
202
Perl Module Version:        $perlver
 
203
 
 
204
These versions must match for perfect support of the module.  It is possible
 
205
that different versions may work together, but it is strongly recommended
 
206
that you make these two versions identical.  You can get the Net-SNMP
 
207
source code and the associated perl modules directly from 
 
208
 
 
209
   http://www.net-snmp.org/
 
210
 
 
211
If you want to continue anyway please set the NETSNMP_DONT_CHECK_VERSION
 
212
environmental variable to 1 and re-run the Makefile.PL script.\n";
 
213
                    exit(1);
 
214
                }
 
215
            }
 
216
            $foundversion = 1;
 
217
            last;
 
218
        }
 
219
    }
 
220
    close(I);
 
221
    die "ERROR: Couldn't find version number of this module\n" 
 
222
      if (!$foundversion);
 
223
  }
 
224
}
 
225
 
 
226
sub floatize_version {
 
227
    my ($major, $minor, $patch, $opps) = ($_[0] =~ /^(\d+)\.(\d+)\.?(\d*)\.?(\d*)/);
 
228
    return $major + $minor/100 + $patch/10000 + $opps/100000;
 
229
}