#!/bin/sh

DEFS=/tmp/defs.$$
USES=/tmp/uses.$$

( util/cstrip asm-common.h; util/cstrip $1 ) | grep '^#define _' | sed 's/^[^ ]* //;s/[ (].*$//' > $DEFS
util/cstrip $1 | sed 's/^[^ ]* [^ )]*.//;s/\([_A-Za-z0-9]*\)/!\1\!/g' | tr '!' '\012' | grep '^_' | sort | uniq > $USES

for i in `cat $USES`; do
  if ! fgrep -q $i $DEFS; then
    echo UNDEFINED: $i
  fi
done

for i in `cat $DEFS`; do
  if ! fgrep -q $i $USES; then
    echo UNUSED: $i
  fi
done

/bin/rm /tmp/defs.* /tmp/uses.*
