]> err.no Git - util-linux/commitdiff
tools: add checkconfig to top-level Makefile
authorKarel Zak <kzak@redhat.com>
Wed, 26 Nov 2008 12:42:16 +0000 (13:42 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 26 Nov 2008 12:42:16 +0000 (13:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
Makefile.am
tools/checkconfig.sh

index fefff76f56ec04893c356a9d18bf303388d1c2ce..6fce69cc5b8110e71c02fdeec7ee380f507c6910 100644 (file)
@@ -48,10 +48,15 @@ distclean-local:
 
 
 checkincludes:
-       -find * $(RCS_FIND_IGNORE) \
+       @find * $(RCS_FIND_IGNORE) \
                -name '*.[hcS]' -type f -print | sort -u \
                | xargs $(top_srcdir)/tools/checkincludes.pl
 
+checkconfig:
+       @find * $(RCS_FIND_IGNORE) \
+               -name '*.[hcS]' -type f -print | sort -u \
+               | xargs $(top_srcdir)/tools/checkconfig.sh $(top_srcdir)
+
 
 ENABLE_ALL = --enable-static-programs \
  --enable-elvtune --enable-init --enable-kill --enable-last \
index ff38bac7d0a335f5c73607f3a7342c68ec66b8cd..c5f307387ad4a47ee43414892eff6d7ecd506747 100755 (executable)
@@ -4,34 +4,43 @@
 # This script checks for HAVE_ and ENABLE_ macros which are
 # not included in config.h.in
 #
+# Usage:   checkconfig.sh <top_srcdir> <srcfile> [<srcfile> ...]
+#
 # Copyright (C) 2007 Matthias Koenig <mkoenig@suse.de>
+# Copyright (C) 2008 Karel Zak <kzak@redhat.com>
 #
 
+
+function die() {
+       echo "error: $1"
+       exit 1
+}
+
 srcdir=$1
+config="$srcdir/config.h.in"
 
-if [ ! "$srcdir" ]; then
-       srcdir=$PWD
-fi
+[ -d "$srcdir" ] || die "$srcdir: not such directory."
+[ -f "$config" ] || die "$config: not such file."
 
-CONFIG="$srcdir/config.h.in"
-if [ ! -f "$CONFIG" ]; then
-       echo "config.h.in is needed"
-       exit 1
-fi
+shift
+
+while (( "$#" )); do
+       srcfile=$1
+       shift
 
-SOURCES=$(find $srcdir -name "*.c")
+       [ ! -f "$srcfile" ] && continue;
 
-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)
+                         $srcfile | 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"
-
+               HAVE_CONFIG_H) continue
+                  ;;
+               *) grep -q "$d\( \|\>\)" $config || \
+                    echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
                   ;;
                esac
        done