From 1dd0d3d262fa53e72c64d02da795ccdee958caab Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Thu, 14 Jul 2005 13:04:10 +0000 Subject: [PATCH] 2001-06-05 Havoc Pennington Author: hp Date: 2001-06-05 18:41:27 GMT 2001-06-05 Havoc Pennington * main.c: add --errors-to-stdout so you can capture them with backticks * pkg.m4: set FOO_PKG_ERRORS after a failed check, so people can print the errors. --- ChangeLog | 9 ++++++++- main.c | 15 ++++++++++++--- pkg-config.1 | 6 ++++++ pkg.m4 | 8 ++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 008f94e..096e0f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2001-06-05 Havoc Pennington - + + * main.c: add --errors-to-stdout so you can capture them with backticks + + * pkg.m4: set FOO_PKG_ERRORS after a failed check, so people can + print the errors. + +2001-06-05 Havoc Pennington + * parse.c: never use flockfile, getc_unlocked 2001-06-05 Havoc Pennington diff --git a/main.c b/main.c index 140e531..ba872fd 100644 --- a/main.c +++ b/main.c @@ -13,13 +13,15 @@ static int want_debug_spew = 0; static int want_verbose_errors = 0; +static int want_stdout_errors = 0; void debug_spew (const char *format, ...) { va_list args; gchar *str; - + FILE* stream; + g_return_if_fail (format != NULL); if (!want_debug_spew) @@ -29,8 +31,13 @@ debug_spew (const char *format, ...) str = g_strdup_vprintf (format, args); va_end (args); - fputs (str, stderr); - fflush (stdout); + if (want_stdout_errors) + stream = stdout; + else + stream = stderr; + + fputs (str, stream); + fflush (stream); g_free (str); } @@ -193,6 +200,8 @@ main (int argc, char **argv) "show verbose information about missing or conflicting packages" }, { "silence-errors", 0, POPT_ARG_NONE, &want_silence_errors, 0, "show verbose information about missing or conflicting packages" }, + { "errors-to-stdout", 0, POPT_ARG_NONE, &want_stdout_errors, 0, + "print errors from --print-errors to stdout not stderr" }, POPT_AUTOHELP { NULL, 0, 0, NULL, 0 } }; diff --git a/pkg-config.1 b/pkg-config.1 index 6eb4937..60930e9 100644 --- a/pkg-config.1 +++ b/pkg-config.1 @@ -83,6 +83,10 @@ option is only useful with options such as "--cflags" or "--modversion" that print errors by default. The PKG_CONFIG_DEBUG_SPEW environment variable overrides this option. +.TP +.I "--errors-to-stdout" +If printing errors, print them to stdout rather than the default stderr + .PP The following options are used to compile and link programs: .TP @@ -212,6 +216,8 @@ If a module is missing or has the wrong version, by default configure will abort with a message. To replace the default action, specify an ACTION-IF-NOT-FOUND. PKG_CHECK_MODULES will not print any error messages if you specify your own ACTION-IF-NOT-FOUND. +However, it will set the variable MYSTUFF_PKG_ERRORS, which you can +use to display what went wrong. .SH METADATA FILE SYNTAX To add a library to the set of packages \fIpkg-config\fP knows about, diff --git a/pkg.m4 b/pkg.m4 index bc67203..33b1d52 100644 --- a/pkg.m4 +++ b/pkg.m4 @@ -1,6 +1,7 @@ dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page +dnl also defines GSTUFF_PKG_ERRORS on error AC_DEFUN(PKG_CHECK_MODULES, [ succeeded=no @@ -16,6 +17,7 @@ AC_DEFUN(PKG_CHECK_MODULES, else if ! $PKG_CONFIG --atleast-pkgconfig-version 0.7.0; then echo "*** Your version of pkg-config is too old. You need version 0.7.0 or newer." + echo "*** See http://www.freedesktop.org/software/pkgconfig" else AC_MSG_CHECKING(for $2) @@ -33,8 +35,10 @@ AC_DEFUN(PKG_CHECK_MODULES, else $1_CFLAGS="" $1_LIBS="" - ## If we have a custom action on failure, don't print errors - ifelse([$4], , $PKG_CONFIG --print-errors "$2",) + ## If we have a custom action on failure, don't print errors, but + ## do set a variable so people can do so. + $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + ifelse([$4], ,echo $1_PKG_ERRORS,) fi AC_SUBST($1_CFLAGS) -- 2.39.5