[PATCH util-macros 2/3] XORG_WITH_GLIB: check for the GLib package
Dan Nicholson
dbn.lists at gmail.com
Thu Mar 10 09:04:00 PST 2011
On Thu, Mar 10, 2011 at 5:55 AM, Gaetan Nadon <memsize at videotron.ca> wrote:
> XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
> ----------------------------------------
> Minimum version: 1.13.0
>
> GLib is a library which provides advanced data structures and functions.
> This macro enables a module to test for the presence of Glib.
>
> When used in conjunction with XORG_ENABLE_UNIT_TESTS, use both AM_CONDITIONAL
> ENABLE_UNIT_TESTS and HAVE_GLIB.
> Glib may be used for purpose other than testing
>
> Package builders should use --without-glib to ensure it does not get pulled in.
> Unit tests may or may not use GLib.
>
> Developers should use --with-glib to error out if GLib is missing.
>
> Interface to module:
> HAVE_GLIB: used in makefiles to conditionally build targets
> with_glib: used in configure.ac to know if GLib has been found
> --with-glib: 'yes' user instructs the module to use glib
> 'no' user instructs the module not to use glib
>
> Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
> ---
> xorg-macros.m4.in | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 58 insertions(+), 0 deletions(-)
>
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 420e4ce..c9ca311 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -960,6 +960,10 @@ AC_MSG_RESULT([$build_specs])
> # Test cases may or may not use Automake "Support for test suites"
> # They may or may not use the software utility library GLib
> #
> +# When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL
> +# ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib.
> +# The variable enable_unit_tests is used by other macros in this file.
> +#
> # Interface to module:
> # ENABLE_UNIT_TESTS: used in makefiles to conditionally build tests
> # enable_unit_tests: used in configure.ac for additional configuration
> @@ -968,6 +972,7 @@ AC_MSG_RESULT([$build_specs])
> # parm1: specify the default value, yes or no.
> #
> AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[
> +AC_BEFORE([$0], [XORG_WITH_GLIB])
> m4_define([_defopt], m4_default([$1], [auto]))
> AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests],
> [Enable building unit test cases (default: ]_defopt[)]),
> @@ -978,6 +983,59 @@ AC_MSG_CHECKING([whether to build unit test cases])
> AC_MSG_RESULT([$enable_unit_tests])
> ]) # XORG_ENABLE_UNIT_TESTS
>
> +# XORG_WITH_GLIB([MIN-VERSION], [DEFAULT])
> +# ----------------------------------------
> +# Minimum version: 1.13.0
> +#
> +# GLib is a library which provides advanced data structures and functions.
> +# This macro enables a module to test for the presence of Glib.
> +#
> +# When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing.
> +# Otherwise the value of $enable_unit_tests is blank.
> +#
> +# Interface to module:
> +# HAVE_GLIB: used in makefiles to conditionally build targets
> +# with_glib: used in configure.ac to know if GLib has been found
> +# --with-glib: 'yes' user instructs the module to use glib
> +# 'no' user instructs the module not to use glib
> +#
> +AC_DEFUN([XORG_WITH_GLIB],[
> +m4_define([_defopt], m4_default([$2], [auto]))
> +AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib],
> + [Use GLib software utility library (default: ]_defopt[)]),
This should probably say "for tests" or something so that builders
don't think they're gaining some extra functionality with glib.
> + [with_glib=$withval], [with_glib=]_defopt)
> +m4_undefine([_defopt])
> +
> +have_glib=no
> +# Do not probe GLib if user explicitly disabled unit testing
> +if test "x$enable_unit_tests" != x"no"; then
> + # Do not probe GLib if user explicitly disabled it
> + if test "x$with_glib" != x"no"; then
> + m4_ifval(
> + [$1],
> + [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])],
> + [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])]
Since this is under a conditional, do we need PKG_PROG_PKGCONFIG
earlier? I'm not sure if one of the other macros ensures this first.
> + )
> + fi
> +fi
> +
> +# Not having GLib when unit testing has been explicitly requested is an error
> +if test "x$enable_unit_tests" = x"yes"; then
> + if test "x$have_glib" = x"no"; then
> + AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found])
> + fi
> +fi
> +
> +# Not having GLib when it has been explicitly requested is an error
> +if test "x$with_glib" = x"yes"; then
> + if test "x$have_glib" = x"no"; then
> + AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found])
> + fi
> +fi
> +
> +AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes])
> +]) # XORG_WITH_GLIB
Looks good otherwise.
Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
More information about the xorg-devel
mailing list