Prepend PKG_CONFIG_PATH on pkgconfig requires extraction too (rhbz#473814)
[platform/upstream/rpm.git] / scripts / pkgconfigdeps.sh
1 #!/bin/bash
2
3 pkgconfig=/usr/bin/pkg-config
4 test -x $pkgconfig || {
5     cat > /dev/null
6     exit 0
7 }
8
9 [ $# -ge 1 ] || {
10     cat > /dev/null
11     exit 0
12 }
13
14 case $1 in
15 -P|--provides)
16     while read filename ; do
17     case "${filename}" in
18     *.pc)
19         # Query the dependencies of the package.
20         DIR="`dirname ${filename}`"
21         export PKG_CONFIG_PATH="$DIR:$DIR/../../share/pkgconfig"
22         $pkgconfig --print-provides "$filename" 2> /dev/null | while read n r v ; do
23             # We have a dependency.  Make a note that we need the pkgconfig
24             # tool for this package.
25             echo "pkgconfig($n)" "$r" "$v"
26         done
27         ;;
28     esac
29     done
30     ;;
31 -R|--requires)
32     while read filename ; do
33     case "${filename}" in
34     *.pc)
35         i="`expr $i + 1`"
36         [ $i -eq 1 ] && echo "$pkgconfig"
37         DIR="`dirname ${filename}`"
38         export PKG_CONFIG_PATH="$DIR:$DIR/../../share/pkgconfig"
39         $pkgconfig --print-requires "$filename" 2> /dev/null | while read n r v ; do
40             echo "pkgconfig($n)" "$r" "$v"
41         done
42     esac
43     done
44     ;;
45 esac
46 exit 0