aboutsummaryrefslogtreecommitdiffstats
path: root/package/boot/uboot-ar71xx/patches/0002-upstream-Makefile-Reproducible-U-Boot-build-support.patch
blob: 664a4adb669f3a6c03cea2c760f7caabceb560f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--- a/Makefile
+++ b/Makefile
@@ -389,8 +389,26 @@ $(VERSION_FILE):
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 $(TIMESTAMP_FILE):
-		@date +'#define U_BOOT_DATE "%b %d %C%y"' > $@
-		@date +'#define U_BOOT_TIME "%T"' >> $@
+	(if test -n "$${SOURCE_DATE_EPOCH}"; then \
+                SOURCE_DATE="@$${SOURCE_DATE_EPOCH}"; \
+                DATE=""; \
+                for date in gdate date.gnu date; do \
+                        $${date} -u -d "$${SOURCE_DATE}" >/dev/null 2>&1 && DATE="$${date}"; \
+                done; \
+                if test -n "$${DATE}"; then \
+                        LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"' > $@; \
+                        LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"' >> $@; \
+                        LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"' >> $@; \
+                        LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"' >> $@; \
+                else \
+                        return 42; \
+                fi; \
+        else \
+                LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
+                LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
+                LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \
+                LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \
+        fi)
 
 gdbtools:
 		$(MAKE) -C tools/gdb all || exit 1