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