forked from KhronosGroup/OpenCL-Docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
520 lines (418 loc) · 18.4 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# Copyright (c) 2013-2023 The Khronos Group Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
QUIET ?=
ASCIIDOCTOR ?= asciidoctor
XMLLINT ?= xmllint
DBLATEX ?= dblatex
DOS2UNIX ?= dos2unix
RM = rm -f
RMRF = rm -rf
MKDIR = mkdir -p
CP = cp
GS_EXISTS := $(shell command -v gs 2> /dev/null)
GITHEAD = ./.git/logs/HEAD
# Target directories for output files
# HTMLDIR - 'html' target
# PDFDIR - 'pdf' target
# CHECKDIR - 'allchecks' target
OUTDIR := out
HTMLDIR := $(OUTDIR)/html
PDFDIR := $(OUTDIR)/pdf
# PDF Equations are written to SVGs, this dictates the location to store those files (temporary)
PDFMATHDIR := $(OUTDIR)/equations_temp
# Set VERBOSE to -v to see what asciidoc is doing.
VERBOSE =
# asciidoc attributes to set.
# NOTEOPTS sets options controlling which NOTEs are generated
# ATTRIBOPTS sets the api revision and enables MathJax generation, and
# the path to generate include files
# ADOCOPTS options for asciidoc->HTML5 output (book document type)
# ADOCMANOPTS options for asciidoc->HTML5 output (manpage document type)
# Currently unused in CL spec
NOTEOPTS = -a editing-notes
# Spell out RFC2822 format as not all date commands support -R
SPECDATE = $(shell echo `date -u "+%a, %d %b %Y %T %z"`)
# Generate Asciidoc attributes for spec version and remark
# The dependency on HEAD is per the suggestion in
# http://neugierig.org/software/blog/2014/11/binary-revisions.html
ifeq ($(wildcard $(GITHEAD)),)
# If GITHEAD does not exist, don't include branch info.
SPECREVISION = Git tag information not available
SPECREMARK = Git branch information not available
else
# Expect the tag to be in the format MAJOR.MINOR-REVISION, e.g. 2.2-9.
# If your current commit is not a tag then a commit hash will be appended.
# If you have locally modified files then -dirty will be appended.
# Could use `git log -1 --format="%cd"` to get branch commit date
SPECREVISION = $(shell echo `git describe --tags --dirty`)
# This used to be a dependency in the spec html/pdf targets,
# but that's likely to lead to merge conflicts. Just regenerate
# when pushing a new spec for review to the sandbox.
SPECREMARK = from git branch: $(shell echo `git symbolic-ref --short HEAD`) \
commit: $(shell echo `git log -1 --format="%H"`)
endif
# The C++ for OpenCL document revision scheme is aligned with its release date.
# Revision naming scheme is as follows:
# DocRevYYYY.MM,
# where YYYY corresponds to its release year,
# MM corresponds to its release month.
# Example for the release in Dec 2021 the revision is DocRev2021.12.
# Leave as 'DocRevYYYY.MM-Next' if the doc content does not correspond to any official revision.
# where DocRevYYYY.MM is the last released revision.
CXX4OPENCL_DOCREVISION = DocRev2021.12
CXX4OPENCL_DOCREMARK = $(SPECREMARK) \
tag: $(SPECREVISION)
COMMONATTRIBOPTS = -a revdate="$(SPECDATE)" \
-a stem=latexmath \
-a generated=$(GENERATED) \
-a sectnumlevels=5
ATTRIBOPTS = -a revnumber="$(SPECREVISION)" \
-a revremark="$(SPECREMARK)" \
$(COMMONATTRIBOPTS)
CXX4OPENCL_ATTRIBOPTS = -a revnumber="$(CXX4OPENCL_DOCREVISION)" \
-a revremark="$(CXX4OPENCL_DOCREMARK)" \
$(COMMONATTRIBOPTS)
ADOCEXTS = -r $(CURDIR)/config/sectnumoffset-treeprocessor.rb \
-r $(CURDIR)/config/spec-macros.rb \
-r $(CURDIR)/config/rouge_opencl.rb
CXX4OPENCL_ADOCOPTS = -d book $(CXX4OPENCL_ATTRIBOPTS) $(NOTEOPTS) $(VERBOSE) $(ADOCEXTS)
ADOCCOMMONOPTS = -a apispec="$(CURDIR)/api" \
-a config="$(CURDIR)/config" \
-a cspec="$(CURDIR)/c" \
-a images="$(CURDIR)/images" \
$(ATTRIBOPTS) $(NOTEOPTS) $(VERBOSE) $(ADOCEXTS)
ADOCOPTS = -d book $(ADOCCOMMONOPTS)
ADOCMANOPTS = -d manpage $(ADOCCOMMONOPTS)
# ADOCHTMLOPTS relies on the relative runtime path from the output HTML
# file to the katex scripts being set with KATEXDIR. This is overridden
# by some targets.
# ADOCHTMLOPTS also relies on the absolute build-time path to the
# 'stylesdir' containing our custom CSS.
KATEXDIR = ../katex
ADOCHTMLEXTS = -r $(CURDIR)/config/katex_replace.rb
ADOCHTMLOPTS = $(ADOCHTMLEXTS) -a katexpath=$(KATEXDIR) \
-a stylesheet=khronos.css -a stylesdir=$(CURDIR)/config \
-a sectanchors
ADOCPDFEXTS = -r asciidoctor-pdf -r asciidoctor-mathematical --trace
ADOCPDFOPTS = $(ADOCPDFEXTS) -a mathematical-format=svg \
-a imagesoutdir=$(PDFMATHDIR)
# Where to put dynamically generated dependencies of the spec and other
# targets, from API XML. GENERATED and APIINCDIR specify the location of
# the API interface includes.
# GENDEPENDS could have multiple dependencies.
GENERATED = $(CURDIR)/generated
REFPATH = $(GENERATED)/refpage
APIINCDIR = $(GENERATED)/api
VERSIONDIR = $(APIINCDIR)/version-notes
GENDEPENDS = $(APIINCDIR)/timeMarker
.PHONY: directories
# README.md is a proxy for all the katex files that need to be installed
KATEXINST = $(OUTDIR)/katex/README.md
$(OUTDIR)/katex/README.md: katex/README.md
$(QUIET)$(MKDIR) $(OUTDIR)
$(QUIET)$(RMRF) $(OUTDIR)/katex
$(QUIET)$(CP) -rf katex $(OUTDIR)
all: api env ext extensions cxx c icdinst
allman: manhtmlpages
api: apihtml apipdf
env: envhtml envpdf
ext: exthtml extpdf
extensions: extensionshtml extensionspdf
cxx: cxxhtml cxxpdf
cxx4opencl: cxx4openclhtml cxx4openclpdf
c: chtml cpdf
icdinst: icdinsthtml icdinstpdf
html: apihtml envhtml exthtml extensionshtml cxxhtml chtml icdinsthtml
pdf: apipdf envpdf extpdf extensionspdf cxxpdf cpdf icdinstpdf
# Spec targets.
# There is some complexity to try and avoid short virtual targets like
# 'html' causing specs to *always* be regenerated.
src:
@echo APISPECSRC = $(APISPECSRC)
@echo ENVSPECSRC = $(ENVSPECSRC)
@echo EXTSPECSRC = $(EXTSPECSRC)
# API spec
# Top-level spec source file
APISPEC = OpenCL_API
APISPECSRC = $(APISPEC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(APISPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
apihtml: $(HTMLDIR)/$(APISPEC).html $(APISPECSRC)
$(HTMLDIR)/$(APISPEC).html: $(APISPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(APISPEC).txt
apipdf: $(PDFDIR)/$(APISPEC).pdf $(APISPECSRC)
$(PDFDIR)/$(APISPEC).pdf: $(APISPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(APISPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(APISPEC)-optimized.pdf $@
endif
# Environment spec
# Top-level spec source file
ENVSPEC = OpenCL_Env
ENVSPECSRC = $(ENVSPEC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(ENVSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
envhtml: $(HTMLDIR)/$(ENVSPEC).html $(ENVSPECSRC)
$(HTMLDIR)/$(ENVSPEC).html: $(ENVSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(ENVSPEC).txt
envpdf: $(PDFDIR)/$(ENVSPEC).pdf $(ENVSPECSRC)
$(PDFDIR)/$(ENVSPEC).pdf: $(ENVSPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(ENVSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(ENVSPEC)-optimized.pdf $@
endif
# Extensions spec
EXTSPEC = OpenCL_Ext
EXTSPECSRC = $(EXTSPEC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(EXTSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
exthtml: $(HTMLDIR)/$(EXTSPEC).html $(EXTSPECSRC)
$(HTMLDIR)/$(EXTSPEC).html: $(EXTSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(EXTSPEC).txt
extpdf: $(PDFDIR)/$(EXTSPEC).pdf $(EXTSPECSRC)
$(PDFDIR)/$(EXTSPEC).pdf: $(EXTSPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(EXTSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(EXTSPEC)-optimized.pdf $@
endif
# Individual extensions spec(s)
EXTDIR = extensions
EXTENSIONSSPEC = extensions
EXTENSIONSSPECSRC = $(EXTDIR)/$(EXTENSIONSSPEC).txt \
$(shell grep ^include:: $(EXTDIR)/$(EXTENSIONSSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
# Included extension documents
EXTENSIONS := $(notdir $(wildcard $(EXTDIR)/[A-Za-z]*.asciidoc))
EXTENSIONS_HTML = $(patsubst %.asciidoc,$(HTMLDIR)/%.html,$(EXTENSIONS))
EXTENSIONS_PDF = $(patsubst %.asciidoc,$(PDFDIR)/%.pdf,$(EXTENSIONS))
extensionshtml: $(HTMLDIR)/$(EXTENSIONSSPEC).html $(EXTENSIONSSPECSRC) $(EXTENSIONS_HTML)
$(HTMLDIR)/$(EXTENSIONSSPEC).html: $(EXTENSIONSSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(EXTDIR)/$(EXTENSIONSSPEC).txt
# I don't know why the pattern rule below requires vpath be overridden
# to point to the extensions/ directory, since the rule itself already
# points there.
vpath %.asciidoc $(EXTDIR)
$(HTMLDIR)/%.html: $(EXTDIR)/%.asciidoc $(GENDEPENDS)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $<
extensionspdf: $(PDFDIR)/$(EXTENSIONSSPEC).pdf $(EXTENSIONSSPECSRC)
$(PDFDIR)/$(EXTENSIONSSPEC).pdf: $(EXTENSIONSSPECSRC) $(GENDEPENDS)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(EXTDIR)/$(EXTENSIONSSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(EXTENSIONSSPEC)-optimized.pdf $@
endif
# Language Extensions spec
CEXTDOC = OpenCL_LangExt
CEXTDOCSRC = $(CEXTDOC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(CEXTDOC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
cexthtml: $(HTMLDIR)/$(CEXTDOC).html $(CEXTDOCSRC)
$(HTMLDIR)/$(CEXTDOC).html: $(CEXTDOCSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(CEXTDOC).txt
cextpdf: $(PDFDIR)/$(CEXTDOC).pdf $(CEXTDOCSRC)
$(PDFDIR)/$(CEXTDOC).pdf: $(CEXTDOCSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(CEXTDOC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(CEXTDOC)-optimized.pdf $@
endif
# C++ (cxx) spec
CXXSPEC = OpenCL_Cxx
CXXSPECSRC = $(CXXSPEC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(CXXSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
cxxhtml: $(HTMLDIR)/$(CXXSPEC).html $(CXXSPECSRC)
$(HTMLDIR)/$(CXXSPEC).html: $(CXXSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(CXXSPEC).txt
cxxpdf: $(PDFDIR)/$(CXXSPEC).pdf $(CXXSPECSRC)
$(PDFDIR)/$(CXXSPEC).pdf: $(CXXSPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(CXXSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(CXXSPEC)-optimized.pdf $@
endif
# C spec
CSPEC = OpenCL_C
CSPECSRC = $(CSPEC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(CSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
chtml: $(HTMLDIR)/$(CSPEC).html $(CSPECSRC)
$(HTMLDIR)/$(CSPEC).html: $(CSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(CSPEC).txt
cpdf: $(PDFDIR)/$(CSPEC).pdf $(CSPECSRC)
$(PDFDIR)/$(CSPEC).pdf: $(CSPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(CSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(CSPEC)-optimized.pdf $@
endif
# C++ for OpenCL doc
CXX4OPENCLDOC = CXX_for_OpenCL
CXX4OPENCLDOCSRC = $(CXX4OPENCLDOC).txt $(GENDEPENDS) \
$(shell grep ^include:: $(CXX4OPENCLDOC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
cxx4openclhtml: $(HTMLDIR)/$(CXX4OPENCLDOC).html $(CXX4OPENCLDOCSRC)
$(HTMLDIR)/$(CXX4OPENCLDOC).html: $(CXX4OPENCLDOCSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(CXX4OPENCL_ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(CXX4OPENCLDOC).txt
cxx4openclpdf: $(PDFDIR)/$(CXX4OPENCLDOC).pdf $(CXX4OPENCLDOCSRC)
$(PDFDIR)/$(CXX4OPENCLDOC).pdf: $(CXX4OPENCLDOCSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(CXX4OPENCL_ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(CXX4OPENCLDOC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(CXX4OPENCLDOC)-optimized.pdf $@
endif
# ICD installation guidelines
ICDINSTSPEC = OpenCL_ICD_Installation
ICDINSTSPECSRC = $(ICDINSTSPEC).txt \
$(shell grep ^include:: $(ICDINSTSPEC).txt | sed -e 's/^include:://' -e 's/\[\]/ /' | xargs echo)
icdinsthtml: $(HTMLDIR)/$(ICDINSTSPEC).html $(ICDINSTSPECSRC)
$(HTMLDIR)/$(ICDINSTSPEC).html: $(ICDINSTSPECSRC) $(KATEXINST)
$(QUIET)$(ASCIIDOCTOR) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(ICDINSTSPEC).txt
icdinstpdf: $(PDFDIR)/$(ICDINSTSPEC).pdf $(ICDINSTSPECSRC)
$(PDFDIR)/$(ICDINSTSPEC).pdf: $(ICDINSTSPECSRC)
$(QUIET)$(MKDIR) $(PDFDIR)
$(QUIET)$(MKDIR) $(PDFMATHDIR)
$(QUIET)$(ASCIIDOCTOR) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(ICDINSTSPEC).txt
ifndef GS_EXISTS
$(QUIET) echo "Warning: Ghostscript not installed, skipping pdf optimization"
else
$(QUIET)$(CURDIR)/config/optimize-pdf $@
$(QUIET)rm $@
$(QUIET)mv $(PDFDIR)/$(ICDINSTSPEC)-optimized.pdf $@
endif
# Clean generated and output files
clean: clean_html clean_pdf clean_generated
clean_html:
$(QUIET)$(RMRF) $(HTMLDIR) $(MANHTMLDIR) $(OUTDIR)/katex
clean_pdf:
$(QUIET)$(RMRF) $(PDFDIR) $(PDFMATHDIR)
clean_generated:
$(QUIET)$(RMRF) $(APIINCDIR)/* $(GENERATED)/api.py $($(REFPATH)/
$(QUIET)$(RMRF) $(PDFMATHDIR)
$(QUIET)$(RMRF) $(GENERATED)/__pycache__
# Ref page targets for individual pages
MANDIR := man
MANSECTION := 3
# These lists should be autogenerated
# Ref page sources for all CL interfaces
# Most are autogenerated; man/static/*.txt are hand-coded at present
# MANSOURCES is the list of individual refpage sources, excluding the
# single-page index, boilerplate document footer, and include files.
# For now, always build all refpages.
MANSOURCES = $(filter-out $(REFPATH)/apispec.txt $(REFPATH)/footer.txt $(wildcard $(REFPATH)/*Inc.txt), $(wildcard $(REFPATH)/*.txt))
# Generation of ref page asciidoctor sources by extraction from the
# specification(s).
#
# Should have a proper dependency causing the man page sources to be
# generated by running genRef.py (once), but adding $(MANSOURCES) to the
# targets causes genRef.py to run once/target.
#
# Should pass in $(EXTOPTIONS) to determine which pages to generate.
# For now, all core and extension ref pages are extracted by genRef.py.
## Temporary - eventually should be all spec asciidoctor source files
SPECFILES = $(wildcard api/*.asciidoc) OpenCL_API.txt OpenCL_C.txt
SCRIPTS = scripts
GENREF = $(SCRIPTS)/genRef.py
LOGFILE = $(REFPATH)/refpage.log
refpages: $(REFPATH)/apispec.txt
$(REFPATH)/apispec.txt: $(SPECFILES) $(GENREF) $(SCRIPTS)/reflib.py $(GENERATED)/api.py
$(QUIET)$(MKDIR) $(REFPATH)
$(PYTHON) $(GENREF) -genpath $(GENERATED) -basedir $(REFPATH) \
-rewrite $(REFPATH)/rewritebody -toc $(REFPATH)/tocbody \
-log $(LOGFILE) $(SPECFILES)
cat $(MANDIR)/tochead $(REFPATH)/tocbody $(MANDIR)/toctail > $(REFPATH)/toc.html
(cat $(MANDIR)/rewritehead ; \
echo ; echo "# Aliases hard-coded in refpage markup" ; \
sort < $(REFPATH)/rewritebody) > $(REFPATH)/.htaccess
$(CP) $(MANDIR)/static/*.txt $(REFPATH)
# These targets are HTML5 ref pages
#
# The recursive $(MAKE) is an apparently unavoidable hack, since the
# actual list of man page sources isn't known until after
# $(REFPATH)/apispec.txt is generated. $(GENDEPENDS) is generated before
# running the recursive make, so it doesn't trigger twice
manhtmlpages: $(REFPATH)/apispec.txt $(GENDEPENDS)
$(MAKE) -e buildmanpages
$(CP) $(MANDIR)/*.html $(MANDIR)/*.css $(MANDIR)/*.gif $(MANHTMLDIR)
$(CP) $(REFPATH)/.htaccess $(REFPATH)/*.html $(MANHTMLDIR)
MANHTMLDIR = $(OUTDIR)/man/html
MANHTML = $(MANSOURCES:$(REFPATH)/%.txt=$(MANHTMLDIR)/%.html)
buildmanpages: $(MANHTML)
$(MANHTMLDIR)/%.html: KATEXDIR = ../../katex
$(MANHTMLDIR)/%.html: $(REFPATH)/%.txt $(MANCOPYRIGHT) $(GENDEPENDS) $(KATEXINST)
$(QUIET)$(MKDIR) $(MANHTMLDIR)
$(QUIET)$(ASCIIDOCTOR) -b html5 -a cross-file-links \
$(ADOCMANOPTS) $(ADOCHTMLOPTS) -o $@ $<
$(MANHTMLDIR)/intro.html: $(REFPATH)/intro.txt $(MANCOPYRIGHT)
$(QUIET)$(MKDIR) $(MANHTMLDIR)
$(QUIET)$(ASCIIDOCTOR) -b html5 -a cross-file-links \
$(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $<
# Targets generated from the XML and registry processing scripts
# api.py - Python encoding of the registry
# $(APIINCDIR)/timeMarker - proxy for 'apiinc' - generate API interfaces
#
# $(GENSCRIPTEXTRA) are extra options that can be passed to the
# generation script, such as
# '-diag diag'
REGISTRY = xml
APIXML = $(REGISTRY)/cl.xml
GENSCRIPT = $(SCRIPTS)/gencl.py
DICTSCRIPT = $(SCRIPTS)/gen_dictionaries.py
VERSIONSCRIPT = $(SCRIPTS)/gen_version_notes.py
GENSCRIPTOPTS = $(VERSIONOPTIONS) $(EXTOPTIONS) $(GENSCRIPTEXTRA) -registry $(APIXML)
GENSCRIPTEXTRA =
$(GENERATED)/api.py: $(APIXML) $(GENSCRIPT)
$(QUIET)$(PYTHON) $(GENSCRIPT) $(GENSCRIPTOPTS) -o $(GENERATED) api.py
apiinc: $(APIINCDIR)/timeMarker
$(APIINCDIR)/timeMarker: $(APIXML) $(DICTSCRIPT) $(GENSCRIPT) $(VERSIONSCRIPT)
$(QUIET)$(MKDIR) $(APIINCDIR)
$(QUIET)$(PYTHON) $(DICTSCRIPT) -registry $(APIXML) -o $(APIINCDIR)
$(QUIET)$(MKDIR) $(VERSIONDIR)
$(QUIET)$(PYTHON) $(VERSIONSCRIPT) -registry $(APIXML) -o $(VERSIONDIR)
$(QUIET)$(PYTHON) $(GENSCRIPT) $(GENSCRIPTOPTS) -o $(APIINCDIR) apiinc