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
|
DOCDIR=../dist/doc
PANDOC=pandoc
PDFLATEX=pdflatex
# List text files in the order in which you want them to appear in the
# complete manual:
SOURCES=README.mdwn INSTALL.mdwn themes.mdwn hacking.mdwn TODO.mdwn modules.mdwn scripts.mdwn faq.mdwn COPYING.mdwn colophon.mdwn
OTHER=
TODO_SOURCES=$(patsubst TODO.mdwn,,$(SOURCES))
MAN_SOURCES=$(patsubst COPYING.mdwn,copyright_notice00,$(SOURCES))
NEWLINE_SOURCES=$(patsubst %,% oneline.txt,$(SOURCES))
NEWLINE_MAN_SOURCES=$(patsubst %,% oneline.txt,$(MAN_SOURCES))
HTML=plinth.html $(patsubst %.mdwn,%.html,$(SOURCES))
HTML_PART=$(patsubst %.html,%.part.html,$(HTML))
LATEX=plinth.tex $(patsubst %.mdwn,%.tex,$(SOURCES))
PDF=plinth.pdf $(patsubst %.mdwn,%.pdf,$(SOURCES))
MAN=plinth.1
## If you want PDF or Latex files, do them separately. They're not made by default.
OUTPUTS=$(HTML) $(MAN) $(HTML_PART)
DIST_OUTPUT=$(patsubst %,$(DOCDIR)/%,$(OUTPUTS))
# Yes, do it twice. TODO created during the process requires a second run
default:
make all
all: oneline.txt $(OUTPUTS) Makefile
$(DOCDIR)/%: %
cp $< $@
dist: $(DIST_OUTPUT)
###############################################################################
oneline.txt: Makefile
perl -e 'print "\n"' > oneline.txt
$(SOURCES):
@rm -f $@
@ln -s ../$(patsubst %.mdwn,%,$@) $@
../TODO : $(TODO_SOURCES) ../*.py ../modules/*.py ../Makefile Makefile ../templates/Makefile
grep -ro --exclude=.git* --exclude=plinth.1 --exclude=*.tex --exclude=*.html \
--exclude=README.mdwn --exclude=INSTALL.mdwn \
--exclude=TODO.mdwn --exclude=COPYING.mdwn \
"TODO\:.*" ../* 2>/dev/null | \
sed -e "s/TODO\://g" | \
sed -e "s/^..\//* /g" | \
sed -e 's/"""$$//g' | \
sed -e 's/<\/p>$$//g' \
> ../TODO
###############################################################################
##
## MAN PAGES
##
$(MAN): $(SOURCES) ../TODO
@csplit -s -f copyright_notice COPYING.mdwn '/##/'
cat $(NEWLINE_MAN_SOURCES) | perl -pe 'BEGIN { $$/=undef } $$_ =~ s/\n\n#\s.*/\n/gm; $$_ =~ s/\n\n#/\n\n/gm; $$_ =~ s/(\n\n#\s.*)/uc($$1)/gme' > .make_man
$(PANDOC) -s -t man -o $@ .make_man
@rm -f copyright_notice0? .make_man
manpages: $(MAN)
###############################################################################
##
## LaTeX
##
%.tex: %.mdwn
$(PANDOC) -s --toc -f markdown --standalone -o $@ $<
hacking.tex: hacking.mdwn ../TODO
$(PANDOC) -s --toc -f markdown -o $@ hacking.mdwn ../TODO
plinth.tex: $(NEWLINE_SOURCES) ../TODO
$(PANDOC) -s --toc -f markdown -o $@ $(NEWLINE_SOURCES)
latex: $(LATEX)
###############################################################################
##
## HTML
##
# This gets us the html sections complete with TOC, but without the
# HTML and head section boilerplate. /help/view uses the parts.
%.part.html: %.html
csplit -s -f $@ $< '%.*<body>%'
sed '1d' $@00 > $@01
csplit -s -f $@ $@01 '/<\/body>/'
mv $@00 $@
rm $@01
%.html: %.mdwn header.html footer.html style.css Makefile
$(PANDOC) -s --toc -c style.css -f markdown -o $@ header.html $< footer.html
hacking.html: hacking.mdwn ../TODO style.css Makefile
$(PANDOC) -s --toc -c style.css -o $@ -f markdown hacking.mdwn ../TODO
#plinth.html: $(NEWLINE_SOURCES) ../TODO style.css Makefile
# $(PANDOC) -s --toc -c style.css -o $@ -f markdown $(NEWLINE_SOURCES)
plinth.html: $(NEWLINE_SOURCES) ../TODO style.css Makefile
@csplit -s -f copyright_notice COPYING.mdwn '/##/'
$(PANDOC) -s --toc -c style.css -o $@ -f markdown $(NEWLINE_MAN_SOURCES)
@rm -f copyright_notice0? .make_man
html: $(HTML) $(HTML_PART)
###############################################################################
%.pdf: %.tex
$(PDFLATEX) -interaction=batchmode $< >/dev/null
$(PDFLATEX) -interaction=batchmode $< >/dev/null # yes, do it twice so the toc works
pdf: $(PDF)
###############################################################################
clean-latex:
rm -f *.log *.out *.aux *.toc *.tex
clean: clean-latex
rm -f $(OUTPUTS) README.mdwn INSTALL.mdwn TODO.mdwn COPYING.mdwn \
copyright_notice0? \#*\# ../TODO oneline.txt *.pdf
|