From: Bernhard M. Wiedemann Date: Sat, 1 Jul 2017 09:07:19 +0000 (+0200) Subject: Allow to override build date X-Git-Tag: v4.2.4~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7160749d5ab184e36a3368f24c3ca83383c9ede;p=thirdparty%2Ftvheadend.git Allow to override build date 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 --- diff --git a/Makefile b/Makefile index 9ae581d99..14052f147 100644 --- 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 $@ $<