/[ascend]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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