/[ascend]/trunk/scons/sundials.py
ViewVC logotype

Contents of /trunk/scons/sundials.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2551 - (show annotations) (download) (as text)
Thu Feb 2 20:14:50 2012 UTC (6 years, 10 months ago) by jpye
File MIME type: text/x-python
File size: 3480 byte(s)
Merge 'ospath_chdir' and 'ospath_getcwd' into trunk (from Leon).
Add detection of Ubuntu 11.10 in Sundials, since extra linkage to 'lapack' is required.
Disable defaultall output for the moment.

1 import os, os.path, platform, subprocess
2 from SCons.Script import *
3
4 munge = lambda s: s
5
6 try:
7 # if we have access to GetShortPathName, we'll use it...
8 import win32api
9 def munge1(s):
10 s1 = s
11 try:
12 # we can only munge the path if it actually exists
13 s1 = win32api.GetShortPathName(s)
14 except:
15 # if it doesn't exist, we just return the un-munged path
16 pass
17 return s1
18 munge = munge1
19 except:
20 pass
21
22 def generate(env):
23 """
24 Detect SUNDIALS (IDA) settings and add them to the environment.
25 """
26 try:
27 if platform.system()=="Windows":
28 try:
29 # one day, we'll provide a SUNDIALS installer so that people don't have to
30 # build their own SUNDIALS. In that case, look for the settings in the registry
31 import _winreg
32 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
33 y= _winreg.OpenKey(x,r"SOFTWARE\SUNDIALS")
34 PATH,t = _winreg.QueryValueEx(y,"InstallPath")
35 LIB = os.path.join(PATH,"lib")
36 BIN = os.path.join(PATH,"bin")
37 INCLUDE = os.path.join(PATH,"include")
38 env['SUNDIALS_CPPPATH'] = [munge(INCLUDE)]
39 env['SUNDIALS_LIBPATH'] = [munge(BIN)]
40 env['SUNDIALS_LIBS'] = ['sundials_ida','sundials_nvecserial','m']
41 except WindowsError:
42 # if someone has installed sundials with ./configure --prefix=/MinGW using MSYS, then
43 # this should work, but we would like to make this a lot more robust!
44 cmd = ['sh.exe','/mingw/bin/sundials-config','-mida','-ts','-lc']
45 env1 = env.Clone()
46 env1['CPPPATH'] = None
47 env1['LIBPATH'] = None
48 env1['LIBS'] = None
49 print "RUNNING sundials-config"
50 env1.ParseConfig(cmd)
51 env['SUNDIALS_CPPPATH'] = env1.get('CPPPATH')
52 env['SUNDIALS_LIBPATH'] = env1.get('LIBPATH')
53 env['SUNDIALS_LIBS'] = env1.get('LIBS')
54 env['HAVE_SUNDIALS'] = True
55
56 env['HAVE_SUNDIALS'] = True
57
58 else:
59 cmd = ['sundials-config','-mida','-ts','-lc']
60 env1 = env.Clone()
61 env1['CPPPATH'] = None
62 env1['LIBPATH'] = None
63 env1['LIBS'] = None
64 env1.ParseConfig(cmd)
65
66 # tricky stuff to detect the necessary extra 'lapack' linkage if required
67 if os.path.exists("/etc/lsb-release"):
68 print "CHECKING SUNDIALS"
69 s = env.WhereIs('sundials-config')
70 if s == "/usr/bin/sundials-config":
71 print "STANDARD CONFIG"
72 # With Ubuntu 11.10 onwards, we need to explicitly add lapack (and blas?)
73 f = file("/etc/lsb-release")
74 v = {}
75 for l in f:
76 x = l.strip().split("=")
77 v[x[0]] = x[1]
78 print v
79 if v['DISTRIB_ID']=="Ubuntu" and float(v['DISTRIB_RELEASE'])>=11.10:
80 print "ADDING LAPACK"
81 env1['LIBS'].append("lapack")
82
83 env['SUNDIALS_CPPPATH'] = env1.get('CPPPATH')
84 env['SUNDIALS_LIBPATH'] = env1.get('LIBPATH')
85 env['SUNDIALS_LIBS'] = env1.get('LIBS')
86 env['HAVE_SUNDIALS'] = True
87
88 print "SUNDIALS_LIBS =",env.get('SUNDIALS_LIBS')
89 print "SUNDIALS_LIBPATH =",env.get('SUNDIALS_LIBPATH')
90 print "SUNDIALS_CPPPATH =",env.get('SUNDIALS_CPPPATH')
91
92 except Exception, e:
93 print "FAILED SUNDIALS DETECTION (%s):" % platform.system(),e.__class__,str(e)
94 env['HAVE_SUNDIALS'] = False
95
96 def exists(env):
97 """
98 Make sure this tool exists.
99 """
100 if platform.system()=="Windows":
101 try:
102 import _winreg
103 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
104 y= _winreg.OpenKey(x,r"SOFTWARE\SUNDIALS")
105 INCLUDE,t = _winreg.QueryValueEx(y,'INSTALL_INCLUDE')
106 return True
107 except:
108 return False
109 else:
110 if not subprocess.call('sundials-config -h'):
111 return True
112 return False
113

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22