rosfran@253: # This file is part of Autoconf. -*- Autoconf -*- rosfran@253: rosfran@253: # Copyright (C) 2004 Oren Ben-Kiki rosfran@253: # This file is distributed under the same terms as the Autoconf macro files. rosfran@253: rosfran@253: # Generate automatic documentation using Doxygen. Works in concert with the rosfran@253: # aminclude.m4 file and a compatible doxygen configuration file. Defines the rosfran@253: # following public macros: rosfran@253: # rosfran@253: # DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature. rosfran@253: # Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics, rosfran@253: # 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI' rosfran@253: # for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF', rosfran@253: # 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment rosfran@253: # variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide' rosfran@253: # paper size. rosfran@253: # rosfran@253: # By default, HTML, PDF and PS documentation is generated as this seems to be rosfran@253: # the most popular and portable combination. MAN pages created by Doxygen are rosfran@253: # usually problematic, though by picking an appropriate subset and doing some rosfran@253: # massaging they might be better than nothing. CHM and RTF are specific for MS rosfran@253: # (note that you can't generate both HTML and CHM at the same time). The XML is rosfran@253: # rather useless unless you apply specialized post-processing to it. rosfran@253: # rosfran@253: # The macro mainly controls the default state of the feature. The use can rosfran@253: # override the default by specifying --enable or --disable. The macros ensure rosfran@253: # that contradictory flags are not given (e.g., --enable-doxygen-html and rosfran@253: # --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.) rosfran@253: # Finally, each feature will be automatically disabled (with a warning) if the rosfran@253: # required programs are missing. rosfran@253: # rosfran@253: # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with rosfran@253: # the following parameters: a one-word name for the project for use as a rosfran@253: # filename base etc., an optional configuration file name (the default is rosfran@253: # 'Doxyfile', the same as Doxygen's default), and an optional output directory rosfran@253: # name (the default is 'doxygen-doc'). rosfran@253: rosfran@253: ## ----------## rosfran@253: ## Defaults. ## rosfran@253: ## ----------## rosfran@253: rosfran@253: DX_ENV="" rosfran@253: AC_DEFUN([DX_FEATURE_doc], ON) rosfran@253: AC_DEFUN([DX_FEATURE_dot], ON) rosfran@253: AC_DEFUN([DX_FEATURE_man], OFF) rosfran@253: AC_DEFUN([DX_FEATURE_html], ON) rosfran@253: AC_DEFUN([DX_FEATURE_chm], OFF) rosfran@253: AC_DEFUN([DX_FEATURE_chi], OFF) rosfran@253: AC_DEFUN([DX_FEATURE_rtf], OFF) rosfran@253: AC_DEFUN([DX_FEATURE_xml], OFF) rosfran@253: AC_DEFUN([DX_FEATURE_pdf], ON) rosfran@253: AC_DEFUN([DX_FEATURE_ps], ON) rosfran@253: rosfran@253: ## --------------- ## rosfran@253: ## Private macros. ## rosfran@253: ## --------------- ## rosfran@253: rosfran@253: # DX_ENV_APPEND(VARIABLE, VALUE) rosfran@253: # ------------------------------ rosfran@253: # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. rosfran@253: AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) rosfran@253: rosfran@253: # DX_DIRNAME_EXPR rosfran@253: # --------------- rosfran@253: # Expand into a shell expression prints the directory part of a path. rosfran@253: AC_DEFUN([DX_DIRNAME_EXPR], rosfran@253: [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) rosfran@253: rosfran@253: # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) rosfran@253: # ------------------------------------- rosfran@253: # Expands according to the M4 (static) status of the feature. rosfran@253: AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) rosfran@253: rosfran@253: # DX_REQUIRE_PROG(VARIABLE, PROGRAM) rosfran@253: # ---------------------------------- rosfran@253: # Require the specified program to be found for the DX_CURRENT_FEATURE to work. rosfran@253: AC_DEFUN([DX_REQUIRE_PROG], [ rosfran@253: AC_PATH_TOOL([$1], [$2]) rosfran@253: if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then rosfran@253: AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) rosfran@253: AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0) rosfran@253: fi rosfran@253: ]) rosfran@253: rosfran@253: # DX_TEST_FEATURE(FEATURE) rosfran@253: # ------------------------ rosfran@253: # Expand to a shell expression testing whether the feature is active. rosfran@253: AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) rosfran@253: rosfran@253: # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) rosfran@253: # ------------------------------------------------- rosfran@253: # Verify that a required features has the right state before trying to turn on rosfran@253: # the DX_CURRENT_FEATURE. rosfran@253: AC_DEFUN([DX_CHECK_DEPEND], [ rosfran@253: test "$DX_FLAG_$1" = "$2" \ rosfran@253: || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, rosfran@253: requires, contradicts) doxygen-DX_CURRENT_FEATURE]) rosfran@253: ]) rosfran@253: rosfran@253: # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) rosfran@253: # ---------------------------------------------------------- rosfran@253: # Turn off the DX_CURRENT_FEATURE if the required feature is off. rosfran@253: AC_DEFUN([DX_CLEAR_DEPEND], [ rosfran@253: test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0) rosfran@253: ]) rosfran@253: rosfran@253: # DX_FEATURE_ARG(FEATURE, DESCRIPTION, rosfran@253: # CHECK_DEPEND, CLEAR_DEPEND, rosfran@253: # REQUIRE, DO-IF-ON, DO-IF-OFF) rosfran@253: # -------------------------------------------- rosfran@253: # Parse the command-line option controlling a feature. CHECK_DEPEND is called rosfran@253: # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), rosfran@253: # otherwise CLEAR_DEPEND is called to turn off the default state if a required rosfran@253: # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional rosfran@253: # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and rosfran@253: # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. rosfran@253: AC_DEFUN([DX_ARG_ABLE], [ rosfran@253: AC_DEFUN([DX_CURRENT_FEATURE], [$1]) rosfran@253: AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) rosfran@253: AC_ARG_ENABLE(doxygen-$1, rosfran@253: [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], rosfran@253: [--enable-doxygen-$1]), rosfran@253: DX_IF_FEATURE([$1], [don't $2], [$2]))], rosfran@253: [ rosfran@253: case "$enableval" in rosfran@253: #( rosfran@253: y|Y|yes|Yes|YES) rosfran@253: AC_SUBST([DX_FLAG_$1], 1) rosfran@253: $3 rosfran@253: ;; #( rosfran@253: n|N|no|No|NO) rosfran@253: AC_SUBST([DX_FLAG_$1], 0) rosfran@253: ;; #( rosfran@253: *) rosfran@253: AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) rosfran@253: ;; rosfran@253: esac rosfran@253: ], [ rosfran@253: AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) rosfran@253: $4 rosfran@253: ]) rosfran@253: if DX_TEST_FEATURE([$1]); then rosfran@253: $5 rosfran@253: : rosfran@253: fi rosfran@253: if DX_TEST_FEATURE([$1]); then rosfran@253: AM_CONDITIONAL(DX_COND_$1, :) rosfran@253: $6 rosfran@253: : rosfran@253: else rosfran@253: AM_CONDITIONAL(DX_COND_$1, false) rosfran@253: $7 rosfran@253: : rosfran@253: fi rosfran@253: ]) rosfran@253: rosfran@253: ## -------------- ## rosfran@253: ## Public macros. ## rosfran@253: ## -------------- ## rosfran@253: rosfran@253: # DX_XXX_FEATURE(DEFAULT_STATE) rosfran@253: # ----------------------------- rosfran@253: AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) rosfran@253: AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) rosfran@253: AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) rosfran@253: AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) rosfran@253: AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) rosfran@253: AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) rosfran@253: AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) rosfran@253: AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) rosfran@253: AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) rosfran@253: AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) rosfran@253: rosfran@253: # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) rosfran@253: # --------------------------------------------------------- rosfran@253: # PROJECT also serves as the base name for the documentation files. rosfran@253: # The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc". rosfran@253: AC_DEFUN([DX_INIT_DOXYGEN], [ rosfran@253: rosfran@253: # Files: rosfran@253: AC_SUBST([DX_PROJECT], [$1]) rosfran@253: AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) rosfran@253: AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])]) rosfran@253: rosfran@253: # Environment variables used inside doxygen.cfg: rosfran@253: DX_ENV_APPEND(SRCDIR, $srcdir) rosfran@253: DX_ENV_APPEND(PROJECT, $DX_PROJECT) rosfran@253: DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) rosfran@253: DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) rosfran@253: rosfran@253: # Doxygen itself: rosfran@253: DX_ARG_ABLE(doc, [generate any doxygen documentation], rosfran@253: [], rosfran@253: [], rosfran@253: [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) rosfran@253: DX_REQUIRE_PROG([DX_PERL], perl)], rosfran@253: [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) rosfran@253: rosfran@253: # Dot for graphics: rosfran@253: DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [DX_REQUIRE_PROG([DX_DOT], dot)], rosfran@253: [DX_ENV_APPEND(HAVE_DOT, YES) rosfran@253: DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], rosfran@253: [DX_ENV_APPEND(HAVE_DOT, NO)]) rosfran@253: rosfran@253: # Man pages generation: rosfran@253: DX_ARG_ABLE(man, [generate doxygen manual pages], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [], rosfran@253: [DX_ENV_APPEND(GENERATE_MAN, YES)], rosfran@253: [DX_ENV_APPEND(GENERATE_MAN, NO)]) rosfran@253: rosfran@253: # RTF file generation: rosfran@253: DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [], rosfran@253: [DX_ENV_APPEND(GENERATE_RTF, YES)], rosfran@253: [DX_ENV_APPEND(GENERATE_RTF, NO)]) rosfran@253: rosfran@253: # XML file generation: rosfran@253: DX_ARG_ABLE(xml, [generate doxygen XML documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [], rosfran@253: [DX_ENV_APPEND(GENERATE_XML, YES)], rosfran@253: [DX_ENV_APPEND(GENERATE_XML, NO)]) rosfran@253: rosfran@253: # (Compressed) HTML help generation: rosfran@253: DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [DX_REQUIRE_PROG([DX_HHC], hhc)], rosfran@253: [DX_ENV_APPEND(HHC_PATH, $DX_HHC) rosfran@253: DX_ENV_APPEND(GENERATE_HTML, YES) rosfran@253: DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], rosfran@253: [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) rosfran@253: rosfran@253: # Seperate CHI file generation. rosfran@253: DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], rosfran@253: [DX_CHECK_DEPEND(chm, 1)], rosfran@253: [DX_CLEAR_DEPEND(chm, 1)], rosfran@253: [], rosfran@253: [DX_ENV_APPEND(GENERATE_CHI, YES)], rosfran@253: [DX_ENV_APPEND(GENERATE_CHI, NO)]) rosfran@253: rosfran@253: # Plain HTML pages generation: rosfran@253: DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], rosfran@253: [], rosfran@253: [DX_ENV_APPEND(GENERATE_HTML, YES)], rosfran@253: [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) rosfran@253: rosfran@253: # PostScript file generation: rosfran@253: DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [DX_REQUIRE_PROG([DX_LATEX], latex) rosfran@253: DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) rosfran@253: DX_REQUIRE_PROG([DX_DVIPS], dvips) rosfran@253: DX_REQUIRE_PROG([DX_EGREP], egrep)]) rosfran@253: rosfran@253: # PDF file generation: rosfran@253: DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], rosfran@253: [DX_CHECK_DEPEND(doc, 1)], rosfran@253: [DX_CLEAR_DEPEND(doc, 1)], rosfran@253: [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) rosfran@253: DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) rosfran@253: DX_REQUIRE_PROG([DX_EGREP], egrep)]) rosfran@253: rosfran@253: # LaTeX generation for PS and/or PDF: rosfran@253: if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then rosfran@253: AM_CONDITIONAL(DX_COND_latex, :) rosfran@253: DX_ENV_APPEND(GENERATE_LATEX, YES) rosfran@253: else rosfran@253: AM_CONDITIONAL(DX_COND_latex, false) rosfran@253: DX_ENV_APPEND(GENERATE_LATEX, NO) rosfran@253: fi rosfran@253: rosfran@253: # Paper size for PS and/or PDF: rosfran@253: AC_ARG_VAR(DOXYGEN_PAPER_SIZE, rosfran@253: [a4wide (default), a4, letter, legal or executive]) rosfran@253: case "$DOXYGEN_PAPER_SIZE" in rosfran@253: #( rosfran@253: "") rosfran@253: AC_SUBST(DOXYGEN_PAPER_SIZE, "") rosfran@253: ;; #( rosfran@253: a4wide|a4|letter|legal|executive) rosfran@253: DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) rosfran@253: ;; #( rosfran@253: *) rosfran@253: AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) rosfran@253: ;; rosfran@253: esac rosfran@253: rosfran@253: #For debugging: rosfran@253: #echo DX_FLAG_doc=$DX_FLAG_doc rosfran@253: #echo DX_FLAG_dot=$DX_FLAG_dot rosfran@253: #echo DX_FLAG_man=$DX_FLAG_man rosfran@253: #echo DX_FLAG_html=$DX_FLAG_html rosfran@253: #echo DX_FLAG_chm=$DX_FLAG_chm rosfran@253: #echo DX_FLAG_chi=$DX_FLAG_chi rosfran@253: #echo DX_FLAG_rtf=$DX_FLAG_rtf rosfran@253: #echo DX_FLAG_xml=$DX_FLAG_xml rosfran@253: #echo DX_FLAG_pdf=$DX_FLAG_pdf rosfran@253: #echo DX_FLAG_ps=$DX_FLAG_ps rosfran@253: #echo DX_ENV=$DX_ENV rosfran@253: ])