/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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