/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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