summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2015-06-13 10:22:48 -0700
committerDan Nicholson <dbn.lists@gmail.com>2016-01-29 14:32:24 -0800
commitae0a8b1ad5e40f68fc09ffedac215e038a50f070 (patch)
treebb8c37ac58dce6a6224b0f7b8db4cc8a6c7c0ea2 /check
parent9ef2d3475df0eba199427e9c47d9e502bd45b116 (diff)
downloadpkg-config-ae0a8b1ad5e40f68fc09ffedac215e038a50f070.tar.gz
Allow overriding package variables with env vars
pkg-config allows a way to override package variables through the --define-prefix interface, but this is very cumbersome to do in a global way since it always needs to be passed on the command line and the override cannot be scoped to a single packge. Allow overriding package variables using environment variables of the form PKG_CONFIG_$PACKAGE_$VARIABLE. For example, setting PKG_CONFIG_GLADEUI_2_0_CATALOGDIR will override the variable "catalogdir" in the "gladeui-2.0" package. https://bugs.freedesktop.org/show_bug.cgi?id=90917
Diffstat (limited to 'check')
-rw-r--r--check/Makefile.am4
-rwxr-xr-xcheck/check-variable-override35
2 files changed, 38 insertions, 1 deletions
diff --git a/check/Makefile.am b/check/Makefile.am
index 34d0e34..4f92e0d 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -26,7 +26,9 @@ TESTS = \
check-debug \
check-gtk \
check-tilde \
- check-relocatable
+ check-relocatable \
+ check-variable-override \
+ $(NULL)
EXTRA_DIST = \
$(TESTS) \
diff --git a/check/check-variable-override b/check/check-variable-override
new file mode 100755
index 0000000..e3f6cbd
--- /dev/null
+++ b/check/check-variable-override
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+set -e
+
+. ${srcdir}/common
+
+# Check the normal behavior
+RESULT="/usr"
+run_test --variable=prefix simple
+RESULT="/usr/lib"
+run_test --variable=libdir simple
+
+# Override prefix with correct environment variable
+export PKG_CONFIG_SIMPLE_PREFIX="/foo"
+RESULT="/foo"
+run_test --variable=prefix simple
+RESULT="/foo/lib"
+run_test --variable=libdir simple
+RESULT="-I/foo/include"
+run_test --cflags simple
+unset PKG_CONFIG_SIMPLE_PREFIX
+
+# Override prefix with incorrect environment variable case. On Windows
+# this will have no effect as environment variables are case
+# insensitive.
+if [ "$native_win32" != yes ]; then
+ export PKG_CONFIG_SIMPLE_prefix="/foo"
+ RESULT="/usr"
+ run_test --variable=prefix simple
+ RESULT="/usr/lib"
+ run_test --variable=libdir simple
+ RESULT=""
+ run_test --cflags simple
+ unset PKG_CONFIG_SIMPLE_prefix
+fi