Imported Upstream version 3.3.3
[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-2012 Zmanda, Inc.  All Rights Reserved.
31 #  
32 #   This program is free software; you can redistribute it and/or
33 #   modify it under the terms of the GNU General Public License
34 #   as published by the Free Software Foundation; either version 2
35 #   of the License, or (at your option) any later version.
36 #  
37 #   This program is distributed in the hope that it will be useful, but
38 #   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
39 #   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
40 #   for more details.
41 #  
42 #   You should have received a copy of the GNU General Public License along
43 #   with this program; if not, write to the Free Software Foundation, Inc.,
44 #   59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
45 #
46 #   This special exception to the GPL applies to versions of the
47 #   Autoconf Macro released by the Autoconf Macro Archive. When you
48 #   make and distribute a modified version of the Autoconf Macro, you
49 #   may extend this special exception to the GPL to apply to your
50 #   modified version as well.
51 #
52 #   Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
53 #   Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
54
55 AC_DEFUN([AC_CHECK_DOCBOOK_XSLT_MIN],
56 [
57     AC_REQUIRE([AC_PROG_XSLTPROC])
58
59     AC_CACHE_CHECK([for current Docbook XSLT version], [ac_cv_docbook_xslt_current_version],
60     [
61         ac_cv_docbook_xslt_current_version=no
62
63         if test -n "$XSLTPROC"; then
64             cat >conftest.xsl <<EOF
65                 <xsl:stylesheet
66                     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
67                     xmlns:fm="http://freshmeat.net/projects/freshmeat-submit/"
68                     version="1.0">
69                     <xsl:output method="text"/>
70                     <xsl:template match="fm:project/fm:Version">
71                         <xsl:value-of select="." />
72                     </xsl:template>
73                     <!-- do nothing with any other text -->
74                     <xsl:template match="text()"/>
75                 </xsl:stylesheet>
76 EOF
77             echo "Trying '$XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/current/VERSION' with input:" >&AS_MESSAGE_LOG_FD
78             echo "====" >&AS_MESSAGE_LOG_FD
79             cat conftest.xsl >&AS_MESSAGE_LOG_FD
80             echo "====" >&AS_MESSAGE_LOG_FD
81
82             ac_cv_docbook_xslt_current_version=`$XSLTPROC $XSLTPROC_FLAGS conftest.xsl http://docbook.sourceforge.net/release/xsl/current/VERSION 2>&AS_MESSAGE_LOG_FD`
83
84             if test "$?" != 0; then
85                 ac_cv_docbook_xslt_current_version='no'
86             fi
87
88             rm conftest.xsl
89         fi
90     ])
91
92     DOCBOOK_XSLT_CURRENT_VERSION="$ac_cv_docbook_xslt_current_version"
93     AC_MSG_CHECKING([whether Docbook XSLT version is $1 or newer])
94
95     if test x"$DOCBOOK_XSLT_CURRENT_VERSION" = x"no"; then
96         AC_MSG_RESULT([no])
97     else
98         AX_COMPARE_VERSION([$DOCBOOK_XSLT_CURRENT_VERSION], [lt], [$1], [
99             # version is less than required, so mark it as "no"
100             DOCBOOK_XSLT_CURRENT_VERSION=no
101         ])
102
103         if test x"$DOCBOOK_XSLT_CURRENT_VERSION" = x"no"; then
104             AC_MSG_RESULT([no])
105         else
106             AC_MSG_RESULT([yes ($DOCBOOK_XSLT_CURRENT_VERSION)])
107         fi
108     fi
109 ])