]> granicus.if.org Git - postgresql/blob - src/tools/version_stamp.pl
MSVC: Apply icons to all binaries having them in a MinGW build.
[postgresql] / src / tools / version_stamp.pl
1 #! /usr/bin/perl -w
2
3 #################################################################
4 # version_stamp.pl -- update version stamps throughout the source tree
5 #
6 # Copyright (c) 2008-2014, PostgreSQL Global Development Group
7 #
8 # src/tools/version_stamp.pl
9 #################################################################
10
11 #
12 # This script updates the version stamp in configure.in, and also in assorted
13 # other files wherein it's not convenient to obtain the version number from
14 # configure's output.  Note that you still have to run autoconf afterward
15 # to regenerate configure from the updated configure.in.
16 #
17 # Usage: cd to top of source tree and issue
18 #       src/tools/version_stamp.pl MINORVERSION
19 # where MINORVERSION can be a minor release number (0, 1, etc), or
20 # "devel", "alphaN", "betaN", "rcN".
21 #
22
23 # Major version is hard-wired into the script.  We update it when we branch
24 # a new development version.
25 $major1 = 9;
26 $major2 = 5;
27
28 # Validate argument and compute derived variables
29 $minor = shift;
30 defined($minor) || die "$0: missing required argument: minor-version\n";
31
32 if ($minor =~ m/^\d+$/)
33 {
34         $dotneeded    = 1;
35         $numericminor = $minor;
36 }
37 elsif ($minor eq "devel")
38 {
39         $dotneeded    = 0;
40         $numericminor = 0;
41 }
42 elsif ($minor =~ m/^alpha\d+$/)
43 {
44         $dotneeded    = 0;
45         $numericminor = 0;
46 }
47 elsif ($minor =~ m/^beta\d+$/)
48 {
49         $dotneeded    = 0;
50         $numericminor = 0;
51 }
52 elsif ($minor =~ m/^rc\d+$/)
53 {
54         $dotneeded    = 0;
55         $numericminor = 0;
56 }
57 else
58 {
59         die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
60 }
61
62 # Create various required forms of the version number
63 $majorversion = $major1 . "." . $major2;
64 if ($dotneeded)
65 {
66         $fullversion = $majorversion . "." . $minor;
67 }
68 else
69 {
70         $fullversion = $majorversion . $minor;
71 }
72 $numericversion = $majorversion . "." . $numericminor;
73 $padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor);
74
75 # Get the autoconf version number for eventual nag message
76 # (this also ensures we're in the right directory)
77
78 $aconfver = "";
79 open(FILE, "configure.in") || die "could not read configure.in: $!\n";
80 while (<FILE>)
81 {
82         if (
83 m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/)
84         {
85                 $aconfver = $1;
86                 last;
87         }
88 }
89 close(FILE);
90 $aconfver ne ""
91   || die "could not find autoconf version number in configure.in\n";
92
93 # Update configure.in and other files that contain version numbers
94
95 $fixedfiles = "";
96
97 sed_file("configure.in",
98 "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
99 );
100
101 sed_file("doc/bug.template",
102 "-e 's/PostgreSQL version (example: PostgreSQL .*) *:  PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion):  PostgreSQL $fullversion/'"
103 );
104
105 sed_file("src/include/pg_config.h.win32",
106 "-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' "
107           . "-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' "
108           . "-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' "
109           . "-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'"
110 );
111
112 sed_file("src/interfaces/libpq/libpq.rc.in",
113 "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' "
114           . "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' "
115           . "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' "
116           . "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'"
117 );
118
119 sed_file("src/port/win32ver.rc",
120 "-e 's/FILEVERSION    [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION    $major1,$major2,$numericminor,0/' "
121           . "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'"
122 );
123
124 print "Stamped these files with version number $fullversion:\n$fixedfiles";
125 print "Don't forget to run autoconf $aconfver before committing.\n";
126
127 exit 0;
128
129 sub sed_file
130 {
131         my ($filename, $sedargs) = @_;
132         my ($tmpfilename) = $filename . ".tmp";
133
134         system("sed $sedargs $filename >$tmpfilename") == 0
135           or die "sed failed: $?";
136         system("mv $tmpfilename $filename") == 0
137           or die "mv failed: $?";
138
139         $fixedfiles .= "\t$filename\n";
140 }