#!/bin/sh
# Usage: autoheadercheck configure config.h.in
# checks whether some macros put into DEFS by `configure' but are not listed
# in `config.h.in'.
# Bruno Haible 7.7.1994

syms=`grep 'DEFS="$DEFS -D' $1 | sed -e 's/^.*DEFS="$DEFS -D//g' -e 's/=.*$//g' | sort | uniq`
#echo $syms
syms=`echo "$syms" | sed -e 's/${trhdr}//g' | sed -e 's/${trfunc}//g'`
#echo $syms
syms1=`grep 'for hdr in ' $1 | sed -e 's/^.*for hdr in //g'`
syms2=''
for sym in $syms1; do syms2=$syms2' HAVE_'`echo $sym | tr '[a-z]./' '[A-Z]__'`; done
syms="$syms $syms2"
#echo $syms
syms1=`grep 'for func in ' $1 | sed -e 's/^.*for func in //g'`
syms2=''
for sym in $syms1; do syms2=$syms2' HAVE_'`echo $sym | tr '[a-z]' '[A-Z]'`; done
syms="$syms $syms2"
#echo $syms

# syms is now the list of symbols that may be defined in `configure'.

ksyms=`(grep '^#undef' $2 ; grep '^#define' $2) | sed -e 's/^#[a-z]*[ 	]*//g' | sed -e 's/[ 	].*$//g' | sort | uniq`
#echo $ksyms

# ksyms is now the list of symbols that are listed in `config.h.in'.

# Now list every symbol contained in syms but not contained in ksyms:

for sym in $syms; do
  if test -z `echo "$ksyms" | grep "^$sym\$"`; then
    echo "$sym missing from $2" ;
  fi
done


