/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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