/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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