[m4 macro] Autoconf support for gtk-doc



Hello,

The configure.in autoconf example given in the gtk-doc source works
OK, but it's a bit of a pain to paste it into your configure.ac every
time.

The text that follows is an m4 autoconf macro to do all this for you.
All you need to do is put

  AX_GTK_DOC([version])

(where version is an optional version number) into your configure.ac,
and everything is done for you.  For example,

  AX_GTK_DOC([1.0])

(It uses the AX_ "autoconf extension" namespace, rather than the AC_
and AM_ reserved for autoconf and automake.)  The result is cached.

This also checks for each of the gtk-doc programs, for substitution
into Makefiles, but I've not updated Makefile.am yet.  It does not set
the HTML_DIR as previously (this belongs in the Makefile.am).

I have licensed it under the same licence as the official autoconf
macros, but feel free to change it.  You can reassign the copyright
also if you wish.  If the project name is not the "GNOME Project",
then you should change it to the correct name in the licence text.

I hope you find this useful!


Regards,
Roger

PS.  As with the last message, a previous copy I posted is stuck in
"moderator limbo".  This version is the correct version of the macro
(it uses ax_cv_ instead of ac_cv_ for the cache namespace).


---start gtkdoc.m4---
dnl This file is part of gtk-doc.                        -*- Autoconf -*-
dnl gtk-doc macro.
dnl Copyright (C) 2003  Roger Leigh (rleigh debian org).
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
dnl
dnl As a special exception, the author gives you unlimited permission to
dnl copy, distribute and modify the configure scripts that contain
dnl output of this macro.  You need not follow the terms of the GNU
dnl General Public License when using or distributing such scripts, even
dnl though portions of the text of this macro appear in them.  The GNU
dnl General Public License (GPL) does govern all other use of the
dnl material that constitutes this macro.
dnl
dnl This special exception to the GPL applies to versions of Autoconf
dnl released by the GNOME Project.  When you make and distribute a
dnl modified version of this macro, you may extend this special
dnl exception to the GPL to apply to your modified version as well,
dnl *unless* your modified version has the potential to copy into its
dnl output some of the text that was the non-data portion of the version
dnl that you started with.  (In other words, unless your change moves or
dnl copies text from the non-data portions to the data portions.)  If
dnl your modification has such potential, you must delete any notice of
dnl this special exception to the GPL from your modified version.


dnl Table of Contents:
dnl 1. Option handling
dnl 2. Check for gtk-doc


dnl ------------------
dnl 1. Option handling
dnl ------------------


dnl _AX_GTK_DOC_ARG_WITH_DETAILED ([(NAME, [NAME_OPTION], HELP,
dnl [HELP_OPTION], VARIABLE, DEFAULT, [OPTION_TRUE],
dnl [OPTION_FALSE])])
dnl -----------------------------------------------------------
dnl Create a standardised configure option.
dnl NAME		Option name i.e. --with-foo or --enable-foo.
dnl NAME_OPTION	Optional input for use with NAME (informational).
dnl HELP		Help string to display.
dnl HELP_OPTION	Additional defaults information in addition to
dnl		DEFAULT.
dnl VARIABLE	Variable to set with command-line results.
dnl DEFAULT	Default value of VARIABLE.
dnl OPTION_TRUE	case statement body if an option is supplied.
dnl		This replaces the default actions.
dnl OPTION_FALSE Shell commands to run if no option is supplied.
AC_DEFUN([_AX_GTK_DOC_ARG_WITH_DETAILED],
[# create custom command-line --with option
AC_MSG_CHECKING([whether to $3])
AC_ARG_WITH($1,
            [AC_HELP_STRING([--with-$1]m4_if([$2], , , [$2]),
              [$3 ]m4_if([$4], , , [$4 ])[@<:@]$6[@:>@])],
            [case "${withval}" in
            m4_if([$7], ,[
                yes) [$5]="yes" ; AC_MSG_RESULT([yes]) ;;
                no) [$5]="no" ; AC_MSG_RESULT([no]) ;;
                *) AC_MSG_RESULT([unknown])
                   AC_MSG_ERROR([bad value ${withval} for --with-$1]) ;;
	    ], [$7])
	    esac],
            [AC_MSG_RESULT($6) ; m4_if([$8], , , [$8])])
if test -z "${[$5]}" ; then
  [$5]="$6"
fi
])


dnl --------------------
dnl 2. Check for gtk-doc
dnl --------------------


dnl AX_GTK_DOC ([MIN-VERSION])
dnl ---------------------------
dnl Check for gtk-doc.
AC_DEFUN([AX_GTK_DOC],
[# Check for gtk-doc
gtk_doc_min_version=m4_if($1, , [1.0], $1)
AC_CACHE_CHECK([gtk-doc version >= ${gtk_doc_min_version}],
               [ax_cv_prog_gtk_doc],
               [if pkg-config --atleast-version=${gtk_doc_min_version} gtk-doc; then
                  ax_cv_prog_gtk_doc=yes
                else
                  ax_cv_prog_gtk_doc=no
                fi])
AC_PATH_PROG([GTKDOC_SCANOBJ], [gtkdoc-scanobj])
AC_SUBST([GTKDOC_SCANOBJ])
AC_PATH_PROG([GTKDOC_SCANGOBJ],[gtkdoc-scangobj])
AC_SUBST([GTKDOC_SCANGOBJ])
AC_PATH_PROG([GTKDOC_SCAN],[gtkdoc-scan])
AC_SUBST([GTKDOC_SCAN])
AC_PATH_PROG([GTKDOC_MKTMPL],[gtkdoc-mktmpl])
AC_SUBST([GTKDOC_MKTMPL])
AC_PATH_PROG([GTKDOC_MKDB],[gtkdoc-mkdb])
AC_SUBST([GTKDOC_MKDB])
AC_PATH_PROG([GTKDOC_MKHTML],[gtkdoc-mkhtml])
AC_SUBST([GTKDOC_MKHTML])
AC_PATH_PROG([GTKDOC_MKMAN],[gtkdoc-mkman])
AC_SUBST([GTKDOC_MKMAN])
AC_PATH_PROG([GTKDOC_FIXXREF],[gtkdoc-fixxref])
AC_SUBST([GTKDOC_FIXXREF])
if test x$ax_cv_prog_gtk_doc = xyes; then
  ENABLE_GTK_DOC=yes
else
  ENABLE_GTK_DOC=no
fi
_AX_GTK_DOC_ARG_WITH_DETAILED([gtk-doc], ,
                               [use gtk-doc to build documentation], ,
                               [ENABLE_GTK_DOC],
                               [(automatic)])

AM_CONDITIONAL(ENABLE_GTK_DOC, test x${ENABLE_GTK_DOC} = xyes)
])
---end gtkdoc.m4---


-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848 available on public keyservers



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]