/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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