Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (49 loc) · 2.11 KB
/
Copy pathMakefile
File metadata and controls
56 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Repository convenience targets. The handout build lives in sfslab/Makefile.
HANDOUT = sfslab
DIST = sfslab-handout.tar
DIST_MTIME = 2024-01-01 00:00Z
HANDOUT_FILES = .clang-format Makefile README sfs-api.h sfs-baseline-ref.c \
sfs-disk.c sfs-disk.h sfs-fsck.c sfs-support.c test-sfs.c
.PHONY: all
all:
$(MAKE) -C $(HANDOUT)
.PHONY: test
test:
$(MAKE) -C $(HANDOUT) test
.PHONY: clean
clean:
$(MAKE) -C $(HANDOUT) clean
# Rebuild the handout tarball deterministically from the working tree
# (requires GNU tar). The PDF is packed as-is, never rebuilt, so the
# tarball does not depend on the PDF toolchain; the mtime check below
# warns when the writeup source looks newer than the packed PDF (a
# warning, not an error: fresh checkouts have uniform mtimes).
.PHONY: dist
dist:
test -f sfslab.pdf
@if [ writeup/sfslab.roff -nt sfslab.pdf ]; then \
echo "warning: sfslab.pdf is older than writeup/sfslab.roff;" >&2; \
echo " run 'make pdf' first or the tarball ships a stale writeup" >&2; \
fi
@set -e; tmp=$$(mktemp -d "$${TMPDIR:-/tmp}/sfslab-dist.XXXXXX"); \
trap 'rm -rf "$$tmp"' EXIT HUP INT TERM; \
mkdir "$$tmp/$(HANDOUT)"; \
cp $(addprefix $(HANDOUT)/,$(HANDOUT_FILES)) "$$tmp/$(HANDOUT)/"; \
cp sfslab.pdf "$$tmp/"; \
find "$$tmp" -type d -exec chmod 755 {} +; \
find "$$tmp" -type f -exec chmod 644 {} +; \
tar --sort=name --mtime='$(DIST_MTIME)' \
--owner=0 --group=0 --numeric-owner -C "$$tmp" -cf "$(DIST)" "$(HANDOUT)" sfslab.pdf
@echo "built $(DIST)"
# Build the writeup PDF from its groff source. The source carries its own
# macro definitions, so this needs only groff-base and ghostscript (ps2pdf),
# both standard on Linux. The Omit* flags suppress ghostscript's embedded
# timestamps and document IDs, so rebuilding on the same toolchain is
# byte-identical and does not dirty the committed sfslab.pdf. (Different
# ghostscript versions may still produce different bytes; CI therefore
# builds the PDF but does not compare it.)
.PHONY: pdf
pdf: sfslab.pdf
sfslab.pdf: writeup/sfslab.roff
groff -t -Tps writeup/sfslab.roff | \
ps2pdf -dOmitInfoDate=true -dOmitXMP=true -dOmitID=true - $@