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", "/opt/local"]
|
---|
23 | known = {}
|
---|
24 |
|
---|
25 | def checkPair(p, v,dllpre,dllsuff, do_bitness_magic):
|
---|
26 | file = os.path.join(p, "include", "python"+v, "Python.h")
|
---|
27 | if not os.path.isfile(file):
|
---|
28 | return None
|
---|
29 | if do_bitness_magic:
|
---|
30 | lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
|
---|
31 | else:
|
---|
32 | lib64 = None
|
---|
33 | return [os.path.join(p, "include", "python"+v),
|
---|
34 | os.path.join(p, "lib", dllpre+"python"+v+dllsuff),
|
---|
35 | lib64]
|
---|
36 |
|
---|
37 | def print_vars(vers, known, sep, do_bitness_magic):
|
---|
38 | print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
|
---|
39 | if do_bitness_magic:
|
---|
40 | print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
|
---|
41 | else:
|
---|
42 | print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
|
---|
43 |
|
---|
44 |
|
---|
45 | def main(argv):
|
---|
46 | dllpre = "lib"
|
---|
47 | dllsuff = ".so"
|
---|
48 | do_bitness_magic = 0
|
---|
49 |
|
---|
50 | if len(argv) > 1:
|
---|
51 | target = argv[1]
|
---|
52 | else:
|
---|
53 | target = sys.platform
|
---|
54 |
|
---|
55 | if len(argv) > 2:
|
---|
56 | arch = argv[2]
|
---|
57 | else:
|
---|
58 | arch = "unknown"
|
---|
59 |
|
---|
60 | if target == 'darwin':
|
---|
61 | prefixes.insert(0, '/Developer/SDKs/MacOSX10.4u.sdk/usr')
|
---|
62 | prefixes.insert(0, '/Developer/SDKs/MacOSX10.5.sdk/usr')
|
---|
63 | # Python 2.3 on Darwin buildbox is bad
|
---|
64 | # /Developer/SDKs/MacOSX10.4u.sdk/usr/include/python2.3/pyport.h:554:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?).
|
---|
65 | versions.remove("2.3")
|
---|
66 | dllsuff = '.dylib'
|
---|
67 |
|
---|
68 | if target == 'solaris' and arch == 'amd64':
|
---|
69 | do_bitness_magic = 1
|
---|
70 |
|
---|
71 | for v in versions:
|
---|
72 | for p in prefixes:
|
---|
73 | c = checkPair(p, v, dllpre, dllsuff, do_bitness_magic)
|
---|
74 | if c is not None:
|
---|
75 | known[v] = c
|
---|
76 | break
|
---|
77 | keys = known.keys()
|
---|
78 | # we want default to be the lowest versioned Python
|
---|
79 | keys.sort()
|
---|
80 | d = None
|
---|
81 | # We need separator other than newline, to sneak through $(shell)
|
---|
82 | sep = "|"
|
---|
83 | for k in keys:
|
---|
84 | if d is None:
|
---|
85 | d = k
|
---|
86 | vers = k.replace('.', '')
|
---|
87 | print_vars(vers, known[k], sep, do_bitness_magic)
|
---|
88 | if d is not None:
|
---|
89 | print_vars("DEF", known[d], sep, do_bitness_magic)
|
---|
90 |
|
---|
91 | if __name__ == '__main__':
|
---|
92 | main(sys.argv)
|
---|