[PATCH] Prefer envvar PKG_CONFIG_SYSTEM_PATH for overriding default path

Dan Nicholson dbn.lists at gmail.com
Sat Apr 20 10:39:23 PDT 2013


Currently PKG_CONFIG_LIBDIR is used to override the default search path,
but this is really a poor name for what it's accomplishing. Accept a new
variable, PKG_CONFIG_SYSTEM_PATH, for this purpose but fallback to
PKG_CONFIG_LIBDIR to maintain compatibility.
---
 README.win32              | 4 ++--
 check/check-gtk           | 2 +-
 check/check-path          | 2 +-
 check/check-print-options | 2 +-
 check/common              | 4 ++--
 main.c                    | 9 +++++++--
 pkg-config.1              | 5 ++++-
 pkg.m4                    | 4 ++--
 8 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/README.win32 b/README.win32
index 320efab..a1c6bdc 100644
--- a/README.win32
+++ b/README.win32
@@ -10,8 +10,8 @@ be useable also by MSVC users.
 When pkg-config.exe is invoked, it uses the glib function
 g_win32_get_package_installation_directory_of_module() to find the
 directory it's being run from. It then adds the "lib" and "share"
-subdirectories to the pkg-config search path unless PKG_CONFIG_LIBDIR is
-set in the environment. This allows pkg-config to adjust to being
+subdirectories to the pkg-config search path unless PKG_CONFIG_SYSTEM_PATH
+is set in the environment. This allows pkg-config to adjust to being
 relocated on Windows.
 
 For each .pc file encountered, pkg-config will replace the prefix
diff --git a/check/check-gtk b/check/check-gtk
index 7fd01bb..68e093f 100755
--- a/check/check-gtk
+++ b/check/check-gtk
@@ -5,7 +5,7 @@ set -e
 . ${srcdir}/common
 
 # Limit pkg-config files to gtk subdir
-PKG_CONFIG_LIBDIR=${srcdir}/gtk
+PKG_CONFIG_SYSTEM_PATH=${srcdir}/gtk
 
 # Fetch Cflags of gtk+-3.0. Prior results to check for regressions.
 # pkg-config-0.21 - pkg-config-0.27.1
diff --git a/check/check-path b/check/check-path
index 2a6be75..a76c434 100755
--- a/check/check-path
+++ b/check/check-path
@@ -31,5 +31,5 @@ if [ "$native_win32" = yes ]; then
 else
     RESULT=$pc_path
 fi
-unset PKG_CONFIG_LIBDIR
+unset PKG_CONFIG_SYSTEM_PATH
 run_test --variable=pc_path pkg-config
diff --git a/check/check-print-options b/check/check-print-options
index a2a41e7..5beb362 100755
--- a/check/check-print-options
+++ b/check/check-print-options
@@ -36,7 +36,7 @@ run_test --print-requires-private requires-test
 # --list-all, limit to a subdirectory
 RESULT="sub1 Subdirectory package 1 - Test package 1 for subdirectory
 sub2 Subdirectory package 2 - Test package 2 for subdirectory"
-PKG_CONFIG_LIBDIR="$srcdir/sub" run_test --list-all
+PKG_CONFIG_SYSTEM_PATH="$srcdir/sub" run_test --list-all
 
 # Check handling when multiple incompatible options are set
 RESULT="Ignoring incompatible output option \"--modversion\"
diff --git a/check/common b/check/common
index 1115c2e..216c77d 100644
--- a/check/common
+++ b/check/common
@@ -9,8 +9,8 @@ pkgconfig=${PKG_CONFIG-../pkg-config}
 . ./config.sh
 
 unset PKG_CONFIG_PATH
-PKG_CONFIG_LIBDIR=$srcdir
-export PKG_CONFIG_LIBDIR
+PKG_CONFIG_SYSTEM_PATH=$srcdir
+export PKG_CONFIG_SYSTEM_PATH
 export LC_ALL=C
 
 run_test () {
diff --git a/main.c b/main.c
index c937efc..c728277 100644
--- a/main.c
+++ b/main.c
@@ -510,11 +510,16 @@ main (int argc, char **argv)
     }
 
   search_path = getenv ("PKG_CONFIG_PATH");
-  if (search_path) 
+  if (search_path)
     {
       add_search_dirs(search_path, G_SEARCHPATH_SEPARATOR_S);
     }
-  if (getenv("PKG_CONFIG_LIBDIR") != NULL) 
+  if (getenv("PKG_CONFIG_SYSTEM_PATH") != NULL)
+    {
+      add_search_dirs(getenv("PKG_CONFIG_SYSTEM_PATH"),
+                      G_SEARCHPATH_SEPARATOR_S);
+    }
+  else if (getenv("PKG_CONFIG_LIBDIR") != NULL)
     {
       add_search_dirs(getenv("PKG_CONFIG_LIBDIR"), G_SEARCHPATH_SEPARATOR_S);
     }
diff --git a/pkg-config.1 b/pkg-config.1
index c5d87d3..66e8305 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -279,11 +279,14 @@ the new system root. this means that a -I/usr/include/libfoo will
 become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR
 equal to /var/target (same rule apply to -L)
 .TP
-.I "PKG_CONFIG_LIBDIR"
+.I "PKG_CONFIG_SYSTEM_PATH"
 Replaces the default
 .I pkg-config
 search directory, usually
 .IR /usr/lib/pkgconfig : /usr/share/pkgconfig .
+The deprecated environment variable
+.I PKG_CONFIG_LIBDIR
+is also accepted.
 .\"
 .SH QUERYING PKG-CONFIG'S DEFAULTS
 .I pkg-config
diff --git a/pkg.m4 b/pkg.m4
index c5b26b5..d607bd0 100644
--- a/pkg.m4
+++ b/pkg.m4
@@ -26,11 +26,11 @@
 # ----------------------------------
 AC_DEFUN([PKG_PROG_PKG_CONFIG],
 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|SYSTEM_PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
-AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+AC_ARG_VAR([PKG_CONFIG_SYSTEM_PATH], [path overriding pkg-config's built-in search path])
 
 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
 	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-- 
1.8.1.4



More information about the pkg-config mailing list