#!/bin/sh
cd ../rules
perl -nle 'next unless /^meta\s+/; s/^meta\s+\S+\s+//; tr/()\!\|\&<>=//d; @t=split; print join("\n",grep(/\w/ && !/^\d+$/,@t))' 2[0-4]*.cf | sort -u > /tmp/meta-rules
sed -e 's/#.*$//' -e '/^$/d' 2[0-4]*.cf | egrep -v '^(describe|tflags|lang|require_version|score|test)' | awk '{print $2}' | sort -u > /tmp/rules

cd /tmp
grep -xFf meta-rules rules > defined

echo "If there are any meta rule dependencies that don't exist, they'll follow:"
diff meta-rules defined

rm -f rules
