]> err.no Git - util-linux/commitdiff
tools: add codecheck-config that checks for {HAVE,ENABLE}_ orphans
authorKarel Zak <kzak@redhat.com>
Fri, 15 Jun 2007 08:17:51 +0000 (10:17 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 15 Jun 2007 08:17:51 +0000 (10:17 +0200)
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Makefile.am
tools/codecheck-config [new file with mode: 0755]

index 1b91651f0ec5c1ea0307b433c329d660d747f5e3..e3d7be505206abc5ec05a644e1488cd45e682ede 100644 (file)
@@ -23,7 +23,8 @@ EXTRA_DIST = \
                README.devel \
                licenses/ \
                example.files/ \
-               po/update-potfiles
+               po/update-potfiles \
+               tools
 
 
 distclean-local:
diff --git a/tools/codecheck-config b/tools/codecheck-config
new file mode 100755 (executable)
index 0000000..ff38bac
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+#
+# This script checks for HAVE_ and ENABLE_ macros which are
+# not included in config.h.in
+#
+# Copyright (C) 2007 Matthias Koenig <mkoenig@suse.de>
+#
+
+srcdir=$1
+
+if [ ! "$srcdir" ]; then
+       srcdir=$PWD
+fi
+
+CONFIG="$srcdir/config.h.in"
+if [ ! -f "$CONFIG" ]; then
+       echo "config.h.in is needed"
+       exit 1
+fi
+
+SOURCES=$(find $srcdir -name "*.c")
+
+for f in $SOURCES; do
+       DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+                         -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+                         $f | sort -u)
+       [ -z "$DEFINES" ] && continue
+
+       for d in $DEFINES; do
+               case $d in
+               HAVE_CONFIG_H) continue;;
+               *) grep -q "$d\( \|\>\)" $CONFIG || echo $(echo $f | sed 's:'$srcdir/'::') ": $d"
+
+                  ;;
+               esac
+       done
+done