Makefile 1.87 KB
Newer Older
1
2
include .utils

3
4
BASENAME     = demo
BUILDDIR     = build
5

6
7
8
9
10
11
# environment
TEXDIRS      = resources/tex:resources/latex-sty:resources/listings:resources/latex
TEXDIRS     := $(TEXDIRS):resources/images:resources/tables:resources/latex
TEXDIRS     := $(TEXDIRS):resources/figures
BIBDIRS      = resources/latex/
BSTDIR       = resources/latex-bst/
12
13

# cf. latexmkrc
14
LATEXMK      = latexmk $(OPTS)$1 | fold -sw $(out_length)
15
VIEWER       = xdg-open
16

17
18
LATEXMK_COND = @export DEPSFILE=$(notdir $(basename $(TARGET))) &&                                  \
               $(if $(strip $(TARGET)),                                                             \
19
                 $(call LATEXMK, $(basename $(TARGET).tex )$1),                                          \
20
                 $(call LATEXMK, $(BASENAME)$1)                                                     \
21
               && echo $(INSTRUCTIONS))
22

23
24
25
26
LATEXMK_ERRS = $(if $(strip $1),                                                                    \
                 $(call LOG, $(BUILDDIR)/$(basename $1).log),                                       \
                 $(call LOG, $(BUILDDIR)/$(basename $(BASENAME)).log)                               \
               )
27

28
all: build
29

30
31
build: setup
	$(call LATEXMK_COND, )
32

33
log: setup
34
	$(call LATEXMK_ERRS, $(TARGET))
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
view: setup
	$(call LATEXMK_COND, -pv)

preview: setup
	$(call LATEXMK_COND, -pvc)

clean: setup
	$(call LATEXMK_COND, -c)

distclean: setup
	$(call LATEXMK_COND, -C)

help:
	@echo $(INSTRUCTIONS)
50
51
52
53

%/:
	mkdir -p $@

54
55
setup: .FORCE | $(BUILDDIR)/

56
57
.PHONY: all clean distclean .FORCE

58
# export all variables by default
59
60
61
62
63
64
.EXPORT_ALL_VARIABLES:
TEXINPUTS := :.:$(TEXDIRS)
# bibtex invoked from BUILDDIR, thus prepend './../'
BSTINPUTS := ./../$(BSTDIR)
BIBINPUTS := :.:./../$(BIBDIRS)

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