/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22