File reproducible-builds.patch of Package swipl

diff -Nur swipl-7.4.1/packages/table/Makefile.in new/packages/table/Makefile.in
--- swipl-7.4.1/packages/table/Makefile.in	2016-12-18 16:39:36.000000000 +0100
+++ new/packages/table/Makefile.in	2017-03-15 00:21:55.667370636 +0100
@@ -11,6 +11,12 @@
 CFLAGS+= -I.
 LIBS=@LIBS@
 
+DATE_FMT = %Y-%m-%d
+ifdef SOURCE_DATE_EPOCH
+    BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)"  2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
+    CFLAGS += -DBUILD_DATE=\"${BUILD_DATE}\"
+endif
+
 LIBPL=		table.pl table_util.pl
 TARGETS=	table.@SO@
 
diff -Nur swipl-7.4.1/packages/table/table.c new/packages/table/table.c
--- swipl-7.4.1/packages/table/table.c	2016-12-18 16:39:36.000000000 +0100
+++ new/packages/table/table.c	2017-03-15 00:30:04.822515400 +0100
@@ -38,6 +38,10 @@
 
 #define O_ORDER				/* include order.c package */
 
+#ifndef BUILD_DATE
+#define BUILD_DATE __DATE__
+#endif
+
 #include <SWI-Stream.h>
 
 #include "table.h"
@@ -2198,7 +2202,7 @@
 static foreign_t
 pl_table_version(term_t version, term_t date)
 { if ( PL_unify_atom_chars(version, TABLE_VERSION) &&
-       PL_unify_atom_chars(date, __DATE__) )
+       PL_unify_atom_chars(date, BUILD_DATE) )
     return TRUE;
 
   return FALSE;
diff -Nur swipl-7.4.1/src/Makefile.in new/src/Makefile.in
--- swipl-7.4.1/src/Makefile.in	2017-03-02 21:37:35.000000000 +0100
+++ new/src/Makefile.in	2017-03-15 01:04:41.980399442 +0100
@@ -166,6 +166,15 @@
 UNICODE=blocks.pl unicode_data.pl
 builddirs=../lib ../lib/$(PLARCH) os
 
+# For reproducible builds
+DATE_FMT = "%b %e %Y"
+TIME_FMT = "%R"
+ifdef SOURCE_DATE_EPOCH
+BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
+BUILD_TIME ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
+CFLAGS += -DBUILD_DATE=\"${BUILD_DATE}\" -DBUILD_TIME=\"${BUILD_TIME}\"
+endif
+
 # OPTIMISE=noprof: normal build; prof: build twice, using profiling
 # information to optimise branches.  Normally set through
 # configure --enable-useprofile
diff -Nur swipl-7.4.1/src/os/pl-prologflag.c new/src/os/pl-prologflag.c
--- swipl-7.4.1/src/os/pl-prologflag.c	2017-03-02 21:37:35.000000000 +0100
+++ new/src/os/pl-prologflag.c	2017-03-15 01:06:44.249304023 +0100
@@ -1396,7 +1396,9 @@
   setPrologFlag("kernel_compile_mode", FT_ATOM|FF_READONLY, "debug");
 #endif
 
-#if defined(__DATE__) && defined(__TIME__)
+#if   defined(BUILD_TIME) && defined(BUILD_DATE)
+  setPrologFlag("compiled_at", FT_ATOM|FF_READONLY, BUILD_DATE ", " BUILD_TIME);
+#elif defined(__DATE__) && defined(__TIME__)
   setPrologFlag("compiled_at", FT_ATOM|FF_READONLY, __DATE__ ", " __TIME__);
 #endif