m4macros: Allow information from pkg-config to be overridden

By using PKG_CHECK_VAR, we declare $GLIB_COMPILE_SCHEMAS,
$GLIB_GENMARSHAL, $GOBJECT_QUERY, $GLIB_MKENUMS and
$GLIB_COMPILE_RESOURCES as Autoconf "precious variables" with AC_ARG_VAR,
similar to $PKG_CONFIG and $CC, so that they can be put on a configure
command line:

    ./configure GLIB_COMPILE_RESOURCES=my-glib-compile-resources

If they are set to a non-empty value, PKG_CHECK_VAR will use that
instead of auto-detecting from pkg-config, so that builders can
override them, for example when cross-compiling.

Similarly, use the standard PKG_CHECK_MODULES macro to get GLib's CFLAGS
and LIBS.

It's possible that most of the rest of each macro can also disappear,
but for the moment I've given them the benefit of the doubt.

This does result in printing "checking for GLIB" twice (once for
PKG_CHECK_MODULES and once for GLib's custom checks), but if you're
using Autotools, you probably don't have a strong objection to overly
verbose output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2018-10-04 20:13:32 +01:00
parent 6e0a03ee07
commit 4bb16f4845
2 changed files with 25 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
# Increment this whenever this file is changed.
#serial 1
#serial 2
dnl GLIB_GSETTINGS
dnl Defines GSETTINGS_SCHEMAS_INSTALL which controls whether
@@ -8,6 +8,10 @@ dnl
AC_DEFUN([GLIB_GSETTINGS],
[
dnl We can't use PKG_PREREQ because that needs 0.29.
m4_ifndef([PKG_PROG_PKG_CONFIG],
[pkg.m4 version 0.28 or later is required])
m4_pattern_allow([AM_V_GEN])
AC_ARG_ENABLE(schemas-compile,
AS_HELP_STRING([--disable-schemas-compile],
@@ -20,11 +24,9 @@ AC_DEFUN([GLIB_GSETTINGS],
AC_SUBST([GSETTINGS_DISABLE_SCHEMAS_COMPILE])
PKG_PROG_PKG_CONFIG([0.16])
AC_SUBST(gsettingsschemadir, [${datadir}/glib-2.0/schemas])
if test x$cross_compiling != xyes; then
GLIB_COMPILE_SCHEMAS=`$PKG_CONFIG --variable glib_compile_schemas gio-2.0`
else
AC_PATH_PROG(GLIB_COMPILE_SCHEMAS, glib-compile-schemas)
fi
AS_IF([test x$cross_compiling != xyes],
[PKG_CHECK_VAR([GLIB_COMPILE_SCHEMAS], [gio-2.0], [glib_compile_schemas])],
[AC_PATH_PROG([GLIB_COMPILE_SCHEMAS], [glib-compile-schemas])])
AC_SUBST(GLIB_COMPILE_SCHEMAS)
if test "x$GLIB_COMPILE_SCHEMAS" = "x"; then
ifelse([$2],,[AC_MSG_ERROR([glib-compile-schemas not found.])],[$2])