1 Debian patch touch this file
-
Proposed improvements to the Khronos OpenCL man pages package
- Author
- Giuseppe Bilotta <[email protected]>
- Forwarded
- no
| •1 | #!gmake |
| 2 | |
| 3 | # This Makefile is used to transform OpenCL reference pages in DocBook XML format to man pages. |
| 4 | # The input .xml files are assumed to be in the parent directory |
| 5 | |
| 6 | # XSLT processor - other possibilities like Saxon exist |
| 7 | XSLT = xsltproc --nonet |
| 8 | |
| 9 | SED = sed |
| 10 | MV = mv |
| 11 | |
| 12 | # Location of locally customized stylesheet, which imports |
| 13 | # the Docbook modular stylesheets, and specifically the |
| 14 | # stylesheet to convert Docbook+MathML => man+MathML |
| 15 | DB2MAN = opencl-manpages.xsl |
| 16 | |
| 17 | # OpenCL man pages currently need some preprocessing to produce quality man pages. |
| 18 | # This is done using the following XSLT |
| 19 | DB2MANPRE = opencl-manpages-pre.xsl |
| 20 | |
| 21 | # The Khronos Group also provides a ruby script that fixups named-section links to the |
| 22 | # OpenCL specifications into links to the appropriate pages on the PDF. We extract the relevant data |
| 23 | # from this script to assemble a an XSLT that does something similar for us |
| 24 | SECREF2PAGE = section-to-page.xml |
| 25 | |
| 26 | .SUFFIXES: .xml .3clc .xsl |
| 27 | |
| 28 | # The list of man pages to be produced. This is obtained by changing the extension of all |
| 29 | # source files that contain the '<keyword>' tag. |
| 30 | MANFILES=$(patsubst %.xml,%.3clc,$(shell cd .. && grep -l '<keyword>' *.xml)) |
| 31 | |
| 32 | default: $(MANFILES) |
| 33 | |
| 34 | # Some source files depend on additional files. These dependencies can be extracted running |
| 35 | # grep '!ENTITY' *.xml | sed -e 's/:.*SYSTEM "/: ..\//' -e 's/">//' -e 's/\.xml:/.3cl:/' |
| 36 | # in the source file directory |
| 37 | XMLDEPS=Makefile.xmldeps |
| 38 | |
| 39 | $(XMLDEPS): |
| 40 | (cd .. && grep '!ENTITY' *.xml | sed -e 's/:.*SYSTEM "/: ..\//' -e 's/">//' -e 's/\.xml:/.3clc:/') > $@ |
| 41 | |
| 42 | sinclude $(XMLDEPS) |
| 43 | |
| 44 | $(SECREF2PAGE): ../xhtml/pageNumberLookup.rb Makefile |
| 45 | @echo '<sections>' > $@ |
| 46 | @$(SED) -n -e '/=>/ { s!^\s\+!<section id=! ; s!\s\+=>\s\+\[!><spec>! ; s!, !</spec><page>! ; s!\],\s\+\# !</page><title>! ; s!$$!</title></section>! ; p }' \ |
| 47 | $< >> $@ |
| 48 | @echo '</sections>' >> $@ |
| 49 | |
| 50 | |
| 51 | # First preprocess the original docbook to a more man-compatible form |
| 52 | # Then turn it into an actual manpage |
| 53 | # And finally do some whitespace cleanup to fix some DB2MAN problems: |
| 54 | # * unindent lines (this is necessary to fix some indented .RE commands, |
| 55 | # and also fixes other spurious indentation that have only aesthetical |
| 56 | # effects) |
| 57 | # * much less aggressive interparagraph spacing |
| 58 | %.3clc: ../%.xml $(DB2MAN) $(DB2MANPRE) $(SECREF2PAGE) |
| 59 | @$(XSLT) --xinclude -o [email protected] $(DB2MANPRE) $< |
| 60 | @$(XSLT) --xinclude -o $@ $(DB2MAN) [email protected] |
| 61 | @$(SED) -i -e 's/^\s\+//' -e '/^.sp$$/ {N;N;s/^\.sp\n\n/.sp/}' $@ |
| 62 | @$(RM) [email protected] |
| 63 | |
| 64 | clean: |
| 65 | $(RM) $(MANFILES) |
| 66 | |
| 67 | clobber: clean |
| 68 | $(RM) $(XMLDEPS) $(SECREF2PAGE) |
| 69 | |
| 70 |