From 5de1df39d322de2f0a6029ed6747615a1c6131ea Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 May 2014 09:27:09 +1000 Subject: [PATCH] Add a --print-location argument to print _where_ a .pc file is located This can help tremendously when debugging PKG_CONFIG_PATH errors, especially if the path is set up to the wrong directory. With --print-location one can easily find out which .pc file is picked up and where an error comes from. Freedesktop #79030 (https://bugs.freedesktop.org/show_bug.cgi?id=79030) --- main.c | 24 +++++++++++++++++++++++- pkg-config.1 | 4 ++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 62758b8..aa63092 100644 --- a/main.c +++ b/main.c @@ -50,6 +50,7 @@ static gboolean want_exists = FALSE; static gboolean want_provides = FALSE; static gboolean want_requires = FALSE; static gboolean want_requires_private = FALSE; +static gboolean want_location = FALSE; static char *required_atleast_version = NULL; static char *required_exact_version = NULL; static char *required_max_version = NULL; @@ -247,6 +248,8 @@ output_opt_cb (const char *opt, const char *arg, gpointer data, want_requires = TRUE; else if (strcmp (opt, "--print-requires-private") == 0) want_requires_private = TRUE; + else if (strcmp (opt, "--print-location") == 0) + want_location = TRUE; else return FALSE; @@ -461,6 +464,8 @@ static const GOptionEntry options_table[] = { { "print-requires-private", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, &output_opt_cb, "print which packages the package requires for static " "linking", NULL }, + { "print-location", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + &output_opt_cb, "print the location of the .pc file", NULL }, { "define-prefix", 0, 0, G_OPTION_ARG_NONE, &define_prefix, "try to override the value of prefix for each .pc file found with a " "guesstimated value based on the location of the .pc file", NULL }, @@ -801,7 +806,24 @@ main (int argc, char **argv) } } } - + + if (want_location) + { + GList *tmp; + tmp = packages; + while (tmp != NULL) + { + Package *pkg = tmp->data; + printf("%s/%s.pc\n", pkg->pcfiledir, pkg->key); + + if (pkg_uninstalled (pkg)) + return 0; + + tmp = g_list_next (tmp); + } + + } + /* Print all flags; then print a newline at the end. */ need_newline = FALSE; diff --git a/pkg-config.1 b/pkg-config.1 index 3ee869f..01ecba4 100644 --- a/pkg-config.1 +++ b/pkg-config.1 @@ -23,6 +23,7 @@ pkg-config \- Return metainformation about installed libraries [\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION] [\-\-max-version=VERSION] [\-\-list\-all] [\-\-print-provides] [\-\-print-requires] [\-\-print-requires-private] [LIBRARIES...] +[\-\-print-location] [LIBRARIES...] .SH DESCRIPTION The \fIpkg-config\fP program is used to retrieve information about @@ -276,6 +277,9 @@ List all modules the given packages requires. .TP .I "--print-requires-private" List all modules the given packages requires for static linking (see --static). +.TP +.I "--print-location" +Print the full path of .pc file for each library. .\" .SH ENVIRONMENT VARIABLES .TP -- 1.9.0