Skip to content

Commit

Permalink
Fix handling of SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
If no SOURCE_DATE_EPOCH is specified via configure, then it can't be
set as an environment variable in doc/Makefile.am build rules. Change
the build rules to check if SOURCE_DATE_EPOCH is non-empty and use it
if so, otherwise leave it out of the commands.

Also fix verbosity for make in doc/Makefile.am. If V=1 is passed on
the make command line, echo the build commands, otherwise echo
abbreviated commands. Special handling is needed because of the "if"
commands in the build rules have echo unconditionally disabled via @.
  • Loading branch information
vinoski committed Jan 31, 2022
1 parent ada124f commit 9ddb504
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ The above configurations for enabling deterministic builds add the erlc flag
`yaws_generated.beam`, and set e.g. creation date in `yaws.ps` and `yaws.pdf`
from the value of `SOURCE_DATE_EPOCH`, which is expected to be an integer
reflecting a number of seconds since the Unix epoch. (One way to get an epoch
integer value is via the command `date '+%s'` on Linux or macOS, for example.)
integer value is via the command `date '+%s'` on Linux or macOS, for example.
If you're using the bash shell version 4.2 or newer, `printf '%(%s)T\n' -1`
gives an epoch integer value, and starting at version 5, the bash shell
provides the `$EPOCHSECONDS` variable.)

Note that various paths in configuration files, templates, examples etc. are
generated from the configured installation prefix config files; thus they
Expand Down
93 changes: 80 additions & 13 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,26 @@ endif

# For reproducible builds, SOURCE_DATE_EPOCH replaces DVIPSSource date if set
yaws.ps: yaws.dvi
$(AM_V_GEN)TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
@if [ x"$(SOURCE_DATE_EPOCH)" == x ]; then \
if [ x'$(AM_V_GEN)' != x ]; then \
echo ' $(DVIPS) $<' ; \
else \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(DVIPS) -q -o $@ $< ; \
fi; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(DVIPS) -q -o $@ $< ; \
else \
if [ x'$(AM_V_GEN)' != x ]; then \
echo ' $(DVIPS) $<' ; \
else \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(DVIPS) -q -o $@ $<
$(AM_V_at)if [ x"$(SOURCE_DATE_EPOCH)" != "x" ]; then \
$(DVIPS) -q -o $@ $< ; \
fi; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(DVIPS) -q -o $@ $< ; \
code='{{Y,Mo,D},{H,Mi,S}} = calendar:system_time_to_local_time('$(SOURCE_DATE_EPOCH)', 1),' ; \
code="$$code "'io:format("~4.4w~2.2.0w~2.2.0w:~2.2.0w~2.2.0w~2.2.0w\n", [Y,Mo,D,H,Mi,S]).' ; \
newdate=`$(ERL) -noshell -noinput -eval "$$code" -s init stop` || exit 1; \
Expand All @@ -62,24 +78,75 @@ yaws.ps: yaws.dvi
fi

yaws.pdf: yaws.tex $(IMG_PDF)
$(AM_V_GEN)TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
@if [ x"$(SOURCE_DATE_EPOCH)" != x ]; then \
if [ x'$(AM_V_GEN)' != x ]; then \
echo ' $(PDFLATEX) $<' ; \
else \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(PDFLATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(PDFLATEX) yaws.tex > /dev/null
$(AM_V_at)TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(PDFLATEX) $< > /dev/null; \
if [ x'$(AM_V_at)' = x ]; then \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(PDFLATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(PDFLATEX) yaws.tex > /dev/null
$(PDFLATEX) $< > /dev/null; \
else \
if [ x'$(AM_V_GEN)' != x ]; then \
echo ' $(PDFLATEX) $<' ; \
else \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(PDFLATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(PDFLATEX) $< > /dev/null; \
if [ x'$(AM_V_at)' = x ]; then \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(PDFLATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(PDFLATEX) $< > /dev/null; \
fi

yaws.dvi: yaws.tex $(IMG_EPS)
$(AM_V_GEN)TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
@if [ x"$(SOURCE_DATE_EPOCH)" != x ]; then \
if [ x'$(AM_V_at)' = x ]; then \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(DVILATEX) yaws.tex > /dev/null
$(AM_V_at)TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(DVILATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(DVILATEX) yaws.tex > /dev/null
$(DVILATEX) $< > /dev/null; \
else \
if [ x'$(AM_V_at)' = x ]; then \
echo TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(DVILATEX) $< ; \
fi ; \
TEXINPUTS="$${TEXTINPUTS}:@srcdir@" \
$(DVILATEX) $< > /dev/null; \
fi

.eps.pdf:
$(AM_V_GEN)SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(EPSTOPDF) --outfile=$@ $< > /dev/null
@if [ x"$(SOURCE_DATE_EPOCH)" != x ]; then \
if [ x'$(AM_V_at)' = x ]; then \
echo SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(EPSTOPDF) --outfile=$@ $< ; \
fi ; \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
$(EPSTOPDF) --outfile=$@ $< > /dev/null; \
else \
if [ x'$(AM_V_at)' = x ]; then \
echo $(EPSTOPDF) --outfile=$@ $< ; \
fi ; \
$(EPSTOPDF) --outfile=$@ $< > /dev/null; \
fi

.NOTPARALLEL:
# Local Variables:
Expand Down

0 comments on commit 9ddb504

Please sign in to comment.