/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1723 - (hide annotations) (download)
Fri Jan 11 23:24:27 2008 UTC (11 years, 10 months ago) by jpye
File size: 63574 byte(s)
Fixed 'lmodern' test.
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 jpye 1723 lmodern_test_text = r"""
1926 jpye 1701 \documentclass{article}
1927 jpye 1723 \usepackage{lmodern}
1928 jpye 1701 \title{Cartesian closed categories and the price of eggs}
1929     \author{Jane Doe}
1930     \date{September 1994}
1931     \begin{document}
1932     \maketitle
1933     Hello world!
1934     \end{document}
1935     """;
1936    
1937     def CheckLModern(context):
1938     context.Message("Checking for lmodern...")
1939 jpye 1723 b = context.env.DVI
1940     is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".tex")
1941 jpye 1701 context.Result(is_ok)
1942     return is_ok
1943    
1944     #----------------
1945 johnpye 485 # GCC Version sniffing
1946    
1947     # TODO FIXME
1948    
1949     gcc_version4 = False
1950    
1951 johnpye 398 #------------------------------------------------------
1952 johnpye 385 # CONFIGURATION
1953    
1954     conf = Configure(env
1955     , custom_tests = {
1956 jpye 1448 'CheckCC' : CheckCC
1957     , 'CheckCXX' : CheckCXX
1958 jpye 1641 , 'CheckF77' : CheckF77
1959 jpye 1448 , 'CheckMath' : CheckMath
1960 jpye 1656 , 'CheckMalloc' : CheckMalloc
1961     , 'CheckDLOpen' : CheckDLOpen
1962 johnpye 673 , 'CheckSwigVersion' : CheckSwigVersion
1963 johnpye 957 , 'CheckPythonLib' : CheckPythonLib
1964 johnpye 400 , 'CheckCUnit' : CheckCUnit
1965 johnpye 938 , 'CheckDMalloc' : CheckDMalloc
1966 jpye 1442 , 'CheckLyx' : CheckLyx
1967     , 'CheckLatex2HTML' : CheckLatex2HTML
1968 jpye 1701 , 'CheckLModern' : CheckLModern
1969 jpye 1678 , 'CheckGraphViz' : CheckGraphViz
1970 jpye 1721 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
1971 jpye 1326 , 'CheckUFSparse' : CheckUFSparse
1972 johnpye 404 , 'CheckTcl' : CheckTcl
1973     , 'CheckTclVersion' : CheckTclVersion
1974 johnpye 405 , 'CheckTk' : CheckTk
1975     , 'CheckTkVersion' : CheckTkVersion
1976 johnpye 502 , 'CheckGcc' : CheckGcc
1977 johnpye 500 , 'CheckGccVisibility' : CheckGccVisibility
1978 johnpye 502 , 'CheckYacc' : CheckYacc
1979 johnpye 1025 , 'CheckLex' : CheckLex
1980 johnpye 521 , 'CheckTkTable' : CheckTkTable
1981     , 'CheckX11' : CheckX11
1982 johnpye 673 , 'CheckIDA' : CheckIDA
1983 jpye 1400 , 'CheckSUNDIALS' : CheckSUNDIALS
1984 johnpye 783 , 'CheckCONOPT' : CheckCONOPT
1985 jpye 1529 , 'CheckIPOPT' : CheckIPOPT
1986 johnpye 816 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1987 johnpye 953 , 'CheckFPE' : CheckFPE
1988 johnpye 968 , 'CheckSIGINT' : CheckSIGINT
1989     , 'CheckSigReset' : CheckSigReset
1990 johnpye 400 # , 'CheckIsNan' : CheckIsNan
1991     # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1992 jpye 1691 }
1993 johnpye 459 # , config_h = "config.h"
1994 johnpye 385 )
1995    
1996 jpye 1357 def sconsversioncheck():
1997    
1998     # uncomment the following line to skip the version check:
1999     # return 1
2000    
2001     import SCons
2002     v = SCons.__version__.split(".")
2003     if v[0] != '0':
2004     return 0
2005 jpye 1431 if int(v[1]) >= 97:
2006     return 1
2007 jpye 1357 if v[1] != '96':
2008     return 0
2009     micro = int(v[2])
2010 jpye 1394 if micro == 92 or micro == 93 or micro == 96:
2011 jpye 1357 return 1;
2012     return 0
2013    
2014     if not sconsversioncheck():
2015     print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2016     print "or consult the developers in the case of newer versions. Modify"
2017     print "the function 'sconsversioncheck' in the file SConstruct if you"
2018     print "want to *force* SCons to continue."
2019     Exit(1)
2020    
2021 jpye 1448 # check C compiler
2022    
2023 jpye 1654 if conf.CheckCC() is False:
2024 jpye 1448 print "Failed to build simple test file with your C compiler."
2025     print "Check your compiler is installed and running correctly."
2026     Exit(1)
2027    
2028 jpye 1654 if conf.CheckCXX() is False:
2029 jpye 1448 print "Failed to build simple test file with your C++ compiler."
2030     print "Check your compiler is installed and running correctly."
2031 jpye 1630 print "You can set your C++ compiler using the CXX scons option."
2032 jpye 1448 Exit(1)
2033    
2034 johnpye 740 # stdio -- just to check that compiler is behaving
2035 johnpye 398
2036 jpye 1654 if conf.CheckHeader('stdio.h') is False:
2037 johnpye 832 print "CPPPATH =",env.get('CPPPATH')
2038 johnpye 740 print "Did not find 'stdio.h'! Check your compiler configuration."
2039 johnpye 1080 print ""
2040     print "You environment is printed here:"
2041     for k,v in os.environ.iteritems():
2042     print "%-30s%s" % ("%s :" % k, v)
2043 johnpye 740 Exit(1)
2044    
2045 jpye 1654 if conf.CheckFunc('snprintf') is False:
2046 johnpye 1228 print "Didn't find snprintf";
2047     exit(1)
2048    
2049 jpye 1678 if conf.CheckFunc('strdup'):
2050     conf.env['HAVE_STRDUP'] = True
2051    
2052 jpye 1720 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2053     conf.env.Append(LIBS='msvcr71')
2054    
2055 johnpye 385 # Math library
2056    
2057 johnpye 1262 conf.env['HAVE_IEEE']=True
2058    
2059 jpye 1654 if need_libm and (conf.CheckMath() is False):
2060 johnpye 1232 conf.env['HAVE_IEEE']=False
2061 johnpye 1262 print 'Did not find math library, exiting!'
2062     Exit(1)
2063 johnpye 427
2064 jpye 1656 # Malloc
2065    
2066     if conf.CheckMalloc() is False:
2067     conf.env['HAVE_MALLOC']=False
2068     print "Did not find functioning 'malloc', exiting!"
2069     Exit(1)
2070    
2071     # dlopen/LoadLibrary
2072    
2073 jpye 1659 # CURRENTLY BREAKS LATER TEST (libsave?)
2074     #if conf.CheckDLOpen() is False:
2075     # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2076     # Exit(1)
2077 jpye 1656
2078 johnpye 385 # Where is 'isnan'?
2079    
2080 jpye 1654 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2081 johnpye 385 print "Didn't find isnan"
2082 johnpye 414 # Exit(1)
2083 johnpye 385
2084 johnpye 500 # GCC visibility
2085    
2086 johnpye 502 if conf.CheckGcc():
2087     conf.env['HAVE_GCC']=True;
2088 johnpye 526 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
2089 johnpye 509 conf.env['HAVE_GCCVISIBILITY']=True;
2090     conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2091     conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2092 johnpye 709 conf.env.Append(CCFLAGS=['-Wall'])
2093 johnpye 500
2094 johnpye 968 # Catching SIGINT
2095    
2096 johnpye 1142 if env['WITH_SIGNALS']:
2097 jpye 1655 if not conf.CheckSIGINT():
2098 johnpye 1142 with_signals = False
2099     without_signals_reason = "SIGINT uncatchable"
2100 johnpye 968
2101 johnpye 953 # Catching SIGFPE
2102    
2103     if conf.CheckFPE():
2104 johnpye 968 conf.env['HAVE_C99FPE']=True
2105 johnpye 953 else:
2106 johnpye 968 conf.env['HAVE_C99FPE']=False
2107 johnpye 953
2108 johnpye 968 # Checking for signal reset requirement
2109    
2110 jpye 1654 if conf.CheckSigReset() is False:
2111 johnpye 968 print "Unable to determine if signal reset is required"
2112 johnpye 1260 Exit(1)
2113 johnpye 968
2114 johnpye 502 # YACC
2115    
2116 jpye 1552 if conf.CheckYacc():
2117 johnpye 502 conf.env['HAVE_YACC']=True
2118    
2119 jpye 1552 if conf.CheckLex():
2120 johnpye 1025 conf.env['HAVE_LEX']=True
2121 johnpye 502
2122 johnpye 387 # Tcl/Tk
2123 johnpye 386
2124 johnpye 586 if with_tcltk:
2125     if conf.CheckTcl():
2126     if conf.CheckTclVersion():
2127     if conf.CheckTk():
2128     if with_tcltk and conf.CheckTkVersion():
2129     if env['STATIC_TCLTK']:
2130     if conf.CheckTkTable():
2131     pass
2132     else:
2133     without_tcltk_reason = "TkTable not found"
2134     with_tcltk = False
2135     else:
2136     without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2137     with_tcltk = False
2138 johnpye 521 else:
2139 johnpye 586 without_tcltk_reason = "Tk not found."
2140 johnpye 551 with_tcltk = False
2141 johnpye 428 else:
2142 johnpye 586 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2143 johnpye 551 with_tcltk = False
2144 johnpye 586
2145 johnpye 428 else:
2146 johnpye 586 without_tcltk_reason = "Tcl not found."
2147 johnpye 551 with_tcltk = False
2148 johnpye 386
2149 johnpye 521 if env['STATIC_TCLTK']:
2150     conf.CheckX11()
2151    
2152 johnpye 395 # Python... obviously we're already running python, so we just need to
2153     # check that we can link to the python library OK:
2154    
2155 jpye 1655 if not conf.CheckPythonLib():
2156 johnpye 957 without_python_reason = 'libpython2.x not found or not linkable'
2157     with_python = False
2158 johnpye 982 env['WITH_PYTHON']=False
2159 johnpye 391
2160 johnpye 395 # SWIG version
2161    
2162 jpye 1656 if with_python and conf.CheckSwigVersion() is False:
2163 johnpye 413 without_python_reason = 'SWIG >= 1.3.24 is required'
2164     with_python = False
2165 johnpye 982 env['WITH_PYTHON']=False
2166 johnpye 413
2167 johnpye 400 # CUnit
2168    
2169 johnpye 593 if with_cunit:
2170 jpye 1655 if not conf.CheckCUnit():
2171 johnpye 427 without_cunit_reason = 'CUnit not found'
2172 johnpye 665 with_cunit = False
2173 johnpye 705 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2174 johnpye 427
2175 johnpye 938 # DMALLOC
2176    
2177     if with_dmalloc:
2178 jpye 1655 if not conf.CheckDMalloc():
2179 johnpye 938 without_dmalloc_reason = 'dmalloc not found'
2180     with_dmalloc = False
2181    
2182 jpye 1678 # GRAPHVIZ
2183 johnpye 1109
2184 jpye 1678 if with_graphviz:
2185     if not conf.CheckGraphViz():
2186     without_graphviz_reason = 'graphviz not found'
2187     with_graphviz = False
2188     env['WITH_GRAPHVIZ'] = False
2189 jpye 1721 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2190 johnpye 1109
2191 jpye 1326 # UFSPARSE
2192    
2193     if with_ufsparse:
2194 jpye 1655 if not conf.CheckUFSparse():
2195 jpye 1678 without_ufsparse_reason = 'ufsparse not found'
2196 jpye 1326 with_ufsparse = False
2197     env['WITH_UFSPARSE'] = False
2198    
2199 johnpye 673 # IDA
2200    
2201     if not with_ida:
2202     without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
2203 jpye 1655 elif not conf.CheckSUNDIALS():
2204 jpye 1400 with_ida = False
2205     without_ida_reason = "SUNDIALS not found, or bad version"
2206 jpye 1655 elif not conf.CheckIDA():
2207 johnpye 673 with_ida = False
2208 jpye 1400 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2209 johnpye 673
2210 johnpye 797 # CONOPT
2211 johnpye 783
2212     if not with_conopt:
2213     without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2214 jpye 1654 elif conf.CheckCONOPT() is False:
2215 jpye 1541 if conf.env.get('CONOPT_LINKED'):
2216     conf.env['CONOPT_LINKED'] = False
2217     # we no longer require CONOPT at buildtime in order to build support for it
2218     #with_conopt = False
2219     #without_conpt_reason = "CONOPT not found"
2220 johnpye 783
2221 jpye 1529 # IPOPT
2222    
2223     if not with_ipopt:
2224     without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2225 jpye 1657 elif not conf.CheckIPOPT():
2226 jpye 1529 with_ipopt = False
2227     without_ipopt_reason = "IPOPT not found"
2228    
2229 johnpye 427 # BLAS
2230    
2231 johnpye 459 need_blas=False
2232 johnpye 673
2233     if with_lsode:
2234     need_fortran = True
2235 jpye 1641 need_fortran_reasons.append("LSODE")
2236 johnpye 459 need_blas=True
2237 johnpye 673
2238 johnpye 459 if need_blas:
2239     if conf.CheckLib('blas'):
2240     with_local_blas = False
2241     without_local_blas_reason = "Found BLAS installed on system"
2242     else:
2243     with_local_blas = True
2244     need_fortran = True
2245 jpye 1641 need_fortran_reasons.append("BLAS")
2246 johnpye 673 else:
2247     with_local_blas= False;
2248     without_local_blas_reason = "BLAS not required"
2249 johnpye 427
2250     # FORTRAN
2251    
2252     if need_fortran:
2253 johnpye 629 conf.env.Tool('fortran')
2254 jpye 1380 detect_fortran = conf.env.Detect(['gfortran','g77'])
2255 johnpye 427 if detect_fortran:
2256     # For some reason, g77 doesn't get detected properly on MinGW
2257 johnpye 673 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2258 jpye 1357 print "Fixing detection of F77 on MinGW...(?)"
2259 johnpye 427 conf.env.Replace(F77=detect_fortran)
2260     conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2261     conf.env.Replace(F77FLAGS='')
2262 johnpye 428 #print "F77:",conf.env['F77']
2263     #print "F77COM:",conf.env['F77COM']
2264     #print "F77FLAGS:",conf.env['F77FLAGS']
2265 johnpye 427 fortran_builder = Builder(
2266     action='$F77COM'
2267     , suffix='.o'
2268     , src_suffix='.f'
2269     )
2270     conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2271 johnpye 1284 if platform.system()=="Linux":
2272     conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2273 johnpye 427 else:
2274 johnpye 673 with_lsode=False;
2275     without_lsode_reason="FORTRAN-77 required but not found"
2276 johnpye 629
2277 jpye 1654 if need_fortran and conf.CheckF77() is False:
2278 jpye 1641 print "Failed to build simple test file with your Fortran compiler."
2279     print "Check your compiler is installed and running correctly."
2280     print "You can set your Fortran compiler using the FORTRAN scons option."
2281     print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2282     print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2283     Exit(1)
2284    
2285 johnpye 464 #else:
2286     # print "FORTRAN not required"
2287 johnpye 400
2288 johnpye 673 # F2C
2289    
2290     if need_fortran:
2291     if platform.system()=="Windows":
2292 jpye 1380 pass
2293     #conf.env.Append(LIBPATH='c:\mingw\lib')
2294 johnpye 673
2295 johnpye 816 # scrollkeeper
2296 johnpye 673
2297 johnpye 816 if with_scrollkeeper:
2298 jpye 1654 if conf.CheckScrollkeeperConfig() is False:
2299 johnpye 816 with_scrollkeeper=False
2300     without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2301    
2302 jpye 1442 # lyx
2303    
2304 jpye 1470 if with_doc_build:
2305 jpye 1654 if conf.CheckLyx() is False:
2306 jpye 1470 with_doc_build = False
2307     without_doc_build_reason="unable to locate lyx"
2308 jpye 1442
2309     with_latext2html = conf.CheckLatex2HTML()
2310    
2311 jpye 1723 if conf.CheckLModern() is False:
2312     with_doc_build = False
2313     without_doc_build_reason="'lmodern' is not available"
2314 jpye 1701
2315 johnpye 385 # TODO: -D_HPUX_SOURCE is needed
2316    
2317     # TODO: check size of void*
2318    
2319 johnpye 393 # TODO: detect if dynamic libraries are possible or not
2320    
2321 johnpye 427 if platform.system()=="Windows" and env.has_key('MSVS'):
2322 johnpye 740 _found_windows_h = conf.CheckHeader('Windows.h')
2323    
2324     if not _found_windows_h:
2325 johnpye 741 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2326 johnpye 740 Exit(1)
2327 johnpye 741
2328 jpye 1654 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2329 johnpye 427 with_python = 0;
2330     without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2331    
2332 johnpye 395 conf.Finish()
2333    
2334 johnpye 507 #---------------------------------------
2335     # SUBSTITUTION DICTIONARY for .in files
2336    
2337 johnpye 658 release = env.get('RELEASE')
2338     if release=="0.":
2339     release="0"
2340    
2341 johnpye 800 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2342    
2343 johnpye 507 subst_dict = {
2344     '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2345 jpye 1519 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2346 johnpye 507 , '@GLADE_FILE@':'ascend.glade'
2347     , '@HELP_ROOT@':''
2348     , '@ICON_EXTENSION@':icon_extension
2349 johnpye 628 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2350 johnpye 507 , '@INSTALL_BIN@':env['INSTALL_BIN']
2351     , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2352 johnpye 683 , '@INSTALL_LIB@':env['INSTALL_LIB']
2353 johnpye 721 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2354 jpye 1504 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2355 johnpye 507 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2356     , '@VERSION@':version
2357 johnpye 658 , '@RELEASE@':release
2358 johnpye 563 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2359 jpye 1590 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2360 johnpye 1228 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2361     , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2362 jpye 1597 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2363     , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2364 johnpye 589 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2365 johnpye 627 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2366 johnpye 683 , '@PYTHON@' : python_exe
2367 jpye 1466 , '@PYVERSION@' : pyversion
2368 johnpye 800 , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2369     , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2370 jpye 1399 , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2371 johnpye 1174 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2372 jpye 1535 , '@WITH_SOLVERS@':",".join(env.get('WITH_SOLVERS'))
2373 jpye 1680 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2374 johnpye 507 }
2375    
2376 jpye 1442 if env.get('WITH_DOC'):
2377     print "WITH_DOC:",env['WITH_DOC']
2378     subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2379 johnpye 507
2380 johnpye 597 # bool options...
2381 johnpye 673 for k,v in {
2382 johnpye 1142 'ASC_WITH_IDA':with_ida
2383     ,'ASC_WITH_DMALLOC':with_dmalloc
2384 jpye 1326 ,'ASC_WITH_UFSPARSE':with_ufsparse
2385 johnpye 1142 ,'ASC_WITH_CONOPT':with_conopt
2386 jpye 1541 ,'ASC_LINKED_CONOPT':env.get('CONOPT_LINKED')
2387 jpye 1529 ,'ASC_WITH_IPOPT':with_ipopt
2388 johnpye 1142 ,'ASC_WITH_LSODE':with_lsode
2389     ,'ASC_WITH_MMIO':with_mmio
2390     ,'ASC_SIGNAL_TRAPS':with_signals
2391     ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2392     ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2393 johnpye 1261 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2394 jpye 1412 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2395 johnpye 1142 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2396     ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2397     }.iteritems():
2398    
2399     if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2400 johnpye 594
2401 johnpye 507 if with_python:
2402     subst_dict['@ASCXX_USE_PYTHON@']="1"
2403 johnpye 673 env['WITH_PYTHON']=1;
2404 johnpye 507
2405 jpye 1442 if with_latex2html:
2406     env['WITH_LATEX2HTML']=1
2407    
2408 johnpye 507 if env.has_key('HAVE_GCCVISIBILITY'):
2409     subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2410    
2411     env.Append(SUBST_DICT=subst_dict)
2412    
2413 johnpye 1142 #for k,v in subst_dict.iteritems():
2414     # print "%-50s%s" % ("'%s'"%k,v)
2415 johnpye 829
2416 johnpye 1142 # REMOVED: long command-line support on Win2k
2417 johnpye 829
2418     #------------------------------------------------------
2419 johnpye 558 # RECIPE: SWIG scanner
2420    
2421     import SCons.Script
2422    
2423     SWIGScanner = SCons.Scanner.ClassicCPP(
2424     "SWIGScan"
2425     , ".i"
2426     , "CPPPATH"
2427     , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2428     )
2429    
2430     env.Append(SCANNERS=[SWIGScanner])
2431    
2432     #------------------------------------------------------
2433 johnpye 463 # Recipe for 'CHMOD' ACTION
2434 johnpye 439
2435     import SCons
2436     from SCons.Script.SConscript import SConsEnvironment
2437     SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2438     lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2439    
2440     def InstallPerm(env, dest, files, perm):
2441     obj = env.Install(dest, files)
2442     for i in obj:
2443     env.AddPostAction(i, env.Chmod(str(i), perm))
2444    
2445     SConsEnvironment.InstallPerm = InstallPerm
2446    
2447     # define wrappers
2448     SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2449 johnpye 578 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2450 johnpye 629 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2451 johnpye 463
2452 johnpye 439 #------------------------------------------------------
2453 johnpye 463 # BUILD...
2454 johnpye 385
2455 johnpye 463 # so that #include <modulename/headername.h> works across all modules...
2456 johnpye 743 env.AppendUnique(CPPPATH=['#base/generic'])
2457 johnpye 385
2458 johnpye 508 if env['DEBUG']:
2459     env.Append(CCFLAGS=['-g'])
2460 jpye 1554 env.Append(LINKFLAGS=['-g'])
2461 johnpye 508
2462 johnpye 591 if env['GCOV']:
2463     env.Append(
2464     CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2465     , LIBS=['gcov']
2466     , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2467     )
2468    
2469 johnpye 673 if with_ida:
2470     env.Append(WITH_IDA=1)
2471    
2472 johnpye 783 if with_conopt:
2473     env.Append(WITH_CONOPT=1)
2474    
2475 jpye 1529 if with_ipopt:
2476     env.Append(WITH_IPOPT=1)
2477    
2478 jpye 1719 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2479 jpye 1718 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2480    
2481 johnpye 463 #-------------
2482     # TCL/TK GUI
2483 johnpye 385
2484 johnpye 551 if with_tcltk:
2485 johnpye 569 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2486 johnpye 391 else:
2487 johnpye 982 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2488 johnpye 386
2489 johnpye 463 #-------------
2490     # PYTHON INTERFACE
2491    
2492 johnpye 387 if with_python:
2493 johnpye 532 env.SConscript(['pygtk/SConscript'],'env')
2494 johnpye 391 else:
2495 johnpye 982 print "Skipping... Python bindings aren't being built:",without_python_reason
2496 johnpye 400
2497 johnpye 463 #------------
2498     # BASE/GENERIC SUBDIRECTORIES
2499    
2500 johnpye 673 libascend_env = env.Copy()
2501    
2502 johnpye 1316 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2503 johnpye 463
2504     srcs = []
2505     for d in dirs:
2506 johnpye 673 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2507 johnpye 463 srcs += heresrcs
2508    
2509     #-------------
2510 johnpye 673 # IMPORTED CODE: LSODE, BLAS, etc
2511    
2512 jpye 1509 #if with_lsode:
2513     # srcs += env.SConscript(['lsod/SConscript'],'env')
2514     # srcs += env.SConscript(['linpack/SConscript'],'env')
2515     #else:
2516     # print "Skipping... LSODE won't be built:", without_lsode_reason
2517 johnpye 673
2518     if with_local_blas:
2519 jpye 1515 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2520 johnpye 673 else:
2521 jpye 1515 env['blasobjs'] = []
2522 johnpye 673 print "Skipping... BLAS won't be built:", without_local_blas_reason
2523    
2524     if not with_ida:
2525     print "Skipping... IDA won't be built:", without_ida_reason
2526    
2527 johnpye 993 if with_mmio:
2528     srcs += env.SConscript(['mmio/SConscript'],'env')
2529     else:
2530     print "Skipping... MMIO export won't be built:", without_mmio_reason
2531 johnpye 673 #-------------
2532 johnpye 463 # LIBASCEND -- all base/generic functionality
2533    
2534 johnpye 938 if with_dmalloc:
2535     libascend_env.Append(LIBS=['dmalloc'])
2536    
2537 jpye 1326 if with_ufsparse:
2538     libascend_env.Append(LIBS=['cxsparse'])
2539    
2540 johnpye 673 libascend = libascend_env.SharedLibrary('ascend',srcs)
2541 johnpye 463
2542 jpye 1510 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2543     env['libascend'] = libascend
2544    
2545 johnpye 673 env.Alias('libascend',libascend)
2546    
2547 johnpye 463 #-------------
2548 johnpye 761 # UNIT TESTS (C CODE)
2549 johnpye 463
2550 johnpye 593 if with_cunit:
2551 jpye 1638 testdirs = ['general','solver','utilities','linear','compiler']
2552 johnpye 593 testsrcs = []
2553 johnpye 400 for testdir in testdirs:
2554     path = 'base/generic/'+testdir+'/test/'
2555     env.SConscript([path+'SConscript'],'env')
2556 johnpye 593 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2557    
2558     #print "TESTSRCS =",testsrcs
2559    
2560 johnpye 400 env.SConscript(['test/SConscript'],'env')
2561     env.SConscript(['base/generic/test/SConscript'],'env')
2562 johnpye 593
2563     env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2564 johnpye 400
2565     else:
2566 johnpye 427 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2567 johnpye 400
2568 johnpye 761 #-------------
2569 jpye 1504 # EXTERNAL SOLVERS
2570    
2571     env['extfns']=[]
2572    
2573 jpye 1505 env.SConscript(['solvers/SConscript'],'env')
2574 jpye 1504
2575     #-------------
2576 johnpye 761 # EXTERNAL FUNCTIONS
2577    
2578 johnpye 811 modeldirs = env.SConscript(['models/SConscript'],'env')
2579    
2580     if not with_extfns:
2581 johnpye 761 print "Skipping... External modules aren't being built:",without_extfns_reason
2582    
2583 johnpye 811 env.Alias('extfns',env['extfns'])
2584 johnpye 761
2585 johnpye 463 #------------------------------------------------------
2586 johnpye 683 # CREATE ASCEND-CONFIG scriptlet
2587    
2588     ascendconfig = env.SubstInFile('ascend-config.in')
2589    
2590 jpye 1625
2591 johnpye 683 #------------------------------------------------------
2592 jpye 1625 # CREATE asc4dev scriptlet
2593    
2594     asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2595     env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2596     #------------------------------------------------------
2597 johnpye 463 # INSTALLATION
2598 johnpye 427
2599 johnpye 552 if env.get('CAN_INSTALL'):
2600 johnpye 427
2601 jpye 1442 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2602 jpye 1436 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2603 jpye 1505 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2604 johnpye 449
2605 johnpye 463 # TODO: add install options
2606     env.Alias('install',install_dirs)
2607 johnpye 400
2608 jpye 1436 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2609 johnpye 435
2610 jpye 1436 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2611 johnpye 683
2612 johnpye 438 #------------------------------------------------------
2613 johnpye 631 # WINDOWS INSTALLER
2614    
2615 jpye 1551 if not env.get('NSIS'):
2616     with_installer = False
2617     without_installer_reason = "NSIS not found"
2618    
2619 johnpye 631 if with_installer:
2620 jpye 1467 env.Append(NSISDEFINES={
2621     'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2622     ,"VERSION":version
2623     ,'PYVERSION':pyversion
2624     })
2625 jpye 1570 installer = env.Installer('nsis/installer.nsi')
2626 jpye 1465 Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2627     env.Alias('installer',installer)
2628 johnpye 631 else:
2629     print "Skipping... Windows installer isn't being built:",without_installer_reason
2630    
2631 jpye 1465
2632 johnpye 631 #------------------------------------------------------
2633 johnpye 673 # PROJECT FILE for MSVC
2634    
2635     env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2636    
2637     #------------------------------------------------------
2638 johnpye 438 # CREATE the SPEC file for generation of RPM packages
2639    
2640 johnpye 463 if platform.system()=="Linux":
2641     env.SubstInFile('ascend.spec.in')
2642 johnpye 552
2643     #------------------------------------------------------
2644 johnpye 816 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2645    
2646 jpye 1442 #if with_scrollkeeper:
2647     # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2648     # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2649 johnpye 816
2650     #------------------------------------------------------
2651 johnpye 552 # DISTRIBUTION TAR FILE
2652    
2653 johnpye 554 env['DISTTAR_FORMAT']='bz2'
2654 johnpye 556 env.Append(
2655 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']
2656 jpye 1417 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2657 johnpye 556 )
2658 johnpye 554
2659 johnpye 563 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2660 johnpye 556 , [env.Dir('#')]
2661 johnpye 554 )
2662    
2663 johnpye 680 env.Depends(tar,'ascend.spec')
2664 jpye 1442 env.Depends(tar,'#doc/book.pdf')
2665 johnpye 680
2666 jpye 1596 #------------------------------------------------------
2667 jpye 1622 # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2668    
2669     # ...
2670    
2671     #------------------------------------------------------
2672 jpye 1596 # DEBIAN TARBALL for use with Build Service
2673 johnpye 862
2674 jpye 1596 import glob
2675     deb_manfiles = glob.glob('debian/*.man')
2676    
2677     deb_tar = env.Tar(
2678     'dist/debian.tar.gz'
2679 jpye 1609 ,deb_manfiles + ['debian/compat','debian/copyright','debian/dirs'
2680     ,'debian/postinst','debian/postrm']
2681 jpye 1596 ,TARFLAGS = ['cz']
2682     )
2683    
2684     Alias('dist',[tar,deb_tar])
2685    
2686 johnpye 554 #------------------------------------------------------
2687 jpye 1551 # DOCUMENTATION
2688 johnpye 816
2689    
2690 jpye 1551 if not with_doc_build:
2691     print "Skipping... Documentation isn't being built:",without_doc_build_reason
2692 jpye 1442
2693 jpye 1551 #user's manual
2694     env.SConscript('doc/SConscript',['env'])
2695 johnpye 766
2696 jpye 1551 # doxygen documentation
2697 johnpye 766 env.SConscript('base/doc/SConscript',['env'])
2698