File: gp-manual-documentation.m4

package info (click to toggle)
gtkam 1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 4,328 kB
  • sloc: ansic: 10,269; sh: 4,858; xml: 816; makefile: 233
file content (329 lines) | stat: -rw-r--r-- 9,607 bytes parent folder | download | duplicates (31)
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
dnl
dnl check where to install documentation
dnl
dnl determines documentation "root directory", i.e. the directory
dnl where all documentation will be placed in
dnl

AC_DEFUN([GP_CHECK_DOCDIR],
[

AC_ARG_WITH(doc-dir, [  --with-doc-dir=PATH       Where to install docs  [default=autodetect]])dnl

# check for the main ("root") documentation directory
AC_MSG_CHECKING([main docdir])

if test "x${with_doc_dir}" != "x"
then # docdir is given as parameter
    docdir="${with_doc_dir}"
    AC_MSG_RESULT([${docdir} (from parameter)])
else # otherwise invent a docdir hopefully compatible with system policy
    if test -d "/usr/share/doc"
    then
        maindocdir='${prefix}/share/doc'
        AC_MSG_RESULT([${maindocdir} (FHS style)])
    elif test -d "/usr/doc"
    then
        maindocdir='${prefix}/doc'
        AC_MSG_RESULT([${maindocdir} (old style)])
    else
        maindocdir='${datadir}/doc'
        AC_MSG_RESULT([${maindocdir} (default value)])
    fi
    AC_MSG_CHECKING(package docdir)
    # check whether to include package version into documentation path
    # FIXME: doesn't work properly.
    if ls -d /usr/{share/,}doc/*-[[]0-9[]]* > /dev/null 2>&1
    then
        docdir="${maindocdir}/${PACKAGE}-${VERSION}"
        AC_MSG_RESULT([${docdir} (redhat style)])
    else
        docdir="${maindocdir}/${PACKAGE}"
        AC_MSG_RESULT([${docdir} (default style)])
    fi
fi

AC_SUBST(docdir)

])dnl

dnl Solaris hack for grep and tr
AC_DEFUN([GP_CHECK_TR],
[
if test -n "`echo $host_os | grep '[sS]olaris'`"; then
  TR=/usr/xpg4/bin/tr
  GREP=/usr/xpg4/bin/grep  
else
  TR=tr
  GREP=grep
fi	
])

dnl
dnl check whether to build docs and where to:
dnl
dnl * determine presence of prerequisites (only gtk-doc for now)
dnl * determine destination directory for HTML files
dnl

AC_DEFUN([GP_BUILD_DOCS],
[
# doc dir has to be determined in advance
AC_REQUIRE([GP_CHECK_DOCDIR])
AC_REQUIRE([GP_CHECK_GTK_DOC])
AC_REQUIRE([GP_CHECK_FIG2DEV])
AC_REQUIRE([GP_CHECK_DOCBOOK_XML])
AC_REQUIRE([GP_CHECK_TR])
AC_REQUIRE([GP_CHECK_PSTOIMG])
AC_REQUIRE([GP_CHECK_DOT])
AC_REQUIRE([GP_CHECK_W3M])

gphoto2xml='$(top_srcdir)/src/gphoto2.xml'
AC_SUBST(gphoto2xml)

dnl ---------------------------------------------------------------------------
dnl Give the user the possibility to install documentation in
dnl user-defined locations.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(html-dir, [  --with-html-dir=PATH      Where to install html docs [default=autodetect]])
AC_MSG_CHECKING([for html dir])
if test "x${with_html_dir}" = "x" ; then
    htmldir="${docdir}/html"
    AC_MSG_RESULT([${htmldir} (default)])
else
    htmldir="${with_html_dir}"
    AC_MSG_RESULT([${htmldir} (from parameter)])
fi
AC_SUBST(htmldir)

AC_ARG_WITH(xhtml-dir, [  --with-xhtml-dir=PATH     Where to install xhtml docs [default=autodetect]])
AC_MSG_CHECKING([for xhtml dir])
if test "x${with_xhtml_dir}" = "x" ; then
    xhtmldir="${docdir}/xhtml"
    AC_MSG_RESULT([${xhtmldir} (default)])
else
    xhtmldir="${with_xhtml_dir}"
    AC_MSG_RESULT([${xhtmldir} (from parameter)])
fi
AC_SUBST(xhtmldir)

AC_ARG_WITH(html-nochunks-dir, [  --with-html-nochunks-dir=PATH      Where to install html-nochunks docs [default=autodetect]])
AC_MSG_CHECKING([for html-nochunks dir])
if test "x${with_html_nochunks_dir}" = "x" ; then
    htmlnochunksdir="${docdir}/html-nochunks"
    AC_MSG_RESULT([${htmlnochunksdir} (default)])
else
    htmlnochunksdir="${with_html_nochunks_dir}"
    AC_MSG_RESULT([${htmlnochunksdir} (from parameter)])
fi
AC_SUBST(htmlnochunksdir)

AC_ARG_WITH(xhtml-nochunks-dir, [  --with-xhtml-nochunks-dir=PATH      Where to install xhtml-nochunks docs [default=autodetect]])
AC_MSG_CHECKING([for xhtml-nochunks dir])
if test "x${with_xhtml_nochunks_dir}" = "x" ; then
    xhtmlnochunksdir="${docdir}/xhtml-nochunks"
    AC_MSG_RESULT([${xhtmlnochunksdir} (default)])
else
    xhtmlnochunksdir="${with_xhtml_nochunks_dir}"
    AC_MSG_RESULT([${xhtmlnochunksdir} (from parameter)])
fi
AC_SUBST(xhtmlnochunksdir)

AC_ARG_WITH(xml-dir, [  --with-xml-dir=PATH      Where to install xml docs [default=autodetect]])
AC_MSG_CHECKING([for xml dir])
if test "x${with_xml_dir}" = "x" ; then
    xmldir="${docdir}/xml"
    AC_MSG_RESULT([${xmldir} (default)])
else
    xmldir="${with_xml_dir}"
    AC_MSG_RESULT([${xmldir} (from parameter)])
fi
AC_SUBST(xmldir)
xmlcssdir="${xmldir}/css"
AC_SUBST(xmlcssdir)

AC_ARG_WITH(txt-dir, [  --with-txt-dir=PATH      Where to install txt docs [default=autodetect]])
AC_MSG_CHECKING([for txt dir])
if test "x${with_txt_dir}" = "x" ; then
    txtdir="${docdir}/txt"
    AC_MSG_RESULT([${txtdir} (default)])
else
    txtdir="${with_txt_dir}"
    AC_MSG_RESULT([${txtdir} (from parameter)])
fi
AC_SUBST(txtdir)

AC_ARG_WITH(man-dir, [  --with-man-dir=PATH      Where to install man docs [default=autodetect]])
AC_MSG_CHECKING([for man dir])
if test "x${with_man_dir}" = "x" ; then
    manmandir="${docdir}/man"
    AC_MSG_RESULT([${manmandir} (default)])
else
    manmandir="${with_man_dir}"
    AC_MSG_RESULT([${manmandir} (from parameter)])
fi
AC_SUBST(manmandir)

AC_ARG_WITH(pdf-dir, [  --with-pdf-dir=PATH      Where to install pdf docs [default=autodetect]])
AC_MSG_CHECKING([for pdf dir])
if test "x${with_pdf_dir}" = "x" ; then
    pdfdir="${docdir}/pdf"
    AC_MSG_RESULT([${pdfdir} (default)])
else
    pdfdir="${with_pdf_dir}"
    AC_MSG_RESULT([${pdfdir} (from parameter)])
fi
AC_SUBST(pdfdir)

AC_ARG_WITH(ps-dir, [  --with-ps-dir=PATH      Where to install ps docs [default=autodetect]])
AC_MSG_CHECKING([for ps dir])
if test "x${with_ps_dir}" = "x" ; then
    psdir="${docdir}/ps"
    AC_MSG_RESULT([${psdir} (default)])
else
    psdir="${with_ps_dir}"
    AC_MSG_RESULT([${psdir} (from parameter)])
fi
AC_SUBST(psdir)

AC_ARG_WITH(figure-dir, [  --with-figure-dir=PATH      Where to install figures [default=autodetect]])
AC_MSG_CHECKING([for figure dir])
if test "x${with_figure_dir}" = "x" ; then
    figuredir="${docdir}/figures"
    AC_MSG_RESULT([${figuredir} (default)])
else
    figuredir="${with_figure_dir}"
    AC_MSG_RESULT([${figuredir} (from parameter)])
fi
AC_SUBST(figuredir)

AC_ARG_WITH(screenshots-dir, [  --with-screenshots-dir=PATH      Where to install screenshotss [default=autodetect]])
AC_MSG_CHECKING([for screenshots dir])
if test "x${with_screenshots_dir}" = "x" ; then
    screenshotsdir="${docdir}/screenshots"
    AC_MSG_RESULT([${screenshotsdir} (default)])
else
    screenshotsdir="${with_screenshots_dir}"
    AC_MSG_RESULT([${screenshotsdir} (from parameter)])
fi
AC_SUBST(screenshotsdir)
screenshotsgtkamdir="${screenshotsdir}/gtkam"
AC_SUBST(screenshotsgtkamdir)

doc_formats_list='man html txt ps pdf'

# initialize have_xmlto* to false
for i in $doc_formats_list; do
  d=`echo $i | $TR A-Z a-z`
  eval "have_xmlto$d=false"
done

AC_MSG_CHECKING(checking doc formats)
AC_ARG_WITH(doc_formats,
  [  --with-doc-formats=<list>   create doc with format in <list>; ]
  [                            'all' build all doc formats; ]
  [                            possible formats are: ]
  [                            man, html, ps, pdf ],
  doc_formats="$withval", doc_formats="man html txt")

if test "$doc_formats" = "all"; then
  doc_formats=$doc_formats_list
else
  doc_formats=`echo $doc_formats | sed 's/,/ /g'`
fi

# set have_xmlto* to true if requested and possible
if $have_xmlto; then
  for i in $doc_formats; do
    if test -n "`echo $doc_formats_list | $GREP -E \"(^| )$i( |\$)\"`"; then
      eval "have_xmlto$i=true"
    else
      AC_ERROR(Unknown doc format $i!)
    fi
  done
  AC_MSG_RESULT($doc_formats)
else
  AC_MSG_RESULT([deactivated (requires xmlto)])
fi

# Make sure that xmltopdf actually works
if $have_xmltopdf; then
	AC_MSG_CHECKING([whether pdf creation works])
	oldcwd="$(pwd)"
	top_srcdir() { echo "$srcdir"; }
	mkdir test-pdf
	cd test-pdf
	cat>test-db.xml<<EOF
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<book id="foobook">
	<bookinfo>
		<title>Foo Title</title>
	</bookinfo>
	<chapter id="foochapter">
		<title>Foo Chapter</title>
		<para>
			Foo bar blah blah
		      <!--ulink url="https://www.hypothetical-url.invalid/with&amp;ersand">ampersand</ulink-->.
		</para>
	</chapter>
</book>
EOF
	${PURE_XMLTO} pdf -o . test-db.xml --searchpath ..
	if test -s test-db.pdf; then
		AC_MSG_RESULT([yes, look at $(pwd)/test-db.pdf to verify])
	else
		if $have_xmltopdf; then
			AC_MSG_ERROR([PDF creation requested, but failed. See $(pwd) ...])
		else
			AC_MSG_RESULT([no, but not requested])
		fi
	fi
	cd "$oldcwd"
	unset top_srcdir
fi

AM_CONDITIONAL(XMLTOHTML,$have_xmltohtml)
AM_CONDITIONAL(XMLTOMAN,$have_xmltoman)
AM_CONDITIONAL(XMLTOTXT,$have_xmltotxt)
AM_CONDITIONAL(XMLTOTXT2,$have_xmltotxt && $have_w3m)
AM_CONDITIONAL(XMLTOPDF,$have_xmltopdf)
AM_CONDITIONAL(XMLTOPS,$have_xmltops)

# create list of supported formats
AC_MSG_CHECKING([for manual formats to recreate])
xxx=""
manual_html=""
manual_pdf=""
manual_ps=""
if $have_xmltohtml; then
        xxx="${xxx} html"
fi
if $have_xmltoman; then
        xxx="${xxx} man"
fi
if $have_xmltopdf; then
        xxx="${xxx} pdf"
fi
if $have_xmltops; then 
        xxx="${xxx} ps"
fi
if $have_xmltotxt; then 
        xxx="${xxx} txt"
fi
AC_SUBST(manual_html)
AC_SUBST(manual_pdf)
AC_SUBST(manual_ps)
AC_MSG_RESULT($xxx)

if test "x$xxx" != "x"
then
        if $have_fig2dev; then
                fig_out=""
        else
                fig_out="out"
        fi
        manual_msg="in (${xxx} ) formats with${fig_out} figures"
fi

])dnl