/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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