aboutsummaryrefslogtreecommitdiff
path: root/libxcb/check-pc-requires
blob: 063356fb452a3992490bd834ca2e95377cb3ebcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh

case "$AM_SRCDIR" in
"")
	AM_SRCDIR="."
	;;
*)
	;;
esac

fix=n
status=0
case "$1" in
"-fix")
	fix=y
	;;
esac

for inc in src/*.h; do
	package=xcb-`basename $inc .h`
	pcin="$AM_SRCDIR"/$package.pc.in
	if [ -f $pcin ]; then
		included=`grep '# *include' $inc |
			sed -e 's/[^<"]*[<"]//' -e 's/[>"]//' |
			grep -v 'xcb.h\|xproto.h'`
		requires=`grep '^Requires.private:' $pcin`
		missing=""
		for i in $included; do
			ibase=`basename $i .h`
			r="xcb-$ibase"
			rpcin="$AM_SRCDIR"/$r.pc.in
			if [ -f $rpcin ]; then
				m="$r"
				for has in $requires; do
					if [ $has = $r ]; then
						m=""
					fi
				done
				case "$m" in
				"")
					;;
				*)
					case "$missing" in
					"")
						missing=$m
						;;
					*)
						missing="$missing $m"
						;;
					esac
					;;
				esac
			fi
		done
		case "$missing" in
		"")
			;;
		*)
			if [ "$fix" = "y" ]; then
			    echo $package adding dependency on $missing
			    sed -i '/^Requires.private:/s/$/ '"$missing"'/' $pcin
			else
			    echo $package missing $missing
			    status=1
			fi
			;;
		esac
	fi
done
exit $status