#!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 '' tag. MANFILES=$(patsubst %.xml,%.3clc,$(shell cd .. && grep -l '' *.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 '' > $@ @$(SED) -n -e '/=>/ { s!^\s\+!
\s\+\[!>! ; s!, !! ; s!\],\s\+\# !! ; s!$$!
! ; p }' \ $< >> $@ @echo '
' >> $@ # 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)