/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1723 - (show annotations) (download)
Fri Jan 11 23:24:27 2008 UTC (12 years, 7 months ago) by jpye
File size: 63574 byte(s)
Fixed 'lmodern' test.
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 = r"""
1926 \documentclass{article}
1927 \usepackage{lmodern}
1928 \title{Cartesian closed categories and the price of eggs}
1929 \author{Jane Doe}
1930 \date{September 1994}
1931 \begin{document}
1932 \maketitle
1933 Hello world!
1934 \end{document}
1935 """;
1936
1937 def CheckLModern(context):
1938 context.Message("Checking for lmodern...")
1939 b = context.env.DVI
1940 is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".tex")
1941 context.Result(is_ok)
1942 return is_ok
1943
1944 #----------------
1945 # GCC Version sniffing
1946
1947 # TODO FIXME
1948
1949 gcc_version4 = False
1950
1951 #------------------------------------------------------
1952 # CONFIGURATION
1953
1954 conf = Configure(env
1955 , custom_tests = {
1956 'CheckCC' : CheckCC
1957 , 'CheckCXX' : CheckCXX
1958 , 'CheckF77' : CheckF77
1959 , 'CheckMath' : CheckMath
1960 , 'CheckMalloc' : CheckMalloc
1961 , 'CheckDLOpen' : CheckDLOpen
1962 , 'CheckSwigVersion' : CheckSwigVersion
1963 , 'CheckPythonLib' : CheckPythonLib
1964 , 'CheckCUnit' : CheckCUnit
1965 , 'CheckDMalloc' : CheckDMalloc
1966 , 'CheckLyx' : CheckLyx
1967 , 'CheckLatex2HTML' : CheckLatex2HTML
1968 , 'CheckLModern' : CheckLModern
1969 , 'CheckGraphViz' : CheckGraphViz
1970 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
1971 , 'CheckUFSparse' : CheckUFSparse
1972 , 'CheckTcl' : CheckTcl
1973 , 'CheckTclVersion' : CheckTclVersion
1974 , 'CheckTk' : CheckTk
1975 , 'CheckTkVersion' : CheckTkVersion
1976 , 'CheckGcc' : CheckGcc
1977 , 'CheckGccVisibility' : CheckGccVisibility
1978 , 'CheckYacc' : CheckYacc
1979 , 'CheckLex' : CheckLex
1980 , 'CheckTkTable' : CheckTkTable
1981 , 'CheckX11' : CheckX11
1982 , 'CheckIDA' : CheckIDA
1983 , 'CheckSUNDIALS' : CheckSUNDIALS
1984 , 'CheckCONOPT' : CheckCONOPT
1985 , 'CheckIPOPT' : CheckIPOPT
1986 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1987 , 'CheckFPE' : CheckFPE
1988 , 'CheckSIGINT' : CheckSIGINT
1989 , 'CheckSigReset' : CheckSigReset
1990 # , 'CheckIsNan' : CheckIsNan
1991 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1992 }
1993 # , config_h = "config.h"
1994 )
1995
1996 def sconsversioncheck():
1997
1998 # uncomment the following line to skip the version check:
1999 # return 1
2000
2001 import SCons
2002 v = SCons.__version__.split(".")
2003 if v[0] != '0':
2004 return 0
2005 if int(v[1]) >= 97:
2006 return 1
2007 if v[1] != '96':
2008 return 0
2009 micro = int(v[2])
2010 if micro == 92 or micro == 93 or micro == 96:
2011 return 1;
2012 return 0
2013
2014 if not sconsversioncheck():
2015 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2016 print "or consult the developers in the case of newer versions. Modify"
2017 print "the function 'sconsversioncheck' in the file SConstruct if you"
2018 print "want to *force* SCons to continue."
2019 Exit(1)
2020
2021 # check C compiler
2022
2023 if conf.CheckCC() is False:
2024 print "Failed to build simple test file with your C compiler."
2025 print "Check your compiler is installed and running correctly."
2026 Exit(1)
2027
2028 if conf.CheckCXX() is False:
2029 print "Failed to build simple test file with your C++ compiler."
2030 print "Check your compiler is installed and running correctly."
2031 print "You can set your C++ compiler using the CXX scons option."
2032 Exit(1)
2033
2034 # stdio -- just to check that compiler is behaving
2035
2036 if conf.CheckHeader('stdio.h') is False:
2037 print "CPPPATH =",env.get('CPPPATH')
2038 print "Did not find 'stdio.h'! Check your compiler configuration."
2039 print ""
2040 print "You environment is printed here:"
2041 for k,v in os.environ.iteritems():
2042 print "%-30s%s" % ("%s :" % k, v)
2043 Exit(1)
2044
2045 if conf.CheckFunc('snprintf') is False:
2046 print "Didn't find snprintf";
2047 exit(1)
2048
2049 if conf.CheckFunc('strdup'):
2050 conf.env['HAVE_STRDUP'] = True
2051
2052 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2053 conf.env.Append(LIBS='msvcr71')
2054
2055 # Math library
2056
2057 conf.env['HAVE_IEEE']=True
2058
2059 if need_libm and (conf.CheckMath() is False):
2060 conf.env['HAVE_IEEE']=False
2061 print 'Did not find math library, exiting!'
2062 Exit(1)
2063
2064 # Malloc
2065
2066 if conf.CheckMalloc() is False:
2067 conf.env['HAVE_MALLOC']=False
2068 print "Did not find functioning 'malloc', exiting!"
2069 Exit(1)
2070
2071 # dlopen/LoadLibrary
2072
2073 # CURRENTLY BREAKS LATER TEST (libsave?)
2074 #if conf.CheckDLOpen() is False:
2075 # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2076 # Exit(1)
2077
2078 # Where is 'isnan'?
2079
2080 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2081 print "Didn't find isnan"
2082 # Exit(1)
2083
2084 # GCC visibility
2085
2086 if conf.CheckGcc():
2087 conf.env['HAVE_GCC']=True;
2088 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
2089 conf.env['HAVE_GCCVISIBILITY']=True;
2090 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2091 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2092 conf.env.Append(CCFLAGS=['-Wall'])
2093
2094 # Catching SIGINT
2095
2096 if env['WITH_SIGNALS']:
2097 if not conf.CheckSIGINT():
2098 with_signals = False
2099 without_signals_reason = "SIGINT uncatchable"
2100
2101 # Catching SIGFPE
2102
2103 if conf.CheckFPE():
2104 conf.env['HAVE_C99FPE']=True
2105 else:
2106 conf.env['HAVE_C99FPE']=False
2107
2108 # Checking for signal reset requirement
2109
2110 if conf.CheckSigReset() is False:
2111 print "Unable to determine if signal reset is required"
2112 Exit(1)
2113
2114 # YACC
2115
2116 if conf.CheckYacc():
2117 conf.env['HAVE_YACC']=True
2118
2119 if conf.CheckLex():
2120 conf.env['HAVE_LEX']=True
2121
2122 # Tcl/Tk
2123
2124 if with_tcltk:
2125 if conf.CheckTcl():
2126 if conf.CheckTclVersion():
2127 if conf.CheckTk():
2128 if with_tcltk and conf.CheckTkVersion():
2129 if env['STATIC_TCLTK']:
2130 if conf.CheckTkTable():
2131 pass
2132 else:
2133 without_tcltk_reason = "TkTable not found"
2134 with_tcltk = False
2135 else:
2136 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2137 with_tcltk = False
2138 else:
2139 without_tcltk_reason = "Tk not found."
2140 with_tcltk = False
2141 else:
2142 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2143 with_tcltk = False
2144
2145 else:
2146 without_tcltk_reason = "Tcl not found."
2147 with_tcltk = False
2148
2149 if env['STATIC_TCLTK']:
2150 conf.CheckX11()
2151
2152 # Python... obviously we're already running python, so we just need to
2153 # check that we can link to the python library OK:
2154
2155 if not conf.CheckPythonLib():
2156 without_python_reason = 'libpython2.x not found or not linkable'
2157 with_python = False
2158 env['WITH_PYTHON']=False
2159
2160 # SWIG version
2161
2162 if with_python and conf.CheckSwigVersion() is False:
2163 without_python_reason = 'SWIG >= 1.3.24 is required'
2164 with_python = False
2165 env['WITH_PYTHON']=False
2166
2167 # CUnit
2168
2169 if with_cunit:
2170 if not conf.CheckCUnit():
2171 without_cunit_reason = 'CUnit not found'
2172 with_cunit = False
2173 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2174
2175 # DMALLOC
2176
2177 if with_dmalloc:
2178 if not conf.CheckDMalloc():
2179 without_dmalloc_reason = 'dmalloc not found'
2180 with_dmalloc = False
2181
2182 # GRAPHVIZ
2183
2184 if with_graphviz:
2185 if not conf.CheckGraphViz():
2186 without_graphviz_reason = 'graphviz not found'
2187 with_graphviz = False
2188 env['WITH_GRAPHVIZ'] = False
2189 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2190
2191 # UFSPARSE
2192
2193 if with_ufsparse:
2194 if not conf.CheckUFSparse():
2195 without_ufsparse_reason = 'ufsparse not found'
2196 with_ufsparse = False
2197 env['WITH_UFSPARSE'] = False
2198
2199 # IDA
2200
2201 if not with_ida:
2202 without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
2203 elif not conf.CheckSUNDIALS():
2204 with_ida = False
2205 without_ida_reason = "SUNDIALS not found, or bad version"
2206 elif not conf.CheckIDA():
2207 with_ida = False
2208 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2209
2210 # CONOPT
2211
2212 if not with_conopt:
2213 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2214 elif conf.CheckCONOPT() is False:
2215 if conf.env.get('CONOPT_LINKED'):
2216 conf.env['CONOPT_LINKED'] = False
2217 # we no longer require CONOPT at buildtime in order to build support for it
2218 #with_conopt = False
2219 #without_conpt_reason = "CONOPT not found"
2220
2221 # IPOPT
2222
2223 if not with_ipopt:
2224 without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2225 elif not conf.CheckIPOPT():
2226 with_ipopt = False
2227 without_ipopt_reason = "IPOPT not found"
2228
2229 # BLAS
2230
2231 need_blas=False
2232
2233 if with_lsode:
2234 need_fortran = True
2235 need_fortran_reasons.append("LSODE")
2236 need_blas=True
2237
2238 if need_blas:
2239 if conf.CheckLib('blas'):
2240 with_local_blas = False
2241 without_local_blas_reason = "Found BLAS installed on system"
2242 else:
2243 with_local_blas = True
2244 need_fortran = True
2245 need_fortran_reasons.append("BLAS")
2246 else:
2247 with_local_blas= False;
2248 without_local_blas_reason = "BLAS not required"
2249
2250 # FORTRAN
2251
2252 if need_fortran:
2253 conf.env.Tool('fortran')
2254 detect_fortran = conf.env.Detect(['gfortran','g77'])
2255 if detect_fortran:
2256 # For some reason, g77 doesn't get detected properly on MinGW
2257 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2258 print "Fixing detection of F77 on MinGW...(?)"
2259 conf.env.Replace(F77=detect_fortran)
2260 conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2261 conf.env.Replace(F77FLAGS='')
2262 #print "F77:",conf.env['F77']
2263 #print "F77COM:",conf.env['F77COM']
2264 #print "F77FLAGS:",conf.env['F77FLAGS']
2265 fortran_builder = Builder(
2266 action='$F77COM'
2267 , suffix='.o'
2268 , src_suffix='.f'
2269 )
2270 conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2271 if platform.system()=="Linux":
2272 conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2273 else:
2274 with_lsode=False;
2275 without_lsode_reason="FORTRAN-77 required but not found"
2276
2277 if need_fortran and conf.CheckF77() is False:
2278 print "Failed to build simple test file with your Fortran compiler."
2279 print "Check your compiler is installed and running correctly."
2280 print "You can set your Fortran compiler using the FORTRAN scons option."
2281 print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2282 print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2283 Exit(1)
2284
2285 #else:
2286 # print "FORTRAN not required"
2287
2288 # F2C
2289
2290 if need_fortran:
2291 if platform.system()=="Windows":
2292 pass
2293 #conf.env.Append(LIBPATH='c:\mingw\lib')
2294
2295 # scrollkeeper
2296
2297 if with_scrollkeeper:
2298 if conf.CheckScrollkeeperConfig() is False:
2299 with_scrollkeeper=False
2300 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2301
2302 # lyx
2303
2304 if with_doc_build:
2305 if conf.CheckLyx() is False:
2306 with_doc_build = False
2307 without_doc_build_reason="unable to locate lyx"
2308
2309 with_latext2html = conf.CheckLatex2HTML()
2310
2311 if conf.CheckLModern() is False:
2312 with_doc_build = False
2313 without_doc_build_reason="'lmodern' is not available"
2314
2315 # TODO: -D_HPUX_SOURCE is needed
2316
2317 # TODO: check size of void*
2318
2319 # TODO: detect if dynamic libraries are possible or not
2320
2321 if platform.system()=="Windows" and env.has_key('MSVS'):
2322 _found_windows_h = conf.CheckHeader('Windows.h')
2323
2324 if not _found_windows_h:
2325 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2326 Exit(1)
2327
2328 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2329 with_python = 0;
2330 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2331
2332 conf.Finish()
2333
2334 #---------------------------------------
2335 # SUBSTITUTION DICTIONARY for .in files
2336
2337 release = env.get('RELEASE')
2338 if release=="0.":
2339 release="0"
2340
2341 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2342
2343 subst_dict = {
2344 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2345 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2346 , '@GLADE_FILE@':'ascend.glade'
2347 , '@HELP_ROOT@':''
2348 , '@ICON_EXTENSION@':icon_extension
2349 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2350 , '@INSTALL_BIN@':env['INSTALL_BIN']
2351 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2352 , '@INSTALL_LIB@':env['INSTALL_LIB']
2353 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2354 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2355 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2356 , '@VERSION@':version
2357 , '@RELEASE@':release
2358 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2359 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2360 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2361 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2362 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2363 , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2364 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2365 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2366 , '@PYTHON@' : python_exe
2367 , '@PYVERSION@' : pyversion
2368 , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2369 , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2370 , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2371 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2372 , '@WITH_SOLVERS@':",".join(env.get('WITH_SOLVERS'))
2373 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2374 }
2375
2376 if env.get('WITH_DOC'):
2377 print "WITH_DOC:",env['WITH_DOC']
2378 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2379
2380 # bool options...
2381 for k,v in {
2382 'ASC_WITH_IDA':with_ida
2383 ,'ASC_WITH_DMALLOC':with_dmalloc
2384 ,'ASC_WITH_UFSPARSE':with_ufsparse
2385 ,'ASC_WITH_CONOPT':with_conopt
2386 ,'ASC_LINKED_CONOPT':env.get('CONOPT_LINKED')
2387 ,'ASC_WITH_IPOPT':with_ipopt
2388 ,'ASC_WITH_LSODE':with_lsode
2389 ,'ASC_WITH_MMIO':with_mmio
2390 ,'ASC_SIGNAL_TRAPS':with_signals
2391 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2392 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2393 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2394 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2395 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2396 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2397 }.iteritems():
2398
2399 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2400
2401 if with_python:
2402 subst_dict['@ASCXX_USE_PYTHON@']="1"
2403 env['WITH_PYTHON']=1;
2404
2405 if with_latex2html:
2406 env['WITH_LATEX2HTML']=1
2407
2408 if env.has_key('HAVE_GCCVISIBILITY'):
2409 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2410
2411 env.Append(SUBST_DICT=subst_dict)
2412
2413 #for k,v in subst_dict.iteritems():
2414 # print "%-50s%s" % ("'%s'"%k,v)
2415
2416 # REMOVED: long command-line support on Win2k
2417
2418 #------------------------------------------------------
2419 # RECIPE: SWIG scanner
2420
2421 import SCons.Script
2422
2423 SWIGScanner = SCons.Scanner.ClassicCPP(
2424 "SWIGScan"
2425 , ".i"
2426 , "CPPPATH"
2427 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2428 )
2429
2430 env.Append(SCANNERS=[SWIGScanner])
2431
2432 #------------------------------------------------------
2433 # Recipe for 'CHMOD' ACTION
2434
2435 import SCons
2436 from SCons.Script.SConscript import SConsEnvironment
2437 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2438 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2439
2440 def InstallPerm(env, dest, files, perm):
2441 obj = env.Install(dest, files)
2442 for i in obj:
2443 env.AddPostAction(i, env.Chmod(str(i), perm))
2444
2445 SConsEnvironment.InstallPerm = InstallPerm
2446
2447 # define wrappers
2448 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2449 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2450 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2451
2452 #------------------------------------------------------
2453 # BUILD...
2454
2455 # so that #include <modulename/headername.h> works across all modules...
2456 env.AppendUnique(CPPPATH=['#base/generic'])
2457
2458 if env['DEBUG']:
2459 env.Append(CCFLAGS=['-g'])
2460 env.Append(LINKFLAGS=['-g'])
2461
2462 if env['GCOV']:
2463 env.Append(
2464 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2465 , LIBS=['gcov']
2466 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2467 )
2468
2469 if with_ida:
2470 env.Append(WITH_IDA=1)
2471
2472 if with_conopt:
2473 env.Append(WITH_CONOPT=1)
2474
2475 if with_ipopt:
2476 env.Append(WITH_IPOPT=1)
2477
2478 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2479 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2480
2481 #-------------
2482 # TCL/TK GUI
2483
2484 if with_tcltk:
2485 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2486 else:
2487 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2488
2489 #-------------
2490 # PYTHON INTERFACE
2491
2492 if with_python:
2493 env.SConscript(['pygtk/SConscript'],'env')
2494 else:
2495 print "Skipping... Python bindings aren't being built:",without_python_reason
2496
2497 #------------
2498 # BASE/GENERIC SUBDIRECTORIES
2499
2500 libascend_env = env.Copy()
2501
2502 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2503
2504 srcs = []
2505 for d in dirs:
2506 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2507 srcs += heresrcs
2508
2509 #-------------
2510 # IMPORTED CODE: LSODE, BLAS, etc
2511
2512 #if with_lsode:
2513 # srcs += env.SConscript(['lsod/SConscript'],'env')
2514 # srcs += env.SConscript(['linpack/SConscript'],'env')
2515 #else:
2516 # print "Skipping... LSODE won't be built:", without_lsode_reason
2517
2518 if with_local_blas:
2519 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2520 else:
2521 env['blasobjs'] = []
2522 print "Skipping... BLAS won't be built:", without_local_blas_reason
2523
2524 if not with_ida:
2525 print "Skipping... IDA won't be built:", without_ida_reason
2526
2527 if with_mmio:
2528 srcs += env.SConscript(['mmio/SConscript'],'env')
2529 else:
2530 print "Skipping... MMIO export won't be built:", without_mmio_reason
2531 #-------------
2532 # LIBASCEND -- all base/generic functionality
2533
2534 if with_dmalloc:
2535 libascend_env.Append(LIBS=['dmalloc'])
2536
2537 if with_ufsparse:
2538 libascend_env.Append(LIBS=['cxsparse'])
2539
2540 libascend = libascend_env.SharedLibrary('ascend',srcs)
2541
2542 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2543 env['libascend'] = libascend
2544
2545 env.Alias('libascend',libascend)
2546
2547 #-------------
2548 # UNIT TESTS (C CODE)
2549
2550 if with_cunit:
2551 testdirs = ['general','solver','utilities','linear','compiler']
2552 testsrcs = []
2553 for testdir in testdirs:
2554 path = 'base/generic/'+testdir+'/test/'
2555 env.SConscript([path+'SConscript'],'env')
2556 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2557
2558 #print "TESTSRCS =",testsrcs
2559
2560 env.SConscript(['test/SConscript'],'env')
2561 env.SConscript(['base/generic/test/SConscript'],'env')
2562
2563 env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2564
2565 else:
2566 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2567
2568 #-------------
2569 # EXTERNAL SOLVERS
2570
2571 env['extfns']=[]
2572
2573 env.SConscript(['solvers/SConscript'],'env')
2574
2575 #-------------
2576 # EXTERNAL FUNCTIONS
2577
2578 modeldirs = env.SConscript(['models/SConscript'],'env')
2579
2580 if not with_extfns:
2581 print "Skipping... External modules aren't being built:",without_extfns_reason
2582
2583 env.Alias('extfns',env['extfns'])
2584
2585 #------------------------------------------------------
2586 # CREATE ASCEND-CONFIG scriptlet
2587
2588 ascendconfig = env.SubstInFile('ascend-config.in')
2589
2590
2591 #------------------------------------------------------
2592 # CREATE asc4dev scriptlet
2593
2594 asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2595 env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2596 #------------------------------------------------------
2597 # INSTALLATION
2598
2599 if env.get('CAN_INSTALL'):
2600
2601 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2602 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2603 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2604
2605 # TODO: add install options
2606 env.Alias('install',install_dirs)
2607
2608 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2609
2610 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2611
2612 #------------------------------------------------------
2613 # WINDOWS INSTALLER
2614
2615 if not env.get('NSIS'):
2616 with_installer = False
2617 without_installer_reason = "NSIS not found"
2618
2619 if with_installer:
2620 env.Append(NSISDEFINES={
2621 'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2622 ,"VERSION":version
2623 ,'PYVERSION':pyversion
2624 })
2625 installer = env.Installer('nsis/installer.nsi')
2626 Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2627 env.Alias('installer',installer)
2628 else:
2629 print "Skipping... Windows installer isn't being built:",without_installer_reason
2630
2631
2632 #------------------------------------------------------
2633 # PROJECT FILE for MSVC
2634
2635 env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2636
2637 #------------------------------------------------------
2638 # CREATE the SPEC file for generation of RPM packages
2639
2640 if platform.system()=="Linux":
2641 env.SubstInFile('ascend.spec.in')
2642
2643 #------------------------------------------------------
2644 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2645
2646 #if with_scrollkeeper:
2647 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2648 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2649
2650 #------------------------------------------------------
2651 # DISTRIBUTION TAR FILE
2652
2653 env['DISTTAR_FORMAT']='bz2'
2654 env.Append(
2655 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']
2656 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2657 )
2658
2659 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2660 , [env.Dir('#')]
2661 )
2662
2663 env.Depends(tar,'ascend.spec')
2664 env.Depends(tar,'#doc/book.pdf')
2665
2666 #------------------------------------------------------
2667 # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2668
2669 # ...
2670
2671 #------------------------------------------------------
2672 # DEBIAN TARBALL for use with Build Service
2673
2674 import glob
2675 deb_manfiles = glob.glob('debian/*.man')
2676
2677 deb_tar = env.Tar(
2678 'dist/debian.tar.gz'
2679 ,deb_manfiles + ['debian/compat','debian/copyright','debian/dirs'
2680 ,'debian/postinst','debian/postrm']
2681 ,TARFLAGS = ['cz']
2682 )
2683
2684 Alias('dist',[tar,deb_tar])
2685
2686 #------------------------------------------------------
2687 # DOCUMENTATION
2688
2689
2690 if not with_doc_build:
2691 print "Skipping... Documentation isn't being built:",without_doc_build_reason
2692
2693 #user's manual
2694 env.SConscript('doc/SConscript',['env'])
2695
2696 # doxygen documentation
2697 env.SConscript('base/doc/SConscript',['env'])
2698
2699 #------------------------------------------------------
2700 # RPM BUILD
2701
2702 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2703 # (check * for the version number used to create the tarball)
2704
2705 #------------------------------------------------------
2706 # DEFAULT TARGETS
2707
2708 default_targets =['libascend','solvers']
2709 if with_tcltk:
2710 default_targets.append('tcltk')
2711 if with_python:
2712 default_targets.append('pygtk')
2713 if with_installer:
2714 default_targets.append('installer')
2715 if with_extfns:
2716 default_targets.append('extfns')
2717 if with_doc_build:
2718 default_targets.append('doc')
2719
2720 env.Default(default_targets)
2721
2722 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2723
2724 # vim: set syntax=python:

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