-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
101 lines (80 loc) · 2.65 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
96
97
98
99
100
101
PROJECT:=draftfigure
SHELL = zsh
MAKE = make
CTANBIB = $(PROJECT)-ctan.bib
PKG = $(shell cat $(PROJECT).pkglist)
CTAN = ctanbib $$pkg >> $(CTANBIB) && echo "... $$pkg"
# install
LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL)
# zip
PWD = $(shell pwd)
TEMP := $(shell mktemp -d -t tmp.XXXXXXXXXX)
TDIR = $(TEMP)/$(PROJECT)
VERS = $(shell /bin/date "+%Y-%m-%d---%H-%M-%S")
DATE = $(shell /bin/date "+%Y-%m-%d")
# Colors
RED = \033[0;31m
CYAN = \033[0;36m
NC = \033[0m
echoPROJECT = @echo -e "$(CYAN) <$(PROJECT)>$(RED)"
.PHONY: test
all: doc
# How to get information from CTAN
CTAN: $(PROJECT).pkglist
@for pkg in $(PKG);\
do \
$(CTAN); \
done
# before we retrieve infos from CTAN
# we clean and sort the list with packages
getCTAN: $(PROJECT).pkglist
$(echoPROJECT) "$(RED)Retrieving$(NC) information from CTAN."
$(echoPROJECT) "Fetching information from CTAN about package...$(NC)"
@-rm $(CTANBIB)
$(shell sort -u $(PROJECT).pkglist > $(TEMP)/pkg1.lst)
mv $(TEMP)/pkg1.lst $(PROJECT).pkglist
$(MAKE) CTAN
$(PROJECT).pkglist:
lualatex $(PROJECT).dtx
$(PROJECT).ins:
lualatex $(PROJECT).dtx
doc:
latexmk -lualatex $(PROJECT).dtx
$(echoPROJECT) "* $(PROJECT).pdf created * $(NC)"
@exit 0
$(PROJECT).pdf: getCTAN
$(echoPROJECT) "* creating $(PROJECT).pdf * $(NC)"
latexmk -lualatex $(PROJECT).dtx
$(echoPROJECT) "* $(PROJECT).pdf created * $(NC)"
# clean all temporary files
clean:
rm -f $(PROJECT).{sectionbibs.aux,fls,pkglist,thm,bibexample,biographies.aux,xdv,aux,mw,bbl,bcf,blg,doc,fdb_latexmk,fls,glo,gls,hd,idx,ilg,ind,listing,log,nav,out,run.xml,snm,synctex.gz,toc,vrb}
rm -f $(PROJECT).markdown.{in,lua,out}
rm -f *.{log,aux,latexmk}
rm -rf _markdown_*
$(echoPROJECT) "* cleaned temp files * $(NC)"
ctan: $(PROJECT).dtx doc
$(echoPROJECT) "* start zipping files * $(NC)"
@-mkdir archive
@-rm -f archive/$(PROJECT)-$(DATE)*.zip
@mkdir $(TDIR)
@cp $(PROJECT).{dtx,pdf} *.md makefile $(TDIR)
@cd $(TEMP); \
zip -Drq $(PWD)/archive/$(PROJECT)-$(VERS).zip $(PROJECT)
$(echoPROJECT) "* files zipped * $(NC)"
# clean all files
cleanbundle: clean
rm -f *.{ins,pdf,zip,bib,sty,cls}
$(echoPROJECT) "* cleaned all files * $(NC)"
install: uninstall
@mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(PROJECT)
@cp $(PROJECT).{dtx,ins} $(LOCAL)/source/latex/$(PROJECT)
@cp rwth-*.cls $(LOCAL)/tex/latex/$(PROJECT)
@cp img/* $(LOCAL)/tex/latex/$(PROJECT)
@cp $(PROJECT).pdf $(LOCAL)/doc/latex/$(PROJECT)
mktexlsr
$(echoPROJECT) "* all files installed * $(NC)"
uninstall:
@rm -rf $(LOCAL)/{tex,source,doc}/latex/$(PROJECT)
@rm -rf $(LOCAL)/{tex/latex,bibtex/bib}/$(PROJECT)
$(echoPROJECT) "* all files uninstalled * $(NC)"