/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2493 - (hide annotations) (download)
Sun Aug 14 09:17:13 2011 UTC (8 years, 4 months ago) by jpye
File size: 77333 byte(s)
Working on new installer for Windows 7 (32-bit, should work with XP as well)
1 jpye 2017 #!/usr/bin/python invoke_using_scons
2 jpye 2007 # This is a build script for use with SCons. Use it to compile ASCEND on
3     # Linux, Windows. It should also give some success on Mac, although this is
4     # much less tested.
5    
6     # version number for this ASCEND build:
7 mahesh 2150 version = "0.9.8"
8 johnpye 439
9 jpye 2007 # shared library API numbering, for Linux (FIXME windows too?)
10     soname_major = ".1"
11     soname_minor = ".0"
12    
13     import sys, os, commands, platform, distutils.sysconfig, os.path, re, types
14 jpye 2129 import subprocess
15 jpye 2007
16     # version number for python, useful on Windows
17 jpye 1466 pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
18    
19 johnpye 385 #------------------------------------------------------
20 jpye 2007 # PLATFORM DEFAULTS
21 johnpye 385
22 johnpye 464 #print "PLATFORM = ",platform.system()
23 johnpye 385
24 jpye 2073 default_install_prefix = '/usr/local'
25     default_install_bin = "$INSTALL_PREFIX/bin"
26     default_install_lib = "$INSTALL_PREFIX/lib"
27     default_install_models = "$INSTALL_LIB/ascend/models"
28     default_install_solvers = "$INSTALL_LIB/ascend/solvers"
29     default_install_assets = "$INSTALL_ASCDATA/glade/"
30     default_install_ascdata = "$INSTALL_SHARE/ascend"
31     default_install_include = "$INSTALL_PREFIX/include"
32 jpye 2307 default_install_python = distutils.sysconfig.get_python_lib()
33     default_install_python_ascend = "$INSTALL_PYTHON/ascend"
34 jpye 2073 default_tcl = '/usr'
35     default_tcl_libpath = "$TCL/lib"
36 jpye 1488 default_tcl_cpppath = "$TCL/include"
37 jpye 1501 default_tron_envvar="TRON_PATH"
38     default_conopt_envvar="CONOPT_PATH"
39 jpye 1854 default_with_graphviz = True
40 jpye 2073 default_tcl_lib = "tcl8.5"
41     default_tk_lib = "tk8.5"
42     default_tktable_lib = "Tktable2.9"
43     default_ida_prefix="$DEFAULT_PREFIX"
44 jpye 2132 default_ipopt_libpath = "$IPOPT_PREFIX/lib"
45 jpye 2203 default_ipopt_dll = "$IPOPT_LIBPATH/Ipopt38.dll"
46 jpye 2132 default_ipopt_libs = ["$F2C_LIB","blas","lapack","pthread","ipopt"]
47 jpye 2073 default_conopt_prefix="$DEFAULT_PREFIX"
48     default_conopt_libpath="$CONOPT_PREFIX"
49     default_conopt_cpppath="$CONOPT_PREFIX"
50     default_conopt_dlpath="$CONOPT_PREFIX"
51     default_tron_prefix="$DEFAULT_PREFIX"
52     default_tron_dlpath="$TRON_PREFIX/lib"
53     default_tron_lib="tron1"
54     default_prefix="/usr"
55     default_libpath="$DEFAULT_PREFIX/lib"
56     default_cpppath="$DEFAULT_PREFIX/include"
57     default_fortran="gfortran"
58     default_f2c_lib="gfortran"
59 jpye 2094 default_swig="swig"
60 jpye 1488
61 jpye 2073 icon_extension = '.png'
62    
63 johnpye 464 if platform.system()=="Windows":
64 jpye 2073 default_prefix="c:\\MinGW"
65     default_libpath="$DEFAULT_PREFIX\\lib"
66     default_cpppath="$DEFAULT_PREFIX\\include"
67    
68 jpye 2007 # these correspond the the version of Tcl/Tk linked to in the NSIS scripts
69 jpye 2204 default_tcl_lib = "tcl85"
70     default_tk_lib = "tk85"
71 johnpye 464 default_tktable_lib = "Tktable28"
72 jpye 2007
73 johnpye 499 default_install_assets = "glade/"
74 johnpye 521 default_tcl = "c:\\Tcl"
75 jpye 1645 if os.environ.get('MSYSTEM'):
76 johnpye 642 default_tcl_libpath="$TCL\\bin"
77     else:
78     default_tcl_libpath="$TCL\\lib"
79 jpye 2007
80     # on Windows, we build ASCEND such that it finds it support files
81     # using paths relative to the location of the executable
82 johnpye 628 default_absolute_paths = False
83 jpye 2025 default_dist_rel_bin = '.'
84     default_tk_rel_dist = 'tcltk'
85     default_library_rel_dist = 'models'
86     default_solvers_rel_dist = 'solvers'
87 johnpye 739
88 jpye 2007 # where to look for IDA solver libraries, headers, etc.
89 johnpye 739 default_ida_prefix = "c:\\MinGW"
90 jpye 2132
91     # IPOPT
92     default_ipopt_libpath = "$IPOPT_PREFIX/lib/win32/release"
93 jpye 2203 default_ipopt_libs = ["Ipopt"]
94 johnpye 783
95 jpye 2007 # where to look for CONOPT when compiling
96 johnpye 800 default_conopt_prefix = "c:\\Program Files\\CONOPT"
97     default_conopt_libpath="$CONOPT_PREFIX"
98     default_conopt_cpppath="$CONOPT_PREFIX"
99 jpye 1399 default_conopt_dlpath="$CONOPT_PREFIX"
100 johnpye 800 default_conopt_lib="conopt3"
101 johnpye 935
102 jpye 2007 # FIXME remove this
103 jpye 1515 default_tron_prefix="c:\\Program Files\\TRON"
104     default_tron_dlpath="$TRON_PREFIX"
105 johnpye 739
106 johnpye 673 need_libm = False
107 jpye 1592 python_exe = sys.executable
108 johnpye 816 default_with_scrollkeeper=False
109 jpye 1504 pathsep = ";"
110 jpye 1566
111 jpye 2094 default_fortran="gfortran"
112     default_f2c_lib="gfortran"
113 jpye 1597
114 jpye 2094 default_swig=WhereIs("swig.exe")
115    
116 jpye 2007 soname_minor = ""
117     soname_major = ""
118 jpye 1854 # still problems with Graphviz on Windows, leave it off now by default.
119 jpye 2073
120 jpye 2158 if not os.path.exists(default_conopt_prefix):
121     default_conopt_prefix = None
122    
123 jpye 2073 elif platform.system()=="Darwin":
124    
125 jpye 2075 default_install_prefix = ''
126 jpye 2090 default_install_bin = "$INSTALL_PREFIX/ASCEND.app/Contents"
127 jpye 2076 default_install_lib = "$INSTALL_BIN"
128 jpye 2083 #default_install_models = "$INSTALL_PREFIX/Library/Application Support/ASCEND/Models"
129     default_install_models = "$INSTALL_BIN/Models"
130     #default_install_solvers = "$INSTALL_PREFIX/Library/Application Support/ASCEND/Solvers"
131     default_install_solvers = "$INSTALL_BIN/Solvers"
132 jpye 2090 default_install_ascdata = "$INSTALL_BIN/Resources"
133 jpye 2076 default_install_include = "$INSTALL_BIN/Headers"
134 jpye 2075 default_install_python = "$INSTALL_BIN/Python"
135 jpye 2307 default_install_python_ascend = default_install_python
136 jpye 2073 default_install_assets = "$INSTALL_ASCDATA/glade/"
137 jpye 2083 # FIXME still need to work out the Tcl/Tk side of things...
138 jpye 2073
139     # within the bundle, we'll use relative paths
140     default_absolute_paths = False
141     default_dist_rel_bin = '.'
142     default_tk_rel_dist = 'tcltk'
143    
144     # we want these to be in /Library/ASCEND/Models and /Library/ASCEND/Solvers
145 jpye 2083 default_library_rel_dist = 'Models'
146     default_solvers_rel_dist = 'Solvers'
147 jpye 2073
148     # where to look for CONOPT when compiling
149     default_conopt_prefix = "/Library/CONOPT"
150    
151     default_conopt_lib="conopt3"
152    
153     # FIXME remove this
154     default_tron_dlpath="$TRON_PREFIX"
155     default_tron_lib="tron1"
156    
157     need_libm = False
158     python_exe = sys.executable
159     default_with_scrollkeeper=False
160     pathsep = ";"
161 jpye 1720
162 jpye 2158 if not os.path.exists(default_conopt_prefix):
163     default_conopt_prefix = None
164 jpye 2073
165 ballan 2438 else: # LINUX, unix we hope
166 jpye 2073
167 ballan 2438 # the scons 'philosophy' if there is one is that the scons input arguments
168     # completely determine what external tools get picked any time there might
169     # be choices.
170     # We don't follow that philosophy with regard to tcl/tk.
171     # tcl/tk are often in multiple versions and locations on any given system.
172     # This leaves us trying to guess whether we should take:
173     # - only explicit arguments, otherwise disable tcl, tk
174     # - the first tcl/tk in the users path
175     # - the tcl/tk under a given user-specified prefix
176     # - the folklore-based canonical location of distributor's tcl/tk on a given linux dist
177     # We know one thing for sure. Any tcl installation includes tclsh, and thus
178     # it's the canonical way to find anything about tcl once tclsh is picked.
179     # So all the above reduces to 'how do we find tclsh?'
180 johnpye 499 icon_extension = '.svg'
181 jpye 1488
182 ballan 2438 # here's the folklore we know.
183 jpye 1488 if os.path.exists("/etc/debian_version"):
184     default_tcl_cpppath = "/usr/include/tcl8.4"
185 jpye 1787 default_tcl_lib = "tcl8.4"
186     default_tk_lib = "tk8.4"
187     default_tktable_lib = "Tktable2.8"
188 jpye 1488
189 ballan 2036 if os.path.exists("/etc/SuSE-release"):
190     default_tcl_cpppath = "/usr/include"
191     default_tcl_lib = "tcl8.4"
192     default_tk_lib = "tk8.4"
193     default_tktable_lib = "Tktable2.9"
194    
195 jpye 2006 if os.path.exists("/etc/lsb-release"):
196     _f = file("/etc/lsb-release")
197     _r = re.compile("([A-Z][^=]*)=(.*)")
198     LSB = {}
199     for l in _f:
200     _m = _r.match(l.strip())
201     LSB[_m.group(1)] = _m.group(2)
202 ballan 2036 print LSB
203     if LSB.has_key('DISTRIB_ID') and LSB['DISTRIB_ID'] == "Ubuntu":
204 jpye 2006 if float(LSB['DISTRIB_RELEASE']) >= 9.04:
205     default_tcl_lib = "tcl8.5"
206     default_tk_lib = "tk8.5"
207     default_tktable_lib = "Tktable2.9"
208     default_tcl_cpppath = "/usr/include/tcl8.5"
209 jpye 2445 if not os.path.exists(default_tcl_cpppath):
210     default_tcl_lib = "tcl8.4"
211     default_tk_lib = "tk8.4"
212     default_tktable_lib = "Tktable2.9"
213     default_tcl_cpppath = "/usr/include/tcl8.4"
214    
215 ballan 2438 # centos 5
216     if os.path.exists("/etc/redhat-release"):
217     default_tcl_cpppath = "/usr/include"
218     default_tcl_lib = "tcl"
219     if sys.maxint > 2**32:
220     default_tcl_libpath = "/usr/lib64"
221     else:
222     default_tcl_libpath = "/usr/lib"
223     default_tk_lib = "tk"
224     default_tktable_lib = "Tktable2.9"
225 jpye 2006
226    
227 johnpye 628 default_absolute_paths = True
228 jpye 2025 default_dist_rel_bin = '..'
229     default_tk_rel_dist = 'share/ascend/tcltk'
230     default_library_rel_dist = 'lib/ascend/models'
231     default_solvers_rel_dist = 'lib/ascend/solvers'
232    
233 jpye 2157 default_conopt_prefix = "$DEFAULT_PREFIX"
234 johnpye 800 default_conopt_libpath="$CONOPT_PREFIX/lib"
235     default_conopt_cpppath="$CONOPT_PREFIX/include"
236 jpye 1399 default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
237 johnpye 800 default_conopt_lib="consub3"
238    
239 johnpye 673 need_libm = True
240 johnpye 551 if not os.path.isdir(default_tcl):
241     default_tcl = '/usr'
242 johnpye 683 python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
243 johnpye 816 default_with_scrollkeeper=False
244 jpye 1504 pathsep = ":"
245 jpye 2073
246 jpye 1853 #default_graphviz_libs=["graph","cdt","gvc"]
247     #default_graphviz_libpath = default_libpath
248     #if os.path.exists("/usr/lib/graphviz/libgraph.so"):
249     # # for Ubuntu 7.04
250     # default_graphviz_libpath="/usr/lib/graphviz"
251     # default_graphviz_rpath="$GRAPHVIZ_LIBPATH"
252 jpye 2007
253 jpye 2073 if not os.path.exists(default_tron_prefix):
254     default_tron_prefix = None
255    
256     if not os.path.exists(default_ida_prefix):
257     default_ida_prefix = None
258    
259 jpye 2007 soname_clean = "${SHLIBPREFIX}ascend${SHLIBSUFFIX}"
260     soname_full = "%s%s" % (soname_clean,soname_major)
261    
262     #------------------------------------------------------
263     # OPTIONS
264     #
265     # The following give the set of command-line parameters that can be passed to
266     # SCons from the commandline. Options will be 'remembered' by being cached
267     # in the file 'options.cache'; if you want to start with a clean slate, you
268     # should remove that file.
269    
270 jpye 2162 vars = Variables(['options.cache', 'config.py'])
271 jpye 1597
272 jpye 2162 vars.Add(
273 johnpye 562 'CC'
274     ,'C Compiler command'
275     ,None
276     )
277    
278 jpye 2162 vars.Add(
279 johnpye 562 'CXX'
280     ,'C++ Compiler command'
281     ,None
282     )
283    
284 jpye 2162 vars.Add(BoolVariable(
285 johnpye 591 'GCOV'
286 johnpye 593 , 'Whether to enable coverage testing in object code'
287     , False
288 johnpye 591 ))
289    
290 jpye 2007 if platform.system()!="Windows":
291 jpye 2162 vars.Add(BoolVariable(
292 jpye 2007 'WITH_GCCVISIBILITY'
293     ,"Whether to use GCC Visibility features (only applicable if available)"
294     ,True
295     ))
296 johnpye 526
297 jpye 2162 vars.Add(BoolVariable(
298 johnpye 1142 'WITH_SIGNALS'
299     ,"Whether to permit use of signals for flow control in the C-level code"
300 johnpye 1234 ,True
301 johnpye 1142 ))
302    
303 johnpye 392 # You can turn off building of Tcl/Tk interface
304 jpye 2162 vars.Add(BoolVariable(
305 johnpye 542 'WITH_TCLTK'
306 johnpye 673 ,"Set to False if you don't want to build the original Tcl/Tk GUI."
307 johnpye 542 , True
308 johnpye 386 ))
309    
310 johnpye 392 # You can turn off the building of the Python interface
311 jpye 2162 vars.Add(BoolVariable(
312 johnpye 542 'WITH_PYTHON'
313 johnpye 673 ,"Set to False if you don't want to build Python wrappers."
314 johnpye 542 , True
315 johnpye 387 ))
316    
317 johnpye 392 # Which solvers will we allow?
318 jpye 2162 vars.Add(ListVariable(
319 johnpye 392 'WITH_SOLVERS'
320 johnpye 393 ,"List of the solvers you want to build. The default is the minimum that"
321 jpye 1520 +" works. The option 'LSOD' is provided for backwards compatibility"
322     +"; the value 'LSODE' is preferred."
323 jpye 2422 ,["QRSLV","CMSLV","LSODE","IDA","CONOPT","LRSLV","IPOPT","DOPRI5"]
324 johnpye 392 ,['QRSLV','MPS','SLV','OPTSQP'
325     ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
326 jpye 2421 ,'LSODE','LSOD','OPTSQP',"IDA","TRON","IPOPT","DOPRI5","MAKEMPS","RADAU5"
327 johnpye 392 ]
328     ))
329    
330 johnpye 393 # Where will the local copy of the help files be kept?
331 jpye 2162 vars.Add(BoolVariable(
332 jpye 1442 'WITH_DOC'
333 jpye 1443 , "Should we try to build and install help files? If not, ASCEND will access online help files"
334 jpye 1442 , True
335 johnpye 393 ))
336    
337 jpye 2162 vars.Add(BoolVariable(
338 jpye 1443 'WITH_DOC_BUILD'
339     , "If true, we'll attempt to build docs. Set false, we'll assume we already have then (eg from the tarball)"
340     , "$WITH_DOC"
341     ))
342    
343 jpye 2162 vars.Add(BoolVariable(
344 jpye 1443 'WITH_DOC_INSTALL'
345     , "If true, SCons will install the documentation file(s). If false, assume rpm or dpkg is going to do it."
346     , "$WITH_DOC"
347     ))
348    
349 jpye 2162 vars.Add(
350 jpye 1442 'HELP_ROOT'
351     , "Location of the main help file"
352     , "$INSTALL_DOC/book.pdf"
353     )
354    
355 johnpye 393 # Will bintoken support be enabled?
356 jpye 2162 vars.Add(BoolVariable(
357 johnpye 393 'WITH_BINTOKEN'
358     ,"Enable bintoken support? This means compiling models as C-code before"
359     +" running them, to increase solving speed for large models."
360     ,False
361     ))
362    
363 johnpye 398 # What should the default ASCENDLIBRARY path be?
364     # Note: users can change it by editing their ~/.ascend.ini
365 jpye 2162 vars.Add(
366 johnpye 393 'DEFAULT_ASCENDLIBRARY'
367     ,"Set the default value of the ASCENDLIBRARY -- the location where"
368     +" ASCEND will look for models when running ASCEND"
369 jpye 1519 ,"$INSTALL_MODELS"
370 johnpye 393 )
371    
372 jpye 1519 # What should the default ASCENDLIBRARY path be?
373     # Note: users can change it by editing their ~/.ascend.ini
374 jpye 2162 vars.Add(
375 jpye 1519 'DEFAULT_ASCENDSOLVERS'
376     ,"Set the default value of ASCENDSOLVERS -- the location where"
377     +" ASCEND will look for solver shared-library files"
378     ,"$INSTALL_SOLVERS"
379     )
380    
381 johnpye 398 # Where is SWIG?
382 jpye 2162 vars.Add(
383 johnpye 398 'SWIG'
384     ,"SWIG location, probably only required for MinGW and MSVC users."
385     +" Enter the location as a Windows-style path, for example"
386 johnpye 404 +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
387 jpye 2094 ,default_swig
388 johnpye 398 )
389    
390 johnpye 400 # Build the test suite?
391 jpye 2162 vars.Add(BoolVariable(
392 johnpye 593 'WITH_CUNIT'
393 johnpye 665 ,"You can disable CUnit tests with this option. This will basically stop"
394     +" SCons from parsing the SConscript files relating to the 'test'"
395     +" target, which just might make things marginally faster. Probably"
396     +" you can just ignore this option though. SCons will sniff for Cunit"
397     +" but build the tests only if you specify the 'test' target."
398     ,True
399 johnpye 400 ))
400 johnpye 393
401 johnpye 993 # Build with MMIO matrix export support?
402 jpye 2162 vars.Add(BoolVariable(
403 johnpye 993 'WITH_MMIO'
404     ,"Include support for exporting matrices in Matrix Market format"
405     ,True
406     ))
407    
408 johnpye 938 #----- default paths -----
409 jpye 2162 vars.Add(PackageVariable(
410 johnpye 938 'DEFAULT_PREFIX'
411     ,"Where are most of the shared libraries located on your system?"
412     ,default_prefix
413     ))
414    
415 jpye 2007 #------ cunit --------
416     # CUnit is a unit testing library that we use to test libascend.
417 johnpye 957
418 johnpye 935 # Where was CUNIT installed?
419 jpye 2162 vars.Add(PackageVariable(
420 johnpye 935 'CUNIT_PREFIX'
421     ,"Where are your CUnit files?"
422 johnpye 938 ,"$DEFAULT_PREFIX"
423 johnpye 935 ))
424    
425 johnpye 400 # Where are the CUnit includes?
426 jpye 2162 vars.Add(PackageVariable(
427 johnpye 400 'CUNIT_CPPPATH'
428     ,"Where are your CUnit include files?"
429 johnpye 938 ,"$CUNIT_PREFIX/include"
430 johnpye 400 ))
431 johnpye 392
432 johnpye 404 # Where are the CUnit libraries?
433 jpye 2162 vars.Add(PackageVariable(
434 johnpye 400 'CUNIT_LIBPATH'
435 johnpye 404 ,"Where are your CUnit libraries?"
436 johnpye 938 ,"$CUNIT_PREFIX/lib"
437 johnpye 400 ))
438    
439 johnpye 938 # ----- conopt-----
440 johnpye 783
441 jpye 2162 vars.Add(PackageVariable(
442 johnpye 783 "CONOPT_PREFIX"
443     ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
444 johnpye 800 ,default_conopt_prefix
445 johnpye 783 ))
446    
447 jpye 2162 vars.Add(
448 johnpye 783 "CONOPT_LIB"
449 jpye 1747 ,"Library linked to for CONOPT. This is the name of the CONOPT .so or DLL. On Windows it seems to be called 'copopt3' but on linux it seems to be called 'consub3'."
450 johnpye 800 ,default_conopt_lib
451 johnpye 783 )
452    
453 jpye 2162 vars.Add(BoolVariable(
454 jpye 1541 "CONOPT_LINKED"
455     ,"Do you want to dynamically link to CONOPT (only possible if CONOPT is available at buildtime)"
456     ,False
457     ))
458    
459 jpye 2162 vars.Add(
460 johnpye 783 'CONOPT_CPPPATH'
461     ,"Where is your conopt.h?"
462 johnpye 800 ,default_conopt_cpppath
463 johnpye 783 )
464    
465 jpye 2162 vars.Add(
466 johnpye 783 'CONOPT_LIBPATH'
467 jpye 1399 ,"Where is your CONOPT library installed?"
468 johnpye 800 ,default_conopt_libpath
469 johnpye 783 )
470    
471 jpye 2162 vars.Add(
472 jpye 1399 'CONOPT_DLPATH'
473 jpye 1747 ,"Default (fallback) search path that ASCEND should use when dlopening the CONOPT library at runtime? This is only used if the conopt environment variable doesn't exist and doesn't point to a location where the DLL/SO is found. This is in platform-specific form (paths with ';' separator in Windows, ':' separator on Linux)."
474 jpye 1399 ,default_conopt_dlpath
475     )
476    
477 jpye 2162 vars.Add(
478 johnpye 800 'CONOPT_ENVVAR'
479 jpye 1747 ,"Name of the optional environment variable which will be used for the value of the searchpath for the CONOPT DLL/SO."
480 johnpye 800 ,default_conopt_envvar
481     )
482    
483 jpye 1546 #------- IPOPT -------
484    
485 jpye 2327 if platform.system()=="Windows":
486     vars.Add(PackageVariable(
487     "IPOPT_PREFIX"
488     ,"Prefix for your IPOPT install (IPOPT ./configure --prefix)"
489     ,default_conopt_prefix
490     ))
491 jpye 1546
492 jpye 2327 vars.Add(
493     "IPOPT_LIBS"
494     ,"Library linked to for IPOPT"
495     ,default_ipopt_libs
496     )
497 jpye 1546
498 jpye 1547
499 jpye 2327 vars.Add(
500     "IPOPT_LIBPATH"
501     ,"Where is your IPOPT library installed"
502     ,default_ipopt_libpath
503     )
504 jpye 1546
505 jpye 2327 vars.Add(
506     'IPOPT_CPPPATH'
507     ,"Where is your IPOPT coin/IpStdCInterface.h (do not include the 'coin' in the path)"
508     ,"$IPOPT_PREFIX/include"
509     )
510 jpye 1546
511 jpye 2327 vars.Add(
512     'IPOPT_DLL'
513     ,"Exact path of IPOPT DLL to be included in the installer (Windows only)"
514     ,default_ipopt_dll
515     )
516 jpye 1546
517 jpye 1501 #------- TRON -------
518    
519 jpye 2162 vars.Add(
520 jpye 1501 'TRON_ENVVAR'
521     ,"What environment variable should be used at runtime to override the default search location for TRON DLL/SO?"
522     ,default_tron_envvar
523     )
524    
525 jpye 2162 vars.Add(
526 jpye 1501 "TRON_LIB"
527     ,"Library linked to for TRON"
528     ,"tron"
529     )
530    
531 jpye 2162 vars.Add(
532 jpye 1501 "TRON_PREFIX"
533     ,"Prefix for your TRON install"
534     ,default_tron_prefix
535 jpye 1515 )
536 jpye 1501
537 jpye 2162 vars.Add(
538 jpye 1501 'TRON_DLPATH'
539     ,"What is the default search path that ASCEND should use when dlopening the TRON library at runtime?"
540     ,default_tron_dlpath
541     )
542    
543 johnpye 938 #-------- f2c ------
544    
545 jpye 2162 vars.Add(
546 johnpye 673 "F2C_LIB"
547     ,"F2C library (eg. g2c, gfortran, f2c)"
548 jpye 1566 ,default_f2c_lib # the default is gfortran now
549 johnpye 673 )
550    
551 jpye 2162 vars.Add(PackageVariable(
552 johnpye 673 "F2C_LIBPATH"
553     ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
554     ,"off"
555     ))
556    
557 jpye 2162 vars.Add(
558 jpye 1398 "FORTRAN"
559     ,"Fortran compiler (eg g77, gfortran)"
560 jpye 1566 ,default_fortran
561 jpye 1398 )
562    
563 johnpye 938 #------- tcl/tk --------
564    
565 jpye 2162 vars.Add(
566 johnpye 521 'TCL'
567     ,'Base of Tcl distribution'
568     ,default_tcl
569 johnpye 534 )
570 johnpye 521
571 johnpye 404 # Where are the Tcl includes?
572 jpye 2162 vars.Add(
573 johnpye 404 'TCL_CPPPATH'
574     ,"Where are your Tcl include files?"
575 jpye 1488 ,default_tcl_cpppath
576 johnpye 534 )
577 johnpye 404
578     # Where are the Tcl libs?
579 jpye 2162 vars.Add(
580 johnpye 404 'TCL_LIBPATH'
581     ,"Where are your Tcl libraries?"
582 johnpye 541 ,default_tcl_libpath
583 johnpye 534 )
584 johnpye 404
585 johnpye 428 # What is the name of the Tcl lib?
586 jpye 2162 vars.Add(
587 johnpye 428 'TCL_LIB'
588 johnpye 561 ,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library (if STATIC_TCLTK is set)"
589 johnpye 464 ,default_tcl_lib
590 johnpye 428 )
591    
592 johnpye 405 # Where are the Tk includes?
593 jpye 2162 vars.Add(
594 johnpye 405 'TK_CPPPATH'
595     ,"Where are your Tk include files?"
596 johnpye 464 ,'$TCL_CPPPATH'
597 johnpye 534 )
598 johnpye 404
599 johnpye 405 # Where are the Tk libs?
600 jpye 2162 vars.Add(
601 johnpye 405 'TK_LIBPATH'
602     ,"Where are your Tk libraries?"
603 johnpye 464 ,'$TCL_LIBPATH'
604 johnpye 534 )
605 johnpye 405
606 johnpye 428 # What is the name of the Tk lib?
607 jpye 2162 vars.Add(
608 johnpye 428 'TK_LIB'
609 johnpye 521 ,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library"
610 johnpye 464 ,default_tk_lib
611 johnpye 435 )
612    
613 johnpye 460 # Static linking to TkTable
614    
615 jpye 2162 vars.Add(BoolVariable(
616 johnpye 521 'STATIC_TCLTK'
617 johnpye 554 ,'Set true for static linking for Tcl/Tk and TkTable. EXPERIMENTAL'
618 johnpye 460 ,False
619     ))
620    
621 jpye 2162 vars.Add(
622 johnpye 460 'TKTABLE_LIBPATH'
623     ,'Location of TkTable static library'
624 johnpye 464 ,'$TCL_LIBPATH/Tktable2.8'
625     )
626 johnpye 460
627 jpye 2162 vars.Add(
628 johnpye 460 'TKTABLE_LIB'
629 johnpye 521 ,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)'
630 johnpye 464 ,default_tktable_lib
631 johnpye 460 )
632    
633 jpye 2162 vars.Add(
634 johnpye 521 'TKTABLE_CPPPATH'
635     ,'Location of TkTable header file'
636     ,'$TCL_CPPPATH'
637     )
638    
639 jpye 2162 vars.Add(
640 johnpye 521 'X11'
641 johnpye 554 ,'Base X11 directory. Only used when STATIC_TCLTK is turned on. EXPERIMENTAL'
642 johnpye 521 ,'/usr/X11R6'
643     )
644    
645 jpye 2162 vars.Add(
646 johnpye 521 'X11_LIBPATH'
647 johnpye 554 ,'Location of X11 lib. EXPERIMENTAL'
648 johnpye 521 ,'$X11/lib'
649     )
650    
651 jpye 2162 vars.Add(
652 johnpye 521 'X11_CPPPATH'
653 johnpye 554 ,'Location of X11 includes. EXPERIMENTAL'
654 johnpye 521 ,'$X11/include'
655     )
656    
657 jpye 2162 vars.Add(
658 johnpye 521 'X11_LIB'
659 johnpye 554 ,'Name of X11 lib. EXPERIMENTAL'
660 johnpye 521 ,'X11'
661     )
662    
663 johnpye 938 #----- installed file locations (for 'scons install') -----
664    
665 jpye 2162 vars.Add(
666 johnpye 435 'INSTALL_PREFIX'
667     ,'Root location for installed files'
668 jpye 2073 ,default_install_prefix
669 johnpye 428 )
670    
671 jpye 2162 vars.Add(
672 johnpye 435 'INSTALL_BIN'
673     ,'Location to put binaries during installation'
674 jpye 2073 ,default_install_bin
675 johnpye 435 )
676    
677 jpye 2162 vars.Add(
678 johnpye 463 'INSTALL_LIB'
679 johnpye 683 ,'Location to put libraries during installation'
680 jpye 2073 ,default_install_lib
681 johnpye 463 )
682    
683 jpye 2162 vars.Add(
684 ben.allan 624 'INSTALL_SHARE'
685 johnpye 628 ,'Common shared-file location on this system'
686     ,"$INSTALL_PREFIX/share"
687 johnpye 435 )
688    
689 jpye 2162 vars.Add(
690 jpye 2025 'INSTALL_ASCDATA'
691     ,"Location of ASCEND shared data (TK, python, models etc)"
692 jpye 2073 ,default_install_ascdata
693 jpye 2025 )
694    
695 jpye 2162 vars.Add(
696 jpye 2007 'INSTALL_PYTHON'
697 jpye 2307 ,'General location for Python extensions on this system'
698 jpye 2075 ,default_install_python
699 jpye 2007 )
700    
701 jpye 2162 vars.Add(
702 jpye 2307 'INSTALL_PYTHON_ASCEND'
703     ,'Location for installation of Python modules specific to ASCEND'
704     ,default_install_python_ascend
705     )
706    
707     vars.Add(
708 jpye 2025 'INSTALL_TK'
709     ,'Location for Tcl/Tk files used by ASCEND Tk GUI'
710     ,"$INSTALL_ASCDATA/tcltk"
711 johnpye 628 )
712    
713 jpye 2162 vars.Add(
714 jpye 1504 'INSTALL_MODELS'
715     ,"Location of ASCEND model files (.a4c,.a4l,.a4s)"
716 jpye 2073 ,default_install_models
717 jpye 1504 )
718    
719 jpye 2162 vars.Add(
720 jpye 1504 'INSTALL_SOLVERS'
721     ,"Location of ASCEND solvers"
722 jpye 2073 ,default_install_solvers
723 jpye 1504 )
724    
725 jpye 2162 vars.Add(
726 jpye 1442 'INSTALL_DOC'
727     ,"Location of ASCEND documentation files"
728     ,"$INSTALL_SHARE/doc/ascend-"+version
729     )
730    
731 jpye 2162 vars.Add(
732 johnpye 435 'INSTALL_INCLUDE'
733     ,'Location to put header files during installation'
734 jpye 2073 ,default_install_include
735 johnpye 435 )
736    
737 johnpye 938
738 jpye 2162 vars.Add(
739 johnpye 938 'INSTALL_ROOT'
740     ,'For use by RPM only: location of %{buildroot} during rpmbuild'
741     ,""
742     )
743    
744 jpye 2162 vars.Add(
745 jpye 1597 'EXTLIB_SUFFIX'
746     ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
747 jpye 1598 ,"_ascend$SHLIBSUFFIX"
748 jpye 1597 )
749    
750 jpye 2162 vars.Add(
751 jpye 1597 'EXTLIB_PREFIX'
752     ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
753     ,"$SHLIBPREFIX"
754     )
755    
756 johnpye 938 #----------------------
757    
758 jpye 2162 vars.Add(
759 johnpye 455 'PYGTK_ASSETS'
760 jpye 2007 ,'Default location for Glade assets (will be recorded in pygtk/config.py)'
761 johnpye 455 ,default_install_assets
762     )
763    
764 jpye 2162 vars.Add(BoolVariable(
765 johnpye 508 'DEBUG'
766     ,"Compile source with debugger symbols, eg for use with 'gdb'"
767     ,False
768     ))
769    
770 jpye 2162 vars.Add(BoolVariable(
771 johnpye 597 'MALLOC_DEBUG'
772     ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
773     ,False
774     ))
775    
776 johnpye 938 #------ dmalloc --------
777 jpye 2162 vars.Add(PackageVariable(
778 johnpye 938 'DMALLOC_PREFIX'
779     ,"Where are your dmalloc files?"
780     ,default_prefix
781     ))
782 johnpye 448
783 jpye 2162 vars.Add(PackageVariable(
784 johnpye 938 'DMALLOC_CPPPATH'
785     ,"Where are your dmalloc include files?"
786     ,default_cpppath
787     ))
788    
789 jpye 2162 vars.Add(PackageVariable(
790 johnpye 938 'DMALLOC_LIBPATH'
791     ,"Where are your dmalloc libraries?"
792     ,default_libpath
793     ))
794    
795 jpye 2162 vars.Add(BoolVariable(
796 johnpye 938 'WITH_DMALLOC'
797     ,"Link to the DMALLOC library (if available) for debugging of memory usage."
798     ,False
799     ))
800    
801 jpye 1853 #------ Graphviz --------
802 jpye 2162 # vars.Add(PackageVariable(
803 jpye 1853 # 'GRAPHVIZ_PREFIX'
804     # ,"Where are your GRAPHVIZ files?"
805     # ,default_prefix
806     # ))
807     #
808 jpye 2162 # vars.Add(PackageVariable(
809 jpye 1853 # 'GRAPHVIZ_CPPPATH'
810     # ,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
811     # ,default_cpppath
812     # ))
813     #
814 jpye 2162 # vars.Add(PackageVariable(
815 jpye 1853 # 'GRAPHVIZ_LIBPATH'
816     # ,"Where are your GRAPHVIZ libraries?"
817     # ,default_graphviz_libpath
818     # ))
819     #
820 jpye 2162 # vars.Add(
821 jpye 1853 # 'GRAPHVIZ_LIBS'
822     # ,"What are your GRAPHVIZ libraries named?"
823     # ,default_graphviz_libs
824     # )
825     #
826 jpye 2162 # vars.Add(PackageVariable(
827 jpye 1853 # 'GRAPHVIZ_RPATH'
828     # ,"What is your GRAPHVIZ rpath for locating libraries at runtime? (only required for old Ubuntu)"
829     # ,default_graphviz_rpath
830     # ))
831 johnpye 1109
832 jpye 2162 vars.Add(BoolVariable(
833 jpye 1678 'WITH_GRAPHVIZ'
834     ,"Link to the GRAPHVIZ library (if available, for generating incidence graphs)"
835 jpye 1854 ,default_with_graphviz
836 johnpye 1109 ))
837    
838 jpye 1326
839     #------ ufsparse --------
840 jpye 2162 vars.Add(PackageVariable(
841 jpye 1326 'UFSPARSE_PREFIX'
842     ,"Where are your UFSPARSE files?"
843     ,default_prefix
844     ))
845    
846 jpye 2162 vars.Add(PackageVariable(
847 jpye 1326 'UFSPARSE_CPPPATH'
848     ,"Where are your UFSPARSE include files?"
849     ,default_cpppath
850     ))
851    
852 jpye 2162 vars.Add(PackageVariable(
853 jpye 1326 'UFSPARSE_LIBPATH'
854     ,"Where are your UFSPARSE libraries?"
855     ,default_libpath
856     ))
857    
858 jpye 2162 vars.Add(BoolVariable(
859 jpye 1326 'WITH_UFSPARSE'
860     ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
861     ,True
862     ))
863    
864 johnpye 938 #-----------------------
865    
866 jpye 2162 vars.Add(BoolVariable(
867 jpye 1557 'UPDATE_NO_YACC_LEX'
868     ,"Update the *_no_yacc* and *_no_lex* files in the source tree? (these files are created so that ASCEND can be compiled in the absence of those tools)"
869     ,False
870     ))
871    
872 jpye 2162 vars.Add(
873 johnpye 563 'DISTTAR_NAME'
874     ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
875     ,"ascend-"+version
876     )
877    
878 jpye 2162 vars.Add(
879 johnpye 656 'RELEASE'
880     ,"Release number for use in RPM spec file. This should always start with a zero for releases made by the ASCEND group, in order that third parties can make 'patch' releases of higher version numbers."
881     ,"0"
882     )
883    
884 jpye 2162 vars.Add(BoolVariable(
885 johnpye 628 'ABSOLUTE_PATHS'
886 johnpye 605 ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
887 johnpye 628 ,default_absolute_paths
888 johnpye 605 ))
889    
890 jpye 2162 vars.Add(
891 johnpye 578 'WIN_INSTALLER_NAME'
892     ,"Name of the installer .exe to create under Windows (minus the '.exe')"
893 jpye 1467 ,"ascend-"+version+"-py"+pyversion+".exe"
894 johnpye 578 )
895    
896 jpye 2162 vars.Add(BoolVariable(
897 johnpye 594 'WITH_XTERM_COLORS'
898     ,"Set to 0 if you don't want xterm colour codes in the console output"
899     ,True
900     ))
901    
902 jpye 2162 vars.Add(BoolVariable(
903 johnpye 761 'WITH_EXTFNS'
904 jpye 1504 ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
905 johnpye 761 ,True
906     ))
907    
908 jpye 2162 vars.Add(BoolVariable(
909 johnpye 816 'WITH_SCROLLKEEPER'
910     ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
911     ,default_with_scrollkeeper
912     ))
913    
914 jpye 2162 vars.Add(BoolVariable(
915 jpye 1720 'WITH_MSVCR71'
916     ,"Attempt to link against MSVCR71.DLL, to enable passing of FILE* objects to/from python"
917     ,False
918     ))
919 jpye 1557
920 johnpye 546
921 johnpye 392 # TODO: OTHER OPTIONS?
922     # TODO: flags for optimisation
923 johnpye 393 # TODO: turning on/off bintoken functionality
924 johnpye 427 # TODO: Where will the 'Makefile.bt' file be installed?
925 johnpye 393
926 johnpye 498 # Import the outside environment
927    
928 johnpye 800 def c_escape(str):
929     return re.sub("\\\\","/",str)
930    
931     envadditional={}
932 johnpye 740
933 jpye 1630 tools = [
934 jpye 2146 'lex', 'yacc', 'fortran', 'swig', 'substinfile'
935 mahesh 2150 ,'disttar', 'tar', 'graphviz','sundials'
936 jpye 1630 ]
937 johnpye 832 if platform.system()=="Windows":
938 jpye 2146 tools += ['nsis']
939    
940 johnpye 1078 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
941 johnpye 832 envenv = os.environ;
942 jpye 1459 tools += ['mingw']
943 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
944 johnpye 832 envadditional['IS_MINGW']=True
945     else:
946 johnpye 1082 print "Assuming VC++ build environment (Note: MinGW is preferred)"
947 johnpye 832 envenv = {
948     'PATH':os.environ['PATH']
949     ,'INCLUDE':os.environ['INCLUDE']
950     ,'LIB':os.environ['LIB']
951     ,'MSVS_IGNORE_IDE_PATHS':1
952     }
953 jpye 1459 tools += ['default']
954 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
955 johnpye 832 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
956 johnpye 498 else:
957 johnpye 832 if os.environ.get('TARGET')=='mingw':
958     envenv = os.environ
959 jpye 1459 tools += ['crossmingw']
960 jpye 1420 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
961     envadditional['LIBS']=['gcc']
962 johnpye 832 else:
963     envenv = os.environ
964 jpye 2327 tools += ['default','doxygen','ipopt']
965 jpye 2315
966 johnpye 800 env = Environment(
967     ENV=envenv
968     , toolpath=['scons']
969     , tools=tools
970     , **envadditional
971     )
972 johnpye 498
973 jpye 2493 # Create .def files by default on Windows (or else SCons 2.0.1 never seems to be happy)
974     if platform.system()=="Windows":
975     env.Append(WINDOWS_INSERT_DEF=1)
976    
977 jpye 1420 #print "PATH =",os.environ['PATH']
978     #print "PROGSUFFIX =",env['PROGSUFFIX']
979     #print "CPPPATH =",env['CPPPATH']
980 jpye 1380
981 jpye 2162 vars.Update(env)
982 jpye 1520
983 jpye 1853 for l in ['SUNDIALS','IPOPT']:
984 jpye 1712 var = "%s_LIBS" % l
985 jpye 2161 if env.get(var) and not isinstance(env[var],types.ListType):
986 jpye 1712 env[var] = env[var].split(",")
987    
988 jpye 1520 if 'LSOD' in env['WITH_SOLVERS']:
989     if 'LSODE' not in env['WITH_SOLVERS']:
990     env['WITH_SOLVERS'].append('LSODE')
991     env['WITH_SOLVERS'].remove('LSOD')
992    
993 jpye 2162 vars.Save('options.cache',env)
994 johnpye 385
995 jpye 2162 Help(vars.GenerateHelpText(env))
996 johnpye 385
997 johnpye 551 with_tcltk = env.get('WITH_TCLTK')
998 johnpye 427 without_tcltk_reason = "disabled by options/config.py"
999 johnpye 386
1000 johnpye 551 with_python = env.get('WITH_PYTHON')
1001 johnpye 427 without_python_reason = "disabled by options/config.py"
1002 johnpye 387
1003 johnpye 593 with_cunit = env.get('WITH_CUNIT')
1004 johnpye 427 without_cunit_reason = "not requested"
1005 johnpye 400
1006 johnpye 761 with_extfns = env.get('WITH_EXTFNS')
1007     without_extfn_reason = "disabled by options/config.py"
1008    
1009 johnpye 816 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
1010     without_scrollkeeper_reason = "disabled by options/config.py"
1011    
1012 johnpye 938 with_dmalloc = env.get('WITH_DMALLOC')
1013     without_dmalloc_reason = "disabled by options/config.py"
1014    
1015 jpye 1678 with_graphviz = env.get('WITH_GRAPHVIZ')
1016     without_graphiviz_reason = "disabled by options/config.py"
1017 johnpye 1109
1018 jpye 1326 with_ufsparse = env.get('WITH_UFSPARSE')
1019     without_ufsparse_reason = "disabled by options/config.py"
1020    
1021 johnpye 993 with_mmio = env.get('WITH_MMIO')
1022     without_mmio_reason = "disabled by options/config.py"
1023    
1024 johnpye 1142 with_signals = env.get('WITH_SIGNALS')
1025     without_signals_reason = "disabled by options/config.py"
1026    
1027 jpye 1442 with_doc = env.get('WITH_DOC')
1028    
1029 jpye 1443 with_doc_build = env.get('WITH_DOC_BUILD');
1030 jpye 1470 without_doc_build_reason = "disabled by options/config.py"
1031 jpye 1443 if not with_doc:
1032 jpye 1470 with_doc_build = False
1033     without_doc_build_reason = "disabled by with_doc"
1034 jpye 1443
1035 jpye 1442 with_latex2html = False
1036    
1037 johnpye 631 if platform.system()=="Windows":
1038     with_installer=1
1039     else:
1040     with_installer=0
1041     without_installer_reason = "only possible under Windows"
1042 johnpye 673
1043 jpye 2379 notselected = "Not selected (see config option WITH_SOLVERS)"
1044    
1045 jpye 1734 with_lsode = 'LSODE' in env['WITH_SOLVERS']
1046 jpye 2379 without_lsode_reason = notselected
1047 johnpye 673
1048 jpye 1734 with_ida = 'IDA' in env['WITH_SOLVERS']
1049 jpye 2379 without_ida_reason = notselected
1050 johnpye 783
1051 jpye 1734 with_dopri5 = 'DOPRI5' in env['WITH_SOLVERS']
1052 jpye 2379 without_dopri5_reason = notselected
1053 johnpye 783
1054 jpye 2421 with_radau5 = 'RADAU5' in env['WITH_SOLVERS']
1055     without_radau5_reason = notselected
1056    
1057 jpye 1734 with_conopt = 'CONOPT' in env['WITH_SOLVERS']
1058 jpye 2379 without_conopt_reason = notselected
1059 jpye 1529
1060 jpye 1734 with_ipopt = 'IPOPT' in env['WITH_SOLVERS']
1061 jpye 2379 without_ipopt_reason = notselected
1062 jpye 1734
1063 jpye 2378 with_makemps = 'MAKEMPS' in env['WITH_SOLVERS']
1064 jpye 2379 without_makemps_reason = notselected
1065 jpye 1734
1066 jpye 2378
1067 johnpye 464 #print "SOLVERS:",env['WITH_SOLVERS']
1068     #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
1069     #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
1070 johnpye 393
1071 johnpye 463 can_install = True
1072     if platform.system()=='Windows':
1073     can_install = False
1074    
1075     env['CAN_INSTALL']=can_install
1076 johnpye 721
1077 jpye 1437 print "TCL=",env['TCL']
1078 johnpye 521 print "TCL_CPPPATH =",env['TCL_CPPPATH']
1079     print "TCL_LIBPATH =",env['TCL_LIBPATH']
1080     print "TCL_LIB =",env['TCL_LIB']
1081 johnpye 562 print "CC =",env['CC']
1082     print "CXX =",env['CXX']
1083 johnpye 673 print "FORTRAN=",env.get('FORTRAN')
1084 johnpye 393
1085 johnpye 628 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
1086 jpye 1504 print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
1087 jpye 1413 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
1088 jpye 1504 print "INSTALL_MODELS =",env['INSTALL_MODELS']
1089     print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
1090 jpye 2016 print "INSTALL_PYTHON =",env['INSTALL_PYTHON']
1091 jpye 2307 print "INSTALL_PYTHON_ASCEND =",env['INSTALL_PYTHON_ASCEND']
1092    
1093 jpye 1504 print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
1094 jpye 1519 print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
1095 jpye 1504
1096    
1097 johnpye 385 #------------------------------------------------------
1098 johnpye 398 # SPECIAL CONFIGURATION TESTS
1099    
1100 johnpye 463 need_fortran = False
1101 jpye 1641 need_fortran_reasons = []
1102 johnpye 463
1103 johnpye 400 #----------------
1104 jpye 1448 # CC
1105    
1106     cc_test_text = """
1107     int main(void){
1108     return 0;
1109     }
1110     """;
1111    
1112     def CheckCC(context):
1113     context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
1114     is_ok = context.TryCompile(cc_test_text,".c")
1115     context.Result(is_ok)
1116     return is_ok
1117    
1118     #----------------
1119     # CXX
1120    
1121     cxx_test_text = """
1122     template<class X>
1123     class pair{
1124     public:
1125     X a;
1126     X b;
1127     };
1128    
1129     int main(void){
1130     pair<double> P;
1131     P.a = 0;
1132     return 0;
1133     }
1134     """;
1135    
1136     def CheckCXX(context):
1137     context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
1138 jpye 1630 if not context.env.get('CXX'):
1139     context.Result("not found")
1140     return False
1141     is_ok = context.TryCompile(cxx_test_text,".cpp")
1142 jpye 1448 context.Result(is_ok)
1143     return is_ok
1144    
1145 jpye 1641 #----------------
1146    
1147     f77_test_text = """
1148     C Hello World in Fortran 77
1149    
1150     PROGRAM HELLO
1151     PRINT*, 'Hello World!'
1152     END
1153     """;
1154    
1155     def CheckF77(context):
1156     context.Message("Checking Fortran 77 compiler ('%s')..." % context.env.get('FORTRAN'))
1157     if not context.env.get('FORTRAN'):
1158     context.Result('not found')
1159     return False
1160     is_ok = context.TryCompile(f77_test_text,".f")
1161     context.Result(is_ok)
1162     return is_ok
1163 jpye 1448
1164     #----------------
1165 johnpye 400 # SWIG
1166    
1167 johnpye 398 import os,re
1168    
1169 johnpye 413 def get_swig_version(env):
1170 jpye 2129 cmd = [env['SWIG'],'-version']
1171 jpye 2143 p = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1172     output, err = p.communicate()
1173 johnpye 398
1174 jpye 2143 restr = r"\s*SWIG\s+Version\s+(?P<maj>[0-9]+)\.(?P<min>[0-9]+)\.(?P<pat>[0-9]+)\b"
1175     expr = re.compile(restr,re.MULTILINE|re.IGNORECASE);
1176     m = expr.match(output);
1177 johnpye 398 if not m:
1178 jpye 2143 raise RuntimeError("Failed match on output '%s'" % output)
1179 johnpye 398 maj = int(m.group('maj'))
1180     min = int(m.group('min'))
1181     pat = int(m.group('pat'))
1182 johnpye 413
1183     return (maj,min,pat)
1184 johnpye 398
1185 johnpye 413
1186     def CheckSwigVersion(context):
1187    
1188     try:
1189     context.Message("Checking version of SWIG... ")
1190     maj,min,pat = get_swig_version(context.env)
1191 jpye 2143 except Exception,e:
1192     context.Result("Failed to detect version, or failed to run SWIG (%s)" % str(e))
1193 jpye 2070 return False;
1194 johnpye 413
1195 johnpye 478 context.env['SWIGVERSION']=tuple([maj,min,pat])
1196    
1197 jpye 2094 msg = "too old"
1198     res = False
1199 jpye 2208 if maj == 1 and (
1200 johnpye 400 min > 3
1201     or (min == 3 and pat >= 24)
1202 johnpye 398 ):
1203 jpye 2094 msg = "ok"
1204     res = True
1205 jpye 2312 elif maj == 2:
1206     msg = "ok"
1207     res = True
1208 johnpye 398
1209 jpye 2094 context.Result("%s, %d.%d.%d" % (msg, maj,min,pat))
1210     return res;
1211    
1212 johnpye 400 #----------------
1213 johnpye 816 # Scrollkeeper (Linux documentation system)
1214    
1215     def get_scrollkeeper_omfdir(env):
1216 jpye 2129 cmd = ['scrollkeeper-config','--omfdir']
1217 jpye 2143 p = subprocess.Popen(cmd,stdout=subprocess.PIPE)
1218     output = p.communicate()
1219     return output.strip()
1220 johnpye 816
1221     def CheckScrollkeeperConfig(context):
1222     try:
1223     context.Message("Checking for scrollkeeper...")
1224     dir=get_scrollkeeper_omfdir(context.env)
1225     except:
1226     context.Result("Failed to run 'scrollkeeper-config'")
1227     return 0
1228     context.env['OMFDIR']=dir
1229     context.Result("OK, %s" % dir)
1230     return 1
1231    
1232     #----------------
1233 johnpye 400 # General purpose library-and-header test
1234    
1235 johnpye 404 class KeepContext:
1236 johnpye 521 def __init__(self,context,varprefix,static=False):
1237 johnpye 404 self.keep = {}
1238 johnpye 521 for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
1239 johnpye 705 #print "Keeping env %s = %s" % (k,context.env.get(k))
1240     self.keep[k]=context.env.get(k)
1241 johnpye 404
1242     if context.env.has_key(varprefix+'_CPPPATH'):
1243 johnpye 743 context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
1244 johnpye 800 #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
1245 johnpye 428
1246 johnpye 521 if static:
1247     staticlib=env[varprefix+'_LIB']
1248     #print "STATIC LIB = ",staticlib
1249     context.env.Append(
1250     LINKFLAGS=[staticlib]
1251     )
1252     else:
1253     if context.env.has_key(varprefix+'_LIBPATH'):
1254     context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
1255 johnpye 800 #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
1256 johnpye 428
1257 johnpye 521 if context.env.has_key(varprefix+'_LIB'):
1258     context.env.Append(LIBS=[env[varprefix+'_LIB']])
1259 johnpye 705 #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"
1260 jpye 1547 elif context.env.has_key(varprefix+'_LIBS'):
1261     context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1262 johnpye 404
1263     def restore(self,context):
1264 johnpye 464 #print "RESTORING CONTEXT"
1265     #print self.keep
1266     #print "..."
1267 johnpye 404 for k in self.keep:
1268 johnpye 463 if self.keep[k]==None:
1269 johnpye 521 if context.env.has_key(k):
1270     #print "Clearing "+str(k)
1271     del context.env[k];
1272 johnpye 463 else:
1273 johnpye 705 #print "Restoring %s to '%s'" %(k,self.keep.get(k))
1274 johnpye 463 context.env[k]=self.keep[k];
1275 johnpye 404
1276 jpye 1721 def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False,testname=None):
1277 johnpye 400 """This method will check for variables LIBNAME_LIBPATH
1278     and LIBNAME_CPPPATH and try to compile and link the
1279     file with the provided text, linking with the
1280     library libname."""
1281    
1282 jpye 1721 if testname is None:
1283     testname = libname
1284    
1285 johnpye 521 if static:
1286 jpye 1721 context.Message( 'Checking for static '+testname+'... ' )
1287 johnpye 521 else:
1288 jpye 1721 context.Message( 'Checking for '+testname+'... ' )
1289 johnpye 521
1290 johnpye 400 if varprefix==None:
1291     varprefix = libname.upper()
1292    
1293 johnpye 705 #print "LIBS is currently:",context.env.get('LIBS')
1294 johnpye 521 keep = KeepContext(context,varprefix,static)
1295 johnpye 400
1296 jpye 1678 if not context.env.has_key(varprefix+'_LIB') and not context.env.has_key(varprefix+'_LIBS'):
1297 johnpye 463 # if varprefix_LIB were in env, KeepContext would
1298     # have appended it already
1299 johnpye 705 context.env.Append(LIBS=[libname])
1300 johnpye 428
1301 johnpye 404 is_ok = context.TryLink(text,ext)
1302 johnpye 428
1303 johnpye 521 #print "Link success? ",(is_ok != 0)
1304 johnpye 400
1305 johnpye 405 keep.restore(context)
1306 johnpye 400
1307 johnpye 428 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
1308 johnpye 705 # print "Restored LIBS="+str(context.env['LIBS'])
1309 johnpye 428 # print "Restored LIBPATH="+str(context.env['LIBPATH'])
1310    
1311 johnpye 404 context.Result(is_ok)
1312     return is_ok
1313    
1314     #----------------
1315 johnpye 502 # GCC
1316    
1317     gcc_test_text = """
1318     #ifndef __GNUC__
1319     # error "Not using GCC"
1320     #endif
1321    
1322     int main(void){
1323     return __GNUC__;
1324     }
1325     """
1326    
1327     def CheckGcc(context):
1328     context.Message("Checking for GCC... ")
1329     is_ok = context.TryCompile(gcc_test_text,".c")
1330     context.Result(is_ok)
1331     return is_ok
1332    
1333     #----------------
1334 johnpye 500 # GCC VISIBILITY feature
1335    
1336     gccvisibility_test_text = """
1337     #if __GNUC__ < 4
1338     # error "Require GCC version 4 or newer"
1339     #endif
1340    
1341     __attribute__ ((visibility("default"))) int x;
1342    
1343     int main(void){
1344     extern int x;
1345     x = 4;
1346     }
1347     """
1348    
1349     def CheckGccVisibility(context):
1350     context.Message("Checking for GCC 'visibility' capability... ")
1351 johnpye 546 if not context.env.has_key('WITH_GCCVISIBILITY') or not env['WITH_GCCVISIBILITY']:
1352     context.Result("disabled")
1353     return 0
1354 johnpye 500 is_ok = context.TryCompile(gccvisibility_test_text,".c")
1355     context.Result(is_ok)
1356     return is_ok
1357 johnpye 502
1358 johnpye 500 #----------------
1359 johnpye 502 # YACC
1360    
1361     yacc_test_text = """
1362 johnpye 646 %{
1363     #include <stdio.h>
1364 johnpye 741
1365     /* MSVC++ needs this before it can swallow Bison output */
1366     #ifdef _MSC_VER
1367     # define __STDC__
1368     #endif
1369 johnpye 646 %}
1370     %token MSG
1371 johnpye 502 %start ROOT
1372 johnpye 646 %%
1373     ROOT:
1374     MSG { printf("HELLO"); }
1375     ;
1376     %%
1377 johnpye 502 """
1378    
1379     def CheckYacc(context):
1380 johnpye 644 context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
1381 johnpye 502 is_ok = context.TryCompile(yacc_test_text,".y")
1382     context.Result(is_ok)
1383     return is_ok
1384    
1385     #----------------
1386 johnpye 1025 # LEX
1387    
1388     lex_test_text = """
1389     %{
1390     #include <stdio.h>
1391     %}
1392     DIGIT [0-9]
1393     ID [a-z][a-z0-9]*
1394     %%
1395     {DIGIT}+ {
1396     printf("A digit: %s\\n",yytext);
1397     }
1398    
1399     [ \\t\\n]+ /* ignore */
1400    
1401     . {
1402     printf("Unrecognized guff");
1403     }
1404     %%
1405     main(){
1406     yylex();
1407     }
1408     """
1409    
1410     def CheckLex(context):
1411     context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1412     is_ok = context.TryCompile(lex_test_text,".l")
1413     context.Result(is_ok)
1414     return is_ok
1415    
1416 jpye 2355 lexdestroy_test_text = """
1417     %{
1418     #include <stdio.h>
1419 jpye 2356 #include <unistd.h>
1420 jpye 2355 %}
1421 jpye 2356
1422 jpye 2355 %%
1423 jpye 2356 username printf("%s", getlogin());
1424     %%
1425 jpye 2355
1426 jpye 2356 int yywrap(void){
1427     return 1;
1428     }
1429 jpye 2355
1430     main(){
1431 jpye 2356 //yylex();
1432     yylex_destroy();
1433 jpye 2355 }
1434 jpye 2356
1435 jpye 2355 """
1436    
1437     def CheckLexDestroy(context):
1438     context.Message("Checking for yylex_destroy... ")
1439     is_ok, outstring = context.TryRun(lexdestroy_test_text,".l")
1440     context.Result(is_ok)
1441     return is_ok
1442    
1443 johnpye 1025 #----------------
1444 johnpye 404 # CUnit test
1445    
1446 johnpye 400 cunit_test_text = """
1447 johnpye 451 #include <CUnit/CUnit.h>
1448 johnpye 400 int maxi(int i1, int i2){
1449     return (i1 > i2) ? i1 : i2;
1450     }
1451    
1452     void test_maxi(void){
1453     CU_ASSERT(maxi(0,2) == 2);
1454     CU_ASSERT(maxi(0,-2) == 0);
1455     CU_ASSERT(maxi(2,2) == 2);
1456    
1457     }
1458     int main(void){
1459     /* CU_initialize_registry() */
1460 johnpye 404 return 0;
1461 johnpye 400 }
1462     """
1463    
1464     def CheckCUnit(context):
1465 johnpye 451 return CheckExtLib(context,'cunit',cunit_test_text)
1466 johnpye 400
1467 johnpye 404 #----------------
1468 johnpye 938 # dmalloc test
1469    
1470     dmalloc_test_text = """
1471     #include <stdlib.h>
1472     #include <dmalloc.h>
1473    
1474     int main(void){
1475     char *c;
1476 jpye 1733 c = (char *)malloc(100*sizeof(char));
1477 johnpye 938 free(c);
1478     return 0;
1479     }
1480     """
1481    
1482     def CheckDMalloc(context):
1483     return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1484    
1485     #----------------
1486 jpye 1678 # graphviz test
1487 johnpye 1109
1488 jpye 1678 graphviz_test_text = """
1489 jpye 1714 #ifdef __WIN32__
1490     # include <gvc.h>
1491     #else
1492     # include <graphviz/gvc.h>
1493     #endif
1494 johnpye 1109 int main(void){
1495 jpye 1678 Agraph_t *g;
1496     GVC_t *gvc;
1497     gvc = gvContext();
1498     g = agopen("g", AGDIGRAPH);
1499 johnpye 1109 return 0;
1500     }
1501     """
1502    
1503 jpye 1678 def CheckGraphViz(context):
1504     return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
1505 johnpye 1109
1506 jpye 1721 graphviz_boolean_test = """
1507     #ifdef __WIN32__
1508 jpye 1722 # include <types.h>
1509 jpye 1721 #else
1510 jpye 1722 # include <graphviz/types.h>
1511 jpye 1721 #endif
1512 jpye 1722 #ifndef GV_TYPES_H
1513     # error WHERE IS GV_TYPES_H?
1514     #endif
1515     int main(void){
1516 jpye 1721 boolean x;
1517     x = TRUE;
1518     return 0;
1519     }
1520     """
1521    
1522     def CheckGraphVizBoolean(context):
1523     return CheckExtLib(context,'graphviz',graphviz_boolean_test,ext=".c" \
1524     ,testname="graphviz 'boolean' definition"
1525     )
1526    
1527 johnpye 1109 #----------------
1528 jpye 1326 # ufsparse test
1529    
1530     ufsparse_test_text = """
1531     #include <ufsparse/cs.h>
1532     int main(void){
1533     cs *A,*B,*C;
1534     C = cs_multiply(A,B);
1535     return 0;
1536     }
1537     """
1538    
1539     def CheckUFSparse(context):
1540     return CheckExtLib(context
1541     ,libname='cxsparse'
1542     ,varprefix='ufsparse'
1543     ,text=ufsparse_test_text
1544     ,ext=".c"
1545     )
1546    
1547     #----------------
1548 johnpye 673 # MATH test
1549    
1550     math_test_text = """
1551 johnpye 705 #ifndef _ALL_SOURCE
1552     # define _ALL_SOURCE
1553     #endif
1554     #ifndef _XOPEN_SOURCE
1555     # define _XOPEN_SOURCE
1556     #endif
1557     #ifndef _XOPEN_SOURCE_EXTENDED
1558     # define _XOPEN_SOURCE_EXTENDED 1
1559     #endif
1560 johnpye 673 #include <math.h>
1561     int main(void){
1562 johnpye 705 double x = 1.0; double y = 1.0; int i = 1;
1563     acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1564     j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1565     y0(x); y1(x); yn(i,x);
1566 jpye 1420 /* this part causes problems with crossmingw... */
1567 johnpye 705 #ifdef _THREAD_SAFE
1568     gamma_r(x,&i);
1569     lgamma_r(x,&i);
1570     #else
1571     gamma(x);
1572     lgamma(x);
1573     #endif
1574     hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
1575 johnpye 673 return 0;
1576     }
1577     """
1578    
1579     def CheckMath(context):
1580 johnpye 832 context.Message('Checking for IEEE math library... ')
1581 johnpye 705 libsave=context.env.get('LIBS');
1582     context.env.AppendUnique(LIBS=['m'])
1583     is_ok=context.TryLink(math_test_text,".c")
1584     context.Result(is_ok)
1585 jpye 1941 if libsave is None:
1586     del(context.env['LIBS'])
1587     else:
1588 johnpye 705 context.env['LIBS']=libsave
1589     return is_ok
1590    
1591 johnpye 673 #----------------
1592 jpye 1656 # malloc.h test
1593    
1594     malloc_test_text = """
1595 jpye 1660 #include <stdlib.h>
1596 jpye 1656 int main(){
1597     double *x;
1598     x = malloc(sizeof(double)*5);
1599     x[4] = 3.3;
1600     free(x);
1601     }
1602     """
1603    
1604     def CheckMalloc(context):
1605     context.Message("Checking for malloc...")
1606     is_ok = context.TryLink(malloc_test_text,".c")
1607     context.Result(is_ok)
1608     return is_ok
1609    
1610     #----------------
1611     # dlopen test
1612    
1613     dlopen_test_text = """
1614     #ifdef __WIN32__
1615     # include <windows.h>
1616     #else
1617     # include <dlfcn.h>
1618     #endif
1619     int main(){
1620     #ifdef __WIN32__
1621     HINSTANCE d;
1622     LoadLibrary("imaginary_and_nonexistent.dll");
1623     #else
1624     void *d;
1625     d = dlopen("imaginary_and_nonexistent.so", 1);
1626     #endif
1627     return 0;
1628     }
1629     """
1630    
1631     def CheckDLOpen(context):
1632     context.Message("Checking for ability to load shared libraries at runtime...")
1633     libsave=context.env.get('LIBS');
1634     if platform.system()!="Windows":
1635     context.env.Append(LIBS=['dl'])
1636     is_ok = context.TryLink(dlopen_test_text,".c")
1637     context.Result(is_ok)
1638     context.env['LIBS'] = libsave
1639     return is_ok
1640    
1641     #----------------
1642 johnpye 957 # libpython test
1643    
1644     libpython_test_text = """
1645     #include <Python.h>
1646     int main(void){
1647     PyObject *p;
1648     p = Py_None;
1649     return 0;
1650     }
1651     """
1652    
1653     def CheckPythonLib(context):
1654     context.Message('Checking for libpython... ')
1655    
1656     if platform.system()=="Windows":
1657     python_lib='python%d%d'
1658     else:
1659     python_lib='python%d.%d'
1660    
1661 jpye 1786 try:
1662     python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1663     python_cpppath = [distutils.sysconfig.get_python_inc()]
1664     cfig = distutils.sysconfig.get_config_vars()
1665     except:
1666     context.Result("not found")
1667     return 0
1668 johnpye 957
1669     lastLIBS = context.env.get('LIBS')
1670     lastLIBPATH = context.env.get('LIBPATH')
1671     lastCPPPATH = context.env.get('CPPPATH')
1672 johnpye 959 lastLINKFLAGS = context.env.get('LINKFLAGS')
1673 johnpye 957
1674     python_libpath = []
1675 johnpye 959 python_linkflags = []
1676 johnpye 965 if platform.system()=="Windows":
1677 jpye 1551 python_libpath += [os.path.join(sys.prefix,"libs")]
1678 jpye 2069 elif platform.system()=="Darwin":
1679     python_libpath += [cfig['LIBPL']]
1680     python_linkflags += cfig['LIBS'].split(' ')
1681 johnpye 965 else:
1682     # checked on Linux and SunOS
1683     if cfig['LDLIBRARY']==cfig['LIBRARY']:
1684     sys.stdout.write("(static)")
1685     python_libpath += [cfig['LIBPL']]
1686     python_linkflags += cfig['LIBS'].split(' ')
1687 johnpye 957
1688 johnpye 958 context.env.AppendUnique(LIBS=python_libs)
1689 johnpye 957 context.env.AppendUnique(LIBPATH=python_libpath)
1690     context.env.AppendUnique(CPPPATH=python_cpppath)
1691 johnpye 959 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1692 johnpye 957 result = context.TryLink(libpython_test_text,".c");
1693    
1694 johnpye 958 context.Result(result)
1695 johnpye 957
1696     if(result):
1697 johnpye 958 context.env['PYTHON_LIBPATH']=python_libpath
1698     context.env['PYTHON_LIB']=python_libs
1699     context.env['PYTHON_CPPPATH']=python_cpppath
1700 johnpye 959 context.env['PYTHON_LINKFLAGS']=python_linkflags
1701 johnpye 957
1702     context.env['LIBS'] = lastLIBS
1703     context.env['LIBPATH'] = lastLIBPATH
1704     context.env['CPPPATH'] = lastCPPPATH
1705 johnpye 959 context.env['LINKFLAGS'] = lastLINKFLAGS
1706 johnpye 957
1707     return result
1708    
1709     #----------------
1710 johnpye 673 # IDA test
1711    
1712 johnpye 913 sundials_version_major_required = 2
1713     sundials_version_minor_min = 2
1714 jpye 2085 sundials_version_minor_max = 4
1715 johnpye 913
1716     sundials_version_text = """
1717     #include <sundials/sundials_config.h>
1718     #include <stdio.h>
1719     int main(){
1720     printf("%s",SUNDIALS_PACKAGE_VERSION);
1721     return 0;
1722     }
1723     """
1724    
1725 johnpye 673 ida_test_text = """
1726 jpye 1400 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1727     # include <sundials/sundials_config.h>
1728     # include <sundials/sundials_nvector.h>
1729 jpye 1405 # include <nvector_serial.h>
1730 jpye 1400 # include <ida.h>
1731     # include <ida/ida_spgmr.h>
1732     #else
1733     # include <sundials/sundials_config.h>
1734     # include <nvector/nvector_serial.h>
1735 johnpye 907 # include <ida/ida.h>
1736 jpye 1400 #endif
1737 johnpye 673 int main(){
1738     void *ida_mem;
1739     ida_mem = IDACreate();
1740 johnpye 782 return 0;
1741 johnpye 673 }
1742     """
1743    
1744 johnpye 913 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1745     # so detect the version and act accordingly.
1746 jpye 1400 def CheckSUNDIALS(context):
1747     keep = KeepContext(context,'SUNDIALS')
1748 jpye 1402 context.Message("Checking for SUNDIALS... ")
1749 johnpye 913 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1750     keep.restore(context)
1751     if not is_ok:
1752 jpye 1402 context.Result(0)
1753 johnpye 913 return 0
1754    
1755     major,minor,patch = tuple([int(i) for i in output.split(".")])
1756     context.env['SUNDIALS_VERSION_MAJOR'] = major
1757     context.env['SUNDIALS_VERSION_MINOR'] = minor
1758     if major != sundials_version_major_required \
1759     or minor < sundials_version_minor_min \
1760     or minor > sundials_version_minor_max:
1761     context.Result(output+" (bad version)")
1762     # bad version
1763     return 0
1764    
1765     # good version
1766 johnpye 1086 context.Result("%d.%d.%d, good" % (major,minor,patch))
1767 jpye 1400
1768 johnpye 913 return 1
1769    
1770 jpye 1400
1771     def CheckIDA(context):
1772 jpye 1402 context.Message( 'Checking for IDA... ' )
1773 jpye 1400
1774 jpye 1404 keep = KeepContext(context,"SUNDIALS")
1775 jpye 1400
1776     major = context.env['SUNDIALS_VERSION_MAJOR']
1777     minor = context.env['SUNDIALS_VERSION_MINOR']
1778    
1779 jpye 1404 cppdef = context.env.get('CPPDEFINES')
1780    
1781     context.env.Append(CPPDEFINES=[
1782     ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1783     ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1784     ])
1785    
1786     context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1787     if major==2 and minor==2:
1788     context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1789    
1790 jpye 1400 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1791 jpye 1404 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1792     context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1793 jpye 1400
1794     is_ok = context.TryLink(ida_test_text,".c")
1795     context.Result(is_ok)
1796    
1797 jpye 1404 if cppdef:
1798     context.env['CPPDEFINES']=cppdef
1799 jpye 1552 else:
1800     del context.env['CPPDEFINES']
1801    
1802 jpye 1400 keep.restore(context)
1803    
1804     return is_ok
1805    
1806    
1807 johnpye 673 #----------------
1808 johnpye 783 # CONOPT test
1809    
1810     conopt_test_text = """
1811 johnpye 800 #if !defined(_WIN32)
1812     # define FNAME_LCASE_DECOR
1813     #endif
1814    
1815 johnpye 783 #include <conopt.h>
1816     #include <stdlib.h>
1817     int main(){
1818     int s, *v, e;
1819     s = COIDEF_Size();
1820     v = (int *)malloc(s*sizeof(int));
1821     e = COIDEF_Ini(v);
1822     return e;
1823     }
1824     """
1825    
1826     def CheckCONOPT(context):
1827     context.Message( 'Checking for CONOPT... ' )
1828    
1829     keep = KeepContext(context,"CONOPT")
1830    
1831     is_ok = context.TryLink(conopt_test_text,".c")
1832     context.Result(is_ok)
1833    
1834     keep.restore(context)
1835    
1836     return is_ok
1837    
1838     #----------------
1839 jpye 1529 # IPOPT test
1840    
1841     ipopt_test_text = """
1842     #if !defined(_WIN32)
1843     # define FNAME_LCASE_DECOR
1844     #endif
1845    
1846 jpye 1770 #include <coin/IpStdCInterface.h>
1847 jpye 1529 int main(){
1848     Number n;
1849 jpye 1546 IpoptProblem nlp = 0;
1850 jpye 1941 n = 1;
1851 jpye 1529 FreeIpoptProblem(nlp); // probably a crash if you run this
1852     return 0;
1853     }
1854     """
1855    
1856     def CheckIPOPT(context):
1857     context.Message( 'Checking for IPOPT... ' )
1858    
1859     keep = KeepContext(context,"IPOPT")
1860     is_ok = context.TryLink(ipopt_test_text,".c")
1861     context.Result(is_ok)
1862 jpye 2327
1863     keep.restore(context)
1864 jpye 1529
1865     return is_ok
1866    
1867     #----------------
1868 johnpye 405 # Tcl test
1869 johnpye 404
1870 jpye 1787 # TCL and TK required version 8.1 through 8.5:
1871     tcltk_minor_newest_acceptable = 5
1872 johnpye 561 tcltk_major_required = 8
1873    
1874 johnpye 404 tcl_check_text = r"""
1875     #include <tcl.h>
1876     #include <stdio.h>
1877     int main(void){
1878     printf("%s",TCL_PATCH_LEVEL);
1879     return 0;
1880     }
1881     """
1882    
1883     def CheckTcl(context):
1884 johnpye 521 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1885 johnpye 405
1886     def CheckTclVersion(context):
1887 johnpye 521 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1888 johnpye 405 context.Message("Checking Tcl version... ")
1889     (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1890 johnpye 404 keep.restore(context)
1891     if not is_ok:
1892 johnpye 405 context.Result("failed to run check")
1893 johnpye 404 return 0
1894 johnpye 405
1895 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1896 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1897 johnpye 428 context.Result(output+" (bad version)")
1898 johnpye 405 # bad version
1899     return 0
1900    
1901     # good version
1902 johnpye 552 context.Result(output+", good")
1903 johnpye 404 return 1
1904    
1905 johnpye 405 #----------------
1906 johnpye 463 # Tk test
1907 johnpye 405
1908     tk_check_text = r"""
1909     #include <tk.h>
1910     #include <stdio.h>
1911     int main(void){
1912     printf("%s",TK_PATCH_LEVEL);
1913     return 0;
1914     }
1915     """
1916     def CheckTk(context):
1917 johnpye 673 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1918 johnpye 405
1919 johnpye 428
1920 johnpye 405 def CheckTkVersion(context):
1921 johnpye 521 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1922 johnpye 405 context.Message("Checking Tk version... ")
1923 johnpye 521 #print "LINKFLAGS =",context.env['LINKFLAGS']
1924 johnpye 405 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1925 johnpye 404 keep.restore(context)
1926     if not is_ok:
1927     context.Result("failed to run check")
1928     return 0
1929    
1930 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1931 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1932 johnpye 404 # bad version
1933 johnpye 561 context.Result(output+" (bad version)")
1934 johnpye 404 return 0
1935 johnpye 400
1936 johnpye 404 # good version
1937 johnpye 561 context.Result(output+" (good)")
1938 johnpye 404 return 1
1939 johnpye 485
1940     #----------------
1941 johnpye 521 # Tktable test
1942    
1943     tktable_check_text = r"""
1944     #include <tkTable.h>
1945     #include <stdio.h>
1946     int main(void){
1947     Table mytable;
1948     return 0;
1949     }
1950     """
1951    
1952     def CheckTkTable(context):
1953     return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1954    
1955     #---------------
1956     # X11 test
1957    
1958     x11_check_text = r"""
1959     #include <X11/Xlib.h>
1960     #include <X11/IntrinsicP.h>
1961     #include <X11/Intrinsic.h>
1962     #include <X11/ObjectP.h>
1963     #include <X11/Object.h>
1964     int main(void){
1965     Object mything;
1966     return 0;
1967     }
1968     """
1969    
1970     def CheckX11(context):
1971     return CheckExtLib(context,'X11',x11_check_text)
1972    
1973     #----------------
1974 johnpye 968 # Check that we can raise and catch sigint
1975    
1976     sigint_test_text = r"""
1977     #include <signal.h>
1978     #include <setjmp.h>
1979     #include <stdlib.h>
1980     static jmp_buf g_jmpenv;
1981     void sighandler(int sig){
1982     longjmp(g_jmpenv,sig);
1983     }
1984     void testsigint(){
1985     raise(SIGINT);
1986     }
1987     int main(void){
1988     signal(SIGINT,&sighandler);
1989     switch(setjmp(g_jmpenv)){
1990     case 0:
1991     testsigint();
1992     exit(1);
1993     case SIGINT:
1994     exit(0);
1995     default:
1996     exit(2);
1997     }
1998     }
1999     """
2000    
2001     def CheckSIGINT(context):
2002     context.Message("Checking SIGINT is catchable... ")
2003     (is_ok,output)=context.TryRun(sigint_test_text,".c")
2004     context.Result(is_ok)
2005     return is_ok
2006    
2007     #----------------
2008 johnpye 953 # Check that we're able to catch floating point errors
2009    
2010     sigfpe_test_text = r"""
2011     #include <signal.h>
2012     #include <setjmp.h>
2013     #include <stdlib.h>
2014     #include <fenv.h>
2015     static jmp_buf g_jmpenv;
2016     void fpehandler(int sig){
2017     longjmp(g_jmpenv,sig);
2018     }
2019     int main(void){
2020     fenv_t myfenv;
2021     fegetenv(&myfenv);
2022     fesetenv(&myfenv);
2023     feenableexcept(FE_ALL_EXCEPT);
2024     signal(SIGFPE,&fpehandler);
2025     double x;
2026     switch(setjmp(g_jmpenv)){
2027     case 0:
2028     x = 1.0 / 0.0;
2029     /* failed to catch */
2030     exit(1);
2031     case SIGFPE:
2032     exit(0);
2033     }
2034     }
2035     """
2036    
2037     def CheckFPE(context):
2038 johnpye 968 context.Message("Checking C99 FPE behaviour... ")
2039 johnpye 953 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
2040     context.Result(is_ok)
2041     return is_ok
2042    
2043     #----------------
2044 johnpye 968 # signal reset needed?
2045    
2046     sigreset_test_text = r"""
2047     #include <signal.h>
2048     #include <setjmp.h>
2049     #include <stdlib.h>
2050     #include <stdio.h>
2051     typedef void SigHandlerFn(int);
2052     static jmp_buf g_jmpenv;
2053     void sighandler(int sig){
2054     longjmp(g_jmpenv,sig);
2055     }
2056     void testsigint(){
2057 johnpye 1002 /* fprintf(stderr,"Raising SIGINT\n"); */
2058 johnpye 968 raise(SIGINT);
2059     }
2060     int main(void){
2061     SigHandlerFn *last,*saved;
2062     saved = signal(SIGINT,&sighandler);
2063     if(saved!=SIG_DFL){
2064 johnpye 1002 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
2065 johnpye 968 exit(3);
2066     }
2067     switch(setjmp(g_jmpenv)){
2068     case 0:
2069     testsigint();
2070     fprintf(stderr,"Back from SIGINT\n");
2071     exit(1);
2072     case SIGINT:
2073     break;
2074     default:
2075     exit(2);
2076     };
2077 johnpye 1002 last = signal(SIGINT,SIG_DFL);
2078 johnpye 968 if(last!=&sighandler){
2079     printf("1");
2080     exit(0);
2081     }
2082     printf("0");
2083     exit(0);
2084     }
2085     """
2086    
2087     def CheckSigReset(context):
2088     context.Message("Checking signal handler reset... ")
2089 jpye 1941 libsave=context.env.get('LIBS')
2090     context.env.AppendUnique(LIBS=['m'])
2091 johnpye 968 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
2092 jpye 1941
2093     if libsave is None:
2094     del(context.env['LIBS'])
2095     else:
2096     context.env['LIBS']=libsave
2097    
2098 johnpye 968 if not is_ok:
2099     context.Result("ERROR")
2100 johnpye 1260 return False
2101 johnpye 1002 if int(output)==1:
2102 johnpye 968 context.Result("required");
2103     context.env['ASC_RESETNEEDED'] = True
2104     else:
2105     context.Result("not required");
2106     context.env['ASC_RESETNEEDED'] = False
2107 jpye 1658 return True
2108 johnpye 968
2109     #----------------
2110 jpye 1442 # LyX on this system?
2111    
2112     def CheckLyx(context):
2113     context.Message("Checking for LyX... ")
2114     r = context.env.WhereIs("lyx")
2115 jpye 1469 if r:
2116     context.Result(r)
2117     else:
2118     context.Result(0)
2119 jpye 1442 return r
2120    
2121     #----------------
2122     # Latex2HTML on this system?
2123    
2124     def CheckLatex2HTML(context):
2125     context.Message("Checking for latex2html...")
2126     if context.env.WhereIs("latex2html"):
2127     r = True
2128     else:
2129     r = False
2130     context.Result(r)
2131     return r
2132    
2133     #----------------
2134 jpye 1701 # 'lmodern' package for LaTeX available?
2135    
2136 jpye 1723 lmodern_test_text = r"""
2137 jpye 1701 \documentclass{article}
2138 jpye 1723 \usepackage{lmodern}
2139 jpye 1701 \title{Cartesian closed categories and the price of eggs}
2140     \author{Jane Doe}
2141     \date{September 1994}
2142     \begin{document}
2143     \maketitle
2144     Hello world!
2145     \end{document}
2146     """;
2147    
2148     def CheckLModern(context):
2149     context.Message("Checking for lmodern...")
2150 jpye 1770 b = context.env.get("DVI")
2151     if not b:
2152     context.Result(False)
2153     return False
2154 jpye 2000 ff = context.env.get('LATEXFLAGS')
2155     context.env.Append(LATEXFLAGS=['-interaction=nonstopmode','-halt-on-error'])
2156     is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".latex")
2157     print "is_ok=",is_ok
2158     if ff is not None:
2159     context.env['LATEXFLAGS'] = ff
2160     else:
2161     del context.env['LATEXFLAGS']
2162 jpye 1701 context.Result(is_ok)
2163     return is_ok
2164    
2165     #----------------
2166 johnpye 485 # GCC Version sniffing
2167    
2168     # TODO FIXME
2169    
2170     gcc_version4 = False
2171    
2172 johnpye 398 #------------------------------------------------------
2173 johnpye 385 # CONFIGURATION
2174    
2175     conf = Configure(env
2176     , custom_tests = {
2177 jpye 1448 'CheckCC' : CheckCC
2178     , 'CheckCXX' : CheckCXX
2179 jpye 1641 , 'CheckF77' : CheckF77
2180 jpye 1448 , 'CheckMath' : CheckMath
2181 jpye 1656 , 'CheckMalloc' : CheckMalloc
2182     , 'CheckDLOpen' : CheckDLOpen
2183 johnpye 673 , 'CheckSwigVersion' : CheckSwigVersion
2184 johnpye 957 , 'CheckPythonLib' : CheckPythonLib
2185 johnpye 400 , 'CheckCUnit' : CheckCUnit
2186 johnpye 938 , 'CheckDMalloc' : CheckDMalloc
2187 jpye 1442 , 'CheckLyx' : CheckLyx
2188     , 'CheckLatex2HTML' : CheckLatex2HTML
2189 jpye 1701 , 'CheckLModern' : CheckLModern
2190 jpye 1678 , 'CheckGraphViz' : CheckGraphViz
2191 jpye 1721 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
2192 jpye 1326 , 'CheckUFSparse' : CheckUFSparse
2193 johnpye 404 , 'CheckTcl' : CheckTcl
2194     , 'CheckTclVersion' : CheckTclVersion
2195 johnpye 405 , 'CheckTk' : CheckTk
2196     , 'CheckTkVersion' : CheckTkVersion
2197 johnpye 502 , 'CheckGcc' : CheckGcc
2198 johnpye 500 , 'CheckGccVisibility' : CheckGccVisibility
2199 johnpye 502 , 'CheckYacc' : CheckYacc
2200 johnpye 1025 , 'CheckLex' : CheckLex
2201 jpye 2355 , 'CheckLexDestroy' : CheckLexDestroy
2202 johnpye 521 , 'CheckTkTable' : CheckTkTable
2203     , 'CheckX11' : CheckX11
2204 johnpye 673 , 'CheckIDA' : CheckIDA
2205 jpye 1400 , 'CheckSUNDIALS' : CheckSUNDIALS
2206 johnpye 783 , 'CheckCONOPT' : CheckCONOPT
2207 jpye 1529 , 'CheckIPOPT' : CheckIPOPT
2208 johnpye 816 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
2209 johnpye 953 , 'CheckFPE' : CheckFPE
2210 johnpye 968 , 'CheckSIGINT' : CheckSIGINT
2211     , 'CheckSigReset' : CheckSigReset
2212 johnpye 400 # , 'CheckIsNan' : CheckIsNan
2213     # , 'CheckCppUnitConfig' : CheckCppUnitConfig
2214 jpye 1691 }
2215 johnpye 459 # , config_h = "config.h"
2216 johnpye 385 )
2217    
2218 jpye 1357 def sconsversioncheck():
2219    
2220     # uncomment the following line to skip the version check:
2221     # return 1
2222    
2223     import SCons
2224     v = SCons.__version__.split(".")
2225     if v[0] != '0':
2226 jpye 2313 if v[0] == '1' or v[0] == '2':
2227 jpye 1999 return 1;
2228 jpye 1357 return 0
2229 jpye 1431 if int(v[1]) >= 97:
2230     return 1
2231 jpye 1357 if v[1] != '96':
2232     return 0
2233     micro = int(v[2])
2234 jpye 1394 if micro == 92 or micro == 93 or micro == 96:
2235 jpye 1357 return 1;
2236     return 0
2237    
2238     if not sconsversioncheck():
2239     print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2240     print "or consult the developers in the case of newer versions. Modify"
2241     print "the function 'sconsversioncheck' in the file SConstruct if you"
2242     print "want to *force* SCons to continue."
2243     Exit(1)
2244    
2245 jpye 1448 # check C compiler
2246    
2247 jpye 1654 if conf.CheckCC() is False:
2248 jpye 1448 print "Failed to build simple test file with your C compiler."
2249     print "Check your compiler is installed and running correctly."
2250     Exit(1)
2251    
2252 jpye 1654 if conf.CheckCXX() is False:
2253 jpye 1448 print "Failed to build simple test file with your C++ compiler."
2254     print "Check your compiler is installed and running correctly."
2255 jpye 1630 print "You can set your C++ compiler using the CXX scons option."
2256 jpye 1448 Exit(1)
2257    
2258 johnpye 740 # stdio -- just to check that compiler is behaving
2259 johnpye 398
2260 jpye 1654 if conf.CheckHeader('stdio.h') is False:
2261 johnpye 832 print "CPPPATH =",env.get('CPPPATH')
2262 johnpye 740 print "Did not find 'stdio.h'! Check your compiler configuration."
2263 johnpye 1080 print ""
2264     print "You environment is printed here:"
2265     for k,v in os.environ.iteritems():
2266     print "%-30s%s" % ("%s :" % k, v)
2267 johnpye 740 Exit(1)
2268    
2269 jpye 2037 # sizes of vars used in libascend eg in gl_list etc.
2270 ballan 2036
2271 jpye 2037 _sizes = {
2272     "VOID_P" : "void *"
2273     ,"INT" : "int"
2274     ,"LONG" : "long"
2275     ,"LONG_LONG" : "long long"
2276     }
2277 ballan 2036
2278 jpye 2037 for _var,_type in _sizes.iteritems():
2279     _size = conf.CheckTypeSize(_type)
2280     if not _size:
2281     print "Couldn't determine 'sizeof(%s)'" % _type
2282     Exit(1)
2283     conf.env["SIZEOF_%s" % _var] = str(_size)
2284 ballan 2036
2285 jpye 2037 # check for some string functions
2286 ballan 2036
2287 jpye 1654 if conf.CheckFunc('snprintf') is False:
2288 johnpye 1228 print "Didn't find snprintf";
2289 jpye 2037 Exit(1)
2290 johnpye 1228
2291 jpye 1678 if conf.CheckFunc('strdup'):
2292     conf.env['HAVE_STRDUP'] = True
2293    
2294 jpye 2037 # attempt to support MSVCRT 7.1 on Windows
2295    
2296 jpye 1720 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2297     conf.env.Append(LIBS='msvcr71')
2298    
2299 johnpye 385 # Math library
2300    
2301 johnpye 1262 conf.env['HAVE_IEEE']=True
2302    
2303 jpye 1654 if need_libm and (conf.CheckMath() is False):
2304 johnpye 1232 conf.env['HAVE_IEEE']=False
2305 johnpye 1262 print 'Did not find math library, exiting!'
2306     Exit(1)
2307 johnpye 427
2308 jpye 1656 # Malloc
2309    
2310     if conf.CheckMalloc() is False:
2311     conf.env['HAVE_MALLOC']=False
2312     print "Did not find functioning 'malloc', exiting!"
2313     Exit(1)
2314    
2315     # dlopen/LoadLibrary
2316    
2317 jpye 1659 # CURRENTLY BREAKS LATER TEST (libsave?)
2318     #if conf.CheckDLOpen() is False:
2319     # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2320     # Exit(1)
2321 jpye 1656
2322 johnpye 385 # Where is 'isnan'?
2323    
2324 jpye 1654 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2325 johnpye 385 print "Didn't find isnan"
2326 johnpye 414 # Exit(1)
2327 johnpye 385
2328 johnpye 500 # GCC visibility
2329    
2330 johnpye 502 if conf.CheckGcc():
2331     conf.env['HAVE_GCC']=True;
2332 jpye 2027 if env.get('WITH_GCCVISIBILITY') and conf.CheckGccVisibility():
2333 johnpye 509 conf.env['HAVE_GCCVISIBILITY']=True;
2334     conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2335     conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2336 johnpye 709 conf.env.Append(CCFLAGS=['-Wall'])
2337 johnpye 500
2338 johnpye 968 # Catching SIGINT
2339    
2340 johnpye 1142 if env['WITH_SIGNALS']:
2341 jpye 1655 if not conf.CheckSIGINT():
2342 johnpye 1142 with_signals = False
2343     without_signals_reason = "SIGINT uncatchable"
2344 johnpye 968
2345 johnpye 953 # Catching SIGFPE
2346    
2347     if conf.CheckFPE():
2348 johnpye 968 conf.env['HAVE_C99FPE']=True
2349 johnpye 953 else:
2350 johnpye 968 conf.env['HAVE_C99FPE']=False
2351 johnpye 953
2352 johnpye 968 # Checking for signal reset requirement
2353    
2354 jpye 1654 if conf.CheckSigReset() is False:
2355 johnpye 968 print "Unable to determine if signal reset is required"
2356 johnpye 1260 Exit(1)
2357 johnpye 968
2358 johnpye 502 # YACC
2359    
2360 jpye 1552 if conf.CheckYacc():
2361 johnpye 502 conf.env['HAVE_YACC']=True
2362    
2363 jpye 1552 if conf.CheckLex():
2364 johnpye 1025 conf.env['HAVE_LEX']=True
2365 johnpye 502
2366 jpye 2355 if conf.CheckLexDestroy():
2367     conf.env['HAVE_LEXDESTROY']=True
2368    
2369 johnpye 387 # Tcl/Tk
2370 johnpye 386
2371 johnpye 586 if with_tcltk:
2372     if conf.CheckTcl():
2373     if conf.CheckTclVersion():
2374     if conf.CheckTk():
2375     if with_tcltk and conf.CheckTkVersion():
2376     if env['STATIC_TCLTK']:
2377     if conf.CheckTkTable():
2378     pass
2379     else:
2380     without_tcltk_reason = "TkTable not found"
2381     with_tcltk = False
2382     else:
2383     without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2384     with_tcltk = False
2385 johnpye 521 else:
2386 johnpye 586 without_tcltk_reason = "Tk not found."
2387 johnpye 551 with_tcltk = False
2388 johnpye 428 else:
2389 johnpye 586 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2390 johnpye 551 with_tcltk = False
2391 johnpye 586
2392 johnpye 428 else:
2393 johnpye 586 without_tcltk_reason = "Tcl not found."
2394 johnpye 551 with_tcltk = False
2395 johnpye 386
2396 johnpye 521 if env['STATIC_TCLTK']:
2397     conf.CheckX11()
2398    
2399 johnpye 395 # Python... obviously we're already running python, so we just need to
2400     # check that we can link to the python library OK:
2401    
2402 jpye 1655 if not conf.CheckPythonLib():
2403 johnpye 957 without_python_reason = 'libpython2.x not found or not linkable'
2404     with_python = False
2405 johnpye 982 env['WITH_PYTHON']=False
2406 johnpye 391
2407 johnpye 395 # SWIG version
2408    
2409 jpye 1656 if with_python and conf.CheckSwigVersion() is False:
2410 johnpye 413 without_python_reason = 'SWIG >= 1.3.24 is required'
2411     with_python = False
2412 johnpye 982 env['WITH_PYTHON']=False
2413 johnpye 413
2414 johnpye 400 # CUnit
2415    
2416 johnpye 593 if with_cunit:
2417 jpye 1655 if not conf.CheckCUnit():
2418 johnpye 427 without_cunit_reason = 'CUnit not found'
2419 johnpye 665 with_cunit = False
2420 johnpye 705 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2421 johnpye 427
2422 johnpye 938 # DMALLOC
2423    
2424     if with_dmalloc:
2425 jpye 1655 if not conf.CheckDMalloc():
2426 johnpye 938 without_dmalloc_reason = 'dmalloc not found'
2427     with_dmalloc = False
2428    
2429 jpye 1678 # GRAPHVIZ
2430 johnpye 1109
2431 jpye 1678 if with_graphviz:
2432     if not conf.CheckGraphViz():
2433     without_graphviz_reason = 'graphviz not found'
2434     with_graphviz = False
2435     env['WITH_GRAPHVIZ'] = False
2436 jpye 1721 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2437 johnpye 1109
2438 jpye 1326 # UFSPARSE
2439    
2440     if with_ufsparse:
2441 jpye 1655 if not conf.CheckUFSparse():
2442 jpye 1678 without_ufsparse_reason = 'ufsparse not found'
2443 jpye 1326 with_ufsparse = False
2444     env['WITH_UFSPARSE'] = False
2445    
2446 johnpye 673 # IDA
2447    
2448 jpye 1734 if with_ida:
2449     if not conf.CheckSUNDIALS():
2450     with_ida = False
2451     without_ida_reason = "SUNDIALS not found, or bad version"
2452     elif not conf.CheckIDA():
2453     with_ida = False
2454     without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2455 johnpye 673
2456 johnpye 797 # CONOPT
2457 johnpye 783
2458     if not with_conopt:
2459     without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2460 jpye 1654 elif conf.CheckCONOPT() is False:
2461 jpye 1541 if conf.env.get('CONOPT_LINKED'):
2462     conf.env['CONOPT_LINKED'] = False
2463     # we no longer require CONOPT at buildtime in order to build support for it
2464     #with_conopt = False
2465     #without_conpt_reason = "CONOPT not found"
2466 johnpye 783
2467 jpye 1529 # IPOPT
2468    
2469     if not with_ipopt:
2470     without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2471 jpye 1657 elif not conf.CheckIPOPT():
2472 jpye 1529 with_ipopt = False
2473     without_ipopt_reason = "IPOPT not found"
2474    
2475 johnpye 427 # BLAS
2476    
2477 johnpye 459 need_blas=False
2478 johnpye 673
2479     if with_lsode:
2480     need_fortran = True
2481 jpye 1641 need_fortran_reasons.append("LSODE")
2482 johnpye 459 need_blas=True
2483 johnpye 673
2484 jpye 2000 if with_ipopt:
2485     need_blas=True
2486    
2487 johnpye 459 if need_blas:
2488     if conf.CheckLib('blas'):
2489     with_local_blas = False
2490     without_local_blas_reason = "Found BLAS installed on system"
2491     else:
2492     with_local_blas = True
2493     need_fortran = True
2494 jpye 1641 need_fortran_reasons.append("BLAS")
2495 johnpye 673 else:
2496     with_local_blas= False;
2497     without_local_blas_reason = "BLAS not required"
2498 johnpye 427
2499     # FORTRAN
2500    
2501     if need_fortran:
2502 jpye 1999 print "NEED FORTRAN"
2503 jpye 2163 # Removed stuff for SCons 0.97 (Ubuntu 8.04) from here -- JP
2504 jpye 1380 detect_fortran = conf.env.Detect(['gfortran','g77'])
2505 johnpye 427 if detect_fortran:
2506 jpye 2163 conf.env.Tool(detect_fortran)
2507     if detect_fortran == 'g77':
2508     print "Setting F2C_LIB to 'g2c' because G77 compiler in use"
2509     conf.env['F2C_LIB'] = 'g2c'
2510     #print "DETECT_FORTRAN =",detect_fortran
2511     #print "NOW, FORTAN =",env['FORTRAN']
2512 johnpye 427 else:
2513 jpye 2163 print "FAILED G77/FORTRAN DETECTION"
2514 johnpye 673 with_lsode=False;
2515 jpye 2163 without_lsode_reason="FORTRAN required but not detected"
2516 jpye 2000 else:
2517     print "FORTRAN WAS NOT FOUND TO BE REQUIRED"
2518 johnpye 629
2519 jpye 1654 if need_fortran and conf.CheckF77() is False:
2520 jpye 1641 print "Failed to build simple test file with your Fortran compiler."
2521     print "Check your compiler is installed and running correctly."
2522     print "You can set your Fortran compiler using the FORTRAN scons option."
2523     print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2524     print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2525     Exit(1)
2526    
2527 johnpye 464 #else:
2528     # print "FORTRAN not required"
2529 johnpye 400
2530 johnpye 673 # F2C
2531    
2532     if need_fortran:
2533     if platform.system()=="Windows":
2534 jpye 1380 pass
2535     #conf.env.Append(LIBPATH='c:\mingw\lib')
2536 johnpye 673
2537 johnpye 816 # scrollkeeper
2538 johnpye 673
2539 johnpye 816 if with_scrollkeeper:
2540 jpye 1654 if conf.CheckScrollkeeperConfig() is False:
2541 johnpye 816 with_scrollkeeper=False
2542     without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2543    
2544 jpye 1442 # lyx
2545    
2546 jpye 1470 if with_doc_build:
2547 jpye 1769 if not conf.CheckLyx():
2548 jpye 1470 with_doc_build = False
2549 jpye 1769 without_doc_build_reason="unable to locate LyX"
2550 jpye 1442
2551 jpye 1769 with_latex2html = conf.CheckLatex2HTML()
2552 jpye 1442
2553 jpye 1723 if conf.CheckLModern() is False:
2554     with_doc_build = False
2555     without_doc_build_reason="'lmodern' is not available"
2556 jpye 1701
2557 johnpye 385 # TODO: -D_HPUX_SOURCE is needed
2558    
2559 johnpye 393 # TODO: detect if dynamic libraries are possible or not
2560    
2561 johnpye 427 if platform.system()=="Windows" and env.has_key('MSVS'):
2562 johnpye 740 _found_windows_h = conf.CheckHeader('Windows.h')
2563    
2564     if not _found_windows_h:
2565 johnpye 741 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2566 johnpye 740 Exit(1)
2567 johnpye 741
2568 jpye 1654 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2569 johnpye 427 with_python = 0;
2570     without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2571    
2572 johnpye 395 conf.Finish()
2573    
2574 jpye 2016 #print "-=-=-=-=-=-=-=-=- LIBS =",env.get('LIBS')
2575 jpye 1941
2576 johnpye 507 #---------------------------------------
2577     # SUBSTITUTION DICTIONARY for .in files
2578    
2579 johnpye 658 release = env.get('RELEASE')
2580     if release=="0.":
2581     release="0"
2582    
2583 johnpye 800 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2584    
2585 johnpye 507 subst_dict = {
2586     '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2587 jpye 1519 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2588 johnpye 507 , '@GLADE_FILE@':'ascend.glade'
2589     , '@HELP_ROOT@':''
2590     , '@ICON_EXTENSION@':icon_extension
2591 johnpye 628 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2592 johnpye 507 , '@INSTALL_BIN@':env['INSTALL_BIN']
2593     , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2594 johnpye 683 , '@INSTALL_LIB@':env['INSTALL_LIB']
2595 johnpye 721 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2596 jpye 1504 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2597 jpye 2016 , '@INSTALL_PYTHON@':env['INSTALL_PYTHON']
2598 jpye 2307 , '@INSTALL_PYTHON_ASCEND@':env['INSTALL_PYTHON_ASCEND']
2599 johnpye 507 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2600     , '@VERSION@':version
2601 johnpye 658 , '@RELEASE@':release
2602 johnpye 563 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2603 jpye 1590 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2604 johnpye 1228 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2605     , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2606 jpye 1597 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2607     , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2608 johnpye 589 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2609 johnpye 683 , '@PYTHON@' : python_exe
2610 jpye 1466 , '@PYVERSION@' : pyversion
2611 johnpye 1174 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2612 jpye 1680 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2613 jpye 2025 #define ASC_ABSOLUTE_PATHS @ASC_ABSOLUTE_PATHS@
2614     #if ASC_ABSOLUTE_PATHS
2615     # define ASCENDDIST_DEFAULT "@ASCENDDIST_DEFAULT@"
2616 jpye 2029 # define ASCENDTK_DEFAULT "@ASCENDTK_DEFAULT@"
2617 jpye 2025 # define ASCENDLIBRARY_DEFAULT "@ASCENDLIBRARY_DEFAULT@"
2618     # define ASCENDSOLVERS_DEFAULT "@ASCENDSOLVERS_DEFAULT@"
2619     #else
2620     # define ASC_DIST_REL_BIN "@ASC_DIST_REL_BIN@"
2621     # define ASC_TK_REL_DIST "@ASC_TK_REL_DIST@"
2622     # define ASC_LIBRARY_REL_DIST "@ASC_LIBRARY_REL_DIST@"
2623     # define ASC_SOLVERS_REL_DIST "@ASC_SOLVERS_REL_DIST@"
2624     #endif
2625     , '@ASC_ABSOLUTE_PATHS@': str(int(env.get('ABSOLUTE_PATHS')))
2626     , '@ASCENDDIST_DEFAULT@': c_escape(env['INSTALL_PREFIX'])
2627     , '@ASCENDTK_DEFAULT@': c_escape(os.path.abspath(env.subst(env['INSTALL_TK'])))
2628     , '@ASCENDLIBRARY_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDLIBRARY'])))
2629     , '@ASCENDSOLVERS_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDSOLVERS'])))
2630     , '@ASC_DIST_REL_BIN@' : default_dist_rel_bin
2631     , '@ASC_TK_REL_DIST@' : default_tk_rel_dist
2632     , '@ASC_LIBRARY_REL_DIST@' : default_library_rel_dist
2633     , '@ASC_SOLVERS_REL_DIST@' : default_solvers_rel_dist
2634 jpye 2037 , '@SIZEOF_VOID_P@' : env['SIZEOF_VOID_P']
2635     , '@SIZEOF_INT@' : env['SIZEOF_INT']
2636     , '@SIZEOF_LONG@' : env['SIZEOF_LONG']
2637     , '@SIZEOF_LONG_LONG@' : env['SIZEOF_LONG_LONG']
2638 johnpye 507 }
2639    
2640 jpye 1442 if env.get('WITH_DOC'):
2641     print "WITH_DOC:",env['WITH_DOC']
2642     subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2643 johnpye 507
2644 johnpye 597 # bool options...
2645 johnpye 673 for k,v in {
2646 jpye 1747 'ASC_WITH_DMALLOC':with_dmalloc
2647 jpye 1326 ,'ASC_WITH_UFSPARSE':with_ufsparse
2648 johnpye 1142 ,'ASC_WITH_MMIO':with_mmio
2649     ,'ASC_SIGNAL_TRAPS':with_signals
2650     ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2651     ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2652 johnpye 1261 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2653 johnpye 1142 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2654     ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2655 jpye 2354 ,'ASC_HAVE_LEXDESTROY':env.get('HAVE_LEXDESTROY')
2656 johnpye 1142 }.iteritems():
2657    
2658     if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2659 johnpye 594
2660 johnpye 507 if with_python:
2661     subst_dict['@ASCXX_USE_PYTHON@']="1"
2662 johnpye 673 env['WITH_PYTHON']=1;
2663 johnpye 507
2664 jpye 1442 if with_latex2html:
2665     env['WITH_LATEX2HTML']=1
2666    
2667 johnpye 507 if env.has_key('HAVE_GCCVISIBILITY'):
2668     subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2669    
2670     env.Append(SUBST_DICT=subst_dict)
2671    
2672 johnpye 1142 #for k,v in subst_dict.iteritems():
2673     # print "%-50s%s" % ("'%s'"%k,v)
2674 johnpye 829
2675 johnpye 1142 # REMOVED: long command-line support on Win2k
2676 johnpye 829
2677     #------------------------------------------------------
2678 johnpye 558 # RECIPE: SWIG scanner
2679    
2680     import SCons.Script
2681    
2682     SWIGScanner = SCons.Scanner.ClassicCPP(
2683     "SWIGScan"
2684     , ".i"
2685     , "CPPPATH"
2686     , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2687