File: version.h.pl

package info (click to toggle)
spamassassin 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,988 kB
  • sloc: perl: 88,863; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (55 lines) | stat: -rwxr-xr-x 1,107 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl

use strict;
use warnings;

use lib '../lib';

my $fil = "version.h";
my $ver;

foreach (@ARGV) {
  my ($opt, $arg) = (split(/=/, $_, 2));
  if ($opt eq '--with-version') {
    if ($arg =~ /^(\d)\.(\d\d\d)_?(\d\d\d)/) {
      $ver = join(".", $1*1, $2*1, $3*1);
    }
    else {
      $ver = $arg;
    }
  }
}

print "version.h.pl: creating $fil\n";
unless ($ver) {
  if (-e '../lib/Mail/SpamAssassin.pm') {
    eval {
      require Mail::SpamAssassin;
      $ver = Mail::SpamAssassin::Version();
    };
  }
  else {
    $@ = "File not found.";
  }
  unless ($ver) {
    die join("\n", "Failed to get the version from Mail::SpamAssassin.",
                   "Please use the --with-version= switch to specify it manually.",
                   "",
                   "The error was:",
                   $@,
          );
  }
}

open IN,  "<$fil.in" || die "Failed to open $fil.in: $!";
open OUT, ">$fil"    || die "Failed to open $fil: $!";

print OUT "/* $fil.  Generated by $0.  */\n";
foreach (<IN>) {
  s/(#define\s+VERSION_STRING\s+)".*"/$1"$ver"/;
  print OUT;
}

close IN;
close OUT;