Skip to content
Snippets Groups Projects
vars 2.34 KiB
Newer Older
  • Learn to ignore specific revisions
  • VERSION != git tag | tail -1
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    QR_TARGET != grep mailto: README.md | cut -d: -f2,3 | tail -c+2
    QR_CODE=\qrcode[height=.2\textwidth]{$(QR_TARGET)}
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    COMPRESS = gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=$@ $<
    
    CP := ln -f
    
    BOOK != basename "$(shell pwd)"
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    TITLE != head -1 README.md | tail -c+3 | tr ' ' '_'
    LOCAL_DROSS := rubbish
    DROSS = ../$(LOCAL_DROSS)
    DBOOK = $(DROSS)/$(BOOK).pdf
    COMPILER = latexmk -file-line-error -output-directory=$(DROSS) -pdflua -interaction=nonstopmode -halt-on-error -shell-escape -r config/.latexmkrc -jobname=$(BOOK)
    RELEASE = $(TITLE).pdf
    GLOS := makeglossaries -d $(DROSS)
    RUN := lualatex -output-directory $(DROSS) -shell-escape
    
    targets += check
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    .PHONY: book
    book: $(RELEASE) ## Compile the pdf
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    $(RELEASE): $(DBOOK)
    	@$(CP) $< $@
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    targets += $(RELEASE)
    
    
    .PHONY: LOCTEX
    LOCTEX: $(wildcard *.tex)
    
    .PHONY: HANDOUTS
    HANDOUTS: config/CS.tex config/booklet.tex config/fold_front.tex config/fold_back.tex
    
    .PHONY: STYLE_FILES
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    STYLE_FILES: $(wildcard config/*.sty)
    
    
    .PHONY: EXTERNAL
    EXTERNAL: $(wildcard $(DROSS)/*.glg) | $(DROSS)
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    qr.tex: README.md config/vars
    
    	@printf '%s' '\qrcode[height=.2\textwidth]{$(QR_TARGET)}' > qr.tex
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    .switch-gls:
    	@touch .switch-gls
    
    
    output += qr.tex .switch-gls svg-inkscape
    
    
    images/extracted/:
    	mkdir -p $@
    	echo '*' > $@.gitignore
    images/extracted/inclusion.tex: images/extracted/
    
    	printf '%s\n' '\externaldocument{$(BOOK)}' > $@
    
    	printf '%s\n' '\newcommand\bookTitle{$(TITLE)}' | tr '_' ' ' >> $@
    
    output += images/extracted/
    
    
    $(DROSS):
    	mkdir $(DROSS)
    
    
    output += $(DROSS)
    
    
    dependencies = git git-lfs lualatex latexmk inkscape
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    .PHONY: check
    check: ## Check you have the project dependencies
    
    	@$(foreach program, $(dependencies), \
    	command -v $(program) >/dev/null || { echo install $(program) && exit 1 ;} ;)
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    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
    
    Malin Freeborn's avatar
    Malin Freeborn committed
    graph: ## Show a dependency graph (needs graph-easy and make2graph)
    
    	make -Bind $(TARG) | make2graph | graph-easy --boxart
    
    
    print_%.pdf: %.pdf
    
    	pdfjam --landscape --paper a3paper --nup 1x1 --signature 12 $< -o $@
    
    
    output += $(targets)
    
    .PHONY: all
    
    all: ## All standard targets
    	make $(targets)
    
    
    .PHONY: clean
    clean: ## Clean repo, including cross-reference files
    	$(RM) -r $(output)