summaryrefslogtreecommitdiff
path: root/macros/mm-doc.m4
blob: 0552913acc40e78ea3f5ab6babcfc8aa76fc7f81 (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) 2009  Daniel Elstner <daniel.kitta@gmail.com>
##
## This file is part of mm-common.
##
## mm-common 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 2 of the License,
## or (at your option) any later version.
##
## mm-common 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 mm-common.  If not, see <http://www.gnu.org/licenses/>.

#serial 20090811

## _MM_CONFIG_DOCTOOL_DIR
##
## Query pkg-config for the location of the documentation utilities
## shared by the GNOME C++ bindings.  This is the code path invoked
## from MM_CONFIG_DOCTOOL_DIR when called without a directory name.
##
m4_define([_MM_CONFIG_DOCTOOL_DIR],
[dnl
AC_PROVIDE([$0])[]dnl
AC_REQUIRE([PKG_PROG_PKG_CONFIG])[]dnl
dnl
AC_MSG_CHECKING([location of documentation utilities])
AS_IF([test "x$MMDOCTOOLDIR" = x],
[
  mm_doctooldir=`$PKG_CONFIG --variable doctooldir glibmm-2.4 2>&AS_MESSAGE_LOG_FD`
  AS_IF([test "[$]?" -ne 0],
        [AC_MSG_ERROR([[not found
The required module glibmm could not be found on this system.  If you
are running a binary distribution and the glibmm package is installed,
make sure that any separate development package for glibmm is installed
as well.  If you built glibmm yourself, it may be necessary to adjust
the PKG_CONFIG_PATH environment variable for pkg-config to find it.
]])])
  AS_IF([test "x$mm_doctooldir" = x],
        [AC_MSG_ERROR([[not found
The glibmm module is available, but the installation of glibmm on this
machine is missing the shared documentation utilities of the GNOME C++
bindings.  It may be necessary to upgrade to a more recent release of
glibmm in order to build $PACKAGE_NAME.
]])])
  MMDOCTOOLDIR=$mm_doctooldir[]dnl
])
AC_MSG_RESULT([$MMDOCTOOLDIR])[]dnl
])

## MM_CONFIG_DOCTOOL_DIR([directory])
##
## Define the location of the documentation utilities shared by the
## GNOME C++ binding modules.  If the <directory> argument is given,
## it should name a directory relative to the toplevel directory of
## the source tree.
##
## The directory name is used by mm-common-prepare as the destination
## for copying the required files into the source tree.  If you make
## use of this feature in order to avoid a dependency on glibmm, make
## sure to include the installed files in the distribution tarball of
## your package.
##
AC_DEFUN([MM_CONFIG_DOCTOOL_DIR],
[dnl
AC_REQUIRE([_MM_PRE_INIT])[]dnl
m4_ifval([$1], [MMDOCTOOLDIR='[$]{top_srcdir}/$1'], [AC_REQUIRE([_MM_CONFIG_DOCTOOL_DIR])])
AC_SUBST([MMDOCTOOLDIR])[]dnl
])

