/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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