played a little with settings for headstyle - causes strange numbers - check!!
[cluster_expansion_thesis.git] / little_helpers / tikz / sketch-0.2.161 / makever.pl
blobc816cf8340f7245013cc6802da3e445e7b06d120
1 use strict;
2 use POSIX qw(strftime);
4 sub run {
5 local $/ = undef;
6 local *F;
8 # get raw data
9 open(F, "version.dat") || die "can't open version.dat for input";
10 my $x = <F>;
11 close F;
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
24 my $t = time;
25 $pairs{time} = $t;
26 my $slt = scalar(localtime($t));
27 my $nicelt = strftime("%A, %B %d, %Y", localtime($t));
29 # print the header
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";
39 print F "#endif\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|;
43 close F;
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";
53 close F;
55 if ( open(F, "index-tmp.htm") ) {
56 my $html = <F>;
57 close F;
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";
63 print F $html;
64 close F;
66 else {
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);
73 close F;
76 run;