aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ce3a1fa4ada552f3b1ef30473a1a88bd11ba88a2 (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
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 $@

# 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))
	texhash $(TEXMF)

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

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

uninstall:
	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 test clean
	rm -f tmp.sty
	rm -f *.aux *.hd *.log *.out
	rm -f *.dtx *.ins *.pdf *.sty
	rm -f *~ tex/*~ doc/*~