Generate include/openssl/opensslv.h
authorRichard Levitte <levitte@openssl.org>
Thu, 17 Oct 2019 14:05:38 +0000 (16:05 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 18 Oct 2019 10:22:00 +0000 (12:22 +0200)
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 <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10205)

build.info
include/openssl/opensslv.h.in [moved from include/openssl/opensslv.h with 79% similarity]
util/mkrc.pl

index 5e63b440df260c1d6f3c557e6f472536c5ba0948..6b70b11006c23eea8f59cc38d04daeeba84f3326 100644 (file)
@@ -9,9 +9,11 @@ DEPEND[libssl]=libcrypto
 
 # Empty DEPEND "indices" means the dependencies are expected to be built
 # unconditionally before anything else.
 
 # 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/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
 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
similarity index 79%
rename from include/openssl/opensslv.h
rename to include/openssl/opensslv.h.in
index cb3eb32d0be7508669e1a211433406069f8ce2c0..856e8640b8accb95513af683ea939ff172992d75 100644 (file)
@@ -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
  * 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
  */
  *
  * 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.
 
 /*
  * Additional version information, defined only when used.
@@ -41,10 +43,24 @@ extern "C" {
  */
 
 /* Could be: #define OPENSSL_VERSION_PRE_RELEASE "-alpha.1" */
  */
 
 /* 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" */
 /* 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
 # undef OPENSSL_VERSION_BUILD_METADATA
+_____
+-}
 
 /*
  * Note: OPENSSL_VERSION_BUILD_METADATA will never be defined by
 
 /*
  * 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.
  */
  * 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
 
 /*
  * 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))
 
 # 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
 /*
  * 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.
  */
  * 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
 
 /*
  * 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
 
 /*
  * SECTION 4: BACKWARD COMPATIBILITY
index b4c53edf6b9ee54cf29b11f5e008c1581a1eec33..8ff358857dbb4c6f769c8337d5812684db691edd 100755 (executable)
@@ -11,8 +11,11 @@ use warnings;
 use lib ".";
 use configdata;
 
 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";
 
 my $filename = $ARGV[0];
 my $description = "OpenSSL library";