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