Elliot Lee 5fc6cf0
#!/bin/bash
Elliot Lee 5fc6cf0
pkgconfig=${1:-/usr/bin/pkg-config}
Elliot Lee 5fc6cf0
test -x $pkgconfig || exit 0
Elliot Lee 5fc6cf0
while read filename ; do
Elliot Lee 5fc6cf0
case "${filename}" in
Elliot Lee 5fc6cf0
*.pc)
Elliot Lee 5fc6cf0
	# Assume that this file doesn't contain useful information.
Elliot Lee 5fc6cf0
	needs_pkgconfig=false
Elliot Lee 5fc6cf0
	# Query the dependencies of the package.
Elliot Lee 5fc6cf0
	$pkgconfig --print-provides "$filename" 2> /dev/null | while read n r v ; do
Elliot Lee 5fc6cf0
		# We have a dependency.  Make a note that we need the pkgconfig
Elliot Lee 5fc6cf0
		# tool for this package.
Elliot Lee 5fc6cf0
		echo "pkgconfig($n)" "$r" "$v"
Elliot Lee 5fc6cf0
		needs_pkgconfig=true
Elliot Lee 5fc6cf0
	done
Elliot Lee 5fc6cf0
	# The dependency on the pkgconfig package itself.
Elliot Lee 5fc6cf0
	if $needs_pkgconfig ; then
Elliot Lee 5fc6cf0
		echo pkgconfig
Elliot Lee 5fc6cf0
	fi
Elliot Lee 5fc6cf0
	;;
Elliot Lee 5fc6cf0
esac
Elliot Lee 5fc6cf0
done