2 use POSIX
qw(strftime);
9 open(F
, "version.dat") || die "can't open version.dat for input";
13 # put data pairs in a hash
14 my %pairs = $x =~ /([a-z]+)\s*=\s*(\S+)\s*/g;
15 die "syntax error in version.dat\n" unless
16 defined $pairs{major
} &&
17 defined $pairs{minor
} &&
18 defined $pairs{build
};
20 # update the build number
21 $pairs{build
}++ unless $pairs{dist
} or $ARGV[0] eq 'noinc';
23 # get the current time/date
26 my $slt = scalar(localtime($t));
27 my $nicelt = strftime
("%A, %B %d, %Y", localtime($t));
30 open(F
, "> version.h") || die "can't open version.h for output";
31 print F
"// Produced by makever.pl. Don't edit.\n";
32 print F
"#define VER_MAJOR $pairs{major}\n";
33 print F
"#define VER_MINOR $pairs{minor}\n";
34 print F
"#define VER_BUILD $pairs{build}\n";
35 print F
"#define VER_BUILD_TIME $t\n";
36 print F
"#ifndef STRINGIFY\n";
37 print F
"#define ___S(X) #X\n";
38 print F
"#define STRINGIFY(X) ___S(X)\n";
40 print F
"#define VER_BUILD_TIME_STRING STRINGIFY($slt)\n";
41 my $d = $pairs{dist
} ?
"d" : "";
42 print F
qq|#define VER_STRING STRINGIFY(VER_MAJOR) "." STRINGIFY(VER_MINOR) " (build " STRINGIFY(VER_BUILD) "$d, " VER_BUILD_TIME_STRING ")"\n|;
45 # print doc version information
46 open(F
, "> Doc/version.texi") || die "can't open version.texi";
47 print F
"\@comment Produced by makever.pl. Don't edit.\n";
48 print F
"\@set VER_MAJOR $pairs{major}\n";
49 print F
"\@set VER_MINOR $pairs{minor}\n";
50 print F
"\@set VER_BUILD $pairs{build}\n";
51 print F
"\@set UPDATED $nicelt\n";
52 print F
"\@set VERSION \@value{VER_MAJOR}.\@value{VER_MINOR} (build \@value{VER_BUILD})\n";
55 if ( open(F
, "index-tmp.htm") ) {
58 my $version = "$pairs{major}.$pairs{minor} (build $pairs{build}), $nicelt";
59 $html =~ s/VERSION/$version/g;
60 my $ver = "$pairs{major}.$pairs{minor}.$pairs{build}";
61 $html =~ s/VER/$ver/g;
62 open(F
, "> index.htm") || die "can't open index.htm for output";
67 warn "not generating web page\n";
70 # update the version header
71 open(F
, "> version.dat") || die "can't open version.dat for output";
72 print F
join('', map { "$_ = $pairs{$_}\n" } keys %pairs);