summaryrefslogtreecommitdiff
path: root/doc/CMakeLists.txt
blob: c953efc3817f3e6a3833ff6e003b6b6ca9bf7abe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

SET(DOC_LANGS
  cs
  de
  en
  fr
  pl
  ru
  sco
  sv
  )

FIND_PROGRAM(
  COPY cp
  PATHS /bin /usr/bin /usr/local/bin /usr/pkg/bin
)

FIND_PROGRAM(
  XSLTPROC xsltproc
  PATHS /bin /usr/bin /usr/local/bin /usr/pkg/bin
)

FIND_PROGRAM(
  DBLATEX dblatex
  PATHS /bin /usr/bin /usr/local/bin /usr/pkg/bin
  )

FIND_FILE(DOC_XSL_PREFIX chunk.xsl PATHS
  /usr/share/xml/docbook/stylesheet/nwalsh/
  /usr/share/xml/docbook/xsl-stylesheets-1.69/
  PATH_SUFFIXES html
  DOC "Path to nwalsh xsl stylesheet"
  )
STRING(REPLACE "/html/chunk.xsl" "" DOC_XSL_PREFIX "${DOC_XSL_PREFIX}")
      
IF(XSLTPROC AND DOC_XSL_PREFIX AND COPY)
  SET(BUILD_HTML TRUE)
ENDIF(XSLTPROC AND DOC_XSL_PREFIX AND COPY)

IF(DBLATEX AND COPY)
  SET(BUILD_PDF TRUE)
ENDIF(DBLATEX AND COPY)

IF(BUILD_HTML)
  CONFIGURE_FILE(
    ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html.xsl.in
    ${CMAKE_CURRENT_BINARY_DIR}/weechat-html.xsl
    @ONLY
    )

  CONFIGURE_FILE(
    ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html-one.xsl.in
    ${CMAKE_CURRENT_BINARY_DIR}/weechat-html-one.xsl
    @ONLY
    )
ENDIF(BUILD_HTML)


IF(BUILD_HTML OR BUILD_PDF)
  EXECUTE_PROCESS(
    COMMAND date "+%F %T"
    OUTPUT_VARIABLE DOC_DATE
    )
  STRING(REPLACE "\n" "" DOC_DATE "${DOC_DATE}")

  CONFIGURE_FILE(
    ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
    ${CMAKE_CURRENT_BINARY_DIR}/date.xml
    @ONLY
    )
  
  FOREACH(dlang ${DOC_LANGS})
    IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml)
      
      IF(BUILD_HTML)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang})
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang})
      
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/index.html ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/weechat.${dlang}.html
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/intro.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/install.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/usage.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugins.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_api.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_charset.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_scripts.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/authors.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/config.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/irc_commands.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/key_functions.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_commands.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}"
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/ ${CMAKE_CURRENT_BINARY_DIR}/weechat-html.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build/weechat.${dlang}.xml
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/weechat.${dlang}.html ${CMAKE_CURRENT_BINARY_DIR}/weechat-html-one.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}-build/weechat.${dlang}.xml
	  DEPENDS
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/intro.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/install.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/usage.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugins.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_api.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_scripts.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/authors.${dlang}.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/config.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/irc_commands.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/key_functions.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_commands.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html-one.xsl.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html.xsl.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css
	  COMMENT "Building html doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-html-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/index.html)
	ADD_CUSTOM_TARGET(doc-html-one-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/weechat.${dlang}.html)
	INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang} DESTINATION share/doc/${PROJECT_NAME}/html)
	
      ENDIF(BUILD_HTML)
    
      IF(BUILD_PDF)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang})
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build)
	
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/weechat.${dlang}.pdf
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/intro.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/install.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/usage.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugins.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_api.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_charset.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_scripts.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/authors.${dlang}.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/config.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/irc_commands.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/key_functions.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_commands.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build"
	  COMMAND ${DBLATEX} ARGS -c ${CMAKE_CURRENT_SOURCE_DIR}/dblatex.conf -o ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/weechat.${dlang}.pdf ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}-build/weechat.${dlang}.xml
	  DEPENDS
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/intro.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/install.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/usage.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugins.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_api.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/plugin_scripts.${dlang}.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/authors.${dlang}.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/config.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/irc_commands.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/key_functions.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_commands.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html-one.xsl.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  COMMENT "Building pdf doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-pdf-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/weechat.${dlang}.pdf)
	INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/weechat.${dlang}.pdf DESTINATION share/doc/${PROJECT_NAME})

      ENDIF(BUILD_PDF)
      
    ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat.${dlang}.xml)
  
  ENDFOREACH(dlang ${DOC_LANGS})

ENDIF(BUILD_HTML OR BUILD_PDF)

FOREACH(dlang ${DOC_LANGS})
  IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_quickstart.${dlang}.txt)
    INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_quickstart.${dlang}.txt DESTINATION share/doc/${PROJECT_NAME})
  ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/weechat_quickstart.${dlang}.txt)
ENDFOREACH(dlang ${DOC_LANGS})

INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/weechat-curses.1 DESTINATION share/man/man1)