forked from egraff/uit-thesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (67 loc) · 2.26 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
NAME = uit-thesis
# Try to locate user's local texmf tree
ULTTEXMFHOME = $(shell kpsewhich --var-value TEXMFHOME 2>/dev/null)
ULTTEXMFLOCAL = $(shell kpsewhich --var-value TEXMFLOCAL 2>/dev/null)
all: help
help:
@echo "uit-thesis makefile targets:"
@echo " "
@echo " help - (this message)"
@echo " "
@echo " install - install the uit-thesis class into your home texmf tree"
@echo " uninstall - remove the uit-thesis class from your home texmf tree"
define prompt-texmf
@while [ -z "$$CONTINUE" ]; do \
read -r -p "Is this correct? [y/N] " CONTINUE; \
done ; \
if [ $$CONTINUE != "y" ] && [ $$CONTINUE != "Y" ]; then \
echo "Exiting." ; exit 1 ; \
fi
endef
# Try TEXMFHOME first. If TEXMFHOME is defined, it will override ULTTEXMFLOCAL
try-texmf-home: try-texmf-local
ifneq ($(ULTTEXMFHOME),)
ULTTEXMFLOCAL = $(ULTTEXMFHOME)
endif
# If TEXMFHOME is defined, we use it! Else, we try TEXMFLOCAL
try-texmf-local:
# If neither TEXMFHOME nor TEXMFLOCAL is defined
ifeq ($(ULTTEXMFLOCAL),)
@echo -e "Cannot locate your home texmf tree. Specify manually with\n\n make install TEXMF=/path/to/texmf\n"
@exit 1
else
TEXMF = $(ULTTEXMFLOCAL)
endif
ifdef TEXMF
detect-texmf:
else
detect-texmf: try-texmf-home
endif
@echo "Using texmf tree in \"$(TEXMF)\"."
$(prompt-texmf)
ULTTEXMF = $(subst \,/,$(TEXMF))
LATEXROOT = $(ULTTEXMF)/tex/latex/$(NAME)
LOCALLATEXROOT = texmf-tds/tex/latex/$(NAME)
check-texmf: detect-texmf
@test -d "$(ULTTEXMF)" || mkdir -p "$(ULTTEXMF)"
uninstall: check-texmf
$(MAKE) -C ult-base uninstall TEXMF=$(TEXMF) CONTINUE=y
@echo "$(ULTTEXMF)/tex/latex/$(NAME)"
@if [ -d "$(LATEXROOT)" ]; then \
echo "Uninstalling..." ; \
rm -rf "$(LATEXROOT)" ; \
echo "Uninstalled." ; \
echo "You might have to run 'texhash' to update your texmf database." ; \
fi
install: check-texmf uninstall
$(MAKE) -C ult-base install TEXMF=$(TEXMF) CONTINUE=y
@echo "Installing into \"$(LATEXROOT)\"..."
@test -d "$(LATEXROOT)" || mkdir -p "$(LATEXROOT)"
@cp -r -v "$(LOCALLATEXROOT)"/* "$(LATEXROOT)/"
@if [ $$? -ne 0 ]; then \
echo "Failed to copy class files to texmf directory" ; \
exit 1 ; \
fi
@git rev-parse --verify HEAD > "$(LATEXROOT)/REVISION"
@echo "Done."
@echo "You might have to run 'texhash' to update your texmf database." ; \