]> git.saurik.com Git - apt.git/commitdiff
CMake: Discover docbook stylesheet in other locations
authorJulian Andres Klode <jak@debian.org>
Sun, 21 Aug 2016 18:37:14 +0000 (20:37 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 23 Aug 2016 15:52:41 +0000 (17:52 +0200)
Distributions seem to install this stuff all over the place, so
let's add a common list of paths we know about.

CMake/Documentation.cmake
doc/docbook-html-style.xsl [deleted file]
doc/docbook-html-style.xsl.cmake.in [new file with mode: 0644]
doc/docbook-text-style.xsl [deleted file]
doc/docbook-text-style.xsl.cmake.in [new file with mode: 0644]
doc/manpage-style.xsl [deleted file]
doc/manpage-style.xsl.cmake.in [new file with mode: 0644]

index f679b82e17a9a3635ae1150257b5ac57c474ec06..f3bbfdc6b857dbba0c16895f65c861f79ab80d4c 100644 (file)
 # SOFTWARE.
 
 
+find_path(DOCBOOK_XSL manpages/docbook.xsl
+         # Debian
+         /usr/share/xml/docbook/stylesheet/docbook-xsl
+         /usr/share/xml/docbook/stylesheet/nwalsh
+         # OpenSUSE
+         /usr/share/xml/docbook/stylesheet/nwalsh/current
+         # Arch
+          /usr/share/xml/docbook/xsl-stylesheets
+         # Fedora
+         /usr/share/sgml/docbook/xsl-stylesheets
+         # Fink
+         ${CMAKE_INSTALL_PREFIX}/share/xml/xsl/docbook-xsl
+         # FreeBSD
+         ${CMAKE_INSTALL_PREFIX}/share/xsl/docbook/
+         NO_DEFAULT_PATH)
+
+if(NOT DOCBOOK_XSL)
+    message(FATAL_ERROR "Could not find docbook xsl")
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docbook-text-style.xsl.cmake.in
+                ${CMAKE_CURRENT_BINARY_DIR}/docbook-text-style.xsl)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl.cmake.in
+                ${CMAKE_CURRENT_BINARY_DIR}/docbook-html-style.xsl)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl.cmake.in
+                ${CMAKE_CURRENT_BINARY_DIR}/manpage-style.xsl)
+
+
 # Split up a string of the form DOCUMENT[.DOCUMENT][.LANGUAGE][.SECTION].EXTENSION
 #
 # There might be up to two parts in the document name. The language must be
