summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2017-03-20 10:23:55 -0500
committerDan Nicholson <dbn.lists@gmail.com>2017-03-20 11:06:00 -0500
commit1dfe95b8b85a0d515d8c53d711dd26627859ed3f (patch)
treee6f8eb0f32ba5534d72caa8c99519da6d09982d2
parent309c1787a1d4f7f7a4cfb444c1e34d339f819a49 (diff)
downloadpkg-config-1dfe95b8b85a0d515d8c53d711dd26627859ed3f.tar.gz
check: Add test for system flags pruning
Test that pkg-config respects the various environment variables that override the system flags handling. https://bugs.freedesktop.org/show_bug.cgi?id=94729
-rw-r--r--check/Makefile.am2
-rwxr-xr-xcheck/check-system-flags47
-rw-r--r--check/system.pc10
3 files changed, 59 insertions, 0 deletions
diff --git a/check/Makefile.am b/check/Makefile.am
index cf26019..68c6d84 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -30,6 +30,7 @@ TESTS = \
check-variable-override \
check-variables \
check-dependencies \
+ check-system-flags \
$(NULL)
EXTRA_DIST = \
@@ -116,4 +117,5 @@ EXTRA_DIST = \
dependencies/i_dep_k_j.pc \
dependencies/j_dep_k.pc \
dependencies/k_dep.pc \
+ system.pc \
$(NULL)
diff --git a/check/check-system-flags b/check/check-system-flags
new file mode 100755
index 0000000..831dd0e
--- /dev/null
+++ b/check/check-system-flags
@@ -0,0 +1,47 @@
+#! /bin/sh
+
+set -e
+
+. ${srcdir}/common
+
+# Override the system paths in case pkg-config was built with something
+# that doesn't match the test pc file
+PKG_CONFIG_SYSTEM_INCLUDE_PATH=/usr/include
+if [ "$native_win32" = yes ]; then
+ PKG_CONFIG_SYSTEM_LIBRARY_PATH="/usr/lib;/lib"
+else
+ PKG_CONFIG_SYSTEM_LIBRARY_PATH=/usr/lib:/lib
+fi
+export PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH
+
+RESULT=""
+run_test --cflags system
+
+RESULT="-lsystem"
+run_test --libs system
+
+# Make sure that the full paths come out when the *_ALLOW_SYSTEM_*
+# variables are set
+RESULT="-I/usr/include"
+PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 run_test --cflags system
+
+RESULT="-L/usr/lib -lsystem"
+PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 run_test --libs system
+
+# Set the system paths to something else and test that the output
+# contains the full paths
+PKG_CONFIG_SYSTEM_INCLUDE_PATH=/foo/include
+PKG_CONFIG_SYSTEM_LIBRARY_PATH=/foo/lib
+
+RESULT="-I/usr/include"
+run_test --cflags system
+
+RESULT="-L/usr/lib -lsystem"
+run_test --libs system
+
+# Now check that the various compiler environment variables also update
+# the system include path
+for var in CPATH C_INCLUDE_PATH CPP_INCLUDE_PATH; do
+ RESULT=""
+ eval $var=/usr/include run_test --cflags system
+done
diff --git a/check/system.pc b/check/system.pc
new file mode 100644
index 0000000..2cef2ed
--- /dev/null
+++ b/check/system.pc
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: System library
+Description: Test package
+Version: 1.0.0
+Libs: -L${libdir} -lsystem
+Cflags: -I${includedir}