2 import os
, shutil
, re
, sys
3 from optparse
import OptionParser
6 parser
= OptionParser(usage
="usage: %prog [options]")
7 parser
.add_option("-k", "--keep", help="keep a file we would normally delete", action
='append')
8 parser
.add_option("-V", "--version", help="display version information", action
='store_true')
9 (options
, args
) = parser
.parse_args()
12 print "Make-headers (zero-install) " + version
13 print "Copyright (C) 2007 Thomas Leonard"
14 print "This program comes with ABSOLUTELY NO WARRANTY,"
15 print "to the extent permitted by law."
16 print "You may redistribute copies of this program"
17 print "under the terms of the GNU General Public License."
18 print "For more information about these matters, see the file named COPYING."
21 configure
= os
.path
.join(os
.environ
['SRCDIR'], 'configure')
22 prefix
= os
.environ
['DISTDIR']
25 if os
.spawnvp(os
.P_WAIT
, argv
[0], argv
):
26 raise Exception("Command '%s' failed" % repr(argv
))
28 run(configure
, '--prefix', prefix
)
29 run('make', 'install')
31 keep
= options
.keep
or []
34 for path
in ['bin', 'man', 'share']:
35 if path
not in keep
and os
.path
.isdir(path
):
39 for x
in os
.listdir('.'):
40 if os
.path
.isfile(x
) or os
.path
.islink(x
):
41 if re
.match('^lib.*\.so[.0-9]*$', x
) or \
42 re
.match('^lib.*\.l?a$', x
):
44 elif os
.path
.isdir(x
):
45 if re
.match('^python.*$', x
):
49 for pc
in os
.listdir('.'):
50 if pc
.endswith('.pc'):
51 data
= file(pc
).read().split('\n')
52 for i
in range(len(data
)):
53 if data
[i
].startswith('prefix='):
54 data
[i
] = 'prefix=${pcfiledir}/../..'
56 out
.write('\n'.join(data
))