/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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