Configure: get version from the file 'VERSION' instead of 'opensslv.h'
[openssl.git] / include / openssl / opensslv.h.in
1 /*
2  * {- join("\n * ", @autowarntext) -}
3  *
4  * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved.
5  *
6  * Licensed under the Apache License 2.0 (the "License").  You may not use
7  * this file except in compliance with the License.  You can obtain a copy
8  * in the file LICENSE in the source distribution or at
9  * https://www.openssl.org/source/license.html
10  */
11
12 #ifndef OPENSSL_OPENSSLV_H
13 # define OPENSSL_OPENSSLV_H
14 # pragma once
15
16 # include <openssl/macros.h>
17 # if !OPENSSL_API_3
18 #  define HEADER_OPENSSLV_H
19 # endif
20
21 # ifdef  __cplusplus
22 extern "C" {
23 # endif
24
25 /*
26  * SECTION 1: VERSION DATA.  These will change for each release
27  */
28
29 /*
30  * Base version macros
31  *
32  * These macros express version number MAJOR.MINOR.PATCH exactly
33  */
34 # define OPENSSL_VERSION_MAJOR  {- $config{major} -}
35 # define OPENSSL_VERSION_MINOR  {- $config{minor} -}
36 # define OPENSSL_VERSION_PATCH  {- $config{patch} -}
37
38 /*
39  * Additional version information, defined only when used.
40  *
41  * These are also part of the new version scheme, but aren't part
42  * of the version number itself.
43  */
44
45 /* Could be: #define OPENSSL_VERSION_PRE_RELEASE "-alpha.1" */
46 {- $config{prerelease}
47     ? << "_____"
48 # define OPENSSL_VERSION_PRE_RELEASE "$config{prerelease}"
49 _____
50     : << "_____"
51 # undef OPENSSL_VERSION_PRE_RELEASE
52 _____
53 -}
54 /* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+fips" */
55 /* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+vendor.1" */
56 {- $build_metadata
57     ? << "_____"
58 # define OPENSSL_VERSION_BUILD_METADATA "{- $config{build_metadata} -}"
59 _____
60     : << "_____"
61 # undef OPENSSL_VERSION_BUILD_METADATA
62 _____
63 -}
64
65 /*
66  * Note: OPENSSL_VERSION_BUILD_METADATA will never be defined by
67  * the OpenSSL Project, it's entirely reserved for others vendors
68  */
69
70 /*
71  * Absolute string versions of OPENSSL_VERSION_PRE_RELEASE and
72  * OPENSSL_VERSION_BUILD_METADATA.  As opposed to those, which
73  * may be undefined, these are guaranteed to have strings as
74  * values.
75  */
76
77 # ifdef OPENSSL_VERSION_PRE_RELEASE
78 #  define OPENSSL_VERSION_PRE_RELEASE_STR OPENSSL_VERSION_PRE_RELEASE
79 # else
80 #  define OPENSSL_VERSION_PRE_RELEASE_STR ""
81 # endif
82 # ifdef OPENSSL_VERSION_BUILD_METADATA
83 #  define OPENSSL_VERSION_BUILD_METADATA_STR OPENSSL_VERSION_BUILD_METADATA
84 # else
85 #  define OPENSSL_VERSION_BUILD_METADATA_STR ""
86 # endif
87
88 /*
89  * Shared library version
90  *
91  * This is strictly to express ABI version, which may or may not
92  * be related to the API version expressed with the macros above.
93  * This is defined in free form.
94  */
95 # define OPENSSL_SHLIB_VERSION {- $config{shlib_version} -}
96
97 /*
98  * SECTION 2: USEFUL MACROS AND FUNCTIONS
99  */
100
101 /* For checking general API compatibility when preprocessing */
102 # define OPENSSL_VERSION_PREREQ(maj,min)                                \
103     ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min))
104
105 /*
106  * These return the values of OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR,
107  * OPENSSL_VERSION_PATCH, OPENSSL_VERSION_PRE_RELEASE and
108  * OPENSSL_VERSION_BUILD_METADATA, respectively.
109  */
110 unsigned int OPENSSL_version_major(void);
111 unsigned int OPENSSL_version_minor(void);
112 unsigned int OPENSSL_version_patch(void);
113 const char *OPENSSL_version_pre_release(void);
114 const char *OPENSSL_version_build_metadata(void);
115
116 /*
117  * Macros to get the version in easily digested string form, both the short
118  * "MAJOR.MINOR.PATCH" variant (where MAJOR, MINOR and PATCH are replaced
119  * with the values from the corresponding OPENSSL_VERSION_ macros) and the
120  * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and
121  * OPENSSL_VERSION_BUILD_METADATA_STR appended.
122  */
123 # define OPENSSL_VERSION_STR "{- $config{version} -}"
124 # define OPENSSL_FULL_VERSION_STR "{- $config{full_version} -}"
125
126 /*
127  * SECTION 3: ADDITIONAL METADATA
128  *
129  * These strings are defined separately to allow them to be parsable.
130  */
131 # define OPENSSL_RELEASE_DATE "{- $config{release_date} -}"
132 # define OPENSSL_VERSION_TEXT "OpenSSL {- "$config{full_version} $config{release_date}" -}"
133
134 /*
135  * SECTION 4: BACKWARD COMPATIBILITY
136  */
137 /* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PPSL */
138 # ifdef OPENSSL_VERSION_PRE_RELEASE
139 #  define _OPENSSL_VERSION_PRE_RELEASE 0x0
140 # else
141 #  define _OPENSSL_VERSION_PRE_RELEASE 0xf
142 # endif
143 # define OPENSSL_VERSION_NUMBER          \
144     ( (OPENSSL_VERSION_MAJOR<<28)        \
145       |(OPENSSL_VERSION_MINOR<<20)       \
146       |(OPENSSL_VERSION_PATCH<<4)        \
147       |_OPENSSL_VERSION_PRE_RELEASE )
148
149 # ifdef  __cplusplus
150 }
151 # endif
152 #endif                          /* OPENSSL_OPENSSLV_H */