/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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