summaryrefslogtreecommitdiff
path: root/tools/checkconfig.sh
blob: 91f7b1c05c2803937f2fe1ed2373c0ab507632ad (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
#!/bin/sh

#
# This script checks for HAVE_ and ENABLE_ macros which are
# not included in config.h.in
#
# Usage:   checkconfig.sh <top_srcdir> <srcfile> [<srcfile> ...]
#
# Copyright (C) 2007 Matthias Koenig <mkoenig@suse.de>
# Copyright (C) 2008 Karel Zak <kzak@redhat.com>
#


die() {
	echo "error: $1"
	exit 1
}

srcdir=$1
config="$srcdir/config.h.in"

[ -d "$srcdir" ] || die "$srcdir: not such directory."
[ -f "$config" ] || die "$config: not such file."

shift

while [ "$#" -ne 0 ]; do
	srcfile=$1
	shift

	[ ! -f "$srcfile" ] && continue;

	# Note that we use HAVE_ macros since util-linux-ng-2.14. The
	# previous version also have used ENABLE_ too.
	#
	# ENABLE_ and HAVE_ macros shouldn't be used for any other pupose that
	# for config/build options.
	#
	DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
			 -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
                         $srcfile | sort -u)
	[ -z "$DEFINES" ] && continue

	for d in $DEFINES; do
		case $d in
		HAVE_CONFIG_H) continue
		   ;;
		*) grep -q "$d\( \|\>\)" $config || \
		     echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
	           ;;
		esac
	done
done