-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
317 lines (280 loc) · 12.3 KB
/
Makefile
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#
# ICDEVGROUP Documentation Makefile
# http://www.icdevgroup.org
# http://git.icdevgroup.org/?p=xmldocs.git;a=summary
#
# Davor Ocelic, [email protected]
#
# Those two need to be adjusted with time
export XMLDOCS_CUR_DEVEL = 5.7.0
IC_VERSIONS = 4.6.0 4.8.0 5.0.0 5.2.0 5.4.0 5.6.0 git-head
#############################################################
# Base definitions
SYMBOL_TYPES= pragmas vars tags confs filters orderchecks widgets
GUIDES = iccattut programming-style upgrade faq index optimization search xmldocs WHATSNEW install databases howtos wellwell
GLOSSARY = glossary
ALL_DOCS = $(GLOSSARY) $(GUIDES) $(SYMBOL_TYPES)
SHELL = /bin/sh
OUTPUT ?= -std
TARGET ?= $(XMLDOCS_CUR_DEVEL)
PROFILE ?= --stringparam profile.condition standard
PROFILE += --stringparam profile.revision r$(TARGET)
TARGET_RELEASE = --last $(TARGET)
export O = OUTPUT$(OUTPUT)
export T = tmp
export XCF = docbook/catalog.xml
DC = "/etc/xml/catalog"
# XSLT processor-specific
PSR = xsltproc
PSR_FLAGS = --xinclude --nonet
# Scripts and options
REFS_AUTOGEN = bin/refs-autogen
REFS_AUTOGEN_FLAGS ?=
VPATH = guides refs glossary whatsnew
.SILENT:
.PHONY: all complete
.PHONY: skel
.PHONY: guides symbols glossary
#.PHONY: olinkdbs-nc olinks-nc olinkdbs-c olinks-c
.PHONY: clean clean-cache clean-refs distclean look-clean
.PHONY: up-all git-sources srcs gitrcs git gits all-up gitup
.PHONY: up-% git-% %-up %-git
.PHONY: cache caches
.PHONY: refxmls
.PHONY: $O
#############################################################
# Complete build
all: skel cache refxmls \
olinkdbs-nc olinkdbs-c \
glossary symbols guides
chunked: skel cache refxmls olinkdbs-nc olinkdbs-c \
$(foreach doc,$(ALL_DOCS),OUTPUT/$(doc))
nonchunked: skel cache refxmls olinkdbs-nc olinkdbs-c \
$(foreach doc,$(ALL_DOCS),OUTPUT/$(doc).html )
guides: $(foreach doc,$(GUIDES),OUTPUT/$(doc).html ) \
$(foreach doc,$(GUIDES),OUTPUT/$(doc))
symbols: $(foreach doc,$(SYMBOL_TYPES),OUTPUT/$(doc).html ) \
$(foreach doc,$(SYMBOL_TYPES),OUTPUT/$(doc))
glossary: $(foreach doc,$(GLOSSARY),OUTPUT/$(doc).html ) \
$(foreach doc,$(GLOSSARY),OUTPUT/$(doc))
#############################################################
# Skel
skel:
make $T
make $O
make OUTPUT/files OUTPUT/images OUTPUT/xmldocs.css
$T:
if test -e $T.temporary; then \
echo "U $T/"; mv $T.temporary $T; \
else \
echo "C $T/"; mkdir -p $T; fi
$O:
echo "U $O/"
mkdir -p $O
echo "S OUTPUT -> $O/"
rm -f OUTPUT
ln -s $O OUTPUT
OUTPUT/files: $(shell find files) bin/dbgen
echo "C $@/"
rm -rf $@/
cp -Rp files $O/
rm -rf `find $@ -name CVS`
rm -rf `find $@ -name .git`
cp bin/dbgen $O/files/
cd files; for p in *; do \
if test "$$p" != "CVS"; then \
if test "$$p" != ".git"; then \
if test -d "$$p"; then \
cp -Rp $$p ../$O/files/; \
tar --exclude=CVS --exclude=.git -cf ../$O/files/$$p.tar $$p; \
tar --exclude=CVS --exclude=.git -zcf ../$O/files/$$p.tar.gz $$p; \
tar --exclude=CVS --exclude=.git -jcf ../$O/files/$$p.tar.bz2 $$p \
; fi \
; fi \
; fi \
; done
OUTPUT/images: $(shell find images)
echo "C $@/"
rm -rf $@/
cp -Rp images $O/
rm -rf `find $@ -name CVS`
rm -rf `find $@ -name .git`
OUTPUT/xmldocs.css: docbook/xmldocs.css
echo "C $@"
cp $< $@
#############################################################
# OLINK DBs (interlinking between documents)
olinkdbs-nc olinks-nc: $(foreach f,$(ALL_DOCS),$T/$f-nc.db)
$T/%-nc.db: %.xml
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam collect.xref.targets only \
--stringparam targets.filename $@ \
docbook/html-nochunks.xsl $<
perl -ni -e'print unless $$.==1 and /^<!DOCTYPE/' $@
olinkdbs-c olinks-c: $(foreach f,$(ALL_DOCS),$T/$f-c.db)
$T/%-c.db: %.xml
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam collect.xref.targets only \
--stringparam targets.filename $@ \
docbook/html-chunks.xsl $<
perl -ni -e'print unless $$.==1 and /^<!DOCTYPE/' $@
#############################################################
# STANDARD TARGETS || two-pass processing method
#OUTPUT/howtos.html: DEPTH = "--stringparam toc.max.depth 1"
OUTPUT/%.html: %.xml docbook/autorefs.ent docbook/autoglossary.ent docbook/autofiles.ent
echo "C $@"
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-nc.xml \
-o $T/$*-nc.profiled docbook/profile.xsl $<
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-nc.xml \
-o $@ docbook/html-nochunks.xsl $T/$*-nc.profiled
OUTPUT/%: %.xml docbook/autorefs.ent docbook/autoglossary.ent docbook/autofiles.ent
echo "C $@/"
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-c.xml \
-o $T/$*-c.profiled docbook/profile.xsl $<
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-c.xml \
-o $@/ docbook/html-chunks.xsl $T/$*-c.profiled
OUTPUT/%.man: %.xml docbook/autorefs.ent docbook/autoglossary.ent docbook/autofiles.ent docbook/reference.xsl
echo "C $@/"
mkdir -p "$@"
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-nc.xml \
-o $T/$*-c.profiled docbook/profile.xsl $<
$(PSR) $(PSR_FLAGS) \
$(PROFILE) \
--stringparam current.docid $* \
--stringparam target.database.document ../docbook/olinkdb-nc.xml \
-o $@/ docbook/reference.xsl $T/$*-c.profiled
#OUTPUT/%.pdf: tmp/%.latex
# echo "C $@"
# pdflatex $<
#############################################################
# Supporting target - LATEX output
#tmp/%.latex: %.xml docbook/autorefs.ent docbook/autoglossary.ent docbook/autofiles.ent
# $(PSR) $(PSR_FLAGS) \
# $(PROFILE) \
# --stringparam current.docid $* \
# --stringparam target.database.document ../docbook/olinkdb-nc.xml \
# -o $T/$*-nc.profiled docbook/profile.xsl $<
# $(PSR) $(PSR_FLAGS) \
# $(PROFILE) \
# --stringparam current.docid $* \
# --stringparam target.database.document ../docbook/olinkdb-nc.xml \
# --stringparam paper.type A4 \
# --stringparam page.orientation portrait \
# --stringparam double.sided 1 \
# --stringparam chapter.autolabel 0 \
# --stringparam appendix.autolabel 0 \
# --stringparam section.autolabel 0 \
# -o $T/$*.latex docbook/latex.xsl $T/$*-nc.profiled
#############################################################
# Cleaning
clean:
-rm -rf $O OUTPUT
clean-cache:
-rm -f cache/*/.cache.bin 2>/dev/null
clean-refs:
-rm -f refs/*.xml
distclean: clean clean-cache
-rm -rf $T
-rm -rf {refs,glossary}/*.xml
-rm -rf docbook/auto{refs,glossary,files}.ent
look-clean:
-mv $T $T.temporary 2>/dev/null
commit:
make look-clean
git commit
#############################################################
# sources/ directory management
sources:
echo "U $@/"
mkdir -p $@
sources/%: sources $T
bin/coup $(subst sources/,,$@)
up-all git-sources srcs gitrcs git gits all-up gitup: sources $T
for p in $(IC_VERSIONS); do \
bin/coup -u $$p \
; done
up-% git-% %-up %-git: sources/% $T
bin/coup -u $(subst sources/,,$<)
#############################################################
# Cache files
cache caches: $(foreach icver,$(IC_VERSIONS),cache/$(icver)/.cache.bin) $T
cache/%/.cache.bin: sources/% bin/stattree
echo "C $@"
bin/stattree $<
#############################################################
# Reference .xmls
# Silly, rewrite this, I forgot about $*. Or $* wouldn't help? I'm not
# willing to think about it right now.
refxmls: BOTH = --both
refxmls: $(REFS_AUTOGEN) $(foreach stype,$(SYMBOL_TYPES),refs/$(stype).xml) glossary/glossary.xml
:
$T/%.list: BNAME = $(subst $T/,,$@)
refs/%.xml: BNAME = $(subst refs/,,$@)
$T/%.list: FNAME = $(subst .list,,$(BNAME))
refs/%.xml: FNAME = $(subst .xml,,$(BNAME))
# A little 'overwork' here: we regenerate all .xml files even if just
# one file changes.
$T/%.list refs/%.xml: $(foreach icver,$(IC_VERSIONS),cache/$(icver)/.cache.bin) $(shell find refs/ -regex '.+[^(\.xml)]$$') $(REFS_AUTOGEN)
# PEH, -g is useless since tags migrate between tag groups
#$(REFS_AUTOGEN) $(REFS_AUTOGEN_FLAGS) -g $(FNAME) -o $@ $(BOTH) $(IC_VERSIONS)
$(REFS_AUTOGEN) $(REFS_AUTOGEN_FLAGS) -o $@ $(BOTH) $(TARGET_RELEASE) $(IC_VERSIONS)
#############################################################
# One-shot targets
glossary/glossary.xml docbook/autoglossary.ent: $(shell find glossary/ -regex '.+[^(\.xml)]$$') bin/generic-autogen
bin/generic-autogen glossary
docbook/autorefs.ent: refxmls
docbook/autofiles.ent: refxmls
#############################################################
# Infobot IRC bot factoids
files/infobot/interchange.fact facts: refxmls bin/infobot.facts
bin/infobot.facts
#############################################################
# IC source tree stats
guides/stats.xml: guides/stats-template.xml
bin/mkreport
## Helper target, only used by docelic
#colt-preview:
# tar jcf OUTPUT.tar.bz2 OUTPUT
# scp OUTPUT.tar.bz2 colt.projectgamma.com:web/ic/xmldocs/
##
##tmp/olinkdbs: $(LTMPDIR) \
## $(patsubst guides/%.xml,$(LTMPDIR)/%-c.db,$(wildcard guides/*.xml)) \
## $(patsubst guides/%.xml,$(LTMPDIR)/%-nc.db,$(wildcard guides/*.xml)) \
## $(patsubst refs/%.xml,$(LTMPDIR)/%-c.db,$(wildcard refs/*.xml)) \
## $(patsubst refs/%.xml,$(LTMPDIR)/%-nc.db,$(wildcard refs/*.xml))
## touch tmp/olinkdbs
#$(LTMPDIR)/olinkdbs: $(LTMPDIR)
# make $(patsubst guides/%.xml,$(LTMPDIR)/%-c.db,$(wildcard guides/*.xml))
# make $(patsubst guides/%.xml,$(LTMPDIR)/%-nc.db,$(wildcard guides/*.xml))
# make $(patsubst refs/%.xml,$(LTMPDIR)/%-c.db,$(wildcard refs/*.xml))
# make $(patsubst refs/%.xml,$(LTMPDIR)/%-nc.db,$(wildcard refs/*.xml))
# touch $(LTMPDIR)/olinkdbs
#
# Not needed right now
# ctags -R -x --languages=perl --perl-kinds=cls sources/$$p/ \
# > cache/$$p/.objectlist.perl.txt; \
# ctags -R -x --languages=c --c-kinds=cdf sources/$$p/ \
# > cache/$$p/.objectlist.c.txt; \
# ctags -f cache/$$p/.tags -R --extra=fq --fields=afikKlmnsSz --line-directives sources/$$p \
#
#mkreport: $(LTMPDIR)/mkreport $(LTMPDIR)
#./bin/mkreport $(IC_VERSIONS)
# touch $(LTMPDIR)/mkreport
#