summaryrefslogtreecommitdiff
path: root/doc/CMakeLists.txt
blob: 7b51421cb237f3b1cb635a95a992442648852efd (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# 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}/user/weechat_user.${dlang}.xml)
      
      IF(BUILD_HTML)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/autogen)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/autogen)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user)
        
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user/index.html ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user/weechat_user.${dlang}.html
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/user/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/autogen/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user/"
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user/ ${CMAKE_CURRENT_BINARY_DIR}/weechat-html.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/weechat_user.${dlang}.xml
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user/weechat_user.${dlang}.html ${CMAKE_CURRENT_BINARY_DIR}/weechat-html-one.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user-build/weechat_user.${dlang}.xml
	  DEPENDS
          ${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/user/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*
	  ${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}/weechat-doc.css
	  COMMENT "Building html doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-user-html-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user/index.html)
	ADD_CUSTOM_TARGET(doc-user-html-one-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/user/weechat_user.${dlang}.html)
	INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/user DESTINATION share/doc/${PROJECT_NAME}/html/${dlang}/)
	
      ENDIF(BUILD_HTML)
      
      IF(BUILD_PDF)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/autogen)
        FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/autogen)
	
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user/weechat_user.${dlang}.pdf
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/user/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/autogen/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/"
	  COMMAND ${DBLATEX} ARGS -P draft.mode=no -c ${CMAKE_CURRENT_SOURCE_DIR}/dblatex.conf -o ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user/weechat_user.${dlang}.pdf ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user-build/weechat_user.${dlang}.xml
	  DEPENDS
          ${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/user/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html-one.xsl.in
	  COMMENT "Building pdf doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-user-pdf-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user/weechat_user.${dlang}.pdf)
	INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/user/weechat_user.${dlang}.pdf DESTINATION share/doc/${PROJECT_NAME})

      ENDIF(BUILD_PDF)
      
    ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/user/weechat_user.${dlang}.xml)
    
    IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/weechat_devel.${dlang}.xml)
      
      IF(BUILD_HTML)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/autogen)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/autogen)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel)
        
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel/index.html ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel/weechat_devel.${dlang}.html
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/autogen/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/weechat-doc.css" "${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel/"
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel/ ${CMAKE_CURRENT_BINARY_DIR}/weechat-html.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/weechat_devel.${dlang}.xml
	  COMMAND ${XSLTPROC} ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel/weechat_devel.${dlang}.html ${CMAKE_CURRENT_BINARY_DIR}/weechat-html-one.xsl ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel-build/weechat_devel.${dlang}.xml
	  DEPENDS
          ${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*
	  ${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}/weechat-doc.css
	  COMMENT "Building html doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-devel-html-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel/index.html)
	ADD_CUSTOM_TARGET(doc-devel-html-one-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html-one/${dlang}/devel/weechat_devel.${dlang}.html)
	INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/${dlang}/devel DESTINATION share/doc/${PROJECT_NAME}/html/${dlang}/)
	
      ENDIF(BUILD_HTML)
      
      IF(BUILD_PDF)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel)
	FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel)
        FILE(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/autogen)
        FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/autogen)
        
	ADD_CUSTOM_COMMAND(
	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel/weechat_devel.${dlang}.pdf
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/*.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/"
	  COMMAND ${COPY} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/autogen/"
          COMMAND ${COPY} ARGS "${CMAKE_CURRENT_BINARY_DIR}/date.xml" "${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/"
	  COMMAND ${DBLATEX} ARGS -P draft.mode=no -c ${CMAKE_CURRENT_SOURCE_DIR}/dblatex.conf -o ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel/weechat_devel.${dlang}.pdf ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel-build/weechat_devel.${dlang}.xml
	  DEPENDS
          ${CMAKE_CURRENT_SOURCE_DIR}/include_autogen.xml
          ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/*.xml
	  ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/autogen/*
	  ${CMAKE_CURRENT_SOURCE_DIR}/date.xml.in
	  ${CMAKE_CURRENT_SOURCE_DIR}/weechat-html-one.xsl.in
	  COMMENT "Building pdf doc (${dlang})"
	  )
	ADD_CUSTOM_TARGET(doc-devel-pdf-${dlang} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel/weechat_devel.${dlang}.pdf)
	INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pdf/${dlang}/devel/weechat_devel.${dlang}.pdf DESTINATION share/doc/${PROJECT_NAME})
        
      ENDIF(BUILD_PDF)
      
    ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dlang}/devel/weechat_devel.${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)