/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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