## _MM_ARG_ENABLE_DOCUMENTATION
##
## Implementation of MM_ARG_ENABLE_DOCUMENTATION, pulled in indirectly
## through AC_REQUIRE() to make sure it is expanded only once.
##
m4_define([_MM_ARG_ENABLE_DOCUMENTATION],
[dnl
AC_PROVIDE([$0])[]dnl
dnl
AC_ARG_VAR([PERL], [path to Perl interpreter])[]dnl
AC_ARG_VAR([DOT], [path to dot utility])[]dnl
AC_ARG_VAR([DOXYGEN], [path to Doxygen utility])[]dnl
AC_ARG_VAR([XSLTPROC], [path to xsltproc utility])[]dnl
dnl
AC_PATH_PROG([PERL], [perl], [perl])
AC_PATH_PROG([DOT], [dot], [dot])
AC_PATH_PROG([DOXYGEN], [doxygen], [doxygen])
AC_PATH_PROG([XSLTPROC], [xsltproc], [xsltproc])
dnl
AC_ARG_ENABLE([documentation],
              [AS_HELP_STRING([--disable-documentation],
                              [do not build or install the documentation])],
              [ENABLE_DOCUMENTATION=$enableval],
              [ENABLE_DOCUMENTATION=yes])
AS_IF([test "x$ENABLE_DOCUMENTATION" != xno],
[
  AS_IF([test "x$PERL" = xperl],
        [AC_MSG_FAILURE([[Perl is required for installing the documentation.]])])

  AS_IF([test "x$USE_MAINTAINER_MODE" != xno],
  [
    for mm_prog in "$DOT" "$DOXYGEN" "$XSLTPROC"
    do
      AS_CASE([$mm_prog], [[dot|doxygen|xsltproc]],
              [AC_MSG_FAILURE([[The documentation will be built in this configuration,
but the required tool $mm_prog could not be found.]])])
    done
  ])[]dnl
])
AM_CONDITIONAL([ENABLE_DOCUMENTATION], [test "x$ENABLE_DOCUMENTATION" != xno])
AC_SUBST([DOXYGEN_TAGFILES], [[]])
AC_SUBST([DOCINSTALL_FLAGS], [[]])[]dnl
])

## MM_ARG_ENABLE_DOCUMENTATION
##
## Provide the --disable-documentation configure option.  By default,
## the documentation will be included in the build.  If not explicitly
## disabled, also check whether the necessary tools are installed, and
## abort if any are missing.
##
## The tools checked for are Perl, dot, Doxygen and xsltproc.  The
## substitution variables PERL, DOT, DOXYGEN and XSLTPROC are set to
## the command paths, unless overridden in the user environment.
##
## If the package provides the --enable-maintainer-mode option, the
## tools dot, Doxygen and xsltproc are mandatory only when maintainer
## mode is enabled.  Perl is required for the installdox utility even
## if not in maintainer mode.
##
AC_DEFUN([MM_ARG_ENABLE_DOCUMENTATION],
[dnl
AC_BEFORE([$0], [MM_ARG_WITH_TAGFILE_DOC])[]dnl
AC_REQUIRE([_MM_PRE_INIT])[]dnl
AC_REQUIRE([MM_CONFIG_DOCTOOL_DIR])[]dnl
AC_REQUIRE([_MM_ARG_ENABLE_DOCUMENTATION])[]dnl
])

