summaryrefslogtreecommitdiffstats
path: root/tools/checkconfig.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
commit8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch)
treea9b2e7baeca1be40eb734371e3c8b11b02294497 /tools/checkconfig.sh
parentInitial commit. (diff)
downloadutil-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.tar.xz
util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.zip
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/checkconfig.sh')
-rwxr-xr-xtools/checkconfig.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/checkconfig.sh b/tools/checkconfig.sh
new file mode 100755
index 0000000..5f2063a
--- /dev/null
+++ b/tools/checkconfig.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+#
+# 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>
+#
+
+
+die() {
+ echo "error: $1"
+ exit 1
+}
+
+usage() {
+ echo "Usage:"
+ echo " $0 <top_srcdir> <srcfile> [<srcfile> ...]"
+ echo "Example:"
+ echo " find . -name '*.c' | xargs $0 \$(git rev-parse --show-toplevel)"
+}
+
+if [ $# -eq 0 ]; then
+ usage
+ exit 1
+fi
+srcdir=$1
+config="$srcdir/config.h.in"
+
+[ -d "$srcdir" ] || die "$srcdir: not such directory."
+[ -f "$config" ] || die "$config: not such file."
+
+shift
+
+while [ "$#" -ne 0 ]; do
+ srcfile=$1
+ shift
+
+ [ ! -f "$srcfile" ] && continue;
+
+ # Note that we use HAVE_ macros since util-linux-ng-2.14. The
+ # previous version also have used ENABLE_ too.
+ #
+ # ENABLE_ and HAVE_ macros shouldn't be used for any other pupose that
+ # for config/build options.
+ #
+ DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+ -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+ $srcfile | sort -u)
+ [ -z "$DEFINES" ] && continue
+
+ for d in $DEFINES; do
+ case $d in
+ HAVE_CONFIG_H) continue
+ ;;
+ *) grep -q "$d\( \|\>\)" $config || \
+ echo $(echo $srcfile | sed 's:\\'$srcdir/'::') ": $d"
+ ;;
+ esac
+ done
+done