xref: /freebsd/crypto/krb5/src/util/getsyms (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert#!/bin/sh
2*7f2fe78bSCy Schubert# Run this from the TOP of the source tree!
3*7f2fe78bSCy SchubertM4=gm4
4*7f2fe78bSCy Schubertconfigs=`find $1 -name configure.ac -print|sort|sed -e 's@/configure.ac@@'`
5*7f2fe78bSCy Schubertfor dir in $configs; do
6*7f2fe78bSCy Schubert	syms=""
7*7f2fe78bSCy Schubert	libs=""
8*7f2fe78bSCy Schubert	headers=""
9*7f2fe78bSCy Schubert	types=""
10*7f2fe78bSCy Schubert	funcs=""
11*7f2fe78bSCy Schubert	AC_MACRODIR=./util/autoconf
12*7f2fe78bSCy Schubert	# The following bits shamelessly stolen from autoheader.sh
13*7f2fe78bSCy Schubert	eval "`$M4 -I$AC_MACRODIR autoheader.m4 $dir/configure.ac|
14*7f2fe78bSCy Schubert		sed -n -e '
15*7f2fe78bSCy Schubert		: again
16*7f2fe78bSCy Schubert		/^@@@.*@@@$/s/^@@@\(.*\)@@@$/\1/p
17*7f2fe78bSCy Schubert		/^@@@/{
18*7f2fe78bSCy Schubert			s/^@@@//p
19*7f2fe78bSCy Schubert			n
20*7f2fe78bSCy Schubert			s/^/@@@/
21*7f2fe78bSCy Schubert			b again
22*7f2fe78bSCy Schubert		}'`"
23*7f2fe78bSCy Schubert	allsyms="`for sym in $syms; do echo $sym; done | sort | uniq`"
24*7f2fe78bSCy Schubert	if test -n "$funcs"; then
25*7f2fe78bSCy Schubert		funcs="`for func in $funcs; do echo $func; done | sort | uniq`"
26*7f2fe78bSCy Schubert		funcs="`for func in $funcs; do echo $func
27*7f2fe78bSCy Schubert			done | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]' | sed 's/^/HAVE_/'`"
28*7f2fe78bSCy Schubert	allsyms="$allsyms $funcs"
29*7f2fe78bSCy Schubert	fi
30*7f2fe78bSCy Schubert	if test -n "$headers"; then
31*7f2fe78bSCy Schubert		headers="`for header in $headers; do echo $header
32*7f2fe78bSCy Schubert			done | sort | uniq`"
33*7f2fe78bSCy Schubert		headers="`for header in $headers; do echo $header
34*7f2fe78bSCy Schubert			done | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]' | sed 's/^/HAVE_/'`"
35*7f2fe78bSCy Schubert	allsyms="$allsyms $headers"
36*7f2fe78bSCy Schubert	fi
37*7f2fe78bSCy Schubert	if test -n "$libs"; then
38*7f2fe78bSCy Schubert		libs="`for lib in $libs; do echo $lib
39*7f2fe78bSCy Schubert			done | sort | uniq`"
40*7f2fe78bSCy Schubert		libs="`for lib in $libs; do echo $lib
41*7f2fe78bSCy Schubert			done | sed 's/[^a-zA-Z0-9_]/_/g' | tr '[a-z]' '[A-Z]' | sed 's/^/HAVE_LIB/'`"
42*7f2fe78bSCy Schubert	allsyms="$allsyms $libs"
43*7f2fe78bSCy Schubert	fi
44*7f2fe78bSCy Schubert	echo $dir/configure.ac: $allsyms
45*7f2fe78bSCy Schubert	allsyms="`echo $allsyms|tr ' ' '|'`"
46*7f2fe78bSCy Schubert	files="$dir/*.[ch]"
47*7f2fe78bSCy Schubert	if test ! "`echo $files`" = "$dir/"'*.[ch]'; then
48*7f2fe78bSCy Schubert	for file in $files; do
49*7f2fe78bSCy Schubert		badsyms=""
50*7f2fe78bSCy Schubert		fsyms=`sed -f ./util/getsyms.sed $file`
51*7f2fe78bSCy Schubert		fsyms="`for sym in $fsyms; do echo $sym; done | sort | uniq`"
52*7f2fe78bSCy Schubert		for sym in $fsyms; do
53*7f2fe78bSCy Schubert			if echo $sym|egrep -s "$allsyms">/dev/null; then :
54*7f2fe78bSCy Schubert			else
55*7f2fe78bSCy Schubert				badsyms="$badsyms $sym"
56*7f2fe78bSCy Schubert			fi
57*7f2fe78bSCy Schubert		done
58*7f2fe78bSCy Schubert		if test -n "$badsyms"; then
59*7f2fe78bSCy Schubert			echo $file:$badsyms
60*7f2fe78bSCy Schubert		fi
61*7f2fe78bSCy Schubert	done
62*7f2fe78bSCy Schubert	fi
63*7f2fe78bSCy Schubertdone
64