## _MM_ARG_WITH_TAGFILE_DOC(option-basename, tagfilename, [module])
##
m4_define([_MM_ARG_WITH_TAGFILE_DOC],
[dnl
  AC_MSG_CHECKING([for $1 documentation])
  AC_ARG_WITH([$1-doc],
              [AS_HELP_STRING([[--with-$1-doc=[TAGFILE@]HTMLREFDIR]],
                              [Link to external $1 documentation]m4_ifval([$3], [[ [auto]]]))],
  [
    mm_htmlrefdir=`[expr "@$withval" : '.*@\(.*\)' 2>&]AS_MESSAGE_LOG_FD`
    mm_tagname=`[expr "/$withval" : '[^@]*[\\/]\([^\\/@]*\)@' 2>&]AS_MESSAGE_LOG_FD`
    mm_tagpath=`[expr "X$withval" : 'X\([^@]*\)@' 2>&]AS_MESSAGE_LOG_FD`
    test "x$mm_tagname" != x || mm_tagname="$2"
    test "x$mm_tagpath" != x || mm_tagpath=$mm_tagname[]dnl
  ], [
    mm_htmlrefdir=
    mm_tagname="$2"
    mm_tagpath=$mm_tagname[]dnl
  ])
  AS_CASE([$mm_tagpath], [[.[\\/]*|..[\\/]*]], [mm_tagpath=`pwd`/$mm_tagpath])
m4_ifval([$3], [dnl
  AS_IF([test "x$mm_htmlrefdir" = x],
  [
    mm_htmlrefdir=`$PKG_CONFIG --variable=htmlrefdir "$3" 2>&AS_MESSAGE_LOG_FD`dnl
  ])
  AS_CASE([$mm_htmlrefdir], [[http://*|https://*]], [mm_htmlrefpub=$mm_htmlrefdir],
  [
    mm_htmlrefpub=`$PKG_CONFIG --variable=htmlrefpub "$3" 2>&AS_MESSAGE_LOG_FD`
    test "x$mm_htmlrefpub" != x || mm_htmlrefpub=$mm_htmlrefdir
    test "x$mm_htmlrefdir" != x || mm_htmlrefdir=$mm_htmlrefpub
  ])
  AS_CASE([$mm_tagpath], [[*[\\/]*]],,
  [
    mm_doxytagfile=`$PKG_CONFIG --variable=doxytagfile "$3" 2>&AS_MESSAGE_LOG_FD`
    test "x$mm_doxytagfile" = x || mm_tagpath=$mm_doxytagfile
  ])
])[]dnl
  AC_MSG_RESULT([$mm_tagpath@$mm_htmlrefdir])

  AS_IF([test "x$USE_MAINTAINER_MODE" != xno && test ! -f "$mm_tagpath"],
        [AC_MSG_WARN([Doxygen tag file $2 not found])])
  AS_IF([test "x$mm_htmlrefdir" = x],
        [AC_MSG_WARN([Location of external $1 documentation not set])],
        [AS_IF([test "x$DOCINSTALL_FLAGS" = x],
               [DOCINSTALL_FLAGS="-l '$mm_tagname@$mm_htmlrefdir'"],
               [DOCINSTALL_FLAGS="$DOCINSTALL_FLAGS -l '$mm_tagname@$mm_htmlrefdir'"])])

  AS_IF([test "x$[mm_htmlref]m4_ifval([$3], [pub], [dir])" = x],
        [mm_val=$mm_tagpath],
        [mm_val="$mm_tagpath=$[mm_htmlref]m4_ifval([$3], [pub], [dir])"])
  AS_IF([test "x$DOXYGEN_TAGFILES" = x],
        [DOXYGEN_TAGFILES=[\]"$mm_val[\]"],
        [DOXYGEN_TAGFILES="$DOXYGEN_TAGFILES "[\]"$mm_val[\]"])[]dnl
])

## MM_ARG_WITH_TAGFILE_DOC(tagfilename, [module])
##
## Provide a --with-<tagfilebase>-doc=[/path/tagfile@]htmlrefdir configure
## option, which may be used to specify the location of a tag file and the
## path to the corresponding HTML reference documentation.  If the project
## provides the maintainer mode option and maintainer mode is not enabled,
## the user does not have to provide the full path to the tag file.  The
## full path is only required for rebuilding the documentation.
##
## If the optional <module> argument has been specified, and either the tag
## file or the HTML location have not been overridden by the user already,
## try to retrieve the missing paths automatically via pkg-config.  Also ask
## pkg-config for the URI to the online documentation, for use as the preset
## location when the documentation is generated.
##
## A warning message will be shown if the HTML path could not be determined.
## If maintainer mode is active, a warning is also displayed if the tag file
## could not be found.
##
## The results are appended to the substitution variables DOXYGEN_TAGFILES
## and DOCINSTALL_FLAGS, using the following format:
##
##  DOXYGEN_TAGFILES = "/path/tagfile=htmlrefpub" [...]
##  DOCINSTALL_FLAGS = -l 'tagfile@htmlrefdir' [...]
##
## The substitutions are intended to be used for the Doxygen configuration,
## and as argument list to the doc-install.pl or installdox utility.
##
AC_DEFUN([MM_ARG_WITH_TAGFILE_DOC],
[dnl
m4_assert([$# >= 1])[]dnl
m4_ifval([$2], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])])[]dnl
AC_REQUIRE([MM_CONFIG_DOCTOOL_DIR])[]dnl
AC_REQUIRE([_MM_ARG_ENABLE_DOCUMENTATION])[]dnl
dnl
AS_IF([test "x$ENABLE_DOCUMENTATION" != xno], [_MM_ARG_WITH_TAGFILE_DOC(
  m4_quote(m4_bpatsubst([$1], [\([-+][0123456789]\|[+]*[._]\).*$])), [$1], [$2])])[]dnl
])