Upload Tizen:Base source
[framework/base/util-linux-ng.git] / tools / checkconfig.sh
1 #!/bin/bash
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 function die() {
15         echo "error: $1"
16         exit 1
17 }
18
19 srcdir=$1
20 config="$srcdir/config.h.in"
21
22 [ -d "$srcdir" ] || die "$srcdir: not such directory."
23 [ -f "$config" ] || die "$config: not such file."
24
25 shift
26
27 while (( "$#" )); do
28         srcfile=$1
29         shift
30
31         [ ! -f "$srcfile" ] && continue;
32
33         # Note that we use HAVE_ macros since util-linux-ng-2.14. The
34         # previous version also have used ENABLE_ too.
35         #
36         # ENABLE_ and HAVE_ macros shouldn't be used for any other pupose that
37         # for config/build options.
38         #
39         DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
40                          -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
41                          $srcfile | sort -u)
42         [ -z "$DEFINES" ] && continue
43
44         for d in $DEFINES; do
45                 case $d in
46                 HAVE_CONFIG_H) continue
47                    ;;
48                 *) grep -q "$d\( \|\>\)" $config || \
49                      echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
50                    ;;
51                 esac
52         done
53 done