aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: e6dff0bd55fd87bfa6230493d35e2856a0fe9023 (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
PKG = fripost
SRC = fripost acronyms attendants
AUTHOR = Fripost
LICENSE = gpl

.PHONY: all test install

DTX = $(addsuffix .dtx, $(PKG))
INS = $(addsuffix .ins, $(PKG))
PDF = $(addsuffix .pdf, $(PKG))
STY = $(addsuffix .sty, $(PKG))

all: $(DTX) $(INS) $(PDF) $(STY)

# Generate package using makedtx and pdflatex

$(DTX) $(INS): doc/$(PKG).tex tmp.sty
	makedtx -author "$(AUTHOR)" -license $(LICENSE) \
	   -src "tmp\.sty=>$(STY)" -doc $< $(PKG)

tmp.sty: $(addprefix tex/, $(addsuffix .sty, $(SRC)))
	cat $^ > $@

# Testing

test:
	make -C $@ clean
	make -C $@
	make -C pandoc $@

# Compilation for installation

%.sty: %.ins %.dtx
	pdflatex $<

%.pdf: %.dtx %.ins
	pdflatex $<

# Installation

TEXMF ?= $(HOME)/texmf
DST_STY := $(TEXMF)/tex/latex/$(PKG)
DST_PDF := $(TEXMF)/doc

install: \
  $(addprefix $(DST_STY)/, $(STY)) \
  $(addprefix $(DST_PDF)/, $(PDF))
	make -C pandoc $@

$(DST_STY)/%.sty: %.sty
	mkdir -p $(dir $@)
	cp $< $@
	texhash $(TEXMF)

$(DST_PDF)/%.pdf: %.pdf
	mkdir -p $(dir $@)
	cp $< $@
	texhash $(TEXMF)

uninstall:
	make -C pandoc $@
	rm -f $(DST_STY)/* $(DST_PDF)/$(PKG).pdf
	texhash $(TEXMF)
	rmdir --ignore-fail-on-non-empty -p $(DST_STY) $(DST_PDF)

# Clean

clean:
	make -C pandoc $@
	make -C test $@
	rm -f tmp.sty
	rm -f *.aux *.hd *.log *.out
	rm -f *.dtx *.ins *.pdf *.sty
	rm -f *~ tex/*~ doc/*~