Skip to content

Commit

Permalink
Allow to override build date and host
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
bmwiedemann committed Dec 2, 2019
1 parent af0227f commit 68e2264
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,19 @@ all: $(BIN_LIST)

allall: $(BIN_LIST) $(BIN_LIST_AUX)


DATE_FMT = %Y-%m-%dT%H:%M:%S
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_HOST := reproduciblebuild
else
BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
BUILD_HOST ?= `hostname`
endif
DEFS=-fno-strict-aliasing \
-DBOWTIE_VERSION="\"`cat VERSION`\"" \
-DBUILD_HOST="\"`hostname`\"" \
-DBUILD_TIME="\"`date`\"" \
-DBUILD_HOST="\"$(BUILD_HOST)\"" \
-DBUILD_TIME="\"$(BUILD_DATE)\"" \
-DCOMPILER_VERSION="\"`$(CXX) -v 2>&1 | tail -1`\"" \
$(FILE_FLAGS) \
$(PTHREAD_DEF) \
Expand Down

0 comments on commit 68e2264

Please sign in to comment.