1 | #!/usr/bin/python
|
---|
2 | #
|
---|
3 | # Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
4 | #
|
---|
5 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | # available from http://www.virtualbox.org. This file is free software;
|
---|
7 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | # General Public License (GPL) as published by the Free Software
|
---|
9 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | #
|
---|
13 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
14 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
15 | # additional information or have any questions.
|
---|
16 | #
|
---|
17 |
|
---|
18 |
|
---|
19 | import os,sys
|
---|
20 |
|
---|
21 | versions = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
|
---|
22 | prefixes = ["/usr", "/usr/local", "/opt"]
|
---|
23 | known = {}
|
---|
24 |
|
---|
25 | def checkPair(p,v):
|
---|
26 | file = os.path.join(p, "include", "python"+v, "Python.h")
|
---|
27 | # or just stat()?
|
---|
28 | if not os.path.isfile(file):
|
---|
29 | return None
|
---|
30 | return [os.path.join(p, "include", "python"+v),
|
---|
31 | os.path.join(p, "lib", "libpython"+v+".so")]
|
---|
32 |
|
---|
33 | def main(argv):
|
---|
34 | for v in versions:
|
---|
35 | for p in prefixes:
|
---|
36 | c = checkPair(p, v)
|
---|
37 | if c is not None:
|
---|
38 | known[v] = c
|
---|
39 | break
|
---|
40 | keys = known.keys()
|
---|
41 | # we want default to be the lowest versioned Python
|
---|
42 | keys.sort()
|
---|
43 | d = None
|
---|
44 | # We need separator other than newline, to sneak through $(shell)
|
---|
45 | sep = "|"
|
---|
46 | for k in keys:
|
---|
47 | if d is None:
|
---|
48 | d = k
|
---|
49 | vers = k.replace('.', '')
|
---|
50 | print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[k][0], sep)
|
---|
51 | print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[k][1], sep)
|
---|
52 | if d is not None:
|
---|
53 | print "VBOX_PYTHONDEF_INC=%s%s" %(known[d][0], sep)
|
---|
54 | print "VBOX_PYTHONDEF_LIB=%s%s" %(known[d][1], sep)
|
---|
55 |
|
---|
56 | if __name__ == '__main__':
|
---|
57 | main(sys.argv)
|
---|