summaryrefslogtreecommitdiffstats
path: root/Configure
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-10-17 16:03:06 +0200
committerRichard Levitte <levitte@openssl.org>2019-10-18 12:22:00 +0200
commit20551b2e62ed8c2fa97e0106a0350f40f3422dd5 (patch)
treebc0f9f84cbb832070ebceea1ad6aad3ecad3e34f /Configure
parent3d48457478bd61030c370e4090c1462fc4453d81 (diff)
Configure: get version from the file 'VERSION' instead of 'opensslv.h'
'VERSION' is a very easy file to parse, as opposed to a header file. We also have the benefit of holding the version information in one very well known place and can then generate all other version texts as we see fit, for example opensslv.h. Fixes #10203 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10205)
Diffstat (limited to 'Configure')
-rwxr-xr-xConfigure51
1 files changed, 26 insertions, 25 deletions
diff --git a/Configure b/Configure
index 3df3e0c96a..7ff8b06214 100755
--- a/Configure
+++ b/Configure
@@ -255,38 +255,39 @@ if (grep /^reconf(igure)?$/, @argvcopy) {
$config{perlargv} = [ @argvcopy ];
# Collect version numbers
-$config{major} = "unknown";
-$config{minor} = "unknown";
-$config{patch} = "unknown";
-$config{prerelease} = "";
-$config{build_metadata} = "";
-$config{shlib_version} = "unknown";
+my %version = ();
collect_information(
- collect_from_file(catfile($srcdir,'include/openssl/opensslv.h')),
- qr/#\s+define\s+OPENSSL_VERSION_MAJOR\s+(\d+)/ =>
- sub { $config{major} = $1; },
- qr/#\s+define\s+OPENSSL_VERSION_MINOR\s+(\d+)/ =>
- sub { $config{minor} = $1; },
- qr/#\s+define\s+OPENSSL_VERSION_PATCH\s+(\d+)/ =>
- sub { $config{patch} = $1; },
- qr/#\s+define\s+OPENSSL_VERSION_PRE_RELEASE\s+"((?:\\.|[^"])*)"/ =>
- sub { $config{prerelease} = $1; },
- qr/#\s+define\s+OPENSSL_VERSION_BUILD_METADATA\s+"((?:\\.|[^"])*)"/ =>
- sub { $config{build_metadata} = $1; },
- qr/#\s+define\s+OPENSSL_SHLIB_VERSION\s+([\d\.]+)/ =>
- sub { $config{shlib_version} = $1; },
+ collect_from_file(catfile($srcdir,'VERSION')),
+ qr/\s*(\w+)\s*=\s*(.*?)\s*$/ =>
+ sub {
+ # Only define it if there is a value at all
+ $version{uc $1} = $2 if $2 ne '';
+ },
+ "OTHERWISE" =>
+ sub { die "Something wrong with this line:\n$_\nin $srcdir/VERSION" },
);
-die "erroneous version information in opensslv.h: ",
- "$config{major}.$config{minor}.$config{patch}, $config{shlib_version}\n"
- if ($config{major} eq "unknown"
- || $config{minor} eq "unknown"
- || $config{patch} eq "unknown"
- || $config{shlib_version} eq "unknown");
+
+$config{major} = $version{MAJOR} // 'unknown';
+$config{minor} = $version{MINOR} // 'unknown';
+$config{patch} = $version{PATCH} // 'unknown';
+$config{prerelease} =
+ defined $version{PRE_RELEASE_TAG} ? "-$version{PRE_RELEASE_TAG}" : '';
+$config{build_metadata} =
+ defined $version{BUILD_METADATA} ? "+$version{BUILD_METADATA}" : '';
+$config{shlib_version} = $version{SHLIB_VERSION} // 'unknown';
+$config{release_date} = $version{RELEASE_DATE} // 'xx XXX xxxx';
$config{version} = "$config{major}.$config{minor}.$config{patch}";
$config{full_version} = "$config{version}$config{prerelease}$config{build_metadata}";
+die "erroneous version information in VERSION: ",
+ "$config{version}, $config{shlib_version}\n"
+ unless (defined $version{MAJOR}
+ && defined $version{MINOR}
+ && defined $version{PATCH}
+ && defined $version{SHLIB_VERSION});
+
# Collect target configurations
my $pattern = catfile(dirname($0), "Configurations", "*.conf");