maemo-ui-old/m4/ac_doxygen.m4
branchtrunk
changeset 897 715f854a93cd
parent 23 915ef81992c0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/maemo-ui-old/m4/ac_doxygen.m4	Tue Jan 29 20:12:30 2008 +0000
     1.3 @@ -0,0 +1,312 @@
     1.4 +# This file is part of Autoconf.                       -*- Autoconf -*-
     1.5 +
     1.6 +# Copyright (C) 2004 Oren Ben-Kiki
     1.7 +# This file is distributed under the same terms as the Autoconf macro files.
     1.8 +
     1.9 +# Generate automatic documentation using Doxygen. Works in concert with the
    1.10 +# aminclude.m4 file and a compatible doxygen configuration file. Defines the
    1.11 +# following public macros:
    1.12 +#
    1.13 +# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature.
    1.14 +# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics,
    1.15 +# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI'
    1.16 +# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF',
    1.17 +# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment
    1.18 +# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide'
    1.19 +# paper size.
    1.20 +#
    1.21 +# By default, HTML, PDF and PS documentation is generated as this seems to be
    1.22 +# the most popular and portable combination. MAN pages created by Doxygen are
    1.23 +# usually problematic, though by picking an appropriate subset and doing some
    1.24 +# massaging they might be better than nothing. CHM and RTF are specific for MS
    1.25 +# (note that you can't generate both HTML and CHM at the same time). The XML is
    1.26 +# rather useless unless you apply specialized post-processing to it.
    1.27 +#
    1.28 +# The macro mainly controls the default state of the feature. The use can
    1.29 +# override the default by specifying --enable or --disable. The macros ensure
    1.30 +# that contradictory flags are not given (e.g., --enable-doxygen-html and
    1.31 +# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.)
    1.32 +# Finally, each feature will be automatically disabled (with a warning) if the
    1.33 +# required programs are missing.
    1.34 +#
    1.35 +# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with
    1.36 +# the following parameters: a one-word name for the project for use as a
    1.37 +# filename base etc., an optional configuration file name (the default is
    1.38 +# 'Doxyfile', the same as Doxygen's default), and an optional output directory
    1.39 +# name (the default is 'doxygen-doc').
    1.40 +
    1.41 +## ----------##
    1.42 +## Defaults. ##
    1.43 +## ----------##
    1.44 +
    1.45 +DX_ENV=""
    1.46 +AC_DEFUN([DX_FEATURE_doc],  ON)
    1.47 +AC_DEFUN([DX_FEATURE_dot],  ON)
    1.48 +AC_DEFUN([DX_FEATURE_man],  OFF)
    1.49 +AC_DEFUN([DX_FEATURE_html], ON)
    1.50 +AC_DEFUN([DX_FEATURE_chm],  OFF)
    1.51 +AC_DEFUN([DX_FEATURE_chi],  OFF)
    1.52 +AC_DEFUN([DX_FEATURE_rtf],  OFF)
    1.53 +AC_DEFUN([DX_FEATURE_xml],  OFF)
    1.54 +AC_DEFUN([DX_FEATURE_pdf],  ON)
    1.55 +AC_DEFUN([DX_FEATURE_ps],   ON)
    1.56 +
    1.57 +## --------------- ##
    1.58 +## Private macros. ##
    1.59 +## --------------- ##
    1.60 +
    1.61 +# DX_ENV_APPEND(VARIABLE, VALUE)
    1.62 +# ------------------------------
    1.63 +# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
    1.64 +AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
    1.65 +
    1.66 +# DX_DIRNAME_EXPR
    1.67 +# ---------------
    1.68 +# Expand into a shell expression prints the directory part of a path.
    1.69 +AC_DEFUN([DX_DIRNAME_EXPR],
    1.70 +         [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
    1.71 +
    1.72 +# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
    1.73 +# -------------------------------------
    1.74 +# Expands according to the M4 (static) status of the feature.
    1.75 +AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
    1.76 +
    1.77 +# DX_REQUIRE_PROG(VARIABLE, PROGRAM)
    1.78 +# ----------------------------------
    1.79 +# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
    1.80 +AC_DEFUN([DX_REQUIRE_PROG], [
    1.81 +AC_PATH_TOOL([$1], [$2])
    1.82 +if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
    1.83 +    AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
    1.84 +    AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
    1.85 +fi
    1.86 +])
    1.87 +
    1.88 +# DX_TEST_FEATURE(FEATURE)
    1.89 +# ------------------------
    1.90 +# Expand to a shell expression testing whether the feature is active.
    1.91 +AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
    1.92 +
    1.93 +# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
    1.94 +# -------------------------------------------------
    1.95 +# Verify that a required features has the right state before trying to turn on
    1.96 +# the DX_CURRENT_FEATURE.
    1.97 +AC_DEFUN([DX_CHECK_DEPEND], [
    1.98 +test "$DX_FLAG_$1" = "$2" \
    1.99 +|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
   1.100 +                            requires, contradicts) doxygen-DX_CURRENT_FEATURE])
   1.101 +])
   1.102 +
   1.103 +# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
   1.104 +# ----------------------------------------------------------
   1.105 +# Turn off the DX_CURRENT_FEATURE if the required feature is off.
   1.106 +AC_DEFUN([DX_CLEAR_DEPEND], [
   1.107 +test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
   1.108 +])
   1.109 +
   1.110 +# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
   1.111 +#                CHECK_DEPEND, CLEAR_DEPEND,
   1.112 +#                REQUIRE, DO-IF-ON, DO-IF-OFF)
   1.113 +# --------------------------------------------
   1.114 +# Parse the command-line option controlling a feature. CHECK_DEPEND is called
   1.115 +# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
   1.116 +# otherwise CLEAR_DEPEND is called to turn off the default state if a required
   1.117 +# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
   1.118 +# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
   1.119 +# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
   1.120 +AC_DEFUN([DX_ARG_ABLE], [
   1.121 +    AC_DEFUN([DX_CURRENT_FEATURE], [$1])
   1.122 +    AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
   1.123 +    AC_ARG_ENABLE(doxygen-$1,
   1.124 +                  [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
   1.125 +                                                      [--enable-doxygen-$1]),
   1.126 +                                  DX_IF_FEATURE([$1], [don't $2], [$2]))],
   1.127 +                  [
   1.128 +case "$enableval" in
   1.129 +#(
   1.130 +y|Y|yes|Yes|YES)
   1.131 +    AC_SUBST([DX_FLAG_$1], 1)
   1.132 +    $3
   1.133 +;; #(
   1.134 +n|N|no|No|NO)
   1.135 +    AC_SUBST([DX_FLAG_$1], 0)
   1.136 +;; #(
   1.137 +*)
   1.138 +    AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
   1.139 +;;
   1.140 +esac
   1.141 +], [
   1.142 +AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
   1.143 +$4
   1.144 +])
   1.145 +if DX_TEST_FEATURE([$1]); then
   1.146 +    $5
   1.147 +    :
   1.148 +fi
   1.149 +if DX_TEST_FEATURE([$1]); then
   1.150 +    AM_CONDITIONAL(DX_COND_$1, :)
   1.151 +    $6
   1.152 +    :
   1.153 +else
   1.154 +    AM_CONDITIONAL(DX_COND_$1, false)
   1.155 +    $7
   1.156 +    :
   1.157 +fi
   1.158 +])
   1.159 +
   1.160 +## -------------- ##
   1.161 +## Public macros. ##
   1.162 +## -------------- ##
   1.163 +
   1.164 +# DX_XXX_FEATURE(DEFAULT_STATE)
   1.165 +# -----------------------------
   1.166 +AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc],  [$1])])
   1.167 +AC_DEFUN([DX_MAN_FEATURE],     [AC_DEFUN([DX_FEATURE_man],  [$1])])
   1.168 +AC_DEFUN([DX_HTML_FEATURE],    [AC_DEFUN([DX_FEATURE_html], [$1])])
   1.169 +AC_DEFUN([DX_CHM_FEATURE],     [AC_DEFUN([DX_FEATURE_chm],  [$1])])
   1.170 +AC_DEFUN([DX_CHI_FEATURE],     [AC_DEFUN([DX_FEATURE_chi],  [$1])])
   1.171 +AC_DEFUN([DX_RTF_FEATURE],     [AC_DEFUN([DX_FEATURE_rtf],  [$1])])
   1.172 +AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
   1.173 +AC_DEFUN([DX_XML_FEATURE],     [AC_DEFUN([DX_FEATURE_xml],  [$1])])
   1.174 +AC_DEFUN([DX_PDF_FEATURE],     [AC_DEFUN([DX_FEATURE_pdf],  [$1])])
   1.175 +AC_DEFUN([DX_PS_FEATURE],      [AC_DEFUN([DX_FEATURE_ps],   [$1])])
   1.176 +
   1.177 +# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
   1.178 +# ---------------------------------------------------------
   1.179 +# PROJECT also serves as the base name for the documentation files.
   1.180 +# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
   1.181 +AC_DEFUN([DX_INIT_DOXYGEN], [
   1.182 +
   1.183 +# Files:
   1.184 +AC_SUBST([DX_PROJECT], [$1])
   1.185 +AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
   1.186 +AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
   1.187 +
   1.188 +# Environment variables used inside doxygen.cfg:
   1.189 +DX_ENV_APPEND(SRCDIR, $srcdir)
   1.190 +DX_ENV_APPEND(PROJECT, $DX_PROJECT)
   1.191 +DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
   1.192 +DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
   1.193 +
   1.194 +# Doxygen itself:
   1.195 +DX_ARG_ABLE(doc, [generate any doxygen documentation],
   1.196 +            [],
   1.197 +            [],
   1.198 +            [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
   1.199 +             DX_REQUIRE_PROG([DX_PERL], perl)],
   1.200 +            [DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
   1.201 +
   1.202 +# Dot for graphics:
   1.203 +DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
   1.204 +            [DX_CHECK_DEPEND(doc, 1)],
   1.205 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.206 +            [DX_REQUIRE_PROG([DX_DOT], dot)],
   1.207 +            [DX_ENV_APPEND(HAVE_DOT, YES)
   1.208 +             DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
   1.209 +            [DX_ENV_APPEND(HAVE_DOT, NO)])
   1.210 +
   1.211 +# Man pages generation:
   1.212 +DX_ARG_ABLE(man, [generate doxygen manual pages],
   1.213 +            [DX_CHECK_DEPEND(doc, 1)],
   1.214 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.215 +            [],
   1.216 +            [DX_ENV_APPEND(GENERATE_MAN, YES)],
   1.217 +            [DX_ENV_APPEND(GENERATE_MAN, NO)])
   1.218 +
   1.219 +# RTF file generation:
   1.220 +DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
   1.221 +            [DX_CHECK_DEPEND(doc, 1)],
   1.222 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.223 +            [],
   1.224 +            [DX_ENV_APPEND(GENERATE_RTF, YES)],
   1.225 +            [DX_ENV_APPEND(GENERATE_RTF, NO)])
   1.226 +
   1.227 +# XML file generation:
   1.228 +DX_ARG_ABLE(xml, [generate doxygen XML documentation],
   1.229 +            [DX_CHECK_DEPEND(doc, 1)],
   1.230 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.231 +            [],
   1.232 +            [DX_ENV_APPEND(GENERATE_XML, YES)],
   1.233 +            [DX_ENV_APPEND(GENERATE_XML, NO)])
   1.234 +
   1.235 +# (Compressed) HTML help generation:
   1.236 +DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
   1.237 +            [DX_CHECK_DEPEND(doc, 1)],
   1.238 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.239 +            [DX_REQUIRE_PROG([DX_HHC], hhc)],
   1.240 +            [DX_ENV_APPEND(HHC_PATH, $DX_HHC)
   1.241 +             DX_ENV_APPEND(GENERATE_HTML, YES)
   1.242 +             DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
   1.243 +            [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
   1.244 +
   1.245 +# Seperate CHI file generation.
   1.246 +DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
   1.247 +            [DX_CHECK_DEPEND(chm, 1)],
   1.248 +            [DX_CLEAR_DEPEND(chm, 1)],
   1.249 +            [],
   1.250 +            [DX_ENV_APPEND(GENERATE_CHI, YES)],
   1.251 +            [DX_ENV_APPEND(GENERATE_CHI, NO)])
   1.252 +
   1.253 +# Plain HTML pages generation:
   1.254 +DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
   1.255 +            [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
   1.256 +            [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
   1.257 +            [],
   1.258 +            [DX_ENV_APPEND(GENERATE_HTML, YES)],
   1.259 +            [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
   1.260 +
   1.261 +# PostScript file generation:
   1.262 +DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
   1.263 +            [DX_CHECK_DEPEND(doc, 1)],
   1.264 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.265 +            [DX_REQUIRE_PROG([DX_LATEX], latex)
   1.266 +             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
   1.267 +             DX_REQUIRE_PROG([DX_DVIPS], dvips)
   1.268 +             DX_REQUIRE_PROG([DX_EGREP], egrep)])
   1.269 +
   1.270 +# PDF file generation:
   1.271 +DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
   1.272 +            [DX_CHECK_DEPEND(doc, 1)],
   1.273 +            [DX_CLEAR_DEPEND(doc, 1)],
   1.274 +            [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
   1.275 +             DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
   1.276 +             DX_REQUIRE_PROG([DX_EGREP], egrep)])
   1.277 +
   1.278 +# LaTeX generation for PS and/or PDF:
   1.279 +if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
   1.280 +    AM_CONDITIONAL(DX_COND_latex, :)
   1.281 +    DX_ENV_APPEND(GENERATE_LATEX, YES)
   1.282 +else
   1.283 +    AM_CONDITIONAL(DX_COND_latex, false)
   1.284 +    DX_ENV_APPEND(GENERATE_LATEX, NO)
   1.285 +fi
   1.286 +
   1.287 +# Paper size for PS and/or PDF:
   1.288 +AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
   1.289 +           [a4wide (default), a4, letter, legal or executive])
   1.290 +case "$DOXYGEN_PAPER_SIZE" in
   1.291 +#(
   1.292 +"")
   1.293 +    AC_SUBST(DOXYGEN_PAPER_SIZE, "")
   1.294 +;; #(
   1.295 +a4wide|a4|letter|legal|executive)
   1.296 +    DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
   1.297 +;; #(
   1.298 +*)
   1.299 +    AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
   1.300 +;;
   1.301 +esac
   1.302 +
   1.303 +#For debugging:
   1.304 +#echo DX_FLAG_doc=$DX_FLAG_doc
   1.305 +#echo DX_FLAG_dot=$DX_FLAG_dot
   1.306 +#echo DX_FLAG_man=$DX_FLAG_man
   1.307 +#echo DX_FLAG_html=$DX_FLAG_html
   1.308 +#echo DX_FLAG_chm=$DX_FLAG_chm
   1.309 +#echo DX_FLAG_chi=$DX_FLAG_chi
   1.310 +#echo DX_FLAG_rtf=$DX_FLAG_rtf
   1.311 +#echo DX_FLAG_xml=$DX_FLAG_xml
   1.312 +#echo DX_FLAG_pdf=$DX_FLAG_pdf
   1.313 +#echo DX_FLAG_ps=$DX_FLAG_ps
   1.314 +#echo DX_ENV=$DX_ENV
   1.315 +])