Makefile 1.12 KB
Newer Older
1
2
3
4
BASENAME = demo
BUILDDIR = build

# Environment
5
TEXDIRS = resources/tex:resources/latex-sty:resources/listings:resources/latex:resources/images:resources/tables:resources/latex:resources/figures
6
BIBDIRS = resources/latex/
7
BSTDIR  = resources/latex-bst/
8
9

# cf. latexmkrc
10
LATEXMKS = export TARGET=$(basename $(notdir $1)).pdf && $(call LATEXMK, $(basename $1)$2)
11
12
LATEXMK  = latexmk $1
VIEWER   = xdg-open
13

14
# main targets
15
all:       $(BASENAME).build
16
17
view:      $(BASENAME).view
preview:   $(BASENAME).preview
18
19
clean:     $(BASENAME).clean
distclean: $(BASENAME).distclean
20

21
# dynamic targets
22
23
%.build:
	$(call LATEXMKS, $@, )
24

25
%.view:
26
	$(call LATEXMKS, $@, -pv)
27

28
%.preview:
29
	$(call LATEXMKS, $@, -pvc)
30

31
32
%.clean:
	$(call LATEXMKS, $@, -c)
33

34
35
%.distclean:
	$(call LATEXMKS, $@, -C)
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

%/:
	mkdir -p $@

.PHONY: all clean distclean .FORCE

# Export all variables by default
.EXPORT_ALL_VARIABLES:
TEXINPUTS := :.:$(TEXDIRS)
# bibtex invoked from BUILDDIR, thus prepend './../'
BSTINPUTS := ./../$(BSTDIR)
BIBINPUTS := :.:./../$(BIBDIRS)

# Disable implicit suffix and built-in rules (for performance and profit)
.SUFFIXES:
MAKEFLAGS += --no-builtin-rules