-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (69 loc) · 2.65 KB
/
Makefile
File metadata and controls
84 lines (69 loc) · 2.65 KB
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
SHELL := bash
.DEFAULT_GOAL := .pdf/apuntes.pdf
.PHONY: limpa descargar_fontes comprobar_fontes
METODO := compile
XERADOS := .pdf/*
# Os nomes das figuras en PDF
#
# $(patsubst pattern,replacement,text)
# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html
FIGURAS_PDF = $(patsubst figuras/typ/%.typ, .pdf/%.pdf, $(wildcard figuras/typ/*.typ))
# Opcions para compilar
OPCIONS := \
--format pdf \
--root . \
--pdf-standard 2.0 \
--diagnostic-format short \
--ignore-system-fonts \
--ignore-embedded-fonts \
--font-path=fontes \
--input rama=$(shell git rev-parse --abbrev-ref HEAD) \
--input hash=$(shell git rev-parse --short HEAD) \
--input dirt=$(shell test -z "$$(git status --porcelain)" && echo "limpo" || echo "sucio") \
--input contribucions=$(shell git rev-list HEAD --count)
OPCIONS_FIGURAS := \
--format pdf \
--root . \
--pdf-standard 2.0 \
--diagnostic-format short \
--ignore-system-fonts \
--ignore-embedded-fonts \
--font-path=fontes \
# Hai que asegurarse de que existe o directorio .pdf
$(shell if [ ! -d ".pdf" ]; then mkdir .pdf; fi)
# Xeramos os apuntes
#
# Esto é pa que Make non borre os PDF se o quito con CTRL-C
.PRECIOUS: .pdf/apuntes.pdf $(FIGURAS_PDF)
.pdf/apuntes.pdf: apuntes.typ funcions/* $(wildcard capitulos/*.typ) $(FIGURAS_PDF)
@echo -e "\nCompilando apuntes...\n"
typst $(METODO) \
$(OPCIONS) \
apuntes.typ .pdf/apuntes.pdf
# Xerar as figuras
#
# https://www.gnu.org/software/make/manual/html_node/Static-Usage.html#index-_0025_002c-quoting-in-static-pattern
# 4.12.1 Syntax of Static Pattern Rules
# targets …: target-pattern: prereq-patterns …
#
# $@ -> target, e.g. .pdf/figura1.pdf
# $^ -> prereq, e.g. figuras/typ/figura.typ
# :FACER: non podo poñer funcions/figuras.typ como prerequisito..
$(FIGURAS_PDF): .pdf/%.pdf: figuras/typ/%.typ
@echo -e "\nCompilando figuras...\n"
typst compile \
$(OPCIONS_FIGURAS) \
$^ $@
descargar_fontes:
$(shell if [ ! -d "fontes/NewCM" ]; then mkdir -p fontes/NewCM; fi)
$(shell if [ ! -d "fontes/SymbolsNerdFont" ]; then mkdir -p fontes/SymbolsNerdFont; fi)
# Descargando e descomprimindo fontes
wget -O fontes/NewCM.txz https://download.gnu.org.ua/release/newcm/newcm-7.0.4.txz
tar -xvf fontes/NewCM.txz -C fontes/NewCM
wget -O fontes/SymbolsNerdFont.zip https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/NerdFontsSymbolsOnly.zip
unzip fontes/SymbolsNerdFont.zip -d fontes/SymbolsNerdFont
comprobar_fontes:
# comprobar as rutas
typst fonts --ignore-system-fonts --ignore-embedded-fonts --font-path=fontes --variants
limpa:
rm -rf $(XERADOS)