From a5877af3096bb02c60eb92fdc04a53e8d68b5271 Mon Sep 17 00:00:00 2001
From: Dominic Hargreaves <dom@earth.li>
Date: Wed, 2 Sep 2015 22:15:22 +0100
Subject: Allow the build date/time to be overridden by BUILD_DATE

Including the current date/time in the build means that it cannot be
reproducible. Instead, BUILD_DATE can be set to a value from the source
(in the Debian project, this will be the latest changelog date).

See <https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros>
for more information.

This is the version of the patch modified by
Michael Wobst <wobst.michael@web.de> and applied upstream

Patch-Name: reproducible_date_time.patch
Origin: https://github.com/ircd-hybrid/ircd-hybrid/commit/ff413b31ea4d89fa3fc460bdb66dafd6c1b9856d
Bug: https://github.com/ircd-hybrid/ircd-hybrid/pull/3
---
 src/Makefile.am | 4 +++-
 src/user.c      | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 780417d..dc279b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,9 +2,11 @@ AUTOMAKE_OPTIONS = foreign
 
 sbin_PROGRAMS = ircd
 
+BUILD_DATE ?= $(shell LANG=C date '+%B %-e %Y at %T%z')
+
 AM_YFLAGS = -d
 
-AM_CPPFLAGS = $(LTDLINCL) -I$(top_srcdir)/include
+AM_CPPFLAGS = $(LTDLINCL) -I$(top_srcdir)/include -DBUILD_DATE="\"$(BUILD_DATE)\""
 ircd_LDFLAGS = -export-dynamic
 ircd_LDADD = $(LIBLTDL)
 ircd_DEPENDENCIES = $(LTDLDEPS)
diff --git a/src/user.c b/src/user.c
index d3cc8c5..bc1d010 100644
--- a/src/user.c
+++ b/src/user.c
@@ -230,7 +230,11 @@ introduce_client(struct Client *client)
 static void
 user_welcome(struct Client *client)
 {
+#ifdef BUILD_DATE
+  static const char built_date[] = BUILD_DATE;
+#else
   static const char built_date[] = __DATE__ " at " __TIME__;
+#endif
 
   if (HasFlag(client, FLAGS_TLS))
   {
