pkg-config/check/check-relocatable
Luca Boccassi 50a46d5fbb define-prefix: skip one level if it ends up in /lib
In Debian and Ubuntu the multiarch filesystem layout looks as follows:

/usr/lib/x86_64-linux-gnu/pkgconfig/
/usr/lib/i386-linux-gnu/pkgconfig/

Which means when --define-prefix skips to the grand-parent
directory of pkgconfig, it ends up in /usr/lib rather than
/usr as it's supposed to.

This causes for example the include path to be printed as:
/usr/lib/include
which is wrong and breaks applications.

Check if the new directory is 'lib' and if it is go one step
above. A new series of unit tests is added with this layout.
2019-07-04 14:15:51 +01:00

72 lines
2.9 KiB
Bash
Executable file

#! /bin/sh
set -e
. ${srcdir}/common
# Convert absolute directories to Windows format if necessary.
if [ "$native_win32" = yes ]; then
# Assume we have cmd to do the conversion, except we have to escape
# the command switch on MSYS.
[ "$OSTYPE" = msys ] && opt="\\/C" || opt="/C"
abs_top_srcdir=$($WINE cmd $opt echo "$abs_top_srcdir" | tr -d '\r')
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.
RESULT=$srcdir
run_test --variable=pcfiledir pcfiledir
RESULT=$abs_srcdir
run_test --variable=pcfiledir "$abs_srcdir/pcfiledir.pc"
# 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
# Test prefix redefinition for .pc files with an empty prefix. In this
# case, there should be no prefix adjustment to the other variables. The
# result should be the same regardless of prefix redefinition.
RESULT="-I/some/path/include -L/some/path/lib -lfoo"
run_test --define-prefix --cflags --libs empty-prefix
run_test --dont-define-prefix --cflags --libs empty-prefix
# Test prefix redefinition for .pc files when the pkgconfig directory is in
# ..../lib/arch/ as Debian and Ubuntu and their derivatives do.
PKG_CONFIG_LIBDIR="${abs_srcdir}/lib/arch/pkgconfig"
for pkg in prefixdef prefixdef-expanded; do
# Typical redefinition
RESULT="-I${abs_top_srcdir}/check/include -L${abs_top_srcdir}/check/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}/check -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