/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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