acinclude.m4 12 KB

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