@@ -123,7 +151,7 @@ function(xsltproc_one)
         else()
         set(manpage_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.${section}")
         endif()
-        set(manpage_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl")
+        set(manpage_stylesheet "${CMAKE_CURRENT_BINARY_DIR}/manpage-style.xsl")
         set(manpage_params)
 
         install(FILES ${manpage_output}
@@ -137,7 +165,7 @@ function(xsltproc_one)
         set(html_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.html")
         endif()
         set(html_params --stringparam base.dir ${html_output})
-        set(html_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl")
+        set(html_stylesheet "${CMAKE_CURRENT_BINARY_DIR}/docbook-html-style.xsl")
         install(DIRECTORY ${html_output}
                 DESTINATION ${DOC_INSTALL}
                 OPTIONAL)
@@ -150,7 +178,7 @@ function(xsltproc_one)
         set(text_output "${CMAKE_CURRENT_BINARY_DIR}/${document}.text")
         endif()
         set(text_params --stringparam base.dir ${text_output})
-        set(text_stylesheet "${CMAKE_CURRENT_SOURCE_DIR}/docbook-text-style.xsl")
+        set(text_stylesheet "${CMAKE_CURRENT_BINARY_DIR}/docbook-text-style.xsl")
 
         file(RELATIVE_PATH text_output_relative ${CMAKE_CURRENT_BINARY_DIR} ${text_output})
 
diff --git a/doc/docbook-html-style.xsl b/doc/docbook-html-style.xsl
deleted file mode 100644 (file)
index e4af9f5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-  <!-- Import our base stylesheet -->
-  <xsl:import href="/usr/share/xml/docbook/stylesheet/docbook-xsl/xhtml-1_1/chunk.xsl" />
-
-  <!-- Since we use xsltproc (not saxon), add a workaround to ensure UTF-8 -->
-  <xsl:template xmlns="http://www.w3.org/1999/xhtml" name="head.content.generator">
-    <xsl:param name="node" select="."/>
-    <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-  </xsl:template>
-
-  <xsl:template name="generate.html.title"/>
-
-  <xsl:template match="releaseinfo" mode="titlepage.mode">
-    <xsl:apply-imports/>
-    <hr/>
-  </xsl:template>
-
-  <xsl:param name="root.filename">index</xsl:param>
-
-  <!-- We do not want a title in HTML. -->
-  <xsl:param name="generate.meta.abstract" select="0"/>
-
-  <!-- We do not want the first subsection on the same page as content. -->
-  <xsl:param name="chunk.first.sections" select="0"/>
-  <xsl:param name="chunk.section.depth" select="0"/>
-  <xsl:param name="chunker.output.indent" select="'yes'"/>
-
-  <xsl:param name="use.id.as.filename" select="1"/>
-
-  <xsl:param name="toc.section.depth" select="1"/>
-  <xsl:param name="generate.section.toc.level" select="0"/>
-  <xsl:param name="section.label.includes.component.label" select="1"/>
-  <xsl:param name="section.autolabel" select="1"/>
-
-  <xsl:param name="generate.css.header" select="1"/>
-
-</xsl:stylesheet>
diff --git a/doc/docbook-html-style.xsl.cmake.in b/doc/docbook-html-style.xsl.cmake.in
new file mode 100644 (file)
index 0000000..9216d8e
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+  <!-- Import our base stylesheet -->
+  <xsl:import href="@DOCBOOK_XSL@/xhtml-1_1/chunk.xsl" />
+
+  <!-- Since we use xsltproc (not saxon), add a workaround to ensure UTF-8 -->
+  <xsl:template xmlns="http://www.w3.org/1999/xhtml" name="head.content.generator">
+    <xsl:param name="node" select="."/>
+    <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+  </xsl:template>
+
+  <xsl:template name="generate.html.title"/>
+
+  <xsl:template match="releaseinfo" mode="titlepage.mode">
+    <xsl:apply-imports/>
+    <hr/>
+  </xsl:template>
+
+  <xsl:param name="root.filename">index</xsl:param>
+
+  <!-- We do not want a title in HTML. -->
+  <xsl:param name="generate.meta.abstract" select="0"/>
+
+  <!-- We do not want the first subsection on the same page as content. -->
+  <xsl:param name="chunk.first.sections" select="0"/>
+  <xsl:param name="chunk.section.depth" select="0"/>
+  <xsl:param name="chunker.output.indent" select="'yes'"/>
+
+  <xsl:param name="use.id.as.filename" select="1"/>
+
+  <xsl:param name="toc.section.depth" select="1"/>
+  <xsl:param name="generate.section.toc.level" select="0"/>
+  <xsl:param name="section.label.includes.component.label" select="1"/>
+  <xsl:param name="section.autolabel" select="1"/>
+
+  <xsl:param name="generate.css.header" select="1"/>
+
+</xsl:stylesheet>
diff --git a/doc/docbook-text-style.xsl b/doc/docbook-text-style.xsl
deleted file mode 100644 (file)
index 376dded..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-  <xsl:import href="/usr/share/xml/docbook/stylesheet/docbook-xsl/xhtml-1_1/docbook.xsl" />
-
-  <!-- Parameters for optimal text output. -->
-  <xsl:param name="callout.graphics" select="0"/>
-  <xsl:param name="callout.unicode" select="0"/>
-  <xsl:param name="section.autolabel" select="1"/>
-  <xsl:param name="section.label.includes.component.label" select="1"/>
-
-  <!-- Centering and aligning title elements. -->
-  <xsl:template match="/*/title[position()=1]" mode="titlepage.mode">
-    <br/>
-    <center>
-      <xsl:apply-imports/>
-    </center>
-    <br/>
-    <hr/> <!-- No underline, but at least something. -->
-  </xsl:template>
-  <xsl:template match="author|editor" mode="titlepage.mode">
-    <center>
-      <xsl:apply-imports/>
-    </center>
-  </xsl:template>
-
-  <xsl:template match="releaseinfo" mode="titlepage.mode">
-    <center>
-      <xsl:apply-imports/>
-    </center>
-    <hr/>
-  </xsl:template>
-
-  <!-- Dirty hack to get a left margin for paragraphs etc. -->
-  <xsl:template match="legalnotice/*
-        |chapter/*[not(name(.)='section') and not(name(.)='title')]
-        |section/*[not(name(.)='section') and not(name(.)='title')]
-        |appendix/*[not(name(.)='section') and not(name(.)='title')]
-        |footnote/*">
-    <xsl:copy><table><tr><td>&#xa0;&#xa0;&#xa0;</td><td>
-    <xsl:apply-imports/>
-    </td></tr></table></xsl:copy>
-  </xsl:template>
-
-  <!-- Skip URLs if it has something to print. -->
-  <xsl:template match="ulink[.!='']">
-    <xsl:copy-of select="."/>
-  </xsl:template>
-  <!-- Print URLs if nothing to print. -->
-  <xsl:template match="ulink[.='']">
-    <xsl:value-of select="@url"/>
-  </xsl:template>
-
-  <!-- Make clear where notes etc. begin and end. -->
-  <xsl:template match="caution|important|note|tip|warning">
-    <table width="80%" border="1">
-      <colgroup>
-        <col align="justify"/>
-      </colgroup>
-      <tbody>
-        <tr>
-          <td align="justify">
-            <xsl:apply-imports/>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/doc/docbook-text-style.xsl.cmake.in b/doc/docbook-text-style.xsl.cmake.in
new file mode 100644 (file)
index 0000000..36af1bc
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+  <xsl:import href="@DOCBOOK_XSL@/xhtml-1_1/docbook.xsl" />
+
+  <!-- Parameters for optimal text output. -->
+  <xsl:param name="callout.graphics" select="0"/>
+  <xsl:param name="callout.unicode" select="0"/>
+  <xsl:param name="section.autolabel" select="1"/>
+  <xsl:param name="section.label.includes.component.label" select="1"/>
+
+  <!-- Centering and aligning title elements. -->
+  <xsl:template match="/*/title[position()=1]" mode="titlepage.mode">
+    <br/>
+    <center>
+      <xsl:apply-imports/>
+    </center>
+    <br/>
+    <hr/> <!-- No underline, but at least something. -->
+  </xsl:template>
+  <xsl:template match="author|editor" mode="titlepage.mode">
+    <center>
+      <xsl:apply-imports/>
+    </center>
+  </xsl:template>
+
+  <xsl:template match="releaseinfo" mode="titlepage.mode">
+    <center>
+      <xsl:apply-imports/>
+    </center>
+    <hr/>
+  </xsl:template>
+
+  <!-- Dirty hack to get a left margin for paragraphs etc. -->
+  <xsl:template match="legalnotice/*
+        |chapter/*[not(name(.)='section') and not(name(.)='title')]
+        |section/*[not(name(.)='section') and not(name(.)='title')]
+        |appendix/*[not(name(.)='section') and not(name(.)='title')]
+        |footnote/*">
+    <xsl:copy><table><tr><td>&#xa0;&#xa0;&#xa0;</td><td>
+    <xsl:apply-imports/>
+    </td></tr></table></xsl:copy>
+  </xsl:template>
+
+  <!-- Skip URLs if it has something to print. -->
+  <xsl:template match="ulink[.!='']">
+    <xsl:copy-of select="."/>
+  </xsl:template>
+  <!-- Print URLs if nothing to print. -->
+  <xsl:template match="ulink[.='']">
+    <xsl:value-of select="@url"/>
+  </xsl:template>
+
+  <!-- Make clear where notes etc. begin and end. -->
+  <xsl:template match="caution|important|note|tip|warning">
+    <table width="80%" border="1">
+      <colgroup>
+        <col align="justify"/>
+      </colgroup>
+      <tbody>
+        <tr>
+          <td align="justify">
+            <xsl:apply-imports/>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/doc/manpage-style.xsl b/doc/manpage-style.xsl
deleted file mode 100644 (file)
index a780bad..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
-
-<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl" />
-
-<xsl:param name="man.output.encoding" select="'UTF-8'" />
-
-<xsl:template match="email">&lt;<xsl:apply-templates/>&gt;</xsl:template>
-
-<xsl:template match="date">
-       <xsl:call-template name="datetime.format">
-               <xsl:with-param name="date" select="."/>
-               <xsl:with-param name="format" select="'d B Y'"/>
-       </xsl:call-template>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/doc/manpage-style.xsl.cmake.in b/doc/manpage-style.xsl.cmake.in
new file mode 100644 (file)
index 0000000..53d6780
--- /dev/null
@@ -0,0 +1,18 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:import href="@DOCBOOK_XSL@/manpages/docbook.xsl" />
+
+<xsl:param name="man.output.encoding" select="'UTF-8'" />
+
+<xsl:template match="email">&lt;<xsl:apply-templates/>&gt;</xsl:template>
+
+<xsl:template match="date">
+       <xsl:call-template name="datetime.format">
+               <xsl:with-param name="date" select="."/>
+               <xsl:with-param name="format" select="'d B Y'"/>
+       </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>