From: Karel Zak Date: Fri, 15 Jun 2007 08:17:51 +0000 (+0200) Subject: tools: add codecheck-config that checks for {HAVE,ENABLE}_ orphans X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71be1ee4a1386c141272df32b1184857aa5c9070;p=util-linux tools: add codecheck-config that checks for {HAVE,ENABLE}_ orphans Signed-off-by: Matthias Koenig Signed-off-by: Karel Zak --- diff --git a/Makefile.am b/Makefile.am index 1b91651f..e3d7be50 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..ff38bac7 --- /dev/null +++ b/tools/codecheck-config @@ -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 +# + +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