]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tools/checkconfig.sh
lib/pty: reset mainloop timeout on signal
[thirdparty/util-linux.git] / tools / checkconfig.sh
1 #!/bin/sh
2
3 #
4 # This script checks for HAVE_ and ENABLE_ macros which are
5 # not included in config.h.in
6 #
7 # Usage: checkconfig.sh <top_srcdir> <srcfile> [<srcfile> ...]
8 #
9 # Copyright (C) 2007 Matthias Koenig <mkoenig@suse.de>
10 # Copyright (C) 2008 Karel Zak <kzak@redhat.com>
11 #
12
13
14 die() {
15 echo "error: $1"
16 exit 1
17 }
18
19 usage() {
20 echo "Usage:"
21 echo " $0 <top_srcdir> <srcfile> [<srcfile> ...]"
22 echo "Example:"
23 echo " find . -name '*.c' | xargs $0 \$(git rev-parse --show-toplevel)"
24 }
25
26 if [ $# -eq 0 ]; then
27 usage
28 exit 1
29 fi
30 srcdir=$1
31 config="$srcdir/config.h.in"
32
33 [ -d "$srcdir" ] || die "$srcdir: not such directory."
34 [ -f "$config" ] || die "$config: not such file."
35
36 shift
37
38 while [ "$#" -ne 0 ]; do
39 srcfile=$1
40 shift
41
42 [ ! -f "$srcfile" ] && continue;
43
44 # Note that we use HAVE_ macros since util-linux-ng-2.14. The
45 # previous version also have used ENABLE_ too.
46 #
47 # ENABLE_ and HAVE_ macros shouldn't be used for any other pupose that
48 # for config/build options.
49 #
50 DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
51 -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
52 $srcfile | sort -u)
53 [ -z "$DEFINES" ] && continue
54
55 for d in $DEFINES; do
56 case $d in
57 HAVE_CONFIG_H) continue
58 ;;
59 *) grep -q "$d\( \|\>\)" $config || \
60 echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
61 ;;
62 esac
63 done
64 done