Skip to content

Commit

Permalink
Allow to override build date with SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
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.

Also switch to UTC to be independent of timezone.

Note: This date call is designed to work with different flavors
of date (GNU, BSD and others).
If only GNU (Linux) support is needed, the patch can be simplified.

This PR was done while working on reproducible builds for openSUSE.
  • Loading branch information
bmwiedemann committed Dec 5, 2019
1 parent 2028607 commit 5f1a335
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libpw3270cpp/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ VALGRIND=@VALGRIND@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@

DATE_FMT = +%Y%m%d
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

CFLAGS= \
@CFLAGS@ \
-Wno-deprecated-declarations \
Expand Down Expand Up @@ -102,7 +109,7 @@ $(OBJRLS)/%.o: \
@$(MKDIR) `dirname $@`
@$(CC) $(CFLAGS) \
@RLS_CFLAGS@ \
-DBUILD_DATE=`date +"%Y%m%d"` \
-DBUILD_DATE=$(BUILD_DATE) \
-o $@ -c $<

$(POTDIR)/%.pot: %.c
Expand Down

0 comments on commit 5f1a335

Please sign in to comment.