VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/gen_python_deps.py@ 28537

Last change on this file since 28537 was 28537, checked in by vboxsync, 15 years ago

python/Makefile.kmk++: Massage, hope it still works.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
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.215389.xyz. 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
19import os,sys
20
21versions = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
22prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
23known = {}
24
25def checkPair(p, v,dllpre,dllsuff, bitness_magic):
26 file = os.path.join(p, "include", "python"+v, "Python.h")
27 if not os.path.isfile(file):
28 return None
29
30 lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
31
32 if bitness_magic == 1:
33 lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
34 elif bitness_magic == 2:
35 lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
36 if not os.path.isfile(lib64):
37 lib64 = lib
38 else:
39 lib64 = None
40 return [os.path.join(p, "include", "python"+v),
41 lib,
42 lib64]
43
44def print_vars(vers, known, sep, bitness_magic):
45 print "VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep)
46 if bitness_magic > 0:
47 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
48 else:
49 print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
50
51
52def main(argv):
53 global prefixes
54 global versions
55
56 dllpre = "lib"
57 dllsuff = ".so"
58 bitness_magic = 0
59
60 if len(argv) > 1:
61 target = argv[1]
62 else:
63 target = sys.platform
64
65 if len(argv) > 2:
66 arch = argv[2]
67 else:
68 arch = "unknown"
69
70 if len(argv) > 3:
71 multi = int(argv[3])
72 else:
73 multi = 1
74
75 if multi == 0:
76 prefixes = ["/usr"]
77 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
78
79 if target == 'darwin':
80 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
81 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr', '/Developer/SDKs/MacOSX10.5.sdk/usr', '/Developer/SDKs/MacOSX10.6.sdk/usr']
82 dllsuff = '.dylib'
83
84 if target == 'solaris' and arch == 'amd64':
85 bitness_magic = 1
86
87 if target == 'linux' and arch == 'amd64':
88 bitness_magic = 2
89
90 for v in versions:
91 for p in prefixes:
92 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
93 if c is not None:
94 known[v] = c
95 break
96 keys = known.keys()
97 # we want default to be the lowest versioned Python
98 keys.sort()
99 d = None
100 # We need separator other than newline, to sneak through $(shell)
101 sep = "|"
102 for k in keys:
103 if d is None:
104 d = k
105 vers = k.replace('.', '')
106 print_vars(vers, known[k], sep, bitness_magic)
107 if d is not None:
108 print_vars("DEF", known[d], sep, bitness_magic)
109
110if __name__ == '__main__':
111 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette