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
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.

This date call only works with GNU date.

This patch was done while working on reproducible builds for openSUSE.
  • Loading branch information
bmwiedemann committed Jan 22, 2025
1 parent 1827713 commit 9ee3773
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ debug: all

${OBJ} ${TEST_OBJ}: Makefile config.mk

SOURCE_DATE_EPOCH ?= $(shell date +%s)
src/dunst.o: src/dunst.c
${CC} -o $@ -c $< ${CPPFLAGS} ${CFLAGS} \
-D_CCDATE="$(shell date '+%Y-%m-%d')" -D_CFLAGS="$(filter-out $(filter -I%,${INCS}),${CFLAGS})" -D_LDFLAGS="${LDFLAGS}"
-D_CCDATE="$(shell date -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d')" -D_CFLAGS="$(filter-out $(filter -I%,${INCS}),${CFLAGS})" -D_LDFLAGS="${LDFLAGS}"

%.o: %.c
${CC} -o $@ -c $< ${CPPFLAGS} ${CFLAGS}
Expand Down

0 comments on commit 9ee3773

Please sign in to comment.