Make exim_monitor build reproducible.
[exim.git] / src / exim_monitor / em_version.c
CommitLineData
059ec3d9
PH
1/*************************************************
2* Exim Monitor *
3*************************************************/
4
9242a7e8 5/* Copyright (c) University of Cambridge 1995 - 2017 */
059ec3d9
PH
6/* See the file NOTICE for conditions of use and distribution. */
7
8#include "mytypes.h"
9#include "macros.h"
10#include <string.h>
11#include <stdlib.h>
12
a6f7862b
AM
13#include "version.h"
14
059ec3d9
PH
15extern uschar *version_string;
16extern uschar *version_date;
17
18void
19version_init(void)
20{
21int i = 0;
22uschar today[20];
23
f3f065bb 24version_string = US"2.06";
059ec3d9 25
a6f7862b
AM
26#ifdef EXIM_BUILD_DATE_OVERRIDE
27/* Reproducible build support; build tooling should have given us something looking like
28 * "25-Feb-2017 20:15:40" in EXIM_BUILD_DATE_OVERRIDE based on $SOURCE_DATE_EPOCH in environ
29 * per <https://reproducible-builds.org/specs/source-date-epoch/>
30 */
31version_date = US malloc(32);
32version_date[0] = 0;
33Ustrncat(version_date, EXIM_BUILD_DATE_OVERRIDE, 31);
34
35#else
059ec3d9
PH
36Ustrcpy(today, __DATE__);
37if (today[4] == ' ') i = 1;
38today[3] = today[6] = '-';
39
5903c6ff 40version_date = US malloc(32);
059ec3d9
PH
41version_date[0] = 0;
42Ustrncat(version_date, today+4+i, 3-i);
43Ustrncat(version_date, today, 4);
44Ustrncat(version_date, today+7, 4);
45Ustrcat(version_date, " ");
46Ustrcat(version_date, __TIME__);
a6f7862b 47#endif
059ec3d9
PH
48}
49
50/* End of em_version.c */