[PATCH 8/8] check: Test relocatable features

Dan Nicholson dbn.lists at gmail.com
Sat Apr 20 07:42:25 PDT 2013


Exercise the ${pcfiledir} and --define-prefix features for allowing
relocation of packages. The --define-prefix test .pc files are put in a
pkgconfig subdirectory since the feature will only be enabled in that
situation.
---
 check/Makefile.am                     |  8 ++++++--
 check/check-relocatable               | 29 +++++++++++++++++++++++++++++
 check/pcfiledir.pc                    | 11 +++++++++++
 check/pkgconfig/prefixdef-expanded.pc | 11 +++++++++++
 check/pkgconfig/prefixdef.pc          | 11 +++++++++++
 5 files changed, 68 insertions(+), 2 deletions(-)
 create mode 100644 check/check-relocatable
 create mode 100644 check/pcfiledir.pc
 create mode 100644 check/pkgconfig/prefixdef-expanded.pc
 create mode 100644 check/pkgconfig/prefixdef.pc

diff --git a/check/Makefile.am b/check/Makefile.am
index 5006b5f..f348128 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -25,7 +25,8 @@ TESTS = \
 	check-uninstalled \
 	check-debug \
 	check-gtk \
-	check-tilde
+	check-tilde \
+	check-relocatable
 
 EXTRA_DIST = \
 	$(TESTS) \
@@ -92,4 +93,7 @@ EXTRA_DIST = \
 	gtk/xcb.pc \
 	gtk/xproto.pc \
 	gtk/xrender.pc \
-	tilde.pc
+	tilde.pc \
+	pkgconfig/prefixdef.pc \
+	pkgconfig/prefixdef-expanded.pc \
+	pcfiledir.pc
diff --git a/check/check-relocatable b/check/check-relocatable
new file mode 100644
index 0000000..dc320c4
--- /dev/null
+++ b/check/check-relocatable
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+set -e
+. ${srcdir}/common
+
+# Test if pcfiledir metadata variable is substituted correctly
+RESULT="-I${srcdir}/include -L${srcdir}/lib -lfoo"
+run_test --cflags --libs pcfiledir
+
+# Test prefix redefinition for .pc files in pkgconfig directory. Try .pc
+# 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"
+for pkg in prefixdef prefixdef-expanded; do
+    # Typical redefinition
+    RESULT="-I${abs_top_srcdir}/include -L${abs_top_srcdir}/lib -lfoo"
+    run_test --define-prefix --cflags --libs $pkg
+
+    RESULT="-I/reloc/include -L/reloc/lib -lfoo"
+    run_test --dont-define-prefix --cflags --libs $pkg
+
+    # Non-standard redefinition
+    RESULT="-I/reloc/include -L${abs_top_srcdir} -lfoo"
+    run_test --define-prefix --prefix-variable=libdir --cflags --libs $pkg
+
+    RESULT="-I/reloc/include -L/reloc/lib -lfoo"
+    run_test --dont-define-prefix --cflags --libs $pkg
+done
diff --git a/check/pcfiledir.pc b/check/pcfiledir.pc
new file mode 100644
index 0000000..da50e6d
--- /dev/null
+++ b/check/pcfiledir.pc
@@ -0,0 +1,11 @@
+prefix=${pcfiledir}
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: pcfiledir relocation test
+Description: Test pkg-config pcfiledir metadata variable
+Version: 1.0.0
+Requires:
+Libs: -L${libdir} -lfoo
+Cflags: -I${includedir}
diff --git a/check/pkgconfig/prefixdef-expanded.pc b/check/pkgconfig/prefixdef-expanded.pc
new file mode 100644
index 0000000..464334a
--- /dev/null
+++ b/check/pkgconfig/prefixdef-expanded.pc
@@ -0,0 +1,11 @@
+prefix=/reloc
+exec_prefix=/reloc
+libdir=/reloc/lib
+includedir=/reloc/include
+
+Name: Prefix redefinition with expanded variables test
+Description: Test magic prefix redefinition when variables expanded
+Version: 1.0.0
+Requires:
+Libs: -L${libdir} -lfoo
+Cflags: -I${includedir}
diff --git a/check/pkgconfig/prefixdef.pc b/check/pkgconfig/prefixdef.pc
new file mode 100644
index 0000000..9f4a4ba
--- /dev/null
+++ b/check/pkgconfig/prefixdef.pc
@@ -0,0 +1,11 @@
+prefix=/reloc
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Prefix redefinition test
+Description: Test pkg-config magic prefix redefinition
+Version: 1.0.0
+Requires:
+Libs: -L${libdir} -lfoo
+Cflags: -I${includedir}
-- 
1.8.1.4



More information about the pkg-config mailing list