phd-thesis/manuscrit/Makefile

59 lines
1.4 KiB
Makefile

# Latexmk is configured in .latexmkrc
BUILD_DIR=build
AUX_DIR=$(BUILD_DIR)/aux
CLEANED_MAIN=$(BUILD_DIR)/these.pdf
CLEANED_PRINTOUT=$(BUILD_DIR)/these-printout.pdf
CLEANED_PDFS=$(CLEANED_MAIN) $(CLEANED_PRINTOUT)
MAIN_PDF=$(BUILD_DIR)/main.pdf
PRINTOUT_PDF=$(BUILD_DIR)/main-printout.pdf
ALL=$(CLEANED_PDFS)
REV_FILE=$(BUILD_DIR)/version
TITLE_EN=$(shell cat meta/title-en.txt)
all: _setup $(ALL)
.PHONY: _setup
_setup:
for dir in $$(find . -name '*.tex' -and -not -path './$(BUILD_DIR)/*'); do \
mkdir -p "$(AUX_DIR)/$$(dirname "$$dir")"; \
done
$(CLEANED_MAIN): $(MAIN_PDF)
$(CLEANED_PRINTOUT): $(PRINTOUT_PDF)
$(CLEANED_PDFS):
qpdf "$<" --linearize "$@"
exiftool -all:all= \
-Version="$(shell bin/version.sh)" \
-Author="Théophile Bastian" \
-Title="$(TITLE_EN)" \
"$@"
@ pdffonts "$@" | grep -q ' no' && echo -e "\033[0;1;31mSOME FONTS NOT EMBEDDED\033[0m" || true
@ !(pdffonts "$@" | grep -q ' no')
.PHONY: $(MAIN_PDF) # hack-ish: latexmk knows better when to run.
$(MAIN_PDF): assets $(REV_FILE)
latexmk $($(notdir $@):.pdf=.tex)
.PHONY: $(PRINTOUT_PDF)
$(PRINTOUT_PDF): assets $(REV_FILE)
latexmk $($(notdir $@):.pdf=.tex)
.PHONY: assets
assets:
$(MAKE) -C "$@"
.PHONY: $(REV_FILE) # not costly: just always run it.
$(REV_FILE):
./bin/version.sh > "$@"
clean:
latexmk -C
fullclean:
rm -rf $(BUILD_DIR)
upload: $(CLEANED_MAIN)
scp $< www.tobast:~/files/phd_manuscript.pdf