pkgconfig=/usr/bin/pkg-config
$pkgconfig --atleast-pkgconfig-version="0.24" || {
# Under pkgconf, disables dependency resolver
export PKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH=1
# Query the dependencies of the package.
DIR="`dirname ${filename}`"
export PKG_CONFIG_PATH="$DIR:$DIR/../../share/pkgconfig"
$pkgconfig --print-provides "$filename" 2> /dev/null | while read n r v ; do
# We have a dependency. Make a note that we need the pkgconfig
[ -n "$r" ] && [ -n "$v" ] && echo -n "$r" "$v"
[ $i -eq 1 ] && echo "$pkgconfig"
DIR="`dirname ${filename}`"
export PKG_CONFIG_PATH="$DIR:$DIR/../../share/pkgconfig"
$pkgconfig --print-requires --print-requires-private "$filename" 2> /dev/null | while read n r v ; do
[ -n "$r" ] && [ -n "$v" ] && echo -n "$r" "$v"