[PATCH 3/4] Add option to print the path used by pkg-config

Dan Nicholson dbn.lists at gmail.com
Fri Feb 26 16:15:29 PST 2010


The --list-path option provides a means to find out the current
pkg-config search path. in search path being used by pkg-config is.
---
 main.c       |    9 +++++++++
 pkg-config.1 |    7 ++++++-
 pkg.c        |    6 ++++++
 pkg.h        |    1 +
 4 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/main.c b/main.c
index b9442fc..44486c9 100644
--- a/main.c
+++ b/main.c
@@ -176,6 +176,7 @@ main (int argc, char **argv)
   static int want_I_cflags = 0;
   static int want_other_cflags = 0;
   static int want_list = 0;
+  static int want_pc_path = 0;
   static int want_static_lib_list = ENABLE_INDIRECT_DEPS;
   static int want_short_errors = 0;
   static int want_uninstalled = 0;
@@ -243,6 +244,8 @@ main (int argc, char **argv)
       "return 0 if the module is at no newer than version VERSION", "VERSION" },
     { "list-all", 0, POPT_ARG_NONE, &want_list, 0,
       "list all known packages" },
+    { "list-path", 0, POPT_ARG_NONE, &want_pc_path, 0,
+      "list the pkg-config path elements" },
     { "debug", 0, POPT_ARG_NONE, &want_debug_spew, 0,
       "show verbose debug information" },
     { "print-errors", 0, POPT_ARG_NONE, &want_verbose_errors, 0,
@@ -410,6 +413,12 @@ main (int argc, char **argv)
       return 0;
     }
 
+  if (want_pc_path)
+    {
+      print_pc_path();
+      return 0;
+    }
+
   str = g_string_new ("");
   while (1)
     {
diff --git a/pkg-config.1 b/pkg-config.1
index 4900371..69693d8 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -35,7 +35,8 @@ pkg-config \- Return metainformation about installed libraries
 [\-\-define-variable=VARIABLENAME=VARIABLEVALUE]
 [\-\-uninstalled]
 [\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION]
-[\-\-max-version=VERSION] [\-\-list\-all] [LIBRARIES...]
+[\-\-max-version=VERSION] [\-\-list\-all] [\-\-list\-path]
+[LIBRARIES...]
 .SH DESCRIPTION
 
 The \fIpkg-config\fP program is used to retrieve information about
@@ -210,6 +211,10 @@ output.
 .TP
 .I "--list-all"
 List all modules found in the \fIpkg-config\fP path.
+.TP
+.I "--list-path"
+List the elements of the \fIpkg-config\fP path after processing
+environment variables.
 .\"
 .SH ENVIRONMENT VARIABLES
 .TP
diff --git a/pkg.c b/pkg.c
index 0409531..17d03a3 100644
--- a/pkg.c
+++ b/pkg.c
@@ -1517,6 +1517,12 @@ print_package_list (void)
 }
 
 void
+print_pc_path (void)
+{
+    g_slist_foreach (search_dirs, (GFunc)puts, NULL);
+}
+
+void
 enable_private_libs(void)
 {
   ignore_private_libs = FALSE;
diff --git a/pkg.h b/pkg.h
index 984a461..6777e42 100644
--- a/pkg.h
+++ b/pkg.h
@@ -119,6 +119,7 @@ gboolean version_test (ComparisonType comparison,
 const char *comparison_to_str (ComparisonType comparison);
 
 void print_package_list (void);
+void print_pc_path (void);
 
 void define_global_variable (const char *varname,
                              const char *varval);
-- 
1.6.6.1



More information about the pkg-config mailing list