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

« back to all changes in this revision

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