1# -*- mode: autoconf -*-
2#
3# gtk-doc.m4 - configure macro to check for gtk-doc
4# Copyright (C) 2003 James Henstridge
5#               2007-2017  Stefan Sauer
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#
20# As a special exception, the above copyright owner gives unlimited
21# permission to copy, distribute and modify the configure scripts that
22# are the output of Autoconf when processing the Macro. You need not
23# follow the terms of the GNU General Public License when using or
24# distributing such scripts, even though portions of the text of the
25# Macro appear in them. The GNU General Public License (GPL) does govern
26# all other use of the material that constitutes the Autoconf Macro.
27
28# serial 2
29
30dnl Usage:
31dnl   GTK_DOC_CHECK([minimum-gtk-doc-version])
32AC_DEFUN([GTK_DOC_CHECK],
33[
34  AC_REQUIRE([PKG_PROG_PKG_CONFIG])
35  AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
36  AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
37
38  ifelse([$1],[],[gtk_doc_requires="gtk-doc"],[gtk_doc_requires="gtk-doc >= $1"])
39  AC_MSG_CHECKING([for gtk-doc])
40  PKG_CHECK_EXISTS([$gtk_doc_requires],[have_gtk_doc=yes],[have_gtk_doc=no])
41  AC_MSG_RESULT($have_gtk_doc)
42
43  if test "$have_gtk_doc" = "no"; then
44      AC_MSG_WARN([
45  You will not be able to create source packages with 'make dist'
46  because $gtk_doc_requires is not found.])
47  fi
48
49  dnl check for tools we added during development
50  dnl Use AC_CHECK_PROG to avoid the check target using an absolute path that
51  dnl may not be writable by the user. Currently, automake requires that the
52  dnl test name must end in '.test'.
53  dnl https://bugzilla.gnome.org/show_bug.cgi?id=701638
54  AC_CHECK_PROG([GTKDOC_CHECK],[gtkdoc-check],[gtkdoc-check.test])
55  AC_PATH_PROG([GTKDOC_CHECK_PATH],[gtkdoc-check])
56  AC_PATH_PROGS([GTKDOC_REBASE],[gtkdoc-rebase],[true])
57  AC_PATH_PROG([GTKDOC_MKPDF],[gtkdoc-mkpdf])
58
59  dnl for overriding the documentation installation directory
60  AC_ARG_WITH([html-dir],
61    AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),,
62    [with_html_dir='${datadir}/gtk-doc/html'])
63  HTML_DIR="$with_html_dir"
64  AC_SUBST([HTML_DIR])
65
66  dnl enable/disable documentation building
67  AC_ARG_ENABLE([gtk-doc],
68    AS_HELP_STRING([--enable-gtk-doc],
69                   [use gtk-doc to build documentation [[default=no]]]),,
70    [enable_gtk_doc=no])
71
72  AC_MSG_CHECKING([whether to build gtk-doc documentation])
73  AC_MSG_RESULT($enable_gtk_doc)
74
75  if test "x$enable_gtk_doc" = "xyes" && test "$have_gtk_doc" = "no"; then
76    AC_MSG_ERROR([
77  You must have $gtk_doc_requires installed to build documentation for
78  $PACKAGE_NAME. Please install gtk-doc or disable building the
79  documentation by adding '--disable-gtk-doc' to '[$]0'.])
80  fi
81
82  dnl don't check for glib if we build glib
83  if test "x$PACKAGE_NAME" != "xglib"; then
84    dnl don't fail if someone does not have glib
85    PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0  >= 2.10.0,,[:])
86  fi
87
88  dnl enable/disable output formats
89  AC_ARG_ENABLE([gtk-doc-html],
90    AS_HELP_STRING([--enable-gtk-doc-html],
91                   [build documentation in html format [[default=yes]]]),,
92    [enable_gtk_doc_html=yes])
93    AC_ARG_ENABLE([gtk-doc-pdf],
94      AS_HELP_STRING([--enable-gtk-doc-pdf],
95                     [build documentation in pdf format [[default=no]]]),,
96      [enable_gtk_doc_pdf=no])
97
98  if test -z "$GTKDOC_MKPDF"; then
99    enable_gtk_doc_pdf=no
100  fi
101
102  if test -z "$AM_DEFAULT_VERBOSITY"; then
103    AM_DEFAULT_VERBOSITY=1
104  fi
105  AC_SUBST([AM_DEFAULT_VERBOSITY])
106
107  AM_CONDITIONAL([HAVE_GTK_DOC], [test x$have_gtk_doc = xyes])
108  AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
109  AM_CONDITIONAL([GTK_DOC_BUILD_HTML], [test x$enable_gtk_doc_html = xyes])
110  AM_CONDITIONAL([GTK_DOC_BUILD_PDF], [test x$enable_gtk_doc_pdf = xyes])
111  AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"])
112  AM_CONDITIONAL([GTK_DOC_USE_REBASE], [test -n "$GTKDOC_REBASE"])
113])
114