/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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