Git init
[framework/multimedia/pulseaudio.git] / src / depmod.py
1 #!/usr/bin/python
2
3 # This file is part of PulseAudio.
4 #
5 # PulseAudio is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # PulseAudio is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with PulseAudio; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 # USA.
19
20 import sys, os, string
21
22 exported_symbols = {}
23 imported_symbols = {}
24
25 for fn in sys.argv[1:]:
26     f = os.popen("nm '%s'" % fn, "r")
27
28     imported_symbols[fn] = []
29
30     for line in f:
31         sym_address = line[:7].strip()
32         sym_type = line[9].strip()
33         sym_name = line[11:].strip()
34
35         if sym_name in ('_fini', '_init'):
36             continue
37
38         if sym_type in ('T', 'B', 'R', 'D' 'G', 'S', 'D'):
39             if exported_symbols.has_key(sym_name):
40                 sys.stderr.write("CONFLICT: %s defined in both '%s' and '%s'.\n" % (sym_name, fn, exported_symbols[sym_name]))
41             else:
42                 exported_symbols[sym_name] = fn
43         elif sym_type in ('U',):
44             if sym_name[:3] == 'pa_':
45                 imported_symbols[fn].append(sym_name)
46
47     f.close()
48
49 dependencies = {}
50 unresolved_symbols = {}
51
52 for fn in imported_symbols:
53     dependencies[fn] = []
54     
55     for sym in imported_symbols[fn]:
56         if exported_symbols.has_key(sym):
57             if exported_symbols[sym] not in dependencies[fn]:
58                 dependencies[fn].append(exported_symbols[sym])
59         else:
60             if unresolved_symbols.has_key(sym):
61                 unresolved_symbols[sym].append(fn)
62             else:
63                 unresolved_symbols[sym] = [fn]
64
65 for sym, files in unresolved_symbols.iteritems():
66     print "WARNING: Unresolved symbol '%s' in %s" % (sym, `files`)
67
68 k = dependencies.keys()
69 k.sort()
70 for fn in k:
71     dependencies[fn].sort()
72     print "%s: %s" % (fn, string.join(dependencies[fn], " "))