summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/familytree/cmd.mk
blob: 9c259d2dc53b9d51c972138c42a9dd323e2bf04c (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

Lo =
LATEX ?= latex
define Latex # texsrc
	tmp=/tmp/$${$$}; \
	rc=0; \
	{ \
	${LATEX} \
		-halt-on-error -interaction=nonstopmode \
		-no-mktex tfm -file-line-error \
		-output-directory ${Dir} \
		${Lo}'\input' ${1} > $${tmp} ||\
		{ rc=$${?}; tail -20 $${tmp}; }; \
	${RM} $${tmp}; \
	test $${rc} -eq 0; \
	}
endef

TEXINPUTS := ${Dir}:${TEXINPUTS}
export TEXINPUTS
DVIPDFMX ?= dvipdfmx -q -f erewhon.map -f newtx.map -f Chivo.map
PDFCROP ?= pdfcrop --noverbose

define MakePdf
	$(call Latex, ${1}.${2})
	$(call Latex, ${1}.${2})
	cd ${Dir}; \
	${DVIPDFMX} -o ${1}.pdf ${1}.dvi
	ls -l ${Dir}/${1}.pdf
endef

define MakeFigPdf # tgtname texname
	$(call Latex, ${2}.tex) && \
	cd ${Dir} && \
	${DVIPDFMX} ${2}.dvi && \
	${PDFCROP} ${2}.pdf $@ && \
	mv ${2}.dvi ${1}.dvi
endef

define MakePrintTex # src
	grep -v '^%[^%]' ${1} |\
	tr '\n' '\r' |\
	sed -e 's/^\r\r*//' -e 's/\r\r*$$/\r/' |\
	tr '\r' '\n'
endef