Newer
Older
QR_TARGET != grep mailto: README.md | cut -d: -f2,3 | tail -c+2
QR_CODE=\qrcode[height=.2\textwidth]{$(QR_TARGET)}
COMPRESS = gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=$@ $<
CP := ln -f
BOOK != basename "$(shell pwd)"
TITLE != head -1 README.md | tail -c+3 | tr ' ' '_'
DBOOK ?= $(DROSS)/$(BOOK).pdf
COMPILER = latexmk -e '$$max_repeat=6' -file-line-error -output-directory=$(DROSS) -pdflua -interaction=nonstopmode -halt-on-error -shell-escape -r config/.latexmkrc
RELEASE = $(TITLE).pdf
GLOS := makeglossaries -d $(DROSS)
RUN := lualatex -output-directory $(DROSS) -shell-escape
# 'EXTERNAL_REFERENTS' will usually include 'core', and 'judgement',
# so these lines will include '../aux/core.aux' and copy it to
# 'rubbish/core.aux'.
AUX_DIR = ../aux_share
AUX_EXTERNAL = $(foreach referent, $(EXTERNAL_REFERENTS), \
$(wildcard $(AUX_DIR)/$(referent).aux) \
)
AUX_REFERENCES = $(patsubst $(AUX_DIR)/%.aux, $(DROSS)/%.aux, $(AUX_EXTERNAL))
DEPS += $(wildcard config/*.sty)
echo '*' > $@.gitignore
$(DROSS)/%.pdf: %.tex $(wildcard config/*.sty) | $(DROSS)/
$(COMPILER) -jobname=$(basename $(@F)) $<
%.pdf: $(DROSS)/%.pdf
$(CP) $(DROSS)/$@ $@
$(DROSS)/%.pdf: %/main.tex $(wildcard config/*sty) | $(DROSS)/
$(COMPILER) -jobname=$(<D) $<
$(AUX_REFERENCES): $(DROSS)/%.aux: $(AUX_DIR)/%.aux | $(DROSS)/
cp $< $@
.PHONY: refs
refs: $(AUX_DIR)/$(BOOK).aux
$(AUX_DIR)/$(BOOK).aux: $(DROSS)/$(BOOK).aux | $(AUX_DIR)/
printf '%s' '\qrcode[height=.2\textwidth]{$(QR_TARGET)}' > qr.tex
output += qr.tex .switch-gls svg-inkscape
images/extracted/inclusion.tex: images/extracted/
printf '%s\n' '\externaldocument{$(BOOK)}' > $@
printf '%s\n' '\newcommand\bookTitle{$(TITLE)}' | tr '_' ' ' >> $@
dependencies += git git-lfs lualatex latexmk inkscape
.PHONY: check
check: ## Check you have the project dependencies
@$(foreach program, $(dependencies), \
command -v $(program) >/dev/null || { echo install $(program) && exit 1 ;} ;)
help: ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
column -s ':' -t
graph: ## Show a dependency graph (needs graph-easy and make2graph)
make -Bind $(TARG) | make2graph | graph-easy --boxart
######## Automated Materials Check ########
text_shadows = $(patsubst $(DROSS)/%.pdf, $(DROSS)/%.txt, $(wildcard $(DROSS)/*.pdf))
$(text_shadows): $(DROSS)/%.txt: $(DROSS)/%.pdf
pdftotext $< $@
.PHONY: report
report: $(text_shadows) ## Check for missing references and repetition in all pdfs.
@command -v pdftotext >/dev/null || { echo install pdftotext ; exit 1 ;}
@test -f '$<' || exit 1
@! grep -F '??' $^
@grep --color=always -nE '(\b\S+\b)\s+\b\1\b' $^ || echo "No problems found."
######## A3 12 signature pdfs ########
A3_12_signature_%.pdf: %.pdf
pdfjam --landscape --paper a3paper --nup 1x1 --signature 12 $< -o $@
A3_pdfs = $(patsubst %.pdf, A3_12_signature_%.pdf, $(pdfs))
.PHONY: printables
printables: $(A3_pdfs)
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
######## A7 pdf booklets ########
# The A7 booklet has 16 pages to the signature
layout = 16:
# The layout lists page indexes, so '0' means 'page 1', and '0L' means 'page 1
# but turn 90 degrees to the left'
layout += 4L(1w,0h)+12L(1w,0.25h)+15L(1w,0.5h)+0L(1w,0.75h)+3R(0w,0.25h)+11R(0w,0.5h)+8R(0w,0.75h)+7R(0w,1h),
# The first block ends with a comma, which indicates that we are working on the
# back-page.
layout += 5L(1w,0h)+10L(1w,0.25h)+9L(1w,0.5h)+6L(1w,0.75h)+2R(0w,0.25h)+13R(0w,0.5h)+14R(0w,0.75h)+1R(0w,1h)
# 'make' adds spaces between variables, but `pstops` will not be happy with those spaces.
a7_layout != printf '%s' '$(layout)' | tr -d ' '
$(DROSS)/a7_%.ps: $(DROSS)/a7_%.pdf
pdftops $< $@
$(DROSS)/onepage_%.ps: $(DROSS)/a7_%.ps
pstops -pa4 '$(a7_layout)' $< $@
$(DROSS)/onepage_%.pdf: $(DROSS)/onepage_%.ps
ps2pdf $< $@
%.pdf: $(DROSS)/onepage_%.pdf
$(CP) $< $@
#################################
targets += $(pdfs)
output += $(targets)
all: $(targets) ## All standard targets
.PHONY: clean
clean: ## Clean repo, including cross-reference files