summaryrefslogtreecommitdiff
path: root/Makefile
blob: 9b8b7119f6e546cfb14010f9e0aebcea448ea33f (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
# See COPYING file for copyright, license and warranty details.

SITENAME=http://njw.me.uk
FOAF=http://njw.me.uk/card\#i
MD=smu
MDTEX=/home/nick/src/misc/smu/smu

RSS=index.ttl
BIB=writing/index.ttl
BIBTXT=writing/index.txt
PAGES=$(shell find . -name '*.txt' ! -name 'robots.txt' ! -name $(RSS)) $(BIBTXT)
WRITING=$(shell find ./writing/ -name '*.txt' ! -name 'index.*')
EXTRAS=$(shell find . -name '*.css') card.ttl
TARGETS=$(PAGES:.txt=.html) $(RSS) $(BIBTXT)
GZIP=$(PAGES:=.gz) $(TARGETS:=.gz) $(EXTRAS:=.gz) $(BIB:=.gz)

all: $(TARGETS) $(GZIP)

$(TARGETS): includes/header.xml includes/footer.xml
$(PUBS:.txt=.tex): includes/header.tex includes/footer.tex

.txt.html:
	echo making $@
	sed "s/TITLE/`head -n 1 < $<`/" < includes/header.xml > $@
	$(MD) $< >> $@
	sed "s/MODDATE/`stat -c %y $<|awk '{print $$1}'`/" < includes/footer.xml >> $@

# TODO: clean up sed here
.txt.tex:
	echo making $@
	sed -e "s/TITLE/`head -n 1 < $<`/" -e "s/AUTHOR/`head -n 4 < $< |tail -n 1|sed 's/#//g'`/" -e "s/DATE/`head -n 5 < $< |tail -n 1|sed 's/#//g'`/" < includes/header.tex > $@
	$(MDTEX) $< >> $@
	cat includes/footer.tex >> $@

.tex.pdf:
	echo making $@
	pdflatex -output-directory $(shell dirname $<) $*.tex
	rm $*.aux $*.log $*.out

# not POSIX compatible
%.gz: %
	echo compressing $<
	gzip < $< > $@

$(RSS): $(PAGES)
	echo making $@
	sh makerss.sh $(SITENAME) $(FOAF) $* > $@

writing/index.txt: $(BIB) $(WRITING)
	echo making $@
	cat includes/writingheader.txt > $@
	sh bibtotxt.sh $(BIB) >> $@
	sh listarticles.sh writing $(BIB) >> $@

index.html: index.txt
	echo making $@
	sed "s/TITLE/`head -n 1 < $<`/" < includes/header.xml > $@
	$(MD) $< | sed 's/<p><a href="software/<p style="text-align:center"><a href="software/' >> $@
	sed '2d' < includes/footer.xml >> $@

clean:
	rm -f -- $(TARGETS) $(GZIP)

test:
	sh ../../tests/spelling.sh $(PAGES)

.SUFFIXES: .txt .xml .html .rdf .pdf .tex .gz
.SILENT:
.PHONY: all clean test