/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1566 - (hide annotations) (download)
Thu Aug 2 06:46:43 2007 UTC (13 years, 1 month ago) by jpye
File size: 57807 byte(s)
Changed default fortran to G77 on MinGW/MSYS.
1 johnpye 955 import sys, os, commands, platform, distutils.sysconfig, os.path, re
2 johnpye 385
3 jpye 1514 version = "0.9.5.112"
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 1515 default_tron_prefix="c:\\Program Files\\TRON"
45     default_tron_dlpath="$TRON_PREFIX"
46     default_tron_lib="tron1"
47 jpye 1501
48 johnpye 938 default_prefix="c:\\MinGW"
49     default_libpath="$DEFAULT_PREFIX\\lib"
50     default_cpppath="$DEFAULT_PREFIX\\include"
51 johnpye 800
52 johnpye 783 if not os.path.exists(default_conopt_prefix):
53     default_conopt_prefix = None
54 johnpye 739
55 johnpye 673 need_libm = False
56 johnpye 683 python_exe = "c:\\Python24\\python.exe"
57 johnpye 816 default_with_scrollkeeper=False
58 jpye 1504 pathsep = ";"
59 jpye 1566
60     default_fortran="g77"
61     default_f2c_lib="g2c"
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 johnpye 551
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     #----------------------
577    
578     opts.Add(
579 johnpye 455 'PYGTK_ASSETS'
580 johnpye 532 ,'Default location for Glade assets (placed in pygtk/config.py)'
581 johnpye 455 ,default_install_assets
582     )
583    
584 johnpye 508 opts.Add(BoolOption(
585     'DEBUG'
586     ,"Compile source with debugger symbols, eg for use with 'gdb'"
587     ,False
588     ))
589    
590 johnpye 597 opts.Add(BoolOption(
591     'MALLOC_DEBUG'
592     ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
593     ,False
594     ))
595    
596 johnpye 938 #------ dmalloc --------
597     opts.Add(PackageOption(
598     'DMALLOC_PREFIX'
599     ,"Where are your dmalloc files?"
600     ,default_prefix
601     ))
602 johnpye 448
603 johnpye 938 opts.Add(PackageOption(
604     'DMALLOC_CPPPATH'
605     ,"Where are your dmalloc include files?"
606     ,default_cpppath
607     ))
608    
609     opts.Add(PackageOption(
610     'DMALLOC_LIBPATH'
611     ,"Where are your dmalloc libraries?"
612     ,default_libpath
613     ))
614    
615     opts.Add(BoolOption(
616     'WITH_DMALLOC'
617     ,"Link to the DMALLOC library (if available) for debugging of memory usage."
618     ,False
619     ))
620    
621 jpye 1326 #------ f --------
622 johnpye 1109 opts.Add(PackageOption(
623     'MFGRAPH_PREFIX'
624     ,"Where are your MFGRAPH files?"
625     ,default_prefix
626     ))
627    
628     opts.Add(PackageOption(
629     'MFGRAPH_CPPPATH'
630     ,"Where are your MFGRAPH include files?"
631     ,default_cpppath
632     ))
633    
634     opts.Add(PackageOption(
635     'MFGRAPH_LIBPATH'
636     ,"Where are your MFGRAPH libraries?"
637     ,default_libpath
638     ))
639    
640     opts.Add(BoolOption(
641     'WITH_MFGRAPH'
642 jpye 1326 ,"Link to the MFGRAPH library (if available, for generating incidence graphs)"
643 johnpye 1109 ,True
644     ))
645    
646 jpye 1326
647     #------ ufsparse --------
648     opts.Add(PackageOption(
649     'UFSPARSE_PREFIX'
650     ,"Where are your UFSPARSE files?"
651     ,default_prefix
652     ))
653    
654     opts.Add(PackageOption(
655     'UFSPARSE_CPPPATH'
656     ,"Where are your UFSPARSE include files?"
657     ,default_cpppath
658     ))
659    
660     opts.Add(PackageOption(
661     'UFSPARSE_LIBPATH'
662     ,"Where are your UFSPARSE libraries?"
663     ,default_libpath
664     ))
665    
666     opts.Add(BoolOption(
667     'WITH_UFSPARSE'
668     ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
669     ,True
670     ))
671    
672 johnpye 938 #-----------------------
673    
674 jpye 1557 opts.Add(BoolOption(
675     'UPDATE_NO_YACC_LEX'
676     ,"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)"
677     ,False
678     ))
679    
680 johnpye 563 opts.Add(
681     'DISTTAR_NAME'
682     ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
683     ,"ascend-"+version
684     )
685    
686 johnpye 656 opts.Add(
687     'RELEASE'
688     ,"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."
689     ,"0"
690     )
691    
692 johnpye 605 opts.Add(BoolOption(
693 johnpye 628 'ABSOLUTE_PATHS'
694 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."
695 johnpye 628 ,default_absolute_paths
696 johnpye 605 ))
697    
698 johnpye 578 opts.Add(
699     'WIN_INSTALLER_NAME'
700     ,"Name of the installer .exe to create under Windows (minus the '.exe')"
701 jpye 1467 ,"ascend-"+version+"-py"+pyversion+".exe"
702 johnpye 578 )
703    
704 johnpye 594 opts.Add(BoolOption(
705     'WITH_XTERM_COLORS'
706     ,"Set to 0 if you don't want xterm colour codes in the console output"
707     ,True
708     ))
709    
710 johnpye 761 opts.Add(BoolOption(
711     'WITH_EXTFNS'
712 jpye 1504 ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
713 johnpye 761 ,True
714     ))
715    
716 johnpye 816 opts.Add(BoolOption(
717     'WITH_SCROLLKEEPER'
718     ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
719     ,default_with_scrollkeeper
720     ))
721    
722 jpye 1557
723 johnpye 546 if platform.system()!="Windows":
724     opts.Add(BoolOption(
725     'WITH_GCCVISIBILITY'
726     , 'Whether to use GCC Visibility extensions when building with GCC 4.0'
727     , True
728     ))
729    
730 johnpye 832
731    
732 johnpye 392 # TODO: OTHER OPTIONS?
733     # TODO: flags for optimisation
734 johnpye 393 # TODO: turning on/off bintoken functionality
735 johnpye 427 # TODO: Where will the 'Makefile.bt' file be installed?
736 johnpye 393
737 johnpye 498 # Import the outside environment
738    
739 johnpye 800 def c_escape(str):
740     return re.sub("\\\\","/",str)
741    
742     envadditional={}
743 johnpye 740
744 jpye 1459 tools = ['lex','yacc','fortran','swig','nsis','substinfile','disttar']
745 johnpye 832 if platform.system()=="Windows":
746 johnpye 1078 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
747 johnpye 832 envenv = os.environ;
748 jpye 1459 tools += ['mingw']
749 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
750 johnpye 832 envadditional['IS_MINGW']=True
751     else:
752 johnpye 1082 print "Assuming VC++ build environment (Note: MinGW is preferred)"
753 johnpye 832 envenv = {
754     'PATH':os.environ['PATH']
755     ,'INCLUDE':os.environ['INCLUDE']
756     ,'LIB':os.environ['LIB']
757     ,'MSVS_IGNORE_IDE_PATHS':1
758     }
759 jpye 1459 tools += ['default']
760 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
761 johnpye 832 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
762 johnpye 498 else:
763 johnpye 832 if os.environ.get('TARGET')=='mingw':
764     envenv = os.environ
765 jpye 1459 tools += ['crossmingw']
766 jpye 1420 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
767     envadditional['LIBS']=['gcc']
768 johnpye 832 else:
769     envenv = os.environ
770 jpye 1459 tools += ['default']
771 johnpye 922 #TODO removed 'doxygen' for SCons 0.96.93
772 johnpye 800
773 johnpye 832
774 johnpye 800 env = Environment(
775     ENV=envenv
776     , toolpath=['scons']
777     , tools=tools
778     , **envadditional
779     )
780 johnpye 498
781 jpye 1420 #print "PATH =",os.environ['PATH']
782     #print "PROGSUFFIX =",env['PROGSUFFIX']
783     #print "CPPPATH =",env['CPPPATH']
784 jpye 1380
785 johnpye 385 opts.Update(env)
786 jpye 1520
787     if 'LSOD' in env['WITH_SOLVERS']:
788     if 'LSODE' not in env['WITH_SOLVERS']:
789     env['WITH_SOLVERS'].append('LSODE')
790     env['WITH_SOLVERS'].remove('LSOD')
791    
792 johnpye 385 opts.Save('options.cache',env)
793    
794     Help(opts.GenerateHelpText(env))
795    
796 johnpye 551 with_tcltk = env.get('WITH_TCLTK')
797 johnpye 427 without_tcltk_reason = "disabled by options/config.py"
798 johnpye 386
799 johnpye 551 with_python = env.get('WITH_PYTHON')
800 johnpye 427 without_python_reason = "disabled by options/config.py"
801 johnpye 387
802 johnpye 593 with_cunit = env.get('WITH_CUNIT')
803 johnpye 427 without_cunit_reason = "not requested"
804 johnpye 400
805 johnpye 761 with_extfns = env.get('WITH_EXTFNS')
806     without_extfn_reason = "disabled by options/config.py"
807    
808 johnpye 816 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
809     without_scrollkeeper_reason = "disabled by options/config.py"
810    
811 johnpye 938 with_dmalloc = env.get('WITH_DMALLOC')
812     without_dmalloc_reason = "disabled by options/config.py"
813    
814 johnpye 1109 with_mfgraph = env.get('WITH_MFGRAPH')
815     without_mfgraph_reason = "disabled by options/config.py"
816    
817 jpye 1326 with_ufsparse = env.get('WITH_UFSPARSE')
818     without_ufsparse_reason = "disabled by options/config.py"
819    
820 johnpye 993 with_mmio = env.get('WITH_MMIO')
821     without_mmio_reason = "disabled by options/config.py"
822    
823 johnpye 1142 with_signals = env.get('WITH_SIGNALS')
824     without_signals_reason = "disabled by options/config.py"
825    
826 jpye 1442 with_doc = env.get('WITH_DOC')
827    
828 jpye 1443 with_doc_build = env.get('WITH_DOC_BUILD');
829 jpye 1470 without_doc_build_reason = "disabled by options/config.py"
830 jpye 1443 if not with_doc:
831 jpye 1470 with_doc_build = False
832     without_doc_build_reason = "disabled by with_doc"
833 jpye 1443
834 jpye 1442 with_latex2html = False
835    
836 johnpye 631 if platform.system()=="Windows":
837     with_installer=1
838     else:
839     with_installer=0
840     without_installer_reason = "only possible under Windows"
841 jpye 1529
842 jpye 1509 if 'LSODE' in env['WITH_SOLVERS']:
843 johnpye 673 with_lsode=True
844     else:
845     with_lsode=False
846     without_lsode_reason = "not requested (WITH_SOLVERS)"
847    
848     if 'IDA' in env['WITH_SOLVERS']:
849     with_ida=True
850     else:
851     with_ida=False
852     without_ida_reason = "not requested (WITH_SOLVERS)"
853    
854    
855 johnpye 783 if 'CONOPT' in env['WITH_SOLVERS']:
856     with_conopt=True
857     else:
858     with_conopt=False
859     without_conopt_reason = "not requested (WITH_SOLVERS)"
860    
861 jpye 1529 if 'IPOPT' in env['WITH_SOLVERS']:
862     with_ipopt=True
863     else:
864     with_ipopt=False
865     without_ipopt_reason = "not requested (WITH_SOLVERS)"
866 johnpye 783
867 jpye 1529
868 johnpye 464 #print "SOLVERS:",env['WITH_SOLVERS']
869     #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
870     #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
871 johnpye 393
872 johnpye 463 can_install = True
873     if platform.system()=='Windows':
874     can_install = False
875    
876     env['CAN_INSTALL']=can_install
877 johnpye 721
878 jpye 1437 print "TCL=",env['TCL']
879 johnpye 521 print "TCL_CPPPATH =",env['TCL_CPPPATH']
880     print "TCL_LIBPATH =",env['TCL_LIBPATH']
881     print "TCL_LIB =",env['TCL_LIB']
882 johnpye 562 print "CC =",env['CC']
883     print "CXX =",env['CXX']
884 johnpye 673 print "FORTRAN=",env.get('FORTRAN')
885 johnpye 393
886 johnpye 628 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
887 jpye 1504 print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
888 jpye 1413 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
889 jpye 1504 print "INSTALL_MODELS =",env['INSTALL_MODELS']
890     print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
891     print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
892 jpye 1519 print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
893 jpye 1504
894    
895 johnpye 385 #------------------------------------------------------
896 johnpye 398 # SPECIAL CONFIGURATION TESTS
897    
898 johnpye 463 need_fortran = False
899    
900 johnpye 400 #----------------
901 jpye 1448 # CC
902    
903     cc_test_text = """
904     int main(void){
905     return 0;
906     }
907     """;
908    
909     def CheckCC(context):
910     context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
911     is_ok = context.TryCompile(cc_test_text,".c")
912     context.Result(is_ok)
913     return is_ok
914    
915     #----------------
916     # CXX
917    
918     cxx_test_text = """
919     template<class X>
920     class pair{
921     public:
922     X a;
923     X b;
924     };
925    
926     int main(void){
927     pair<double> P;
928     P.a = 0;
929     return 0;
930     }
931     """;
932    
933     def CheckCXX(context):
934     context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
935     is_ok = context.TryCompile(cc_test_text,".cpp")
936     context.Result(is_ok)
937     return is_ok
938    
939    
940    
941     #----------------
942 johnpye 400 # SWIG
943    
944 johnpye 398 import os,re
945    
946 johnpye 413 def get_swig_version(env):
947 johnpye 403 cmd = env['SWIG']+' -version'
948 johnpye 427 (cin,coutcerr) = os.popen4(cmd)
949 johnpye 403 output = coutcerr.read()
950 johnpye 398
951 johnpye 403 restr = "SWIG\\s+Version\\s+(?P<maj>[0-9]+)\\.(?P<min>[0-9]+)\\.(?P<pat>[0-9]+)\\s*$"
952     expr = re.compile(restr,re.M);
953 johnpye 398 m = expr.search(output);
954     if not m:
955 johnpye 413 return None
956 johnpye 398 maj = int(m.group('maj'))
957     min = int(m.group('min'))
958     pat = int(m.group('pat'))
959 johnpye 413
960     return (maj,min,pat)
961 johnpye 398
962 johnpye 413
963     def CheckSwigVersion(context):
964    
965     try:
966     context.Message("Checking version of SWIG... ")
967     maj,min,pat = get_swig_version(context.env)
968     except:
969     context.Result("Failed to detect version, or failed to run SWIG")
970     return 0;
971    
972 johnpye 478 context.env['SWIGVERSION']=tuple([maj,min,pat])
973    
974 johnpye 398 if maj == 1 and (
975 johnpye 400 min > 3
976     or (min == 3 and pat >= 24)
977 johnpye 398 ):
978     context.Result("ok, %d.%d.%d" % (maj,min,pat))
979     return 1;
980 johnpye 401 else:
981     context.Result("too old, %d.%d.%d" % (maj,min,pat))
982     return 0;
983 johnpye 398
984 johnpye 400 #----------------
985 johnpye 816 # Scrollkeeper (Linux documentation system)
986    
987     def get_scrollkeeper_omfdir(env):
988     cmd = 'scrollkeeper-config --omfdir'
989     (cin,coutcerr) = os.popen4(cmd)
990     output = coutcerr.read()
991     return output.strip()
992    
993     def CheckScrollkeeperConfig(context):
994     try:
995     context.Message("Checking for scrollkeeper...")
996     dir=get_scrollkeeper_omfdir(context.env)
997     except:
998     context.Result("Failed to run 'scrollkeeper-config'")
999     return 0
1000     context.env['OMFDIR']=dir
1001     context.Result("OK, %s" % dir)
1002     return 1
1003    
1004     #----------------
1005 johnpye 400 # General purpose library-and-header test
1006    
1007 johnpye 404 class KeepContext:
1008 johnpye 521 def __init__(self,context,varprefix,static=False):
1009 johnpye 404 self.keep = {}
1010 johnpye 521 for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
1011 johnpye 705 #print "Keeping env %s = %s" % (k,context.env.get(k))
1012     self.keep[k]=context.env.get(k)
1013 johnpye 404
1014     if context.env.has_key(varprefix+'_CPPPATH'):
1015 johnpye 743 context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
1016 johnpye 800 #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
1017 johnpye 428
1018 johnpye 521 if static:
1019     staticlib=env[varprefix+'_LIB']
1020     #print "STATIC LIB = ",staticlib
1021     context.env.Append(
1022     LINKFLAGS=[staticlib]
1023     )
1024     else:
1025     if context.env.has_key(varprefix+'_LIBPATH'):
1026     context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
1027 johnpye 800 #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
1028 johnpye 428
1029 johnpye 521 if context.env.has_key(varprefix+'_LIB'):
1030     context.env.Append(LIBS=[env[varprefix+'_LIB']])
1031 johnpye 705 #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"
1032 jpye 1547 elif context.env.has_key(varprefix+'_LIBS'):
1033     context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1034 johnpye 404
1035     def restore(self,context):
1036 johnpye 464 #print "RESTORING CONTEXT"
1037     #print self.keep
1038     #print "..."
1039 johnpye 404 for k in self.keep:
1040 johnpye 463 if self.keep[k]==None:
1041 johnpye 521 if context.env.has_key(k):
1042     #print "Clearing "+str(k)
1043     del context.env[k];
1044 johnpye 463 else:
1045 johnpye 705 #print "Restoring %s to '%s'" %(k,self.keep.get(k))
1046 johnpye 463 context.env[k]=self.keep[k];
1047 johnpye 404
1048 johnpye 521 def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):
1049 johnpye 400 """This method will check for variables LIBNAME_LIBPATH
1050     and LIBNAME_CPPPATH and try to compile and link the
1051     file with the provided text, linking with the
1052     library libname."""
1053    
1054 johnpye 521 if static:
1055     context.Message( 'Checking for static '+libname+'... ' )
1056     else:
1057     context.Message( 'Checking for '+libname+'... ' )
1058    
1059 johnpye 400 if varprefix==None:
1060     varprefix = libname.upper()
1061    
1062 johnpye 705 #print "LIBS is currently:",context.env.get('LIBS')
1063 johnpye 521 keep = KeepContext(context,varprefix,static)
1064 johnpye 400
1065 johnpye 428 if not context.env.has_key(varprefix+'_LIB'):
1066 johnpye 463 # if varprefix_LIB were in env, KeepContext would
1067     # have appended it already
1068 johnpye 705 context.env.Append(LIBS=[libname])
1069 johnpye 428
1070 johnpye 404 is_ok = context.TryLink(text,ext)
1071 johnpye 428
1072 johnpye 521 #print "Link success? ",(is_ok != 0)
1073 johnpye 400
1074 johnpye 405 keep.restore(context)
1075 johnpye 400
1076 johnpye 428 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
1077 johnpye 705 # print "Restored LIBS="+str(context.env['LIBS'])
1078 johnpye 428 # print "Restored LIBPATH="+str(context.env['LIBPATH'])
1079    
1080 johnpye 404 context.Result(is_ok)
1081     return is_ok
1082    
1083     #----------------
1084 johnpye 502 # GCC
1085    
1086     gcc_test_text = """
1087     #ifndef __GNUC__
1088     # error "Not using GCC"
1089     #endif
1090    
1091     int main(void){
1092     return __GNUC__;
1093     }
1094     """
1095    
1096     def CheckGcc(context):
1097     context.Message("Checking for GCC... ")
1098     is_ok = context.TryCompile(gcc_test_text,".c")
1099     context.Result(is_ok)
1100     return is_ok
1101    
1102     #----------------
1103 johnpye 500 # GCC VISIBILITY feature
1104    
1105     gccvisibility_test_text = """
1106     #if __GNUC__ < 4
1107     # error "Require GCC version 4 or newer"
1108     #endif
1109    
1110     __attribute__ ((visibility("default"))) int x;
1111    
1112     int main(void){
1113     extern int x;
1114     x = 4;
1115     }
1116     """
1117    
1118     def CheckGccVisibility(context):
1119     context.Message("Checking for GCC 'visibility' capability... ")
1120 johnpye 546 if not context.env.has_key('WITH_GCCVISIBILITY') or not env['WITH_GCCVISIBILITY']:
1121     context.Result("disabled")
1122     return 0
1123 johnpye 500 is_ok = context.TryCompile(gccvisibility_test_text,".c")
1124     context.Result(is_ok)
1125     return is_ok
1126 johnpye 502
1127 johnpye 500 #----------------
1128 johnpye 502 # YACC
1129    
1130     yacc_test_text = """
1131 johnpye 646 %{
1132     #include <stdio.h>
1133 johnpye 741
1134     /* MSVC++ needs this before it can swallow Bison output */
1135     #ifdef _MSC_VER
1136     # define __STDC__
1137     #endif
1138 johnpye 646 %}
1139     %token MSG
1140 johnpye 502 %start ROOT
1141 johnpye 646 %%
1142     ROOT:
1143     MSG { printf("HELLO"); }
1144     ;
1145     %%
1146 johnpye 502 """
1147    
1148     def CheckYacc(context):
1149 johnpye 644 context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
1150 johnpye 502 is_ok = context.TryCompile(yacc_test_text,".y")
1151     context.Result(is_ok)
1152     return is_ok
1153    
1154     #----------------
1155 johnpye 1025 # LEX
1156    
1157     lex_test_text = """
1158     %{
1159     #include <stdio.h>
1160     %}
1161     DIGIT [0-9]
1162     ID [a-z][a-z0-9]*
1163     %%
1164     {DIGIT}+ {
1165     printf("A digit: %s\\n",yytext);
1166     }
1167    
1168     [ \\t\\n]+ /* ignore */
1169    
1170     . {
1171     printf("Unrecognized guff");
1172     }
1173     %%
1174     main(){
1175     yylex();
1176     }
1177     """
1178    
1179     def CheckLex(context):
1180     context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1181     is_ok = context.TryCompile(lex_test_text,".l")
1182     context.Result(is_ok)
1183     return is_ok
1184    
1185     #----------------
1186 johnpye 404 # CUnit test
1187    
1188 johnpye 400 cunit_test_text = """
1189 johnpye 451 #include <CUnit/CUnit.h>
1190 johnpye 400 int maxi(int i1, int i2){
1191     return (i1 > i2) ? i1 : i2;
1192     }
1193    
1194     void test_maxi(void){
1195     CU_ASSERT(maxi(0,2) == 2);
1196     CU_ASSERT(maxi(0,-2) == 0);
1197     CU_ASSERT(maxi(2,2) == 2);
1198    
1199     }
1200     int main(void){
1201     /* CU_initialize_registry() */
1202 johnpye 404 return 0;
1203 johnpye 400 }
1204     """
1205    
1206     def CheckCUnit(context):
1207 johnpye 451 return CheckExtLib(context,'cunit',cunit_test_text)
1208 johnpye 400
1209 johnpye 404 #----------------
1210 johnpye 938 # dmalloc test
1211    
1212     dmalloc_test_text = """
1213     #include <stdlib.h>
1214     #include <dmalloc.h>
1215    
1216     int main(void){
1217     char *c;
1218     c = malloc(100*sizeof(char));
1219     free(c);
1220     return 0;
1221     }
1222     """
1223    
1224     def CheckDMalloc(context):
1225     return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1226    
1227     #----------------
1228 johnpye 1109 # mfgraph test
1229    
1230     mfgraph_test_text = """
1231     #include <mfgraph/mfg_draw_graph.h>
1232     int main(void){
1233     using namespace mfg;
1234     DrawGraph g;
1235     return 0;
1236     }
1237     """
1238    
1239     def CheckMFGraph(context):
1240     return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")
1241    
1242     #----------------
1243 jpye 1326 # ufsparse test
1244    
1245     ufsparse_test_text = """
1246     #include <ufsparse/cs.h>
1247     int main(void){
1248     cs *A,*B,*C;
1249     C = cs_multiply(A,B);
1250     return 0;
1251     }
1252     """
1253    
1254     def CheckUFSparse(context):
1255     return CheckExtLib(context
1256     ,libname='cxsparse'
1257     ,varprefix='ufsparse'
1258     ,text=ufsparse_test_text
1259     ,ext=".c"
1260     )
1261    
1262     #----------------
1263 johnpye 673 # MATH test
1264    
1265     math_test_text = """
1266 johnpye 705 #ifndef _ALL_SOURCE
1267     # define _ALL_SOURCE
1268     #endif
1269     #ifndef _XOPEN_SOURCE
1270     # define _XOPEN_SOURCE
1271     #endif
1272     #ifndef _XOPEN_SOURCE_EXTENDED
1273     # define _XOPEN_SOURCE_EXTENDED 1
1274     #endif
1275 johnpye 673 #include <math.h>
1276     int main(void){
1277 johnpye 705 double x = 1.0; double y = 1.0; int i = 1;
1278     acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1279     j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1280     y0(x); y1(x); yn(i,x);
1281 jpye 1420 /* this part causes problems with crossmingw... */
1282 johnpye 705 #ifdef _THREAD_SAFE
1283     gamma_r(x,&i);
1284     lgamma_r(x,&i);
1285     #else
1286     gamma(x);
1287     lgamma(x);
1288     #endif
1289     hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
1290 johnpye 673 return 0;
1291     }
1292     """
1293    
1294     def CheckMath(context):
1295 johnpye 832 context.Message('Checking for IEEE math library... ')
1296 johnpye 705 libsave=context.env.get('LIBS');
1297     context.env.AppendUnique(LIBS=['m'])
1298     is_ok=context.TryLink(math_test_text,".c")
1299     context.Result(is_ok)
1300     if not is_ok:
1301     context.env['LIBS']=libsave
1302     return is_ok
1303    
1304 johnpye 673 #----------------
1305 johnpye 957 # libpython test
1306    
1307     libpython_test_text = """
1308     #include <Python.h>
1309     int main(void){
1310     PyObject *p;
1311     p = Py_None;
1312     return 0;
1313     }
1314     """
1315    
1316     def CheckPythonLib(context):
1317     context.Message('Checking for libpython... ')
1318    
1319     if platform.system()=="Windows":
1320     python_lib='python%d%d'
1321     else:
1322     python_lib='python%d.%d'
1323 johnpye 958 python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1324 johnpye 957
1325     python_cpppath = [distutils.sysconfig.get_python_inc()]
1326     cfig = distutils.sysconfig.get_config_vars()
1327    
1328     lastLIBS = context.env.get('LIBS')
1329     lastLIBPATH = context.env.get('LIBPATH')
1330     lastCPPPATH = context.env.get('CPPPATH')
1331 johnpye 959 lastLINKFLAGS = context.env.get('LINKFLAGS')
1332 johnpye 957
1333     python_libpath = []
1334 johnpye 959 python_linkflags = []
1335 johnpye 965 if platform.system()=="Windows":
1336 jpye 1551 python_libpath += [os.path.join(sys.prefix,"libs")]
1337 johnpye 965 else:
1338     # checked on Linux and SunOS
1339     if cfig['LDLIBRARY']==cfig['LIBRARY']:
1340     sys.stdout.write("(static)")
1341     python_libpath += [cfig['LIBPL']]
1342     python_linkflags += cfig['LIBS'].split(' ')
1343 johnpye 957
1344 johnpye 958 context.env.AppendUnique(LIBS=python_libs)
1345 johnpye 957 context.env.AppendUnique(LIBPATH=python_libpath)
1346     context.env.AppendUnique(CPPPATH=python_cpppath)
1347 johnpye 959 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1348 johnpye 957 result = context.TryLink(libpython_test_text,".c");
1349    
1350 johnpye 958 context.Result(result)
1351 johnpye 957
1352     if(result):
1353 johnpye 958 context.env['PYTHON_LIBPATH']=python_libpath
1354     context.env['PYTHON_LIB']=python_libs
1355     context.env['PYTHON_CPPPATH']=python_cpppath
1356 johnpye 959 context.env['PYTHON_LINKFLAGS']=python_linkflags
1357 johnpye 957
1358     context.env['LIBS'] = lastLIBS
1359     context.env['LIBPATH'] = lastLIBPATH
1360     context.env['CPPPATH'] = lastCPPPATH
1361 johnpye 959 context.env['LINKFLAGS'] = lastLINKFLAGS
1362 johnpye 957
1363     return result
1364    
1365     #----------------
1366 johnpye 673 # IDA test
1367    
1368 johnpye 913 sundials_version_major_required = 2
1369     sundials_version_minor_min = 2
1370     sundials_version_minor_max = 3
1371    
1372     sundials_version_text = """
1373     #include <sundials/sundials_config.h>
1374     #include <stdio.h>
1375     int main(){
1376     printf("%s",SUNDIALS_PACKAGE_VERSION);
1377     return 0;
1378     }
1379     """
1380    
1381 johnpye 673 ida_test_text = """
1382 jpye 1400 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1383     # include <sundials/sundials_config.h>
1384     # include <sundials/sundials_nvector.h>
1385 jpye 1405 # include <nvector_serial.h>
1386 jpye 1400 # include <ida.h>
1387     # include <ida/ida_spgmr.h>
1388     #else
1389     # include <sundials/sundials_config.h>
1390     # include <nvector/nvector_serial.h>
1391 johnpye 907 # include <ida/ida.h>
1392 jpye 1400 #endif
1393 johnpye 673 int main(){
1394     void *ida_mem;
1395     ida_mem = IDACreate();
1396 johnpye 782 return 0;
1397 johnpye 673 }
1398     """
1399    
1400 johnpye 913 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1401     # so detect the version and act accordingly.
1402 jpye 1400 def CheckSUNDIALS(context):
1403     keep = KeepContext(context,'SUNDIALS')
1404 jpye 1402 context.Message("Checking for SUNDIALS... ")
1405 johnpye 913 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1406     keep.restore(context)
1407     if not is_ok:
1408 jpye 1402 context.Result(0)
1409 johnpye 913 return 0
1410    
1411     major,minor,patch = tuple([int(i) for i in output.split(".")])
1412     context.env['SUNDIALS_VERSION_MAJOR'] = major
1413     context.env['SUNDIALS_VERSION_MINOR'] = minor
1414     if major != sundials_version_major_required \
1415     or minor < sundials_version_minor_min \
1416     or minor > sundials_version_minor_max:
1417     context.Result(output+" (bad version)")
1418     # bad version
1419     return 0
1420    
1421     # good version
1422 johnpye 1086 context.Result("%d.%d.%d, good" % (major,minor,patch))
1423 jpye 1400
1424 johnpye 913 return 1
1425    
1426 jpye 1400
1427     def CheckIDA(context):
1428 jpye 1402 context.Message( 'Checking for IDA... ' )
1429 jpye 1400
1430 jpye 1404 keep = KeepContext(context,"SUNDIALS")
1431 jpye 1400
1432     major = context.env['SUNDIALS_VERSION_MAJOR']
1433     minor = context.env['SUNDIALS_VERSION_MINOR']
1434    
1435 jpye 1404 cppdef = context.env.get('CPPDEFINES')
1436    
1437     context.env.Append(CPPDEFINES=[
1438     ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1439     ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1440     ])
1441    
1442     context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1443     if major==2 and minor==2:
1444     context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1445    
1446 jpye 1400 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1447 jpye 1404 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1448     context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1449 jpye 1400
1450     is_ok = context.TryLink(ida_test_text,".c")
1451     context.Result(is_ok)
1452    
1453 jpye 1404 if cppdef:
1454     context.env['CPPDEFINES']=cppdef
1455 jpye 1552 else:
1456     del context.env['CPPDEFINES']
1457    
1458 jpye 1400 keep.restore(context)
1459    
1460     return is_ok
1461    
1462    
1463 johnpye 673 #----------------
1464 johnpye 783 # CONOPT test
1465    
1466     conopt_test_text = """
1467 johnpye 800 #if !defined(_WIN32)
1468     # define FNAME_LCASE_DECOR
1469     #endif
1470    
1471 johnpye 783 #include <conopt.h>
1472     #include <stdlib.h>
1473     int main(){
1474     int s, *v, e;
1475     s = COIDEF_Size();
1476     v = (int *)malloc(s*sizeof(int));
1477     e = COIDEF_Ini(v);
1478     return e;
1479     }
1480     """
1481    
1482     def CheckCONOPT(context):
1483     context.Message( 'Checking for CONOPT... ' )
1484    
1485     keep = KeepContext(context,"CONOPT")
1486    
1487     is_ok = context.TryLink(conopt_test_text,".c")
1488     context.Result(is_ok)
1489    
1490     keep.restore(context)
1491    
1492     return is_ok
1493    
1494     #----------------
1495 jpye 1529 # IPOPT test
1496    
1497     ipopt_test_text = """
1498     #if !defined(_WIN32)
1499     # define FNAME_LCASE_DECOR
1500     #endif
1501    
1502     #include <ipopt/IpStdCInterface.h>
1503     int main(){
1504     Number n;
1505 jpye 1546 IpoptProblem nlp = 0;
1506 jpye 1529 FreeIpoptProblem(nlp); // probably a crash if you run this
1507     return 0;
1508     }
1509     """
1510    
1511     def CheckIPOPT(context):
1512     context.Message( 'Checking for IPOPT... ' )
1513    
1514     keep = KeepContext(context,"IPOPT")
1515     is_ok = context.TryLink(ipopt_test_text,".c")
1516     context.Result(is_ok)
1517    
1518     keep.restore(context)
1519    
1520     return is_ok
1521    
1522     #----------------
1523 johnpye 405 # Tcl test
1524 johnpye 404
1525 johnpye 561 # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:
1526     tcltk_minor_newest_acceptable = 4
1527     tcltk_major_required = 8
1528    
1529 johnpye 404 tcl_check_text = r"""
1530     #include <tcl.h>
1531     #include <stdio.h>
1532     int main(void){
1533     printf("%s",TCL_PATCH_LEVEL);
1534     return 0;
1535     }
1536     """
1537    
1538     def CheckTcl(context):
1539 johnpye 521 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1540 johnpye 405
1541     def CheckTclVersion(context):
1542 johnpye 521 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1543 johnpye 405 context.Message("Checking Tcl version... ")
1544     (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1545 johnpye 404 keep.restore(context)
1546     if not is_ok:
1547 johnpye 405 context.Result("failed to run check")
1548 johnpye 404 return 0
1549 johnpye 405
1550 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1551 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1552 johnpye 428 context.Result(output+" (bad version)")
1553 johnpye 405 # bad version
1554     return 0
1555    
1556     # good version
1557 johnpye 552 context.Result(output+", good")
1558 johnpye 404 return 1
1559    
1560 johnpye 405 #----------------
1561 johnpye 463 # Tk test
1562 johnpye 405
1563     tk_check_text = r"""
1564     #include <tk.h>
1565     #include <stdio.h>
1566     int main(void){
1567     printf("%s",TK_PATCH_LEVEL);
1568     return 0;
1569     }
1570     """
1571     def CheckTk(context):
1572 johnpye 673 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1573 johnpye 405
1574 johnpye 428
1575 johnpye 405 def CheckTkVersion(context):
1576 johnpye 521 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1577 johnpye 405 context.Message("Checking Tk version... ")
1578 johnpye 521 #print "LINKFLAGS =",context.env['LINKFLAGS']
1579 johnpye 405 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1580 johnpye 404 keep.restore(context)
1581     if not is_ok:
1582     context.Result("failed to run check")
1583     return 0
1584    
1585 wangym 511 major,minor,patch = tuple([int(i) for i in output.split(".")])
1586 johnpye 561 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1587 johnpye 404 # bad version
1588 johnpye 561 context.Result(output+" (bad version)")
1589 johnpye 404 return 0
1590 johnpye 400
1591 johnpye 404 # good version
1592 johnpye 561 context.Result(output+" (good)")
1593 johnpye 404 return 1
1594 johnpye 485
1595     #----------------
1596 johnpye 521 # Tktable test
1597    
1598     tktable_check_text = r"""
1599     #include <tkTable.h>
1600     #include <stdio.h>
1601     int main(void){
1602     Table mytable;
1603     return 0;
1604     }
1605     """
1606    
1607     def CheckTkTable(context):
1608     return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1609    
1610     #---------------
1611     # X11 test
1612    
1613     x11_check_text = r"""
1614     #include <X11/Xlib.h>
1615     #include <X11/IntrinsicP.h>
1616     #include <X11/Intrinsic.h>
1617     #include <X11/ObjectP.h>
1618     #include <X11/Object.h>
1619     int main(void){
1620     Object mything;
1621     return 0;
1622     }
1623     """
1624    
1625     def CheckX11(context):
1626     return CheckExtLib(context,'X11',x11_check_text)
1627    
1628     #----------------
1629 johnpye 968 # Check that we can raise and catch sigint
1630    
1631     sigint_test_text = r"""
1632     #include <signal.h>
1633     #include <setjmp.h>
1634     #include <stdlib.h>
1635     static jmp_buf g_jmpenv;
1636     void sighandler(int sig){
1637     longjmp(g_jmpenv,sig);
1638     }
1639     void testsigint(){
1640     raise(SIGINT);
1641     }
1642     int main(void){
1643     signal(SIGINT,&sighandler);
1644     switch(setjmp(g_jmpenv)){
1645     case 0:
1646     testsigint();
1647     exit(1);
1648     case SIGINT:
1649     exit(0);
1650     default:
1651     exit(2);
1652     }
1653     }
1654     """
1655    
1656     def CheckSIGINT(context):
1657     context.Message("Checking SIGINT is catchable... ")
1658     (is_ok,output)=context.TryRun(sigint_test_text,".c")
1659     context.Result(is_ok)
1660     return is_ok
1661    
1662     #----------------
1663 johnpye 953 # Check that we're able to catch floating point errors
1664    
1665     sigfpe_test_text = r"""
1666     #include <signal.h>
1667     #include <setjmp.h>
1668     #include <stdlib.h>
1669     #include <fenv.h>
1670     static jmp_buf g_jmpenv;
1671     void fpehandler(int sig){
1672     longjmp(g_jmpenv,sig);
1673     }
1674     int main(void){
1675     fenv_t myfenv;
1676     fegetenv(&myfenv);
1677     fesetenv(&myfenv);
1678     feenableexcept(FE_ALL_EXCEPT);
1679     signal(SIGFPE,&fpehandler);
1680     double x;
1681     switch(setjmp(g_jmpenv)){
1682     case 0:
1683     x = 1.0 / 0.0;
1684     /* failed to catch */
1685     exit(1);
1686     case SIGFPE:
1687     exit(0);
1688     }
1689     }
1690     """
1691    
1692     def CheckFPE(context):
1693 johnpye 968 context.Message("Checking C99 FPE behaviour... ")
1694 johnpye 953 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1695     context.Result(is_ok)
1696     return is_ok
1697    
1698     #----------------
1699 johnpye 968 # signal reset needed?
1700    
1701     sigreset_test_text = r"""
1702     #include <signal.h>
1703     #include <setjmp.h>
1704     #include <stdlib.h>
1705     #include <stdio.h>
1706     typedef void SigHandlerFn(int);
1707     static jmp_buf g_jmpenv;
1708     void sighandler(int sig){
1709     longjmp(g_jmpenv,sig);
1710     }
1711     void testsigint(){
1712 johnpye 1002 /* fprintf(stderr,"Raising SIGINT\n"); */
1713 johnpye 968 raise(SIGINT);
1714     }
1715     int main(void){
1716     SigHandlerFn *last,*saved;
1717     saved = signal(SIGINT,&sighandler);
1718     if(saved!=SIG_DFL){
1719 johnpye 1002 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1720 johnpye 968 exit(3);
1721     }
1722     switch(setjmp(g_jmpenv)){
1723     case 0:
1724     testsigint();
1725     fprintf(stderr,"Back from SIGINT\n");
1726     exit(1);
1727     case SIGINT:
1728     break;
1729     default:
1730     exit(2);
1731     };
1732 johnpye 1002 last = signal(SIGINT,SIG_DFL);
1733 johnpye 968 if(last!=&sighandler){
1734     printf("1");
1735     exit(0);
1736     }
1737     printf("0");
1738     exit(0);
1739     }
1740     """
1741    
1742     def CheckSigReset(context):
1743     context.Message("Checking signal handler reset... ")
1744     (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1745     if not is_ok:
1746     context.Result("ERROR")
1747 johnpye 1260 return False
1748 johnpye 1002 if int(output)==1:
1749 johnpye 968 context.Result("required");
1750     context.env['ASC_RESETNEEDED'] = True
1751     else:
1752     context.Result("not required");
1753     context.env['ASC_RESETNEEDED'] = False
1754     return is_ok
1755    
1756     #----------------
1757 jpye 1442 # LyX on this system?
1758    
1759     def CheckLyx(context):
1760     context.Message("Checking for LyX... ")
1761     r = context.env.WhereIs("lyx")
1762 jpye 1469 if r:
1763     context.Result(r)
1764     else:
1765     context.Result(0)
1766 jpye 1442 return r
1767    
1768     #----------------
1769     # Latex2HTML on this system?
1770    
1771     def CheckLatex2HTML(context):
1772     context.Message("Checking for latex2html...")
1773     if context.env.WhereIs("latex2html"):
1774     r = True
1775     else:
1776     r = False
1777     context.Result(r)
1778     return r
1779    
1780     #----------------
1781 johnpye 485 # GCC Version sniffing
1782    
1783     # TODO FIXME
1784    
1785     gcc_version4 = False
1786    
1787 johnpye 398 #------------------------------------------------------
1788 johnpye 385 # CONFIGURATION
1789    
1790     conf = Configure(env
1791     , custom_tests = {
1792 jpye 1448 'CheckCC' : CheckCC
1793     , 'CheckCXX' : CheckCXX
1794     , 'CheckMath' : CheckMath
1795 johnpye 673 , 'CheckSwigVersion' : CheckSwigVersion
1796 johnpye 957 , 'CheckPythonLib' : CheckPythonLib
1797 johnpye 400 , 'CheckCUnit' : CheckCUnit
1798 johnpye 938 , 'CheckDMalloc' : CheckDMalloc
1799 jpye 1442 , 'CheckLyx' : CheckLyx
1800     , 'CheckLatex2HTML' : CheckLatex2HTML
1801 johnpye 1109 , 'CheckMFGraph' : CheckMFGraph
1802 jpye 1326 , 'CheckUFSparse' : CheckUFSparse
1803 johnpye 404 , 'CheckTcl' : CheckTcl
1804     , 'CheckTclVersion' : CheckTclVersion
1805 johnpye 405 , 'CheckTk' : CheckTk
1806     , 'CheckTkVersion' : CheckTkVersion
1807 johnpye 502 , 'CheckGcc' : CheckGcc
1808 johnpye 500 , 'CheckGccVisibility' : CheckGccVisibility
1809 johnpye 502 , 'CheckYacc' : CheckYacc
1810 johnpye 1025 , 'CheckLex' : CheckLex
1811 johnpye 521 , 'CheckTkTable' : CheckTkTable
1812     , 'CheckX11' : CheckX11
1813 johnpye 673 , 'CheckIDA' : CheckIDA
1814 jpye 1400 , 'CheckSUNDIALS' : CheckSUNDIALS
1815 johnpye 783 , 'CheckCONOPT' : CheckCONOPT
1816 jpye 1529 , 'CheckIPOPT' : CheckIPOPT
1817 johnpye 816 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1818 johnpye 953 , 'CheckFPE' : CheckFPE
1819 johnpye 968 , 'CheckSIGINT' : CheckSIGINT
1820     , 'CheckSigReset' : CheckSigReset
1821 johnpye 400 # , 'CheckIsNan' : CheckIsNan
1822     # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1823 johnpye 385 }
1824 johnpye 459 # , config_h = "config.h"
1825 johnpye 385 )
1826    
1827 jpye 1357 def sconsversioncheck():
1828    
1829     # uncomment the following line to skip the version check:
1830     # return 1
1831    
1832     import SCons
1833     v = SCons.__version__.split(".")
1834     if v[0] != '0':
1835     return 0
1836 jpye 1431 if int(v[1]) >= 97:
1837     return 1
1838 jpye 1357 if v[1] != '96':
1839     return 0
1840     micro = int(v[2])
1841 jpye 1394 if micro == 92 or micro == 93 or micro == 96:
1842 jpye 1357 return 1;
1843     return 0
1844    
1845     if not sconsversioncheck():
1846     print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
1847     print "or consult the developers in the case of newer versions. Modify"
1848     print "the function 'sconsversioncheck' in the file SConstruct if you"
1849     print "want to *force* SCons to continue."
1850     Exit(1)
1851    
1852 jpye 1448 # check C compiler
1853    
1854     if not conf.CheckCC():
1855     print "Failed to build simple test file with your C compiler."
1856     print "Check your compiler is installed and running correctly."
1857     Exit(1)
1858    
1859     if not conf.CheckCXX():
1860     print "Failed to build simple test file with your C++ compiler."
1861     print "Check your compiler is installed and running correctly."
1862     Exit(1)
1863    
1864 johnpye 740 # stdio -- just to check that compiler is behaving
1865 johnpye 398
1866 johnpye 740 if not conf.CheckHeader('stdio.h'):
1867 johnpye 832 print "CPPPATH =",env.get('CPPPATH')
1868 johnpye 740 print "Did not find 'stdio.h'! Check your compiler configuration."
1869 johnpye 1080 print ""
1870     print "You environment is printed here:"
1871     for k,v in os.environ.iteritems():
1872     print "%-30s%s" % ("%s :" % k, v)
1873 johnpye 740 Exit(1)
1874    
1875 johnpye 1228 if not conf.CheckFunc('snprintf'):
1876     print "Didn't find snprintf";
1877     exit(1)
1878    
1879 johnpye 385 # Math library
1880    
1881 johnpye 1262 conf.env['HAVE_IEEE']=True
1882    
1883     if need_libm and not conf.CheckMath():
1884 johnpye 1232 conf.env['HAVE_IEEE']=False
1885 johnpye 1262 print 'Did not find math library, exiting!'
1886     Exit(1)
1887 johnpye 427
1888 johnpye 385 # Where is 'isnan'?
1889    
1890 johnpye 740 if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1891 johnpye 385 print "Didn't find isnan"
1892 johnpye 414 # Exit(1)
1893 johnpye 385
1894 johnpye 500 # GCC visibility
1895    
1896 johnpye 502 if conf.CheckGcc():
1897     conf.env['HAVE_GCC']=True;
1898 johnpye 526 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
1899 johnpye 509 conf.env['HAVE_GCCVISIBILITY']=True;
1900     conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1901     conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1902 johnpye 709 conf.env.Append(CCFLAGS=['-Wall'])
1903 johnpye 500
1904 johnpye 968 # Catching SIGINT
1905    
1906 johnpye 1142 if env['WITH_SIGNALS']:
1907     if not conf.CheckSIGINT():
1908     with_signals = False
1909     without_signals_reason = "SIGINT uncatchable"
1910 johnpye 968
1911 johnpye 953 # Catching SIGFPE
1912    
1913     if conf.CheckFPE():
1914 johnpye 968 conf.env['HAVE_C99FPE']=True
1915 johnpye 953 else:
1916 johnpye 968 conf.env['HAVE_C99FPE']=False
1917 johnpye 953
1918 johnpye 968 # Checking for signal reset requirement
1919    
1920     if not conf.CheckSigReset():
1921     print "Unable to determine if signal reset is required"
1922 johnpye 1260 Exit(1)
1923 johnpye 968
1924 johnpye 502 # YACC
1925    
1926 jpye 1552 if conf.CheckYacc():
1927 johnpye 502 conf.env['HAVE_YACC']=True
1928    
1929 jpye 1552 if conf.CheckLex():
1930 johnpye 1025 conf.env['HAVE_LEX']=True
1931 johnpye 502
1932 johnpye 387 # Tcl/Tk
1933 johnpye 386
1934 johnpye 586 if with_tcltk:
1935     if conf.CheckTcl():
1936     if conf.CheckTclVersion():
1937     if conf.CheckTk():
1938     if with_tcltk and conf.CheckTkVersion():
1939     if env['STATIC_TCLTK']:
1940     if conf.CheckTkTable():
1941     pass
1942     else:
1943     without_tcltk_reason = "TkTable not found"
1944     with_tcltk = False
1945     else:
1946     without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
1947     with_tcltk = False
1948 johnpye 521 else:
1949 johnpye 586 without_tcltk_reason = "Tk not found."
1950 johnpye 551 with_tcltk = False
1951 johnpye 428 else:
1952 johnpye 586 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
1953 johnpye 551 with_tcltk = False
1954 johnpye 586
1955 johnpye 428 else:
1956 johnpye 586 without_tcltk_reason = "Tcl not found."
1957 johnpye 551 with_tcltk = False
1958 johnpye 386
1959 johnpye 521 if env['STATIC_TCLTK']:
1960     conf.CheckX11()
1961    
1962 johnpye 395 # Python... obviously we're already running python, so we just need to
1963     # check that we can link to the python library OK:
1964    
1965 johnpye 957 if not conf.CheckPythonLib():
1966     without_python_reason = 'libpython2.x not found or not linkable'
1967     with_python = False
1968 johnpye 982 env['WITH_PYTHON']=False
1969 johnpye 391
1970 johnpye 395 # SWIG version
1971    
1972 johnpye 957 if with_python and not conf.CheckSwigVersion():
1973 johnpye 413 without_python_reason = 'SWIG >= 1.3.24 is required'
1974     with_python = False
1975 johnpye 982 env['WITH_PYTHON']=False
1976 johnpye 413
1977 johnpye 400 # CUnit
1978    
1979 johnpye 593 if with_cunit:
1980 johnpye 404 if not conf.CheckCUnit():
1981 johnpye 427 without_cunit_reason = 'CUnit not found'
1982 johnpye 665 with_cunit = False
1983 johnpye 705 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1984 johnpye 427
1985 johnpye 938 # DMALLOC
1986    
1987     if with_dmalloc:
1988     if not conf.CheckDMalloc():
1989     without_dmalloc_reason = 'dmalloc not found'
1990     with_dmalloc = False
1991    
1992 jpye 1326 # MFGRAPH
1993 johnpye 1109
1994     if with_mfgraph:
1995     if not conf.CheckMFGraph():
1996     without_mfgraph_reason = 'mfgraph not found'
1997 johnpye 1113 with_mfgraph = False
1998 johnpye 1114 env['WITH_MFGRAPH'] = False
1999 johnpye 1109
2000 jpye 1326 # UFSPARSE
2001    
2002     if with_ufsparse:
2003     if not conf.CheckUFSparse():
2004     without_ufsparse_reason = 'mfgraph not found'
2005     with_ufsparse = False
2006     env['WITH_UFSPARSE'] = False
2007    
2008 johnpye 673 # IDA
2009    
2010     if not with_ida:
2011     without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
2012 jpye 1400 elif not conf.CheckSUNDIALS():
2013     with_ida = False
2014     without_ida_reason = "SUNDIALS not found, or bad version"
2015 johnpye 673 elif not conf.CheckIDA():
2016     with_ida = False
2017 jpye 1400 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2018 johnpye 673
2019 johnpye 797 # CONOPT
2020 johnpye 783
2021     if not with_conopt:
2022     without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2023     elif not conf.CheckCONOPT():
2024 jpye 1541 if conf.env.get('CONOPT_LINKED'):
2025     conf.env['CONOPT_LINKED'] = False
2026     # we no longer require CONOPT at buildtime in order to build support for it
2027     #with_conopt = False
2028     #without_conpt_reason = "CONOPT not found"
2029 johnpye 783
2030 jpye 1529 # IPOPT
2031    
2032     if not with_ipopt:
2033     without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2034     elif not conf.CheckIPOPT():
2035     with_ipopt = False
2036     without_ipopt_reason = "IPOPT not found"
2037    
2038 johnpye 427 # BLAS
2039    
2040 johnpye 459 need_blas=False
2041 johnpye 673
2042     if with_lsode:
2043     need_fortran = True
2044 johnpye 459 need_blas=True
2045 johnpye 673
2046 johnpye 459 if need_blas:
2047     if conf.CheckLib('blas'):
2048     with_local_blas = False
2049     without_local_blas_reason = "Found BLAS installed on system"
2050     else:
2051     with_local_blas = True
2052     need_fortran = True
2053 johnpye 673 else:
2054     with_local_blas= False;
2055     without_local_blas_reason = "BLAS not required"
2056 johnpye 427
2057     # FORTRAN
2058    
2059     if need_fortran:
2060 johnpye 629 conf.env.Tool('fortran')
2061 jpye 1380 detect_fortran = conf.env.Detect(['gfortran','g77'])
2062 johnpye 427 if detect_fortran:
2063     # For some reason, g77 doesn't get detected properly on MinGW
2064 johnpye 673 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2065 jpye 1357 print "Fixing detection of F77 on MinGW...(?)"
2066 johnpye 427 conf.env.Replace(F77=detect_fortran)
2067     conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2068     conf.env.Replace(F77FLAGS='')
2069 johnpye 428 #print "F77:",conf.env['F77']
2070     #print "F77COM:",conf.env['F77COM']
2071     #print "F77FLAGS:",conf.env['F77FLAGS']
2072 johnpye 427 fortran_builder = Builder(
2073     action='$F77COM'
2074     , suffix='.o'
2075     , src_suffix='.f'
2076     )
2077     conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2078 johnpye 1284 if platform.system()=="Linux":
2079     conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2080 johnpye 427 else:
2081 johnpye 673 with_lsode=False;
2082     without_lsode_reason="FORTRAN-77 required but not found"
2083 johnpye 629
2084 johnpye 464 #else:
2085     # print "FORTRAN not required"
2086 johnpye 400
2087 johnpye 673 # F2C
2088    
2089     if need_fortran:
2090     if platform.system()=="Windows":
2091 jpye 1380 pass
2092     #conf.env.Append(LIBPATH='c:\mingw\lib')
2093 johnpye 673
2094 johnpye 816 # scrollkeeper
2095 johnpye 673
2096 johnpye 816 if with_scrollkeeper:
2097     if not conf.CheckScrollkeeperConfig():
2098     with_scrollkeeper=False
2099     without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2100    
2101 jpye 1442 # lyx
2102    
2103 jpye 1470 if with_doc_build:
2104 jpye 1442 if not conf.CheckLyx():
2105 jpye 1470 with_doc_build = False
2106     without_doc_build_reason="unable to locate lyx"
2107 jpye 1442
2108     with_latext2html = conf.CheckLatex2HTML()
2109    
2110 johnpye 385 # TODO: -D_HPUX_SOURCE is needed
2111    
2112     # TODO: check size of void*
2113    
2114 johnpye 393 # TODO: detect if dynamic libraries are possible or not
2115    
2116 johnpye 427 if platform.system()=="Windows" and env.has_key('MSVS'):
2117 johnpye 740 _found_windows_h = conf.CheckHeader('Windows.h')
2118    
2119     if not _found_windows_h:
2120 johnpye 741 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2121 johnpye 740 Exit(1)
2122 johnpye 741
2123 johnpye 534 if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
2124 johnpye 427 with_python = 0;
2125     without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2126    
2127 johnpye 395 conf.Finish()
2128    
2129 johnpye 507 #---------------------------------------
2130     # SUBSTITUTION DICTIONARY for .in files
2131    
2132 johnpye 658 release = env.get('RELEASE')
2133     if release=="0.":
2134     release="0"
2135    
2136 johnpye 800 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2137    
2138 johnpye 507 subst_dict = {
2139     '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2140 jpye 1519 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2141 johnpye 507 , '@GLADE_FILE@':'ascend.glade'
2142     , '@HELP_ROOT@':''
2143     , '@ICON_EXTENSION@':icon_extension
2144 johnpye 628 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2145 johnpye 507 , '@INSTALL_BIN@':env['INSTALL_BIN']
2146     , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2147 johnpye 683 , '@INSTALL_LIB@':env['INSTALL_LIB']
2148 johnpye 721 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2149 jpye 1504 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2150 johnpye 507 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2151     , '@VERSION@':version
2152 johnpye 658 , '@RELEASE@':release
2153 johnpye 563 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2154 johnpye 507 , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
2155 johnpye 1228 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2156     , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2157 johnpye 589 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2158 johnpye 627 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2159 johnpye 683 , '@PYTHON@' : python_exe
2160 jpye 1466 , '@PYVERSION@' : pyversion
2161 johnpye 800 , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2162     , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2163 jpye 1399 , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2164 johnpye 1174 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2165 jpye 1535 , '@WITH_SOLVERS@':",".join(env.get('WITH_SOLVERS'))
2166 johnpye 507 }
2167    
2168 jpye 1442 if env.get('WITH_DOC'):
2169     print "WITH_DOC:",env['WITH_DOC']
2170     subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2171 johnpye 507
2172 johnpye 597 # bool options...
2173 johnpye 673 for k,v in {
2174 johnpye 1142 'ASC_WITH_IDA':with_ida
2175     ,'ASC_WITH_DMALLOC':with_dmalloc
2176     ,'ASC_WITH_MFGRAPH':with_mfgraph
2177 jpye 1326 ,'ASC_WITH_UFSPARSE':with_ufsparse
2178 johnpye 1142 ,'ASC_WITH_CONOPT':with_conopt
2179 jpye 1541 ,'ASC_LINKED_CONOPT':env.get('CONOPT_LINKED')
2180 jpye 1529 ,'ASC_WITH_IPOPT':with_ipopt
2181 johnpye 1142 ,'ASC_WITH_LSODE':with_lsode
2182     ,'ASC_WITH_MMIO':with_mmio
2183     ,'ASC_SIGNAL_TRAPS':with_signals
2184     ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2185     ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2186 johnpye 1261 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2187 jpye 1412 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2188 johnpye 1142 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2189     ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2190     }.iteritems():
2191    
2192     if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2193 johnpye 594
2194 johnpye 507 if with_python:
2195     subst_dict['@ASCXX_USE_PYTHON@']="1"
2196 johnpye 673 env['WITH_PYTHON']=1;
2197 johnpye 507
2198 jpye 1442 if with_latex2html:
2199     env['WITH_LATEX2HTML']=1
2200    
2201 johnpye 507 if env.has_key('HAVE_GCCVISIBILITY'):
2202     subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2203    
2204     env.Append(SUBST_DICT=subst_dict)
2205    
2206 johnpye 1142 #for k,v in subst_dict.iteritems():
2207     # print "%-50s%s" % ("'%s'"%k,v)
2208 johnpye 829
2209 johnpye 1142 # REMOVED: long command-line support on Win2k
2210 johnpye 829
2211     #------------------------------------------------------
2212 johnpye 558 # RECIPE: SWIG scanner
2213    
2214     import SCons.Script
2215    
2216     SWIGScanner = SCons.Scanner.ClassicCPP(
2217     "SWIGScan"
2218     , ".i"
2219     , "CPPPATH"
2220     , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2221     )
2222    
2223     env.Append(SCANNERS=[SWIGScanner])
2224    
2225     #------------------------------------------------------
2226 johnpye 463 # Recipe for 'CHMOD' ACTION
2227 johnpye 439
2228     import SCons
2229     from SCons.Script.SConscript import SConsEnvironment
2230     SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2231     lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2232    
2233     def InstallPerm(env, dest, files, perm):
2234     obj = env.Install(dest, files)
2235     for i in obj:
2236     env.AddPostAction(i, env.Chmod(str(i), perm))
2237    
2238     SConsEnvironment.InstallPerm = InstallPerm
2239    
2240     # define wrappers
2241     SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2242 johnpye 578 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2243 johnpye 629 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2244 johnpye 463
2245 johnpye 439 #------------------------------------------------------
2246 johnpye 463 # BUILD...
2247 johnpye 385
2248 johnpye 463 # so that #include <modulename/headername.h> works across all modules...
2249 johnpye 743 env.AppendUnique(CPPPATH=['#base/generic'])
2250 johnpye 385
2251 johnpye 508 if env['DEBUG']:
2252     env.Append(CCFLAGS=['-g'])
2253 jpye 1554 env.Append(LINKFLAGS=['-g'])
2254 johnpye 508
2255 johnpye 591 if env['GCOV']:
2256     env.Append(
2257     CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2258     , LIBS=['gcov']
2259     , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2260     )
2261    
2262 johnpye 673 if with_ida:
2263     env.Append(WITH_IDA=1)
2264    
2265 johnpye 783 if with_conopt:
2266     env.Append(WITH_CONOPT=1)
2267    
2268 jpye 1529 if with_ipopt:
2269     env.Append(WITH_IPOPT=1)
2270    
2271 johnpye 463 #-------------
2272     # TCL/TK GUI
2273 johnpye 385
2274 johnpye 551 if with_tcltk:
2275 johnpye 569 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2276 johnpye 391 else:
2277 johnpye 982 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2278 johnpye 386
2279 johnpye 463 #-------------
2280     # PYTHON INTERFACE
2281    
2282 johnpye 387 if with_python:
2283 johnpye 532 env.SConscript(['pygtk/SConscript'],'env')
2284 johnpye 391 else:
2285 johnpye 982 print "Skipping... Python bindings aren't being built:",without_python_reason
2286 johnpye 400
2287 johnpye 463 #------------
2288     # BASE/GENERIC SUBDIRECTORIES
2289    
2290 johnpye 673 libascend_env = env.Copy()
2291    
2292 johnpye 1316 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2293 johnpye 463
2294     srcs = []
2295     for d in dirs:
2296 johnpye 673 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2297 johnpye 463 srcs += heresrcs
2298    
2299     #-------------
2300 johnpye 673 # IMPORTED CODE: LSODE, BLAS, etc
2301    
2302 jpye 1509 #if with_lsode:
2303     # srcs += env.SConscript(['lsod/SConscript'],'env')
2304     # srcs += env.SConscript(['linpack/SConscript'],'env')
2305     #else:
2306     # print "Skipping... LSODE won't be built:", without_lsode_reason
2307 johnpye 673
2308     if with_local_blas:
2309 jpye 1515 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2310 johnpye 673 else:
2311 jpye 1515 env['blasobjs'] = []
2312 johnpye 673 print "Skipping... BLAS won't be built:", without_local_blas_reason
2313    
2314     if not with_ida:
2315     print "Skipping... IDA won't be built:", without_ida_reason
2316    
2317 johnpye 993 if with_mmio:
2318     srcs += env.SConscript(['mmio/SConscript'],'env')
2319     else:
2320     print "Skipping... MMIO export won't be built:", without_mmio_reason
2321 johnpye 673 #-------------
2322 johnpye 463 # LIBASCEND -- all base/generic functionality
2323    
2324 johnpye 938 if with_dmalloc:
2325     libascend_env.Append(LIBS=['dmalloc'])
2326    
2327 jpye 1326 if with_ufsparse:
2328     libascend_env.Append(LIBS=['cxsparse'])
2329    
2330 johnpye 673 libascend = libascend_env.SharedLibrary('ascend',srcs)
2331 johnpye 463
2332 jpye 1510 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2333     env['libascend'] = libascend
2334    
2335 johnpye 673 env.Alias('libascend',libascend)
2336    
2337 johnpye 463 #-------------
2338 johnpye 761 # UNIT TESTS (C CODE)
2339 johnpye 463
2340 johnpye 593 if with_cunit:
2341 jpye 1319 testdirs = ['general','solver','utilities','linear']
2342 johnpye 593 testsrcs = []
2343 johnpye 400 for testdir in testdirs:
2344     path = 'base/generic/'+testdir+'/test/'
2345     env.SConscript([path+'SConscript'],'env')
2346 johnpye 593 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2347    
2348     #print "TESTSRCS =",testsrcs
2349    
2350 johnpye 400 env.SConscript(['test/SConscript'],'env')
2351     env.SConscript(['base/generic/test/SConscript'],'env')
2352 johnpye 593
2353     env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2354 johnpye 400
2355     else:
2356 johnpye 427 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2357 johnpye 400
2358 johnpye 761 #-------------
2359 jpye 1504 # EXTERNAL SOLVERS
2360    
2361     env['extfns']=[]
2362    
2363 jpye 1505 env.SConscript(['solvers/SConscript'],'env')
2364 jpye 1504
2365     #-------------
2366 johnpye 761 # EXTERNAL FUNCTIONS
2367    
2368 johnpye 811 modeldirs = env.SConscript(['models/SConscript'],'env')
2369    
2370     if not with_extfns:
2371 johnpye 761 print "Skipping... External modules aren't being built:",without_extfns_reason
2372    
2373 johnpye 811 env.Alias('extfns',env['extfns'])
2374 johnpye 761
2375 johnpye 463 #------------------------------------------------------
2376 johnpye 683 # CREATE ASCEND-CONFIG scriptlet
2377    
2378     ascendconfig = env.SubstInFile('ascend-config.in')
2379    
2380     #------------------------------------------------------
2381 johnpye 463 # INSTALLATION
2382 johnpye 427
2383 johnpye 552 if env.get('CAN_INSTALL'):
2384 johnpye 427
2385 jpye 1442 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2386 jpye 1436 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2387 jpye 1505 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2388 johnpye 449
2389 johnpye 463 # TODO: add install options
2390     env.Alias('install',install_dirs)
2391 johnpye 400
2392 jpye 1436 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2393 johnpye 435
2394 jpye 1436 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2395 johnpye 683
2396 johnpye 438 #------------------------------------------------------
2397 johnpye 631 # WINDOWS INSTALLER
2398     # For the windows installer, please see pygtk/SConscript
2399    
2400 jpye 1551 if not env.get('NSIS'):
2401     with_installer = False
2402     without_installer_reason = "NSIS not found"
2403    
2404 johnpye 631 if with_installer:
2405 jpye 1467 env.Append(NSISDEFINES={
2406     'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2407     ,"VERSION":version
2408     ,'PYVERSION':pyversion
2409     })
2410 jpye 1465 installer = env.Installer('installer.nsi')
2411     Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2412     env.Alias('installer',installer)
2413 johnpye 631 else:
2414     print "Skipping... Windows installer isn't being built:",without_installer_reason
2415    
2416 jpye 1465
2417 johnpye 631 #------------------------------------------------------
2418 johnpye 673 # PROJECT FILE for MSVC
2419    
2420     env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2421    
2422     #------------------------------------------------------
2423 johnpye 438 # CREATE the SPEC file for generation of RPM packages
2424    
2425 johnpye 463 if platform.system()=="Linux":
2426     env.SubstInFile('ascend.spec.in')
2427 johnpye 552
2428     #------------------------------------------------------
2429 johnpye 816 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2430    
2431 jpye 1442 #if with_scrollkeeper:
2432     # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2433     # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2434 johnpye 816
2435     #------------------------------------------------------
2436 johnpye 552 # DISTRIBUTION TAR FILE
2437    
2438 johnpye 554 env['DISTTAR_FORMAT']='bz2'
2439 johnpye 556 env.Append(
2440 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']
2441 jpye 1417 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2442 johnpye 556 )
2443 johnpye 554
2444 johnpye 563 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2445 johnpye 556 , [env.Dir('#')]
2446 johnpye 554 )
2447    
2448 johnpye 680 env.Depends(tar,'ascend.spec')
2449 jpye 1442 env.Depends(tar,'#doc/book.pdf')
2450 johnpye 680
2451 johnpye 862 Alias('dist',tar)
2452    
2453 johnpye 554 #------------------------------------------------------
2454 jpye 1551 # DOCUMENTATION
2455 johnpye 816
2456    
2457 jpye 1551 if not with_doc_build:
2458     print "Skipping... Documentation isn't being built:",without_doc_build_reason
2459 jpye 1442
2460 jpye 1551 #user's manual
2461     env.SConscript('doc/SConscript',['env'])
2462 johnpye 766
2463 jpye 1551 # doxygen documentation
2464 johnpye 766 env.SConscript('base/doc/SConscript',['env'])
2465    
2466     #------------------------------------------------------
2467 johnpye 554 # RPM BUILD
2468    
2469 johnpye 766 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2470     # (check * for the version number used to create the tarball)
2471 johnpye 554
2472     #------------------------------------------------------
2473     # DEFAULT TARGETS
2474    
2475 jpye 1504 default_targets =['libascend','solvers']
2476 johnpye 629 if with_tcltk:
2477     default_targets.append('tcltk')
2478     if with_python:
2479     default_targets.append('pygtk')
2480 johnpye 631 if with_installer:
2481     default_targets.append('installer')
2482 johnpye 761 if with_extfns:
2483     default_targets.append('extfns')
2484 jpye 1443 if with_doc_build:
2485 jpye 1442 default_targets.append('doc')
2486 johnpye 554
2487 johnpye 629 env.Default(default_targets)
2488    
2489     print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2490    
2491 johnpye 705 # vim: set syntax=python:

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