From 94ef8aeb554d10673109d3eee0f1e3e44e73b443 Mon Sep 17 00:00:00 2001 Message-Id: <94ef8aeb554d10673109d3eee0f1e3e44e73b443.1424548764.git.dbn.lists@gmail.com> From: Dan Nicholson Date: Mon, 4 Jun 2012 08:47:04 -0700 Subject: [PATCH] Prefer envvar PKG_CONFIG_SYSTEM_PATH for overriding default path 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. https://bugs.freedesktop.org/show_bug.cgi?id=89268 --- README.win32 | 4 ++-- check/check-gtk | 2 +- check/check-path | 2 +- check/check-print-options | 2 +- check/check-relocatable | 8 ++++---- check/common | 4 ++-- main.c | 9 +++++++-- pkg-config.1 | 5 ++++- pkg.m4 | 4 ++-- 9 files changed, 24 insertions(+), 16 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 198e5a1..4040f68 100755 --- a/check/check-print-options +++ b/check/check-print-options @@ -38,7 +38,7 @@ run_test --print-requires-private requires-test RESULT="sub1 Subdirectory package 1 - Test package 1 for subdirectory sub2 Subdirectory package 2 - Test package 2 for subdirectory broken Broken package - Module with broken .pc file" -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/check-relocatable b/check/check-relocatable index 589eddf..cad8160 100755 --- a/check/check-relocatable +++ b/check/check-relocatable @@ -12,9 +12,9 @@ if [ "$native_win32" = yes ]; then abs_srcdir=$($WINE cmd $opt echo "$abs_srcdir" | tr -d '\r') fi -# See if the pcfiledir variable is defined. First, with the path -# built from the relative PKG_CONFIG_LIBDIR. Second, with the path -# built from the full path to the pc file. +# See if the pcfiledir variable is defined. First, with the path built +# from the relative PKG_CONFIG_SYSTEM_PATH. Second, with the path built +# from the full path to the pc file. RESULT=$srcdir run_test --variable=pcfiledir pcfiledir RESULT=$abs_srcdir @@ -28,7 +28,7 @@ run_test --cflags --libs pcfiledir # files with both unexpanded and expanded variables. Use the absolute # directory for the search path so that pkg-config can strip enough # components of the file directory to be useful. -PKG_CONFIG_LIBDIR="${abs_srcdir}/pkgconfig" +PKG_CONFIG_SYSTEM_PATH="${abs_srcdir}/pkgconfig" for pkg in prefixdef prefixdef-expanded; do # Typical redefinition RESULT="-I${abs_top_srcdir}/include -L${abs_top_srcdir}/lib -lfoo" 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 227ed35..37f0b50 100644 --- a/main.c +++ b/main.c @@ -518,11 +518,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 74bb70a..f68050a 100644 --- a/pkg-config.1 +++ b/pkg-config.1 @@ -333,11 +333,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 PKG-CONFIG DERIVED VARIABLES .I pkg-config diff --git a/pkg.m4 b/pkg.m4 index 62995f0..9d2425a 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.9.3