File: Makefile

package info (click to toggle)
khronos-opencl-man 1.0~svn33624-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,380 kB
  • sloc: xml: 58,847; makefile: 603; ruby: 183; sh: 22
file content (70 lines) | stat: -rw-r--r-- 2,546 bytes parent folder | download | duplicates (5)
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
#!gmake

# This Makefile is used to transform OpenCL reference pages in DocBook XML format to man pages.
# The input .xml files are assumed to be in the parent directory

# XSLT processor - other possibilities like Saxon exist
XSLT	= xsltproc --nonet

SED	= sed
MV	= mv

# Location of locally customized stylesheet, which imports
# the Docbook modular stylesheets, and specifically the
# stylesheet to convert Docbook+MathML => man+MathML
DB2MAN = opencl-manpages.xsl

# OpenCL man pages currently need some preprocessing to produce quality man pages.
# This is done using the following XSLT
DB2MANPRE = opencl-manpages-pre.xsl

# The Khronos Group also provides a ruby script that fixups named-section links to the
# OpenCL specifications into links to the appropriate pages on the PDF. We extract the relevant data
# from this script to assemble a an XSLT that does something similar for us
SECREF2PAGE = section-to-page.xml

.SUFFIXES: .xml .3clc .xsl

# The list of man pages to be produced. This is obtained by changing the extension of all
# source files that contain the '<keyword>' tag.
MANFILES=$(patsubst %.xml,%.3clc,$(shell cd .. && grep -l '<keyword>' *.xml))

default: $(MANFILES)

# Some source files depend on additional files. These dependencies can be extracted running
#    grep '!ENTITY' *.xml | sed -e 's/:.*SYSTEM "/: ..\//' -e 's/">//' -e 's/\.xml:/.3cl:/'
# in the source file directory
XMLDEPS=Makefile.xmldeps

$(XMLDEPS):
	(cd .. && grep '!ENTITY' *.xml | sed -e 's/:.*SYSTEM "/: ..\//' -e 's/">//' -e 's/\.xml:/.3clc:/') > $@

sinclude $(XMLDEPS)

$(SECREF2PAGE): ../xhtml/pageNumberLookup.rb Makefile
	@echo '<sections>' > $@
	@$(SED) -n -e '/=>/ { s!^\s\+!<section id=! ; s!\s\+=>\s\+\[!><spec>! ; s!, !</spec><page>! ; s!\],\s\+\# !</page><title>! ; s!$$!</title></section>! ; p }' \
		$< >> $@
	@echo '</sections>' >> $@


# First preprocess the original docbook to a more man-compatible form
# Then turn it into an actual manpage
# And finally do some whitespace cleanup to fix some DB2MAN problems:
# * unindent lines (this is necessary to fix some indented .RE commands,
#   and also fixes other spurious indentation that have only aesthetical
#   effects)
# * much less aggressive interparagraph spacing
%.3clc: ../%.xml $(DB2MAN) $(DB2MANPRE) $(SECREF2PAGE)
	@$(XSLT) --xinclude -o $@.tmp $(DB2MANPRE) $<
	@$(XSLT) --xinclude -o $@ $(DB2MAN) $@.tmp
	@$(SED) -i -e 's/^\s\+//' -e '/^.sp$$/ {N;N;s/^\.sp\n\n/.sp/}' $@
	@$(RM) $@.tmp

clean:
	$(RM) $(MANFILES)

clobber: clean
	$(RM) $(XMLDEPS) $(SECREF2PAGE)