]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Allow to override build date
authorBernhard M. Wiedemann <bwiedemann@suse.de>
Sat, 1 Jul 2017 09:07:19 +0000 (11:07 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sat, 1 Jul 2017 13:49:21 +0000 (15:49 +0200)
to enable reproducible builds

See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

The date calls are designed to work with both GNU date and BSD date

Makefile

index 9ae581d99b4ce9c33d0d0c67757ac140748f047f..14052f1479b5a0ebd0dec22606e1bca4c2471623 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -668,10 +668,16 @@ src/webui/extjs.c: make_webui
 include ${ROOTDIR}/support/${OSENV}.mk
 
 # Build files
+DATE_FMT = %Y-%m-%dT%H:%M:%S%z
+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)")
+else
+       BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
+endif
 $(BUILDDIR)/timestamp.c: FORCE
        @mkdir -p $(dir $@)
        @echo '#include "build.h"' > $@
-       @echo 'const char* build_timestamp = "'`date +%Y-%m-%dT%H:%M:%S%z`'";' >> $@
+       @echo 'const char* build_timestamp = "'$(BUILD_DATE)'";' >> $@
 
 $(BUILDDIR)/timestamp.o: $(BUILDDIR)/timestamp.c
        $(pCC) -c -o $@ $<