forked from nrnrnr/qc--
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoweb.mk
98 lines (81 loc) · 2.53 KB
/
noweb.mk
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
#
# Rules for Noweb and HTML
#
# Free variables this codes relies on. They must be defined where this
# code in included.
#
# TOP - path to top level directory (with INSTALL)
# INTERP - residualizing | evaluating
<$TOP/config/latex.mk
NOWEAVE = noweave
NOTANGLE = nofake
NOTANGLE = notangle
CPIF = cpif
# at need, mk CPIF='cp /dev/stdin'
LINE = '# %L "%F"%N'
NOCOND = $TOP/config/nocond $INTERP
OCAMLDEFS = $TOP/config/autodefs.ocaml
NOPOLY = $TOP/src/nopoly.nw
#
# general rules to extract code from noweb files
#
$B&.ml:D: &.nw
{ cat $NOPOLY; $NOTANGLE -L"$LINE" -filter "$NOCOND" -R$stem.ml $prereq; } \
> $target
$B&.mli:D: &.nw
$NOTANGLE -L"$LINE" -filter "$NOCOND" -R$stem.mli $prereq | $CPIF $target
$B&.c:D: &.nw
$NOTANGLE -L -R$stem.c $prereq > $target
%.view:D: %.nw
$NOTANGLE -R$target $prereq > $target
%.asdl:D: %.nw
$NOTANGLE -R$target $prereq | $CPIF $target
# Generate a self-contained LaTeX document from a LaTeX file that
# is supposed to be read by \input from a master LaTeX file. This rule
# allows to specify extra packages like tabularx to be included.
# A file can specify additional lines in the preamble by including
# a formal comment of the following form:
# % inc: <text to be included>
# For example
# % inc: \usepackage{grammar}
# The % sign must be in column 1.
# The here-document ended by EOF relies on a single TAB character at
# the beginning of a line - so don't substitute spaces for it .
NOWEBBREAKCODE=no
%.tex:QD: %.inc
echo "Building $target from $prereq" 1>&2
(tr '\n' ' ' <<EOF
\documentclass{article}
\usepackage{tabularx,array}
\usepackage[hypertex]{hyperref}
\usepackage{path}
\usepackage[dvips]{graphicx}
\usepackage{noweb}
\noweboptions{smallcode,shift}
`if [ $NOWEBBREAKCODE = yes ]; then echo '\noweboptions{breakcode}'; fi`
\input{$TOP/config/macros.tex}
\usepackage[round,sectionbib]{natbib}
EOF
awk '/^% *inc: */ { $1 = ""; $2 = ""; printf "%s ", $0 }' $stem.inc
tr '\n' ' ' <<EOF
\begin{document}
\pagestyle{noweb}
\nwfilename{$stem.nw}
\tableofcontents
\nwbegindocs{}
EOF
cat $stem.inc
tr '\n' ' ' <<EOF
\bibliographystyle{plainnat}
\bibliography{../doc/qc--}
\end{document}
EOF
) > $target
%.inc:D: %.nw
$NOWEAVE -delay -filter $OCAMLDEFS -index $prereq > $target
# next is for interface only
%.int:D: %.nw
$NOWEAVE -delay -filter $OCAMLDEFS -index $prereq > $target
%.html:D: %.nw
cat $TOP/config/macros.tex $prereq |
$NOWEAVE -delay -filter $OCAMLDEFS -index -html -filter l2h - > $target