]> git.saurik.com Git - apt.git/blame - CMake/Documentation.cmake
CMake: Misc: Extract command path_join() from Translations
[apt.git] / CMake / Documentation.cmake
CommitLineData
9a2aa0e7
JAK
1# Copyright (C) 2009, 2016 Julian Andres Klode <jak@debian.org>.
2#
3# Permission is hereby granted, free of charge, to any person
4# obtaining a copy of this software and associated documentation files
5# (the "Software"), to deal in the Software without restriction,
6# including without limitation the rights to use, copy, modify, merge,
7# publish, distribute, sublicense, and/or sell copies of the Software,
8# and to permit persons to whom the Software is furnished to do so,
9# subject to the following conditions:
10#
11# The above copyright notice and this permission notice shall be
12# included in all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22
23function(add_docbook target sourcefiles installdest)
24 foreach(file ${sourcefiles})
25 get_filename_component(relfile ${file} NAME)
26 string(REPLACE ".dbk" "" manual ${relfile})
27 get_filename_component(absolute ${file} ABSOLUTE)
28
29 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/
30 COMMAND xsltproc --nonet --novalid --xinclude
31 --stringparam base.dir ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html/
32 --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/
33 --path ${CMAKE_CURRENT_SOURCE_DIR}/
34 ${CMAKE_CURRENT_SOURCE_DIR}/docbook-html-style.xsl
35 ${absolute}
36 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
37 DEPENDS ${file}
38 )
39 set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html)
40 if (NOT ${installdest} EQUAL "" )
41 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html
42 DESTINATION ${installdest})
43 endif()
44 endforeach(file ${sourcefiles})
45
46 add_custom_target(${target} ALL DEPENDS ${commands})
47endfunction()
48
49
50function(add_po4a type master po target deps)
51 add_custom_command(OUTPUT ${target}
52 COMMAND po4a-translate --keep 0 -f ${type} -m ${master}
53 -p ${po} -l ${target}
54 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
55 DEPENDS ${deps} ${master} ${po})
56endfunction()
57
58
59# Macro for XML man pages.
60function(add_xml_manpages target manpages translations entities)
61 foreach(manpage ${manpages})
62 string(LENGTH ${manpage} manpage_length)
63 math(EXPR manpage_length ${manpage_length}-1)
64 string(SUBSTRING ${manpage} ${manpage_length} 1 section)
65
66 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
67 COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/
68 --path ${CMAKE_CURRENT_SOURCE_DIR}/
69 ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl
70 ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
71 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
72 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
73 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl
74 )
75
76
77 set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manpage})
78
79 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
80 DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section})
81
82 # Add the translations for the manpage.
83 foreach(translation ${translations})
84 set(entities)
85 # transdir = shortcut to the output directory for translations.
86 set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})
87
88 add_po4a(docbook ${manpage}.xml po/${translation}.po
89 ${transdir}/${manpage}.xml "${ent_cmds}")
90
91
92 add_custom_command(OUTPUT ${transdir}/${manpage}
93 COMMAND xsltproc --path ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/${CURRENT_VENDOR}/
94 --path ${CMAKE_CURRENT_SOURCE_DIR}/
95 --stringparam l10n.gentext.default.language ${translation}
96 ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl
97 ${transdir}/${manpage}.xml
98 WORKING_DIRECTORY ${transdir}
99 DEPENDS ${transdir}/${manpage}.xml
100 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manpage-style.xsl)
101
102 set(nls-cmd ${nls-cmd} ${transdir}/${manpage})
103 install(FILES ${transdir}/${manpage}
104 DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section})
105
106 endforeach(translation ${translations})
107 endforeach(manpage ${manpages})
108
109 add_custom_target(${target} ALL DEPENDS ${commands})
110 # Sort the list of the translations.
111 list(SORT nls-cmd)
112 add_custom_target(nls-${target} ALL DEPENDS ${nls-cmd})
113endfunction()
114
115
116function(add_manpages target manpages translations)
117 foreach(man ${manpages})
118 string(LENGTH ${man} manpage_length)
119 math(EXPR manpage_length ${manpage_length}-1)
120 string(SUBSTRING ${man} ${manpage_length} 1 section)
121 install(FILES ${man} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section})
122
123 if (USE_NLS)
124 foreach(translation ${translations})
125 set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})
126 add_po4a(man ${man} po/${translation}.po ${transdir}/${man} "")
127 install(FILES ${transdir}/${man}
128 DESTINATION ${CMAKE_INSTALL_MANDIR}/${translation}/man${section})
129 set(files ${files} ${transdir}/${man})
130 endforeach(translation ${translations})
131 endif()
132 endforeach(man ${manpages})
133 add_custom_target(${target} ALL DEPENDS ${files})
134endfunction()