[PATCH v2] add XORG_WITH_XMLTO to factorize xmlto tests

Gaetan Nadon memsize at videotron.ca
Wed Jan 6 14:25:59 PST 2010


On Wed, 2010-01-06 at 08:05 +0100, Matthieu Herrb wrote:

> >From 861790b2c9ac121d42d71c3258c24d1a6b265bc9 Mon Sep 17 00:00:00 2001
> From: Matthieu Herrb <matthieu.herrb at laas.fr>
> Date: Tue, 5 Jan 2010 23:04:25 +0100
> Subject: [PATCH] Add XORG_WITH_XMLTO to factorize xmlto tests.
> 
> This also allow to configure with --without-xmlto to ignore

--without-xmlto: if you want it, you have to code it. Only --with-xmlto
works.

> a 3rd party xmlto tool on systems that normally don't have it,
> in order to have reproducable builds.
> 
> Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
> ---
>  xorg-macros.m4.in |   45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 45 insertions(+), 0 deletions(-)
> 
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 20d0c70..85d353f 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -310,6 +310,51 @@ AC_SUBST(MAKE_PDF)
>  AC_SUBST(MAKE_HTML)
>  ]) # XORG_CHECK_DOCBOOK
>  
> +# XORG_WITH_XMLTO
> +# ----------------
> +# Minimum version: 1.5.0
> +#
> +# Checks for the availability of the xmlto command.
> +# Adds a --with-xmlto argument to configure that can be used to 
> +# disable xmlto or specify a specific path to the executable.

See case#4. Needs to be reworked as path to xmlto is supplied in XMLTO
env var.

> +# defines the HAVE_XMLTO automake conditionnal according to the result.
> +AC_DEFUN([XORG_WITH_XMLTO],[
> +AC_ARG_VAR([XMLTO], [Path to xmlto command])

Shouldn't "Path to xmlto command" be spelled with a lower case p? 

> +AC_ARG_WITH(xmlto, 
> +	AS_HELP_STRING([--with-xmlto],
> +	   [Use xmlto to regenerate documentation (default: auto)]),
> +	   [use_xmlto=$withval], [use_xmlto=auto])
> +
> +if test "x$use_xmlto" = x"auto"; then
> +   AC_PATH_PROG([XMLTO], [xmlto])
> +   if test "x$XMLTO" = "x"; then
> +        AC_MSG_WARN([xmlto not found - cannot create man pages without it])
> +	have_xmlto=no
> +   else
> +        have_xmlto=yes
> +   fi
> +elif test "x$use_xmlto" = x"yes" ; then
> +   AC_PATH_PROG([XMLTO], [xmlto])
> +   if test "x$XMLTO" = "x"; then
> +        AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH])
> +   fi
> +   have_xmlto=yes
> +elif test "x$use_xmlto" = x"no" ; then
> +   if test "x$XMLTO" != "x"; then 
> +      AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified])
> +   fi
> +   have_xmlto=no
> +else
> +   if test -x $use_xmlto ; then
> +      XMLTO=$use_xmlto
> +      have_xmlto=yes
> +   else
> +      AC_MSG_ERROR([specified xmlto $use_xmlto doesn't exist])
> +   fi

This 4th case should be an error (or ignored). There are only 3 possible
value [yes|no|auto]. If the user wishes to pass a value for XMLTO, it is
done in the environment or on the command line:

        ./configure --prefix $prefix XMLTO=/usr/bin/myxmlto

The user may specify a value for XMLTO without specifying --with-xmlto,
in which case it defaults to "auto".
The AC_PATH_PROG assigns precedence to the user supplied value of XMLTO
as seen here in configure script:

        ac_cv_path_XMLTO="$XMLTO" # Let the user override the test with a path.

It also caches the user value and all works transparently. In any case,
AC_PATH_PROG must always be called (when using xmlto) so that all the
internals are set correctly, regardless of where the value comes from.
It is not required to test -x the existence of the tool, as it was find
in the PATH by AC_PATH_PROG.

Output of ./configure --help:

        Optional Packages:
          --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
          --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
          --with-xmlto            Use xmlto to regenerate documentation (default:
                                  auto)
        

The semantic "Optional Packages" fits perfectly in our case. This calls
for a yes/no type of answer. I noticed modules using the "Optional
Packages" mechanism to pass in values like filename, but it was not
intended for that. In our case, we don't want 2 competing ways to supply
an xmlto path.



> +fi
> +AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
> +]) # XORG_CHECK_XMLTO
> +
>  # XORG_CHECK_MALLOC_ZERO
>  # ----------------------
>  # Minimum version: 1.0.0
> -- 
> 1.6.5.3
> 

Excellent. I have tested all 3 cases (auto, yes,no) and they work as
advertised. Both with and without XMLTO environment variable set. Note
that when a user sets XMLTO, AC_PATH_PROG takes it at face value and
does not complain that it is not in PATH. Because XMLTO is set, our
AC_MSG_WARN is not triggered. This is as designed by Automake:


        The result of this test can be overridden by setting the variable variable

You may want to make a note of this as it can be interpreted as bug.

I'll test the next (and most likely the final) version of the patch. Any
plan for asciidoc or any other tool?





> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.x.org/archives/xorg-devel/attachments/20100106/2f06f581/attachment.htm 


More information about the xorg-devel mailing list