453c79c34e3e2d740cbb54b3fe63e2a22fe88ab1
[debian/amanda] / config / macro-archive / docbook-xslt-min.m4
1 ##### http://autoconf-archive.cryp.to/ac_check_docbook_xslt_min.html
2 #
3 # SYNOPSIS
4 #
5 #   AC_CHECK_DOCBOOK_XSLT_MIN(min-xslt-version)
6 #
7 # DESCRIPTION
8 #
9 #   Check that the 'current' version of docbook is at least version 
10 #   min-xslt-version.
11 #
12 #   If the test is successful, $DOCBOOK_XSLT_CURRENT_VERSION will be set to the
13 #   current docbook version; if not, it will be set to 'no'.
14 #
15 #   Example:
16 #    AC_CHECK_DOCBOOK_XSLT_MIN(1.72.0)
17 #    if test "x$DOCBOOK_XSLT_CURRENT_VERSION" = "xno"; then
18 #      ..
19 #
20 # LAST MODIFICATION
21 #
22 #   2007-06-28
23 #
24 # AUTHOR
25 #
26 #   Dustin J. Mitchell <dustin@zmanda.com>
27 #
28 # COPYRIGHT
29 #
30 #   Copyright (c) 2007,2008 Zmanda, Inc.  All Rights Reserved.
31 #  
32 #   This program is free software; you can redistribute it and/or modify it
33 #   under the terms of the GNU General Public License version 2 as published
34 #   by the Free Software Foundation.
35 #  
36 #   This program is distributed in the hope that it will be useful, but
37 #   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
38 #   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
39 #   for more details.
40 #  
41 #   You should have received a copy of the GNU General Public License along
42 #   with this program; if not, write to the Free Software Foundation, Inc.,
43 #   59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
44 #
45 #   This special exception to the GPL applies to versions of the
46 #   Autoconf Macro released by the Autoconf Macro Archive. When you
47 #   make and distribute a modified version of the Autoconf Macro, you
48 #   may extend this special exception to the GPL to apply to your
49 #   modified version as well.
50 #
51 #   Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
52 #   Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
53
54 AC_DEFUN([AC_CHECK_DOCBOOK_XSLT_MIN],
55 [
56     AC_REQUIRE([AC_PROG_XSLTPROC])
57
58     AC_CACHE_CHECK([for current Docbook XSLT version], [ac_cv_docbook_xslt_current_version],
59     [
60         ac_cv_docbook_xslt_current_version=no
61
62         if test -n "$XSLTPROC"; then
63             cat >conftest.xsl <<EOF
64                 <xsl:stylesheet
65                     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
66                     xmlns:fm="http://freshmeat.net/projects/freshmeat-submit/"
67                     version="1.0">
68                     <xsl:output method="text"/>
69                     <xsl:template match="fm:project/fm:Version">
70                         <xsl:value-of select="." />
71                     </xsl:template>
72                     <!-- do nothing with any other text -->
73                     <xsl:template match="text()"/>
74                 </xsl:stylesheet>
75 EOF
76             echo "Trying '$XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/current/VERSION' with input:" >&AS_MESSAGE_LOG_FD
77             echo "====" >&AS_MESSAGE_LOG_FD
78             cat conftest.xsl >&AS_MESSAGE_LOG_FD
79             echo "====" >&AS_MESSAGE_LOG_FD
80
81             ac_cv_docbook_xslt_current_version=`$XSLTPROC $XSLTPROC_FLAGS conftest.xsl http://docbook.sourceforge.net/release/xsl/current/VERSION 2>&AS_MESSAGE_LOG_FD`
82
83             if test "$?" != 0; then
84                 ac_cv_docbook_xslt_current_version='no'
85             fi
86
87             rm conftest.xsl
88         fi
89     ])
90
91     DOCBOOK_XSLT_CURRENT_VERSION="$ac_cv_docbook_xslt_current_version"
92     AC_MSG_CHECKING([whether Docbook XSLT version is $1 or newer])
93
94     if test x"$DOCBOOK_XSLT_CURRENT_VERSION" = x"no"; then
95         AC_MSG_RESULT([no])
96     else
97         AX_COMPARE_VERSION([$DOCBOOK_XSLT_CURRENT_VERSION], [lt], [$1], [
98             # version is less than required, so mark it as "no"
99             DOCBOOK_XSLT_CURRENT_VERSION=no
100         ])
101
102         if test x"$DOCBOOK_XSLT_CURRENT_VERSION" = x"no"; then
103             AC_MSG_RESULT([no])
104         else
105             AC_MSG_RESULT([yes ($DOCBOOK_XSLT_CURRENT_VERSION)])
106         fi
107     fi
108 ])