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