]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tools/checkconfig.sh
libblkid: check status for the current CDROM slot
[thirdparty/util-linux.git] / tools / checkconfig.sh
CommitLineData
8b32e57f 1#!/bin/sh
71be1ee4
KZ
2
3#
4# This script checks for HAVE_ and ENABLE_ macros which are
5# not included in config.h.in
6#
043102bf
KZ
7# Usage: checkconfig.sh <top_srcdir> <srcfile> [<srcfile> ...]
8#
71be1ee4 9# Copyright (C) 2007 Matthias Koenig <mkoenig@suse.de>
043102bf 10# Copyright (C) 2008 Karel Zak <kzak@redhat.com>
71be1ee4
KZ
11#
12
043102bf 13
8b32e57f 14die() {
043102bf
KZ
15 echo "error: $1"
16 exit 1
17}
18
052a6cf2
SK
19usage() {
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
26if [ $# -eq 0 ]; then
27 usage
28 exit 1
29fi
71be1ee4 30srcdir=$1
043102bf 31config="$srcdir/config.h.in"
71be1ee4 32
043102bf
KZ
33[ -d "$srcdir" ] || die "$srcdir: not such directory."
34[ -f "$config" ] || die "$config: not such file."
71be1ee4 35
043102bf
KZ
36shift
37
8b32e57f 38while [ "$#" -ne 0 ]; do
043102bf
KZ
39 srcfile=$1
40 shift
71be1ee4 41
043102bf 42 [ ! -f "$srcfile" ] && continue;
71be1ee4 43
76fe37da
KZ
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 #
71be1ee4 50 DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
76fe37da 51 -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
043102bf 52 $srcfile | sort -u)
71be1ee4
KZ
53 [ -z "$DEFINES" ] && continue
54
55 for d in $DEFINES; do
56 case $d in
043102bf
KZ
57 HAVE_CONFIG_H) continue
58 ;;
59 *) grep -q "$d\( \|\>\)" $config || \
60 echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
71be1ee4
KZ
61 ;;
62 esac
63 done
64done