Remove generated files
[framework/connectivity/libgphoto2.git] / libgphoto2_port / m4 / gp-manual-documentation.m4
1 dnl
2 dnl check where to install documentation
3 dnl
4 dnl determines documentation "root directory", i.e. the directory
5 dnl where all documentation will be placed in
6 dnl
7
8 AC_DEFUN([GP_CHECK_DOCDIR],
9 [
10
11 AC_ARG_WITH(doc-dir, [  --with-doc-dir=PATH       Where to install docs  [default=autodetect]])dnl
12
13 # check for the main ("root") documentation directory
14 AC_MSG_CHECKING([main docdir])
15
16 if test "x${with_doc_dir}" != "x"
17 then # docdir is given as parameter
18     docdir="${with_doc_dir}"
19     AC_MSG_RESULT([${docdir} (from parameter)])
20 else # otherwise invent a docdir hopefully compatible with system policy
21     if test -d "/usr/share/doc"
22     then
23         maindocdir='${prefix}/share/doc'
24         AC_MSG_RESULT([${maindocdir} (FHS style)])
25     elif test -d "/usr/doc"
26     then
27         maindocdir='${prefix}/doc'
28         AC_MSG_RESULT([${maindocdir} (old style)])
29     else
30         maindocdir='${datadir}/doc'
31         AC_MSG_RESULT([${maindocdir} (default value)])
32     fi
33     AC_MSG_CHECKING(package docdir)
34     # check whether to include package version into documentation path
35     # FIXME: doesn't work properly.
36     if ls -d /usr/{share/,}doc/*-[[]0-9[]]* > /dev/null 2>&1
37     then
38         docdir="${maindocdir}/${PACKAGE}-${VERSION}"
39         AC_MSG_RESULT([${docdir} (redhat style)])
40     else
41         docdir="${maindocdir}/${PACKAGE}"
42         AC_MSG_RESULT([${docdir} (default style)])
43     fi
44 fi
45
46 AC_SUBST(docdir)
47
48 ])dnl
49
50 dnl Solaris hack for grep and tr
51 AC_DEFUN([GP_CHECK_TR],
52 [
53 if test -n "`echo $host_os | grep '[sS]olaris'`"; then
54   TR=/usr/xpg4/bin/tr
55   GREP=/usr/xpg4/bin/grep  
56 else
57   TR=tr
58   GREP=grep
59 fi      
60 ])
61
62 dnl
63 dnl check whether to build docs and where to:
64 dnl
65 dnl * determine presence of prerequisites (only gtk-doc for now)
66 dnl * determine destination directory for HTML files
67 dnl
68
69 AC_DEFUN([GP_BUILD_DOCS],
70 [
71 # doc dir has to be determined in advance
72 AC_REQUIRE([GP_CHECK_DOCDIR])
73 AC_REQUIRE([GP_CHECK_GTK_DOC])
74 AC_REQUIRE([GP_CHECK_FIG2DEV])
75 AC_REQUIRE([GP_CHECK_DOCBOOK_XML])
76 AC_REQUIRE([GP_CHECK_TR])
77 AC_REQUIRE([GP_CHECK_PSTOIMG])
78 AC_REQUIRE([GP_CHECK_DOT])
79 AC_REQUIRE([GP_CHECK_W3M])
80
81 gphoto2xml='$(top_srcdir)/src/gphoto2.xml'
82 AC_SUBST(gphoto2xml)
83
84 dnl ---------------------------------------------------------------------------
85 dnl Give the user the possibility to install documentation in
86 dnl user-defined locations.
87 dnl ---------------------------------------------------------------------------
88 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH      Where to install html docs [default=autodetect]])
89 AC_MSG_CHECKING([for html dir])
90 if test "x${with_html_dir}" = "x" ; then
91     htmldir="${docdir}/html"
92     AC_MSG_RESULT([${htmldir} (default)])
93 else
94     htmldir="${with_html_dir}"
95     AC_MSG_RESULT([${htmldir} (from parameter)])
96 fi
97 AC_SUBST(htmldir)
98
99 AC_ARG_WITH(xhtml-dir, [  --with-xhtml-dir=PATH     Where to install xhtml docs [default=autodetect]])
100 AC_MSG_CHECKING([for xhtml dir])
101 if test "x${with_xhtml_dir}" = "x" ; then
102     xhtmldir="${docdir}/xhtml"
103     AC_MSG_RESULT([${xhtmldir} (default)])
104 else
105     xhtmldir="${with_xhtml_dir}"
106     AC_MSG_RESULT([${xhtmldir} (from parameter)])
107 fi
108 AC_SUBST(xhtmldir)
109
110 AC_ARG_WITH(html-nochunks-dir, [  --with-html-nochunks-dir=PATH      Where to install html-nochunks docs [default=autodetect]])
111 AC_MSG_CHECKING([for html-nochunks dir])
112 if test "x${with_html_nochunks_dir}" = "x" ; then
113     htmlnochunksdir="${docdir}/html-nochunks"
114     AC_MSG_RESULT([${htmlnochunksdir} (default)])
115 else
116     htmlnochunksdir="${with_html_nochunks_dir}"
117     AC_MSG_RESULT([${htmlnochunksdir} (from parameter)])
118 fi
119 AC_SUBST(htmlnochunksdir)
120
121 AC_ARG_WITH(xhtml-nochunks-dir, [  --with-xhtml-nochunks-dir=PATH      Where to install xhtml-nochunks docs [default=autodetect]])
122 AC_MSG_CHECKING([for xhtml-nochunks dir])
123 if test "x${with_xhtml_nochunks_dir}" = "x" ; then
124     xhtmlnochunksdir="${docdir}/xhtml-nochunks"
125     AC_MSG_RESULT([${xhtmlnochunksdir} (default)])
126 else
127     xhtmlnochunksdir="${with_xhtml_nochunks_dir}"
128     AC_MSG_RESULT([${xhtmlnochunksdir} (from parameter)])
129 fi
130 AC_SUBST(xhtmlnochunksdir)
131
132 AC_ARG_WITH(xml-dir, [  --with-xml-dir=PATH      Where to install xml docs [default=autodetect]])
133 AC_MSG_CHECKING([for xml dir])
134 if test "x${with_xml_dir}" = "x" ; then
135     xmldir="${docdir}/xml"
136     AC_MSG_RESULT([${xmldir} (default)])
137 else
138     xmldir="${with_xml_dir}"
139     AC_MSG_RESULT([${xmldir} (from parameter)])
140 fi
141 AC_SUBST(xmldir)
142 xmlcssdir="${xmldir}/css"
143 AC_SUBST(xmlcssdir)
144
145 AC_ARG_WITH(txt-dir, [  --with-txt-dir=PATH      Where to install txt docs [default=autodetect]])
146 AC_MSG_CHECKING([for txt dir])
147 if test "x${with_txt_dir}" = "x" ; then
148     txtdir="${docdir}/txt"
149     AC_MSG_RESULT([${txtdir} (default)])
150 else
151     txtdir="${with_txt_dir}"
152     AC_MSG_RESULT([${txtdir} (from parameter)])
153 fi
154 AC_SUBST(txtdir)
155
156 AC_ARG_WITH(man-dir, [  --with-man-dir=PATH      Where to install man docs [default=autodetect]])
157 AC_MSG_CHECKING([for man dir])
158 if test "x${with_man_dir}" = "x" ; then
159     manmandir="${docdir}/man"
160     AC_MSG_RESULT([${manmandir} (default)])
161 else
162     manmandir="${with_man_dir}"
163     AC_MSG_RESULT([${manmandir} (from parameter)])
164 fi
165 AC_SUBST(manmandir)
166
167 AC_ARG_WITH(pdf-dir, [  --with-pdf-dir=PATH      Where to install pdf docs [default=autodetect]])
168 AC_MSG_CHECKING([for pdf dir])
169 if test "x${with_pdf_dir}" = "x" ; then
170     pdfdir="${docdir}/pdf"
171     AC_MSG_RESULT([${pdfdir} (default)])
172 else
173     pdfdir="${with_pdf_dir}"
174     AC_MSG_RESULT([${pdfdir} (from parameter)])
175 fi
176 AC_SUBST(pdfdir)
177
178 AC_ARG_WITH(ps-dir, [  --with-ps-dir=PATH      Where to install ps docs [default=autodetect]])
179 AC_MSG_CHECKING([for ps dir])
180 if test "x${with_ps_dir}" = "x" ; then
181     psdir="${docdir}/ps"
182     AC_MSG_RESULT([${psdir} (default)])
183 else
184     psdir="${with_ps_dir}"
185     AC_MSG_RESULT([${psdir} (from parameter)])
186 fi
187 AC_SUBST(psdir)
188
189 AC_ARG_WITH(figure-dir, [  --with-figure-dir=PATH      Where to install figures [default=autodetect]])
190 AC_MSG_CHECKING([for figure dir])
191 if test "x${with_figure_dir}" = "x" ; then
192     figuredir="${docdir}/figures"
193     AC_MSG_RESULT([${figuredir} (default)])
194 else
195     figuredir="${with_figure_dir}"
196     AC_MSG_RESULT([${figuredir} (from parameter)])
197 fi
198 AC_SUBST(figuredir)
199
200 AC_ARG_WITH(screenshots-dir, [  --with-screenshots-dir=PATH      Where to install screenshotss [default=autodetect]])
201 AC_MSG_CHECKING([for screenshots dir])
202 if test "x${with_screenshots_dir}" = "x" ; then
203     screenshotsdir="${docdir}/screenshots"
204     AC_MSG_RESULT([${screenshotsdir} (default)])
205 else
206     screenshotsdir="${with_screenshots_dir}"
207     AC_MSG_RESULT([${screenshotsdir} (from parameter)])
208 fi
209 AC_SUBST(screenshotsdir)
210 screenshotsgtkamdir="${screenshotsdir}/gtkam"
211 AC_SUBST(screenshotsgtkamdir)
212
213 doc_formats_list='man html txt ps pdf'
214
215 # initialize have_xmlto* to false
216 for i in $doc_formats_list; do
217   d=`echo $i | $TR A-Z a-z`
218   eval "have_xmlto$d=false"
219 done
220
221 AC_MSG_CHECKING(checking doc formats)
222 AC_ARG_WITH(doc_formats,
223   [  --with-doc-formats=<list>   create doc with format in <list>; ]
224   [                            'all' build all doc formats; ]
225   [                            possible formats are: ]
226   [                            man, html, ps, pdf ],
227   doc_formats="$withval", doc_formats="man html txt")
228
229 if test "$doc_formats" = "all"; then
230   doc_formats=$doc_formats_list
231 else
232   doc_formats=`echo $doc_formats | sed 's/,/ /g'`
233 fi
234
235 # set have_xmlto* to true if requested and possible
236 if $have_xmlto; then
237   for i in $doc_formats; do
238     if test -n "`echo $doc_formats_list | $GREP -E \"(^| )$i( |\$)\"`"; then
239       eval "have_xmlto$i=true"
240     else
241       AC_ERROR(Unknown doc format $i!)
242     fi
243   done
244   AC_MSG_RESULT($doc_formats)
245 else
246   AC_MSG_RESULT([deactivated (requires xmlto)])
247 fi
248
249 # Make sure that xmltopdf actually works
250 if $have_xmltopdf; then
251         AC_MSG_CHECKING([whether pdf creation works])
252         oldcwd="$(pwd)"
253         top_srcdir() { echo "$srcdir"; }
254         mkdir test-pdf
255         cd test-pdf
256         cat>test-db.xml<<EOF
257 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
258  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
259 <book id="foobook">
260         <bookinfo>
261                 <title>Foo Title</title>
262         </bookinfo>
263         <chapter id="foochapter">
264                 <title>Foo Chapter</title>
265                 <para>
266                         Foo bar blah blah
267                       <!--ulink url="https://www.hypothetical-url.invalid/with&amp;ersand">ampersand</ulink-->.
268                 </para>
269         </chapter>
270 </book>
271 EOF
272         ${PURE_XMLTO} pdf -o . test-db.xml --searchpath ..
273         if test -s test-db.pdf; then
274                 AC_MSG_RESULT([yes, look at $(pwd)/test-db.pdf to verify])
275         else
276                 if $have_xmltopdf; then
277                         AC_MSG_ERROR([PDF creation requested, but failed. See $(pwd) ...])
278                 else
279                         AC_MSG_RESULT([no, but not requested])
280                 fi
281         fi
282         cd "$oldcwd"
283         unset top_srcdir
284 fi
285
286 AM_CONDITIONAL(XMLTOHTML,$have_xmltohtml)
287 AM_CONDITIONAL(XMLTOMAN,$have_xmltoman)
288 AM_CONDITIONAL(XMLTOTXT,$have_xmltotxt)
289 AM_CONDITIONAL(XMLTOTXT2,$have_xmltotxt && $have_w3m)
290 AM_CONDITIONAL(XMLTOPDF,$have_xmltopdf)
291 AM_CONDITIONAL(XMLTOPS,$have_xmltops)
292
293 # create list of supported formats
294 AC_MSG_CHECKING([for manual formats to re­create])
295 xxx=""
296 manual_html=""
297 manual_pdf=""
298 manual_ps=""
299 if $have_xmltohtml; then
300         xxx="${xxx} html"
301 fi
302 if $have_xmltoman; then
303         xxx="${xxx} man"
304 fi
305 if $have_xmltopdf; then
306         xxx="${xxx} pdf"
307 fi
308 if $have_xmltops; then 
309         xxx="${xxx} ps"
310 fi
311 if $have_xmltotxt; then 
312         xxx="${xxx} txt"
313 fi
314 AC_SUBST(manual_html)
315 AC_SUBST(manual_pdf)
316 AC_SUBST(manual_ps)
317 AC_MSG_RESULT($xxx)
318
319 if test "x$xxx" != "x"
320 then
321         if $have_fig2dev; then
322                 fig_out=""
323         else
324                 fig_out="out"
325         fi
326         manual_msg="in (${xxx} ) formats with${fig_out} figures"
327 fi
328
329 ])dnl