Jack Nagel jacknagel at gmail.com
Wed Aug 29 15:10:31 PDT 2012

If PKG_CONFIG_FALLBACK_PATH is set, any included paths will be searched
after those on PKG_CONFIG_PATH and the internal pc search path.

This allows a user to add directories that should be searched after
PKG_CONFIG_PATH and the internal search path, but may not have existed
at compile-time.

Signed-off-by: Jack Nagel <jacknagel at gmail.com>

Here's a POC patch for a feature that would greatly simplify a use case
that I have (as part of the Homebrew package manager for OS X).

It's fairly convoluted, but it boils down to supporting multiple ways to
obtain certain packages, and supporting them side-by-side without one
interfering with the other (header version mismatches, etc.). It can be
accomplished with liberal use of PKG_CONFIG_PATH, but for some packages
this gets out of hand quickly (a half dozen or more directories on
PKG_CONFIG_PATH), and it would greatly simplify things if we could just
stick one directory on PKG_CONFIG_FALLBACK_PATH when we need to and be
done with it.

If you are receptive to the idea I would be happy to update the docs as
well, but I wanted to get your feedback first.

 main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/main.c b/main.c
index 385e43d..dee8c5d 100644
--- a/main.c
+++ b/main.c
@@ -221,6 +221,7 @@ main (int argc, char **argv)
   GString *str;
   GSList *packages = NULL;
   char *search_path;
+  char *fallback_path;
   char *pcbuilddir;
   gboolean need_newline;
   FILE *log = NULL;
@@ -338,6 +339,12 @@ main (int argc, char **argv)
       add_search_dirs(pkg_config_pc_path, G_SEARCHPATH_SEPARATOR_S);
+  fallback_path = getenv ("PKG_CONFIG_FALLBACK_PATH");
+  if (fallback_path)
+    {
+	add_search_dirs(fallback_path, G_SEARCHPATH_SEPARATOR_S);
+    }
   pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
   if (pcsysrootdir)

More information about the pkg-config mailing list