Added feed.
[make-headers.git] / make-headers.py
blob7189eddc3248772bcc5f62e7669ecdd2f0631d0b
1 #!/usr/bin/env python
2 import os, shutil, re, sys
3 from optparse import OptionParser
5 version = '0.1'
6 parser = OptionParser(usage="usage: %prog [options]")
7 parser.add_option("-V", "--version", help="display version information", action='store_true')
8 (options, args) = parser.parse_args()
10 if options.version:
11 print "Make-headers (zero-install) " + version
12 print "Copyright (C) 2007 Thomas Leonard"
13 print "This program comes with ABSOLUTELY NO WARRANTY,"
14 print "to the extent permitted by law."
15 print "You may redistribute copies of this program"
16 print "under the terms of the GNU General Public License."
17 print "For more information about these matters, see the file named COPYING."
18 sys.exit(0)
20 configure = os.path.join(os.environ['SRCDIR'], 'configure')
21 prefix = os.environ['DISTDIR']
23 def run(*argv):
24 if os.spawnvp(os.P_WAIT, argv[0], argv):
25 raise Exception("Command '%s' failed" % repr(argv))
27 run(configure, '--prefix', prefix)
28 run('make', 'install')
30 os.chdir(prefix)
31 for path in ['bin', 'man', 'share']:
32 shutil.rmtree(path)
34 os.chdir('lib')
35 for x in os.listdir('.'):
36 if os.path.isfile(x) or os.path.islink(x):
37 if re.match('^lib.*\.so[.0-9]*$', x) or \
38 re.match('^lib.*\.la', x):
39 os.unlink(x)
41 os.chdir('pkgconfig')
42 for pc in os.listdir('.'):
43 if pc.endswith('.pc'):
44 data = file(pc).read().split('\n')
45 for i in range(len(data)):
46 if data[i].startswith('prefix='):
47 data[i] = 'prefix=${pcfiledir}/../..'
48 out = file(pc, 'w')
49 out.write('\n'.join(data))
50 out.close()