/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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