From f3866324f0e9bd33feb48aefbe18d8f465d8f2a2 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 17 Oct 2019 16:05:38 +0200 Subject: [PATCH] Generate include/openssl/opensslv.h The added benefit is that the result becomes much simple, and easier to digest for those that still rely on the pre-3.0 opensslv.h contents. Fixes #10203 Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/10205) --- build.info | 6 ++- include/openssl/{opensslv.h => opensslv.h.in} | 47 +++++++++++-------- util/mkrc.pl | 7 ++- 3 files changed, 36 insertions(+), 24 deletions(-) rename include/openssl/{opensslv.h => opensslv.h.in} (79%) diff --git a/build.info b/build.info index 5e63b440df..6b70b11006 100644 --- a/build.info +++ b/build.info @@ -9,9 +9,11 @@ DEPEND[libssl]=libcrypto # Empty DEPEND "indices" means the dependencies are expected to be built # unconditionally before anything else. -DEPEND[]=include/openssl/opensslconf.h include/crypto/bn_conf.h \ - include/crypto/dso_conf.h doc/man7/openssl_user_macros.pod +DEPEND[]=include/openssl/opensslconf.h include/openssl/opensslv.h \ + include/crypto/bn_conf.h include/crypto/dso_conf.h \ + doc/man7/openssl_user_macros.pod GENERATE[include/openssl/opensslconf.h]=include/openssl/opensslconf.h.in +GENERATE[include/openssl/opensslv.h]=include/openssl/opensslv.h.in GENERATE[include/crypto/bn_conf.h]=include/crypto/bn_conf.h.in GENERATE[include/crypto/dso_conf.h]=include/crypto/dso_conf.h.in GENERATE[doc/man7/openssl_user_macros.pod]=doc/man7/openssl_user_macros.pod.in diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h.in similarity index 79% rename from include/openssl/opensslv.h rename to include/openssl/opensslv.h.in index cb3eb32d0b..856e8640b8 100644 --- a/include/openssl/opensslv.h +++ b/include/openssl/opensslv.h.in @@ -1,4 +1,6 @@ /* + * {- join("\n * ", @autowarntext) -} + * * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -29,9 +31,9 @@ extern "C" { * * These macros express version number MAJOR.MINOR.PATCH exactly */ -# define OPENSSL_VERSION_MAJOR 3 -# define OPENSSL_VERSION_MINOR 0 -# define OPENSSL_VERSION_PATCH 0 +# define OPENSSL_VERSION_MAJOR {- $config{major} -} +# define OPENSSL_VERSION_MINOR {- $config{minor} -} +# define OPENSSL_VERSION_PATCH {- $config{patch} -} /* * Additional version information, defined only when used. @@ -41,10 +43,24 @@ extern "C" { */ /* Could be: #define OPENSSL_VERSION_PRE_RELEASE "-alpha.1" */ -# define OPENSSL_VERSION_PRE_RELEASE "-dev" +{- $config{prerelease} + ? << "_____" +# define OPENSSL_VERSION_PRE_RELEASE "$config{prerelease}" +_____ + : << "_____" +# undef OPENSSL_VERSION_PRE_RELEASE +_____ +-} /* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+fips" */ /* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+vendor.1" */ +{- $build_metadata + ? << "_____" +# define OPENSSL_VERSION_BUILD_METADATA "{- $config{build_metadata} -}" +_____ + : << "_____" # undef OPENSSL_VERSION_BUILD_METADATA +_____ +-} /* * Note: OPENSSL_VERSION_BUILD_METADATA will never be defined by @@ -76,7 +92,7 @@ extern "C" { * be related to the API version expressed with the macros above. * This is defined in free form. */ -# define OPENSSL_SHLIB_VERSION 3 +# define OPENSSL_SHLIB_VERSION {- $config{shlib_version} -} /* * SECTION 2: USEFUL MACROS AND FUNCTIONS @@ -86,10 +102,6 @@ extern "C" { # define OPENSSL_VERSION_PREREQ(maj,min) \ ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min)) -/* Helper macros for CPP string composition */ -# define OPENSSL_MSTR_HELPER(x) #x -# define OPENSSL_MSTR(x) OPENSSL_MSTR_HELPER(x) - /* * These return the values of OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR, * OPENSSL_VERSION_PATCH, OPENSSL_VERSION_PRE_RELEASE and @@ -108,21 +120,16 @@ const char *OPENSSL_version_build_metadata(void); * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and * OPENSSL_VERSION_BUILD_METADATA_STR appended. */ -# define OPENSSL_VERSION_STR \ - OPENSSL_MSTR(OPENSSL_VERSION_MAJOR) "." \ - OPENSSL_MSTR(OPENSSL_VERSION_MINOR) "." \ - OPENSSL_MSTR(OPENSSL_VERSION_PATCH) -# define OPENSSL_FULL_VERSION_STR \ - OPENSSL_VERSION_STR \ - OPENSSL_VERSION_PRE_RELEASE_STR \ - OPENSSL_VERSION_BUILD_METADATA_STR +# define OPENSSL_VERSION_STR "{- $config{version} -}" +# define OPENSSL_FULL_VERSION_STR "{- $config{full_version} -}" /* * SECTION 3: ADDITIONAL METADATA + * + * These strings are defined separately to allow them to be parsable. */ -# define OPENSSL_RELEASE_DATE "xx XXX xxxx" -# define OPENSSL_VERSION_TEXT \ - "OpenSSL " OPENSSL_FULL_VERSION_STR " " OPENSSL_RELEASE_DATE +# define OPENSSL_RELEASE_DATE "{- $config{release_date} -}" +# define OPENSSL_VERSION_TEXT "OpenSSL {- "$config{full_version} $config{release_date}" -}" /* * SECTION 4: BACKWARD COMPATIBILITY diff --git a/util/mkrc.pl b/util/mkrc.pl index b4c53edf6b..8ff358857d 100755 --- a/util/mkrc.pl +++ b/util/mkrc.pl @@ -11,8 +11,11 @@ use warnings; use lib "."; use configdata; -my $cversion = "$config{major},$config{minor},$config{patch}"; -my $version = "$config{major}.$config{minor}.$config{patch}$config{prerelease}$config{build_metadata}"; +my $cversion = "$config{version}"; +my $version = "$config{full_version}"; + +# RC syntax for versions uses commas as separators, rather than period +$cversion =~ s|\.|,|g; my $filename = $ARGV[0]; my $description = "OpenSSL library"; -- 2.25.1