]> gitweb @ CieloNegro.org - oh-my-god.git/blob - m4/docbook.m4
Steal M4 macros from GHC
[oh-my-god.git] / m4 / docbook.m4
1 # FP_GEN_DOCBOOK_XML
2 # ------------------
3 # Generates a DocBook XML V4.5 document in conftest.xml.
4 #
5 # It took a lot of experimentation to find a document that will cause
6 # xsltproc to fail with an error code when the relevant
7 # stylesheets/DTDs are not found.  I couldn't make xsltproc fail with
8 # a single-file document, it seems a multi-file document is needed.
9 # -- SDM 2009-06-03
10 #
11 AC_DEFUN([FP_GEN_DOCBOOK_XML],
12 [rm -f conftest.xml conftest-book.xml
13 cat > conftest.xml << EOF
14 <?xml version="1.0" encoding="iso-8859-1"?>
15 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
16    "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [[
17 <!ENTITY conftest-book SYSTEM "conftest-book.xml">
18 ]]>
19 <book id="test">
20 &conftest-book;
21 </book>
22 EOF
23 cat >conftest-book.xml << EOF
24 <?xml version="1.0" encoding="iso-8859-1"?>
25   <title>A DocBook &ldquo;Test Document&rdquo;</title>
26   <chapter id="id-one">
27     <title>A Chapter Title</title>
28     <para>This is a paragraph, referencing <xref linkend="id-two"/>.</para>
29   </chapter>
30   <chapter id="id-two">
31     <title>Another Chapter Title</title>
32     <para>This is another paragraph, referencing <xref linkend="id-one"/>.</para>
33   </chapter>
34 EOF
35 ]) # FP_GEN_DOCBOOK_XML
36
37
38 # FP_PROG_DBLATEX
39 # ----------------
40 # Sets the output variable DblatexCmd to the full path of dblatex,
41 # which we use for building PDF and PS docs.
42 # DblatexCmd is empty if dblatex could not be found.
43 AC_DEFUN([FP_PROG_DBLATEX],
44 [AC_PATH_PROG([DblatexCmd], [dblatex])
45 if test -z "$DblatexCmd"; then
46   AC_MSG_WARN([cannot find dblatex in your PATH, you will not be able to build the PDF and PS documentation])
47 fi
48 ])# FP_PROG_DBLATEX
49
50
51 # FP_PROG_XSLTPROC
52 # ----------------
53 # Sets the output variable XsltprocCmd to the full path of the XSLT processor
54 # xsltproc. XsltprocCmd is empty if xsltproc could not be found.
55 AC_DEFUN([FP_PROG_XSLTPROC],
56 [AC_PATH_PROG([XsltprocCmd], [xsltproc])
57 if test -z "$XsltprocCmd"; then
58   AC_MSG_WARN([cannot find xsltproc in your PATH, you will not be able to build the HTML documentation])
59 fi
60 ])# FP_PROG_XSLTPROC
61
62
63 # FP_DOCBOOK_XSL
64 # ----------------------------
65 # Check that we can process a DocBook XML document to HTML using xsltproc.
66 AC_DEFUN([FP_DOCBOOK_XSL],
67 [AC_REQUIRE([FP_PROG_XSLTPROC])dnl
68 if test -n "$XsltprocCmd"; then
69   AC_CACHE_CHECK([for DocBook XSL stylesheet], fp_cv_dir_docbook_xsl,
70   [FP_GEN_DOCBOOK_XML
71   fp_cv_dir_docbook_xsl=no
72   if $XsltprocCmd --nonet http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl conftest.xml > /dev/null 2>&1; then
73      fp_cv_dir_docbook_xsl=yes
74   fi
75   rm -rf conftest*])
76 fi
77 if test x"$fp_cv_dir_docbook_xsl" = xno; then
78   AC_MSG_WARN([cannot find DocBook XSL stylesheets, you will not be able to build the documentation])
79   HAVE_DOCBOOK_XSL=NO
80 else
81   HAVE_DOCBOOK_XSL=YES
82 fi
83 AC_SUBST([HAVE_DOCBOOK_XSL])
84 ])# FP_DOCBOOK_XSL
85
86
87 # FP_PROG_XMLLINT
88 # ----------------
89 # Sets the output variable XmllintCmd to the full path of the XSLT processor
90 # xmllint. XmllintCmd is empty if xmllint could not be found.
91 AC_DEFUN([FP_PROG_XMLLINT],
92 [AC_PATH_PROG([XmllintCmd], [xmllint])
93 if test -z "$XmllintCmd"; then
94   AC_MSG_WARN([cannot find xmllint in your PATH, you will not be able to validate your documentation])
95 fi
96 ])# FP_PROG_XMLLINT
97
98
99 # FP_CHECK_DOCBOOK_DTD
100 # --------------------
101 AC_DEFUN([FP_CHECK_DOCBOOK_DTD],
102 [AC_REQUIRE([FP_PROG_XMLLINT])dnl
103 if test -n "$XmllintCmd"; then
104   AC_MSG_CHECKING([for DocBook DTD])
105   FP_GEN_DOCBOOK_XML
106   if $XmllintCmd --nonet --valid --noout conftest.xml ; then
107     AC_MSG_RESULT([ok])
108   else
109     AC_MSG_RESULT([failed])
110     AC_MSG_WARN([cannot find a DTD for DocBook XML V4.5, you will not be able to validate your documentation])
111     AC_MSG_WARN([check your XML_CATALOG_FILES environment variable and/or /etc/xml/catalog])
112   fi
113   rm -rf conftest*
114 fi
115 ])# FP_CHECK_DOCBOOK_DTD
116
117
118 # FP_GEN_FO
119 # ------------------
120 # Generates a formatting objects document in conftest.fo.
121 AC_DEFUN([FP_GEN_FO],
122 [rm -f conftest.fo
123 cat > conftest.fo << EOF
124 <?xml version="1.0"?>
125 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
126   <fo:layout-master-set>
127     <fo:simple-page-master master-name="blank">
128       <fo:region-body/>
129     </fo:simple-page-master>
130   </fo:layout-master-set>
131   <fo:page-sequence master-reference="blank">
132     <fo:flow flow-name="xsl-region-body">
133       <fo:block>
134         Test!
135       </fo:block>
136     </fo:flow>
137   </fo:page-sequence>
138 </fo:root>
139 EOF
140 ]) # FP_GEN_FO
141
142
143 # FP_PROG_FOP
144 # -----------
145 # Set the output variable 'FopCmd' to the first working 'fop' in the current
146 # 'PATH'. Note that /usr/bin/fop is broken in SuSE 9.1 (unpatched), so try
147 # /usr/share/fop/fop.sh in that case (or no 'fop'), too.
148 AC_DEFUN([FP_PROG_FOP],
149 [AC_PATH_PROGS([FopCmd1], [fop fop.sh])
150 if test -n "$FopCmd1"; then
151   AC_CACHE_CHECK([for $FopCmd1 usability], [fp_cv_fop_usability],
152     [FP_GEN_FO
153     if "$FopCmd1" -fo conftest.fo -ps conftest.ps > /dev/null 2>&1; then
154       fp_cv_fop_usability=yes
155     else
156       fp_cv_fop_usability=no
157     fi
158     rm -rf conftest*])
159   if test x"$fp_cv_fop_usability" = xyes; then
160      FopCmd=$FopCmd1
161   fi
162 fi
163 if test -z "$FopCmd"; then
164   AC_PATH_PROGS([FopCmd2], [fop.sh], , [/usr/share/fop])
165   FopCmd=$FopCmd2
166 fi
167 AC_SUBST([FopCmd])
168 ])# FP_PROG_FOP