Merge branch '1957_build_AIX'
[midnight-commander.git] / m4.include / dx_doxygen.m4
blob705e61141b404d58301aab769b4b0217b69d040f
2 # Copyright 2007 Oren Ben-Kiki
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 #         http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing,
11 # software distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.  See the License for the specific language governing
14 # permissions and limitations under the License.
18 # Generate automatic documentation using Doxygen. Works in concert with the
19 # aminclude.m4 file and a compatible doxygen configuration file. Defines the
20 # following public macros:
22 # DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature.
23 # Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics,
24 # 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI'
25 # for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF',
26 # 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment
27 # variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide'
28 # paper size.
30 # By default, HTML, PDF and PS documentation is generated as this seems to be
31 # the most popular and portable combination. MAN pages created by Doxygen are
32 # usually problematic, though by picking an appropriate subset and doing some
33 # massaging they might be better than nothing. CHM and RTF are specific for MS
34 # (note that you can't generate both HTML and CHM at the same time). The XML is
35 # rather useless unless you apply specialized post-processing to it.
37 # The macro mainly controls the default state of the feature. The use can
38 # override the default by specifying --enable or --disable. The macros ensure
39 # that contradictory flags are not given (e.g., --enable-doxygen-html and
40 # --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.)
41 # Finally, each feature will be automatically disabled (with a warning) if the
42 # required programs are missing.
44 # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with
45 # the following parameters: a one-word name for the project for use as a
46 # filename base etc., an optional configuration file name (the default is
47 # 'Doxyfile', the same as Doxygen's default), and an optional output directory
48 # name (the default is 'doxygen-doc').
50 ## ----------##
51 ## Defaults. ##
52 ## ----------##
54 DX_ENV=""
55 AC_DEFUN([DX_FEATURE_doc],  ON)
56 AC_DEFUN([DX_FEATURE_dot],  ON)
57 AC_DEFUN([DX_FEATURE_man],  OFF)
58 AC_DEFUN([DX_FEATURE_html], ON)
59 AC_DEFUN([DX_FEATURE_chm],  OFF)
60 AC_DEFUN([DX_FEATURE_chi],  OFF)
61 AC_DEFUN([DX_FEATURE_rtf],  OFF)
62 AC_DEFUN([DX_FEATURE_xml],  OFF)
63 AC_DEFUN([DX_FEATURE_pdf],  ON)
64 AC_DEFUN([DX_FEATURE_ps],   ON)
66 ## --------------- ##
67 ## Private macros. ##
68 ## --------------- ##
70 # DX_ENV_APPEND(VARIABLE, VALUE)
71 # ------------------------------
72 # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
73 AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
75 # DX_DIRNAME_EXPR
76 # ---------------
77 # Expand into a shell expression prints the directory part of a path.
78 AC_DEFUN([DX_DIRNAME_EXPR],
79          [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
81 # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
82 # -------------------------------------
83 # Expands according to the M4 (static) status of the feature.
84 AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
86 # DX_REQUIRE_PROG(VARIABLE, PROGRAM)
87 # ----------------------------------
88 # Require the specified program to be found for the DX_CURRENT_FEATURE to work.
89 AC_DEFUN([DX_REQUIRE_PROG], [
90 AC_PATH_TOOL([$1], [$2])
91 if test x"$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = x1; then
92     AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
93     AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
97 # DX_TEST_FEATURE(FEATURE)
98 # ------------------------
99 # Expand to a shell expression testing whether the feature is active.
100 AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
102 # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
103 # -------------------------------------------------
104 # Verify that a required features has the right state before trying to turn on
105 # the DX_CURRENT_FEATURE.
106 AC_DEFUN([DX_CHECK_DEPEND], [
107 test x"$DX_FLAG_$1" = x"$2" \
108 || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
109                             requires, contradicts) doxygen-DX_CURRENT_FEATURE])
112 # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
113 # ----------------------------------------------------------
114 # Turn off the DX_CURRENT_FEATURE if the required feature is off.
115 AC_DEFUN([DX_CLEAR_DEPEND], [
116 test x"$DX_FLAG_$1" = x"$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
119 # DX_FEATURE_ARG(FEATURE, DESCRIPTION,
120 #                CHECK_DEPEND, CLEAR_DEPEND,
121 #                REQUIRE, DO-IF-ON, DO-IF-OFF)
122 # --------------------------------------------
123 # Parse the command-line option controlling a feature. CHECK_DEPEND is called
124 # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
125 # otherwise CLEAR_DEPEND is called to turn off the default state if a required
126 # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
127 # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
128 # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
129 AC_DEFUN([DX_ARG_ABLE], [
130     AC_DEFUN([DX_CURRENT_FEATURE], [$1])
131     AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
132     AC_ARG_ENABLE(doxygen-$1,
133                   [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
134                                                       [--enable-doxygen-$1]),
135                                   DX_IF_FEATURE([$1], [don't $2], [$2]))],
136                   [
137 case "$enableval" in
139 y|Y|yes|Yes|YES)
140     AC_SUBST([DX_FLAG_$1], 1)
141     $3
142 ;; #(
143 n|N|no|No|NO)
144     AC_SUBST([DX_FLAG_$1], 0)
145 ;; #(
147     AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
149 esac
150 ], [
151 AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
154 if DX_TEST_FEATURE([$1]); then
155     $5
156     :
158 if DX_TEST_FEATURE([$1]); then
159     AM_CONDITIONAL(DX_COND_$1, :)
160     $6
161     :
162 else
163     AM_CONDITIONAL(DX_COND_$1, false)
164     $7
165     :
169 ## -------------- ##
170 ## Public macros. ##
171 ## -------------- ##
173 # DX_XXX_FEATURE(DEFAULT_STATE)
174 # -----------------------------
175 AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc],  [$1])])
176 AC_DEFUN([DX_MAN_FEATURE],     [AC_DEFUN([DX_FEATURE_man],  [$1])])
177 AC_DEFUN([DX_HTML_FEATURE],    [AC_DEFUN([DX_FEATURE_html], [$1])])
178 AC_DEFUN([DX_CHM_FEATURE],     [AC_DEFUN([DX_FEATURE_chm],  [$1])])
179 AC_DEFUN([DX_CHI_FEATURE],     [AC_DEFUN([DX_FEATURE_chi],  [$1])])
180 AC_DEFUN([DX_RTF_FEATURE],     [AC_DEFUN([DX_FEATURE_rtf],  [$1])])
181 AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
182 AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
183 AC_DEFUN([DX_PDF_FEATURE],     [AC_DEFUN([DX_FEATURE_pdf],  [$1])])
184 AC_DEFUN([DX_PS_FEATURE],      [AC_DEFUN([DX_FEATURE_ps],   [$1])])
186 # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
187 # ---------------------------------------------------------
188 # PROJECT also serves as the base name for the documentation files.
189 # The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
190 AC_DEFUN([DX_INIT_DOXYGEN], [
192 # Files:
193 AC_SUBST([DX_PROJECT], [$1])
194 AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
195 AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
197 # Environment variables used inside doxygen.cfg:
198 SRCDIR=`cd $srcdir; pwd`
199 DX_ENV_APPEND(SRCDIR, $SRCDIR)
200 DX_ENV_APPEND(PROJECT, $DX_PROJECT)
201 DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
202 DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
204 # Doxygen itself:
205 DX_ARG_ABLE(doc, [generate any doxygen documentation],
206             [],
207             [],
208             [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
209              DX_REQUIRE_PROG([DX_PERL], perl)],
210             [DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
212 # Dot for graphics:
213 DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
214             [DX_CHECK_DEPEND(doc, 1)],
215             [DX_CLEAR_DEPEND(doc, 1)],
216             [DX_REQUIRE_PROG([DX_DOT], dot)],
217             [DX_ENV_APPEND(HAVE_DOT, YES)
218              DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
219             [DX_ENV_APPEND(HAVE_DOT, NO)])
221 # Man pages generation:
222 DX_ARG_ABLE(man, [generate doxygen manual pages],
223             [DX_CHECK_DEPEND(doc, 1)],
224             [DX_CLEAR_DEPEND(doc, 1)],
225             [],
226             [DX_ENV_APPEND(GENERATE_MAN, YES)],
227             [DX_ENV_APPEND(GENERATE_MAN, NO)])
229 # RTF file generation:
230 DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
231             [DX_CHECK_DEPEND(doc, 1)],
232             [DX_CLEAR_DEPEND(doc, 1)],
233             [],
234             [DX_ENV_APPEND(GENERATE_RTF, YES)],
235             [DX_ENV_APPEND(GENERATE_RTF, NO)])
237 # XML file generation:
238 DX_ARG_ABLE(xml, [generate doxygen XML documentation],
239             [DX_CHECK_DEPEND(doc, 1)],
240             [DX_CLEAR_DEPEND(doc, 1)],
241             [],
242             [DX_ENV_APPEND(GENERATE_XML, YES)],
243             [DX_ENV_APPEND(GENERATE_XML, NO)])
245 # (Compressed) HTML help generation:
246 DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
247             [DX_CHECK_DEPEND(doc, 1)],
248             [DX_CLEAR_DEPEND(doc, 1)],
249             [DX_REQUIRE_PROG([DX_HHC], hhc)],
250             [DX_ENV_APPEND(HHC_PATH, $DX_HHC)
251              DX_ENV_APPEND(GENERATE_HTML, YES)
252              DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
253             [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
255 # Seperate CHI file generation.
256 DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
257             [DX_CHECK_DEPEND(chm, 1)],
258             [DX_CLEAR_DEPEND(chm, 1)],
259             [],
260             [DX_ENV_APPEND(GENERATE_CHI, YES)],
261             [DX_ENV_APPEND(GENERATE_CHI, NO)])
263 # Plain HTML pages generation:
264 DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
265             [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
266             [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
267             [],
268             [DX_ENV_APPEND(GENERATE_HTML, YES)],
269             [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
271 # PostScript file generation:
272 DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
273             [DX_CHECK_DEPEND(doc, 1)],
274             [DX_CLEAR_DEPEND(doc, 1)],
275             [DX_REQUIRE_PROG([DX_LATEX], latex)
276              DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
277              DX_REQUIRE_PROG([DX_DVIPS], dvips)
278              DX_REQUIRE_PROG([DX_EGREP], egrep)])
280 # PDF file generation:
281 DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
282             [DX_CHECK_DEPEND(doc, 1)],
283             [DX_CLEAR_DEPEND(doc, 1)],
284             [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
285              DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
286              DX_REQUIRE_PROG([DX_EGREP], egrep)])
288 # LaTeX generation for PS and/or PDF:
289 if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
290     AM_CONDITIONAL(DX_COND_latex, :)
291     DX_ENV_APPEND(GENERATE_LATEX, YES)
292 else
293     AM_CONDITIONAL(DX_COND_latex, false)
294     DX_ENV_APPEND(GENERATE_LATEX, NO)
297 # Paper size for PS and/or PDF:
298 AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
299            [a4wide (default), a4, letter, legal or executive])
300 case "$DOXYGEN_PAPER_SIZE" in
303     AC_SUBST(DOXYGEN_PAPER_SIZE, "")
304 ;; #(
305 a4wide|a4|letter|legal|executive)
306     DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
307 ;; #(
309     AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
311 esac
313 #For debugging:
314 #echo DX_FLAG_doc=$DX_FLAG_doc
315 #echo DX_FLAG_dot=$DX_FLAG_dot
316 #echo DX_FLAG_man=$DX_FLAG_man
317 #echo DX_FLAG_html=$DX_FLAG_html
318 #echo DX_FLAG_chm=$DX_FLAG_chm
319 #echo DX_FLAG_chi=$DX_FLAG_chi
320 #echo DX_FLAG_rtf=$DX_FLAG_rtf
321 #echo DX_FLAG_xml=$DX_FLAG_xml
322 #echo DX_FLAG_pdf=$DX_FLAG_pdf
323 #echo DX_FLAG_ps=$DX_FLAG_ps
324 #echo DX_ENV=$DX_ENV