1
# Copyright (C) 2009 Julian Andres Klode <jak@debian.org>.
2
# Licensed under the same terms as APT; i.e. GPL 2 or later.
4
macro(add_debiandoc target sourcefiles installdest)
5
foreach(file ${sourcefiles})
6
get_filename_component(relfile ${file} NAME)
7
string(REPLACE ".sgml" "" manual ${relfile})
8
get_filename_component(absolute ${file} ABSOLUTE)
10
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html
11
COMMAND debiandoc2html ${absolute}
12
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
15
set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html)
16
if (NOT ${installdest} EQUAL "" )
17
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html
18
DESTINATION ${installdest})
19
endif (NOT ${installdest} EQUAL "" )
20
endforeach(file ${sourcefiles})
22
add_custom_target(${target} ALL DEPENDS ${commands})
23
endmacro(add_debiandoc target sourcefiles installdest)
26
macro(add_po4a type master po target deps)
27
add_custom_command(OUTPUT ${target}
28
COMMAND po4a-translate --keep 0 -f ${type} -m ${master}
30
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
31
DEPENDS ${deps} ${master} ${po})
32
endmacro(add_po4a type master po target deps)
35
# Macro for XML man pages.
36
macro(add_xml_manpages target manpages translations entities)
37
foreach(manpage ${manpages})
38
string(LENGTH ${manpage} manpage_length)
39
math(EXPR manpage_length ${manpage_length}-1)
40
string(SUBSTRING ${manpage} ${manpage_length} 1 section)
42
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
43
COMMAND xmlto man ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
44
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
45
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
49
set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manpage})
51
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
52
DESTINATION share/man/man${section})
54
# Add the translations for the manpage.
55
foreach(translation ${translations})
57
# transdir = shortcut to the output directory for translations.
58
set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})
60
foreach(entity ${entities})
61
add_custom_command(OUTPUT ${transdir}/${entity}
62
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
63
COMMAND ${CMAKE_COMMAND} -E make_directory ${transdir}
64
COMMAND ${CMAKE_COMMAND} -E copy ${entity} ${transdir})
65
set(ent_cmds ${ent_cmds} ${transdir}/${entity})
66
endforeach(entity ${entities})
70
add_po4a(docbook ${manpage}.xml po/${translation}.po
71
${transdir}/${manpage}.xml "${ent_cmds}")
74
add_custom_command(OUTPUT ${transdir}/${manpage}
75
COMMAND xmlto -o ${transdir} man ${transdir}/${manpage}.xml
76
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
77
DEPENDS ${transdir}/${manpage}.xml)
79
set(nls-cmd ${nls-cmd} ${transdir}/${manpage})
80
install(FILES ${transdir}/${manpage}
81
DESTINATION share/man/${translation}/man${section})
83
endforeach(translation ${translations})
84
endforeach(manpage ${manpages})
86
add_custom_target(${target} ALL DEPENDS ${commands})
87
# Sort the list of the translations.
89
add_custom_target(nls-${target} ALL DEPENDS ${nls-cmd})
90
endmacro(add_xml_manpages manpages)
93
macro(add_manpages target manpages translations)
94
foreach(man ${manpages})
95
string(LENGTH ${man} manpage_length)
96
math(EXPR manpage_length ${manpage_length}-1)
97
string(SUBSTRING ${man} ${manpage_length} 1 section)
98
install(FILES ${man} DESTINATION share/man/man${section})
101
foreach(translation ${translations})
102
set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})
103
add_po4a(man ${man} po/${translation}.po ${transdir}/${man} "")
104
install(FILES ${transdir}/${man}
105
DESTINATION share/man/${translation}/man${section})
106
set(files ${files} ${transdir}/${man})
107
endforeach(translation ${translations})
109
endforeach(man ${manpages})
110
add_custom_target(${target} ALL DEPENDS ${files})
111
endmacro(add_manpages target manpages translations)