-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
98 lines (72 loc) · 2.59 KB
/
Makefile
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#=============================================================================
# Project related variables
CV_BASENAME = MPinard_CV
CV_VERSIONS = FR FR_QC EN_US
HTML_ZOOM = 1.3
#=============================================================================
# Commands variables
LATEX_COMPILER_CMD = latexmk -g -bibtex -lualatex -silent
PDF_TO_HTML_CMD = pdf2htmlEX --process-outline 0 --zoom $(HTML_ZOOM)
DISPLAY = printf
RM = rm -f
#=============================================================================
# Other
TO_DELETE_EXT = .aux .bbl .bcf .blg .run.xml .fdb_latexmk .fls .log .out .synctex.gz .pdf .html
LATEX_COMPILER_SILENT = 1>/dev/null 2>/dev/null
PDF_TO_HTML_CMD_SILENT = 1>/dev/null 2>/dev/null
#=============================================================================
# Automatic variables
TARGETS = $(addprefix $(CV_BASENAME)_,$(CV_VERSIONS))
HTML_TARGETS = $(addsuffix .pdf,$(TARGETS))
PDF_TARGETS = $(addsuffix .html,$(TARGETS))
TO_DELETE = $(foreach ext,$(TO_DELETE_EXT),$(foreach target,$(TARGETS),$(target)$(ext)))
#=============================================================================
# Functions
define launch_latex_compiler
@$(DISPLAY) "\033[0m\033[1;34m>\033[0m Executing $(LATEX_COMPILER_CMD)\n"
$(LATEX_COMPILER_CMD) $(1) $(if $(SILENT), $(LATEX_COMPILER_SILENT))
endef
define launch_pdf_to_html
@$(DISPLAY) "\033[0m\033[1;34m>\033[0m Executing $(PDF_TO_HTML_CMD)\n"
$(PDF_TO_HTML_CMD) $(1) $(if $(SILENT), $(PDF_TO_HTML_CMD_SILENT))
endef
define remove_file
$(if $(wildcard $(1)), \
@$(DISPLAY) "\033[0m\033[1;34m>\033[0m Removing file $(1)\n", \
)
@$(RM) $(1)
endef
define clean_document
@$(DISPLAY) "\nClean of \033[0;33m$(1)\033[0m:\n"
$(foreach ext, $(TO_DELETE_EXT), \
$(call remove_file,$(1)$(ext)) \
) \
endef
#=============================================================================
# Rules
.PHONY: silent
silent:
@make --silent all SILENT=true
.PHONY: all
all: $(PDF_TARGETS) $(HTML_TARGETS)
@$(DISPLAY) "\n\n"
.PHONY: pdf
pdf: $(PDF_TARGETS)
@$(DISPLAY) "\n\n"
.PHONY: html
html: $(HTML_TARGETS)
@$(DISPLAY) "\n\n"
%.pdf: %.tex FORCE
$(eval DOCUMENT_NAME:=$(patsubst %.pdf,%,$@))
@$(DISPLAY) "\nBuilding \033[0;33m$@\033[0m:\n"
$(call launch_latex_compiler, $(DOCUMENT_NAME))
%.html: %.pdf
@$(DISPLAY) "\nBuilding \033[0;33m$@\033[0m:\n"
$(call launch_pdf_to_html, $^)
.PHONY: clean
clean:
$(foreach target, $(TARGETS), \
$(call clean_document, $(target)) \
)
@$(DISPLAY) "\n"
FORCE: