dx_doxygen.m4 12 KB

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