SPDX: license tags (mostly by guesswork)
[exim.git] / src / src / version.c
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2009 */
6 /* Copyright (c) The Exim Maintainers 2010 - 2018 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-only */
9
10 /* Function for setting up the version string. */
11
12 #include "exim.h"
13
14 #include "version.h"
15
16
17 /* The header file cnumber.h contains a single line containing the
18 compilation number, making it easy to have it updated automatically.
19 Hence the fudgery below to get the number turned into a string, since
20 we can't use #include inside a macro argument list */
21
22 void
23 version_init(void)
24 {
25 static uschar cnumber_buffer[24];
26 static uschar date_buffer[32];
27
28 uschar today[20];
29 uschar *version_cnumber_format;
30
31 int cnumber =
32 #include "cnumber.h"
33 ;
34
35 /* The odd magic after each of these is so they can be easily found
36 for automatic patching to standard values when running regression tests.
37 The reason that version_cnumber_format isn't just written inline in the
38 sprintf() call is the gcc -Wall warns about a \0 in a format string. */
39
40 version_cnumber = cnumber_buffer;
41 version_cnumber_format = US"%d\0<<eximcnumber>>";
42 sprintf(CS version_cnumber, CS version_cnumber_format, cnumber);
43 version_string = US EXIM_VERSION_STR "\0<<eximversion>>";
44
45 #ifdef EXIM_BUILD_DATE_OVERRIDE
46 /* Reproducible build support; build tooling should have given us something looking like
47  * "25-Feb-2017 20:15:40" in EXIM_BUILD_DATE_OVERRIDE based on $SOURCE_DATE_EPOCH in environ
48  * per <https://reproducible-builds.org/specs/source-date-epoch/>
49  */
50 version_date = date_buffer;
51 version_date[0] = 0;
52 Ustrncat(version_date, EXIM_BUILD_DATE_OVERRIDE, sizeof(date_buffer));
53
54 #else
55 Ustrcpy(today, US __DATE__);
56 if (today[4] == ' ') today[4] = '0';
57 today[3] = today[6] = '-';
58
59 version_date = date_buffer;
60 version_date[0] = 0;
61 Ustrncat(version_date, today+4, 3);
62 Ustrncat(version_date, today, 4);
63 Ustrncat(version_date, today+7, 4);
64 Ustrcat(version_date, US" ");
65 Ustrcat(version_date, US __TIME__);
66 #endif
67 }
68
69 /* End of version.c */