File: makedeplist

package info (click to toggle)
cernlib 2004.11.04.dfsg-0sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 29,292 kB
  • ctags: 1,159
  • sloc: ansic: 2,285; sh: 840; makefile: 582
file content (89 lines) | stat: -rw-r--r-- 2,280 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash

# This script creates lists of all the dependencies and symbols required
# by each shared library in $CERNLEVEL/shlib and program in $CERNLEVEL/bin.
# Should be run while in the top-level cernlib-<version> source dir.

errormsg() {
	echo "Not in correct directory or cernlib not compiled with shlibs"
	exit 1
}

# remove old files
for file in `(ls -1 *.txt) 2> /dev/null` libdeps bindeps ; do
	rm -rf $file
done
if [ ! -d shlib ] ; then errormsg ; fi

mkdir -p libdeps
[ -d bin ] && mkdir -p bindeps

# add in lib{c,m,g2c} since we already know everything depends upon them
cd shlib
ln -sf /lib/libc.so.6 ./libc.so
ln -sf /lib/libm.so.6 ./libm.so
ln -sf /usr/lib/libg2c.so ./libg2c.so

# create symbol lists...
for lib in lib*.so ; do
	nm -D $lib | grep ' U ' | awk '{print $2}' > ../${lib%%.so}.undef.txt
	nm -D $lib | grep -v ' U ' | sed 's/@@.*$//g' | \
		awk '{print $3}' > ../${lib%%.so}.def.txt
done

if [ -d "../bin" ] ; then
	cd ../bin
	for prog in * ; do
		if [ -n "`nm $prog 2> /dev/null`" ] ; then
			nm $prog | grep ' U ' | awk '{print $2}' \
			> ../$prog.undef.txt
		fi
	done
fi
	
# create lists of symbol dependencies
cd ..
for symlist in *.undef.txt ; do
	(
		for symbol in `cat $symlist` ; do
			egrep '^'$symbol'$' *.def.txt
		done
	) | tr ':.' '  ' | awk '{print $1 " " $4}' | sort | \
	egrep -v '^lib(c|m|g2c) ' >> ${symlist%%.undef.txt}.symdeps.txt
done

cat *.def.txt > defined.txt

for symlist in *.undef.txt ; do
	(
		for symbol in `cat $symlist` ; do
			if [ -z "`egrep -l '^'$symbol'$' defined.txt`" ] ; then
				echo $symbol
			fi
		done
	) | sort > ${symlist%%.undef.txt}.not-in-cernlib.txt
done

# delete unneeded files
rm -f defined.txt *.def.txt *.undef.txt
rm -f shlib/libc.so shlib/libg2c.so shlib/libm.so
rm -f libc.* libm.* libg2c.*

# create lists of file dependencies with number of dependent symbols
for file in *.symdeps.txt ; do
	tempfile=${file%%.symdeps.txt}.filedeps.txt.tmp
	cat $file | awk '{ print $1 }' | sort | uniq > $tempfile
	for file2 in `cat $tempfile` ; do
		echo "$file2 `grep $file2 $file | wc -l`" >> ${tempfile%%.tmp}
	done
	rm -f $tempfile
done

# move to proper places
mv lib*.txt libdeps/
[ -d bindeps ] && mv *.txt bindeps/
for file in libdeps/* bindeps/* ; do
	[ ! -s $file ] && rm -f $file
done

exit 0