-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
95 lines (80 loc) · 3.54 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
NAME = ult-base
# 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 "ult-base makefile targets:"
@echo " "
@echo " help - (this message)"
@echo " "
@echo " install - install the ult-base packages into your home texmf tree"
@echo " uninstall - remove the ult-base packages 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
# If the TEXMF argument is on the kpathsea form {dir1:dir2:dir3} or {dir1;dir2;dir3} or {dir1,dir2,dir3},
# then select the first directory from the list. Otherwise, use the TEXMF argument verbatim.
define parse-texmf
MULTI_PATHS=$$(echo "$(1)" | sed -n 's/^{\(.*\)}/\1/p') ; \
if [ ! -z "$$MULTI_PATHS" ]; then \
if [ "$(OS)" = "Windows_NT" ]; then \
IFS=';,' ; \
else \
IFS=';:,' ; \
fi ; \
for p in $$MULTI_PATHS; do \
echo "$$p" ; \
break ; \
done ; \
else \
echo "$(1)" ; \
fi
endef
# If TEXMFHOME is defined, we use it! Else, we try TEXMFLOCAL
# (note that if TEXMF has been specified as a command line argument, it takes precedence)
ifneq ($(ULTTEXMFHOME),)
TEXMF = $(shell $(call parse-texmf,$(ULTTEXMFHOME)))
else ifneq ($(ULTTEXMFLOCAL),)
TEXMF = $(shell $(call parse-texmf,$(ULTTEXMFLOCAL)))
endif
check-texmf:
ifeq ($(strip $(TEXMF)),)
@echo "Cannot locate your home texmf tree. Specify manually with"
@echo " "
@echo " make install TEXMF=/path/to/texmf"
@echo " "
@exit 1
endif
detect-texmf: check-texmf
@echo "Using texmf tree in \"$(TEXMF)\"."
@$(prompt-texmf)
ULTTEXMF = $(subst \,/,$(TEXMF))
LATEXROOT = $(ULTTEXMF)/tex/latex/$(NAME)
LOCALLATEXROOT = texmf-tds/tex/latex/$(NAME)
ensure-texmf-exists: detect-texmf
@test -d "$(ULTTEXMF)" || mkdir -p "$(ULTTEXMF)"
uninstall: ensure-texmf-exists
@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: ensure-texmf-exists uninstall
@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." ; \