From 644bdd220e111d25e43cc5a9f457202b010e9fe9 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Thu, 28 Nov 2019 20:01:50 +0100 Subject: [PATCH] Allow to override build date with SOURCE_DATE_EPOCH in order to make builds reproducible. 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. Note: This date call is designed to work with different flavors of date (GNU, BSD and others). --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9952ee6e..e47e1eff 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,13 @@ AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c) PYTHON_INCLUDE ?= /usr/include/python2.7 + +ifdef SOURCE_DATE_EPOCH + BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" -I 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" -I 2>/dev/null || date -u -I) +else + BUILD_DATE ?= $(shell date -I) +endif + ifneq "$(filter Linux GNU%,$(shell uname))" "" LDFLAGS += -ldl endif @@ -299,7 +306,7 @@ source-only: all radamsa $(MAKE) -C libtokencap %.8: % - @echo .TH $* 8 `date -I` "afl++" > $@ + @echo .TH $* 8 $(BUILD_DATE) "afl++" > $@ @echo .SH NAME >> $@ @echo .B $* >> $@ @echo >> $@