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