From 043102bf197e1f0e082cc0eaf4d3d5d7c3b79f7b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 26 Nov 2008 13:42:16 +0100 Subject: tools: add checkconfig to top-level Makefile Signed-off-by: Karel Zak --- tools/checkconfig.sh | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'tools') diff --git a/tools/checkconfig.sh b/tools/checkconfig.sh index ff38bac7d..c5f307387 100755 --- a/tools/checkconfig.sh +++ b/tools/checkconfig.sh @@ -4,34 +4,43 @@ # This script checks for HAVE_ and ENABLE_ macros which are # not included in config.h.in # +# Usage: checkconfig.sh [ ...] +# # Copyright (C) 2007 Matthias Koenig +# Copyright (C) 2008 Karel Zak # + +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 -- cgit v1.2.3-55-g7522