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