summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/hu-berlin-bundle/makefile
blob: 9b1f7675bb0ceebcc0ab123b0f2a6af96097b8a6 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
PROJECT:=hu-berlin-bundle
SHELL = bash
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



examples: files
	$(MAKE) letter
	$(MAKE) md2pdf-letter

md2pdf-letter: files
	pandoc --pdf-engine=lualatex --template hu-berlin-letter-template.latex -o hu-berlin-letter-markdown.pdf hu-berlin-letter.md

letter: files
	latexmk -lualatex  -interaction=nonstopmode hu-berlin-letter.tex

# 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

files: $(PROJECT).ins
	latex $(PROJECT).ins
	$(echoPROJECT) "* source files created * $(NC)"

$(PROJECT).ins:
	latex $(PROJECT).dtx

doc: files
	$(MAKE) $(PROJECT).pdf
	# $(MAKE) install
	$(MAKE) examples
	latexmk -lualatex -f --shell-escape  $(PROJECT).dtx
	$(echoPROJECT) "* $(PROJECT).pdf created * $(NC)"
	@exit 0

$(PROJECT).pdf: getCTAN files
	$(echoPROJECT) "* creating $(PROJECT).pdf * $(NC)"
	latexmk -lualatex -f --shell-escape  $(PROJECT).dtx
	open $(PROJECT).pdf
	$(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
	$(echoPROJECT) "* start zipping files * $(NC)"
	@-mkdir archive
	@rm -f archive/$(PROJECT)-$(DATE)*.zip
	@mkdir $(TDIR)
	@cp $(PROJECT).{dtx,pdf} README.md makefile $(TDIR)
	@cp -R img $(TDIR)
	@cd $(TEMP); \
   zip -Drq $(PWD)/archive/$(PROJECT)-$(VERS).zip $(PROJECT)
	$(echoPROJECT) "* files zipped * $(NC)"


# clean all files
cleanbundle: clean
	rm -f *.{{b,c,d,l}bx,ins,pdf,zip,bib,sty,cls}
	rm -f hu-berlin-letter*.{tex,md,lco,latex}
	$(echoPROJECT) "* cleaned all files * $(NC)"


install: uninstall
	@mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(PROJECT)
	@cp $(PROJECT).{dtx,ins} $(LOCAL)/source/latex/$(PROJECT)
	@cp hu-berlin-*.cls $(LOCAL)/tex/latex/$(PROJECT)
	@cp img/* $(LOCAL)/tex/latex/$(PROJECT)
	@cp $(PROJECT).pdf $(LOCAL)/doc/latex/$(PROJECT)
	mktexlsr
	@cp hu-berlin-*-template.* ~/.pandoc/templates/
	$(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)"