From b95eaf6889563ed3e4603ce2b3df0f793c4abe22 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 26 Mar 2018 19:25:46 +0100 Subject: [PATCH] Makefile improvements to ensure optimized PDFs are only written once. Signed-off-by: Daira Hopwood --- protocol/Makefile | 46 ++++++++++++++++++++++++++------------------- protocol/README.rst | 14 ++++++++------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/protocol/Makefile b/protocol/Makefile index f477f2bb..85483446 100644 --- a/protocol/Makefile +++ b/protocol/Makefile @@ -4,19 +4,17 @@ protocol.pdf: protocol.tex zcash.bib incremental_merkle.pdf key_components.pdf sapling.pdf: protocol.tex zcash.bib incremental_merkle.pdf key_components_sapling.pdf $(MAKE) sapling -.PHONY: pdf -pdf: +.PHONY: auxpdf +auxpdf: printf '\\renewcommand{\\docversion}{Version %s}' "$$(git describe --tags --abbrev=6)" |tee protocol.ver mkdir -p aux rm -f aux/protocol.* latexmk -bibtex -pdf -auxdir=aux -outdir=aux protocol - mv -f aux/protocol.pdf . -.PHONY: html -html: protocol.pdf sapling.pdf - # Can't use --split-pages 1 because XHR doesn't work by default on local files in Chrome. - pdf2htmlEX --decompose-ligature 1 --font-size-multiplier 65 --fit-width 1000 --dest-dir html protocol.pdf - pdf2htmlEX --decompose-ligature 1 --font-size-multiplier 65 --fit-width 1000 --dest-dir html sapling.pdf +.PHONY: pdf +pdf: + $(MAKE) auxpdf + mv -f aux/protocol.pdf . .PHONY: pvcpdf pvcpdf: @@ -25,12 +23,16 @@ pvcpdf: rm -f aux/protocol.* latexmk -bibtex -pdf -pvc -auxdir=aux protocol -.PHONY: sapling -sapling: +.PHONY: auxsapling +auxsapling: printf '\\toggletrue{issapling}\n\\renewcommand{\\docversion}{Version %s [\\SaplingSpec]}' "$$(git describe --tags --abbrev=6)" |tee protocol.ver mkdir -p aux rm -f aux/sapling.* latexmk -bibtex -pdf -jobname=sapling -auxdir=aux -outdir=aux protocol + +.PHONY: sapling +sapling: + $(MAKE) auxsapling mv -f aux/sapling.pdf . .PHONY: pvcsapling @@ -64,6 +66,12 @@ nolatexmk-sapling: $(LATEX) -jobname=sapling protocol.tex || { touch incremental_merkle.pdf; exit 1; } $(LATEX) -jobname=sapling protocol.tex || { touch incremental_merkle.pdf; exit 1; } +.PHONY: html +html: protocol.pdf sapling.pdf + # Can't use --split-pages 1 because XHR doesn't work by default on local files in Chrome. + pdf2htmlEX --decompose-ligature 1 --font-size-multiplier 65 --fit-width 1000 --dest-dir html protocol.pdf + pdf2htmlEX --decompose-ligature 1 --font-size-multiplier 65 --fit-width 1000 --dest-dir html sapling.pdf + .PHONY: clean clean: rm -f aux/* html/* protocol.ver \ @@ -86,17 +94,17 @@ optimizer-installed.flag: clean-optimizer: rm -rf sam2p tif22pnm pdfsizeopt optimizer-installed.flag -.PHONY: optimize-pdf -optimize-pdf: optimizer-installed.flag +.PHONY: optpdf +optpdf: optimizer-installed.flag + $(MAKE) auxpdf PATH="${PATH}:$(CURDIR)/sam2p:$(CURDIR)/tif22pnm" pdfsizeopt/pdfsizeopt --v=40 --use-image-optimizer=sam2p \ - --tmp-dir=aux protocol.pdf protocol-opt.pdf - mv -f protocol-opt.pdf protocol.pdf + --tmp-dir=aux aux/protocol.pdf protocol.pdf -.PHONY: optimize-sapling -optimize-sapling: optimizer-installed.flag +.PHONY: optsapling +optsapling: optimizer-installed.flag + $(MAKE) auxsapling PATH="${PATH}:$(CURDIR)/sam2p:$(CURDIR)/tif22pnm" pdfsizeopt/pdfsizeopt --v=40 --use-image-optimizer=sam2p \ - --tmp-dir=aux sapling.pdf sapling-opt.pdf - mv -f sapling-opt.pdf sapling.pdf + --tmp-dir=aux aux/sapling.pdf sapling.pdf .PHONY: optimized -optimized: pdf sapling optimize-pdf optimize-sapling +optimized: optpdf optsapling diff --git a/protocol/README.rst b/protocol/README.rst index c1b59f7d..466a3ce8 100644 --- a/protocol/README.rst +++ b/protocol/README.rst @@ -36,13 +36,15 @@ Optimizing PDF size Optionally, you can use `Péter Szabó `_'s ``pdfsizeopt`` program to optimize the size of the resulting PDF files. -Run ``make optimized`` to rebuild both PDFs and then optimize them. -This will probably only work on Linux. The first time this is run it -will automatically clone and build the necessary dependencies (pinned -by ``git`` hash) from GitHub. +Use: -Alternatively, you can run ``make optimize-pdf`` or ``make optimize-sapling`` -to optimize just ``protocol.pdf`` or ``sapling.pdf`` respectively. +* ``make optpdf`` to make an optimized version of ``protocol.pdf``; +* ``make optsapling`` to make an optimized version of ``sapling.pdf``; +* ``make optimized`` to make both. + +This will probably only work on Linux. The first time one of these +targets is run, it will automatically clone and build the necessary +dependencies (pinned by ``git`` hash) from GitHub. This gives a size saving of about 50% for ``protocol.pdf``, and 40% for ``sapling.pdf``.