• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl
2dnl check where to install documentation
3dnl
4dnl determines documentation "root directory", i.e. the directory
5dnl where all documentation will be placed in
6dnl
7dnl Copyright (C) 2005-2021 Hans Ulrich Niedermann <gp@n-dimensional.de>
8dnl SPDX-License-Identifier: LGPL-2.0-or-later
9dnl
10
11AC_DEFUN([GP_DOC_GENERAL],[dnl
12AC_MSG_CHECKING([whether to build any docs])
13AC_ARG_ENABLE([docs], [dnl
14AS_HELP_STRING([--disable-docs], [whether to create any documentation])], [dnl
15case "$enableval" in
16	yes|true|on) gp_build_docs="yes" ;;
17	*) gp_build_docs="no" ;;
18esac
19],[dnl
20gp_build_docs="yes"
21])dnl
22AC_MSG_RESULT([${gp_build_docs}])
23AM_CONDITIONAL([BUILD_DOCS], [test "x${gp_build_docs}" = "xyes"])
24])dnl
25
26AC_DEFUN([GP_CHECK_DOC_DIR],
27[
28AC_REQUIRE([GP_DOC_GENERAL])dnl
29AC_BEFORE([$0], [GP_BUILD_GTK_DOCS])dnl
30AC_BEFORE([$0], [GP_CHECK_DOXYGEN])dnl
31
32AC_ARG_WITH([doc-dir],
33[AS_HELP_STRING([--with-doc-dir=PATH],
34[Where to install docs  [default=autodetect]])])
35
36# check for the main ("root") documentation directory
37AC_MSG_CHECKING([main docdir])
38
39if test "x${with_doc_dir}" != "x"
40then # docdir is given as parameter
41    docdir="${with_doc_dir}"
42    AC_MSG_RESULT([${docdir} (from parameter)])
43else # otherwise invent a docdir hopefully compatible with system policy
44    if test -d "/usr/share/doc"
45    then
46        maindocdir='${prefix}/share/doc'
47        AC_MSG_RESULT([${maindocdir} (FHS style)])
48    elif test -d "/usr/doc"
49    then
50        maindocdir='${prefix}/doc'
51        AC_MSG_RESULT([${maindocdir} (old style)])
52    else
53        maindocdir='${datadir}/doc'
54        AC_MSG_RESULT([${maindocdir} (default value)])
55    fi
56    AC_MSG_CHECKING([package docdir])
57    # check whether to include package version into documentation path
58    # FIXME: doesn't work properly.
59    if ls -d /usr/{share/,}doc/make-[0-9]* > /dev/null 2>&1
60    then
61        docdir="${maindocdir}/${PACKAGE}-${VERSION}"
62        AC_MSG_RESULT([${docdir} (redhat style)])
63    else
64        docdir="${maindocdir}/${PACKAGE}"
65        AC_MSG_RESULT([${docdir} (default style)])
66    fi
67fi
68
69AC_SUBST([docdir])
70])dnl
71
72dnl
73dnl check whether to build docs and where to:
74dnl
75dnl * determine presence of prerequisites (only gtk-doc for now)
76dnl * determine destination directory for HTML files
77dnl
78
79AC_DEFUN([GP_BUILD_GTK_DOCS],
80[
81# docdir has to be determined in advance
82AC_REQUIRE([GP_CHECK_DOC_DIR])
83
84# ---------------------------------------------------------------------------
85# gtk-doc: We use gtk-doc for building our documentation. However, we
86#          require the user to explicitly request the build.
87# ---------------------------------------------------------------------------
88try_gtkdoc=false
89gtkdoc_msg="no (not requested)"
90have_gtkdoc=false
91AC_ARG_ENABLE([docs],
92[AS_HELP_STRING([--enable-docs],
93[Use gtk-doc to build documentation [default=no]])],[
94	if test x$enableval = xyes; then
95		try_gtkdoc=true
96	fi
97])
98if $try_gtkdoc; then
99	AC_PATH_PROG([GTKDOC],[gtkdoc-mkdb])
100	if test -n "${GTKDOC}"; then
101		have_gtkdoc=true
102		gtkdoc_msg="yes"
103	else
104		gtkdoc_msg="no (http://www.gtk.org/rdp/download.html)"
105	fi
106fi
107AM_CONDITIONAL([ENABLE_GTK_DOC], [$have_gtkdoc])
108GP_CONFIG_MSG([build API docs with gtk-doc],[$gtkdoc_msg])
109
110
111# ---------------------------------------------------------------------------
112# Give the user the possibility to install html documentation in a
113# user-defined location.
114# ---------------------------------------------------------------------------
115AC_ARG_WITH([html-dir],
116[AS_HELP_STRING([--with-html-dir=PATH],
117[Where to install html docs [default=autodetect]])])
118
119AC_MSG_CHECKING([for html dir])
120if test "x${with_html_dir}" = "x" ; then
121    htmldir="${docdir}/html"
122    AC_MSG_RESULT([${htmldir} (default)])
123else
124    htmldir="${with_html_dir}"
125    AC_MSG_RESULT([${htmldir} (from parameter)])
126fi
127AC_SUBST([htmldir])
128apidocdir="${htmldir}/api"
129AC_SUBST([apidocdir}])
130
131])dnl
132
133
134dnl doxygen related stuff
135dnl look for tools
136dnl define substitutions for Doxyfile.in
137AC_DEFUN([GP_CHECK_DOXYGEN],[dnl
138AC_REQUIRE([GP_CHECK_DOC_DIR])dnl
139AC_PATH_PROG([DOT], [dot], [false])
140AC_PATH_PROG([DOXYGEN], [doxygen], [false])
141AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "xfalse"])
142AM_CONDITIONAL([HAVE_DOT], [test "x$DOT" != "xfalse"])
143if test "x$DOT" != "xfalse"; then
144	AC_SUBST([HAVE_DOT],[YES])
145else
146	AC_SUBST([HAVE_DOT],[NO])
147fi
148AC_SUBST([HTML_APIDOC_DIR], ["${PACKAGE_TARNAME}-api.html"])
149AC_SUBST([DOXYGEN_OUTPUT_DIR], [doxygen-output])
150AC_SUBST([HTML_APIDOC_INTERNALS_DIR], ["${PACKAGE_TARNAME}-internals.html"])
151])dnl
152
153