/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2355 - (show annotations) (download)
Sat Jan 8 12:17:12 2011 UTC (7 years, 11 months ago) by jpye
File size: 75643 byte(s)
More on detecting yylex_destroy.
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 if platform.system()=="Windows":
456 vars.Add(PackageVariable(
457 "IPOPT_PREFIX"
458 ,"Prefix for your IPOPT install (IPOPT ./configure --prefix)"
459 ,default_conopt_prefix
460 ))
461
462 vars.Add(
463 "IPOPT_LIBS"
464 ,"Library linked to for IPOPT"
465 ,default_ipopt_libs
466 )
467
468
469 vars.Add(
470 "IPOPT_LIBPATH"
471 ,"Where is your IPOPT library installed"
472 ,default_ipopt_libpath
473 )
474
475 vars.Add(
476 'IPOPT_CPPPATH'
477 ,"Where is your IPOPT coin/IpStdCInterface.h (do not include the 'coin' in the path)"
478 ,"$IPOPT_PREFIX/include"
479 )
480
481 vars.Add(
482 'IPOPT_DLL'
483 ,"Exact path of IPOPT DLL to be included in the installer (Windows only)"
484 ,default_ipopt_dll
485 )
486
487 #------- TRON -------
488
489 vars.Add(
490 'TRON_ENVVAR'
491 ,"What environment variable should be used at runtime to override the default search location for TRON DLL/SO?"
492 ,default_tron_envvar
493 )
494
495 vars.Add(
496 "TRON_LIB"
497 ,"Library linked to for TRON"
498 ,"tron"
499 )
500
501 vars.Add(
502 "TRON_PREFIX"
503 ,"Prefix for your TRON install"
504 ,default_tron_prefix
505 )
506
507 vars.Add(
508 'TRON_DLPATH'
509 ,"What is the default search path that ASCEND should use when dlopening the TRON library at runtime?"
510 ,default_tron_dlpath
511 )
512
513 #-------- f2c ------
514
515 vars.Add(
516 "F2C_LIB"
517 ,"F2C library (eg. g2c, gfortran, f2c)"
518 ,default_f2c_lib # the default is gfortran now
519 )
520
521 vars.Add(PackageVariable(
522 "F2C_LIBPATH"
523 ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
524 ,"off"
525 ))
526
527 vars.Add(
528 "FORTRAN"
529 ,"Fortran compiler (eg g77, gfortran)"
530 ,default_fortran
531 )
532
533 #------- tcl/tk --------
534
535 vars.Add(
536 'TCL'
537 ,'Base of Tcl distribution'
538 ,default_tcl
539 )
540
541 # Where are the Tcl includes?
542 vars.Add(
543 'TCL_CPPPATH'
544 ,"Where are your Tcl include files?"
545 ,default_tcl_cpppath
546 )
547
548 # Where are the Tcl libs?
549 vars.Add(
550 'TCL_LIBPATH'
551 ,"Where are your Tcl libraries?"
552 ,default_tcl_libpath
553 )
554
555 # What is the name of the Tcl lib?
556 vars.Add(
557 'TCL_LIB'
558 ,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library (if STATIC_TCLTK is set)"
559 ,default_tcl_lib
560 )
561
562 # Where are the Tk includes?
563 vars.Add(
564 'TK_CPPPATH'
565 ,"Where are your Tk include files?"
566 ,'$TCL_CPPPATH'
567 )
568
569 # Where are the Tk libs?
570 vars.Add(
571 'TK_LIBPATH'
572 ,"Where are your Tk libraries?"
573 ,'$TCL_LIBPATH'
574 )
575
576 # What is the name of the Tk lib?
577 vars.Add(
578 'TK_LIB'
579 ,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library"
580 ,default_tk_lib
581 )
582
583 # Static linking to TkTable
584
585 vars.Add(BoolVariable(
586 'STATIC_TCLTK'
587 ,'Set true for static linking for Tcl/Tk and TkTable. EXPERIMENTAL'
588 ,False
589 ))
590
591 vars.Add(
592 'TKTABLE_LIBPATH'
593 ,'Location of TkTable static library'
594 ,'$TCL_LIBPATH/Tktable2.8'
595 )
596
597 vars.Add(
598 'TKTABLE_LIB'
599 ,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)'
600 ,default_tktable_lib
601 )
602
603 vars.Add(
604 'TKTABLE_CPPPATH'
605 ,'Location of TkTable header file'
606 ,'$TCL_CPPPATH'
607 )
608
609 vars.Add(
610 'X11'
611 ,'Base X11 directory. Only used when STATIC_TCLTK is turned on. EXPERIMENTAL'
612 ,'/usr/X11R6'
613 )
614
615 vars.Add(
616 'X11_LIBPATH'
617 ,'Location of X11 lib. EXPERIMENTAL'
618 ,'$X11/lib'
619 )
620
621 vars.Add(
622 'X11_CPPPATH'
623 ,'Location of X11 includes. EXPERIMENTAL'
624 ,'$X11/include'
625 )
626
627 vars.Add(
628 'X11_LIB'
629 ,'Name of X11 lib. EXPERIMENTAL'
630 ,'X11'
631 )
632
633 #----- installed file locations (for 'scons install') -----
634
635 vars.Add(
636 'INSTALL_PREFIX'
637 ,'Root location for installed files'
638 ,default_install_prefix
639 )
640
641 vars.Add(
642 'INSTALL_BIN'
643 ,'Location to put binaries during installation'
644 ,default_install_bin
645 )
646
647 vars.Add(
648 'INSTALL_LIB'
649 ,'Location to put libraries during installation'
650 ,default_install_lib
651 )
652
653 vars.Add(
654 'INSTALL_SHARE'
655 ,'Common shared-file location on this system'
656 ,"$INSTALL_PREFIX/share"
657 )
658
659 vars.Add(
660 'INSTALL_ASCDATA'
661 ,"Location of ASCEND shared data (TK, python, models etc)"
662 ,default_install_ascdata
663 )
664
665 vars.Add(
666 'INSTALL_PYTHON'
667 ,'General location for Python extensions on this system'
668 ,default_install_python
669 )
670
671 vars.Add(
672 'INSTALL_PYTHON_ASCEND'
673 ,'Location for installation of Python modules specific to ASCEND'
674 ,default_install_python_ascend
675 )
676
677 vars.Add(
678 'INSTALL_TK'
679 ,'Location for Tcl/Tk files used by ASCEND Tk GUI'
680 ,"$INSTALL_ASCDATA/tcltk"
681 )
682
683 vars.Add(
684 'INSTALL_MODELS'
685 ,"Location of ASCEND model files (.a4c,.a4l,.a4s)"
686 ,default_install_models
687 )
688
689 vars.Add(
690 'INSTALL_SOLVERS'
691 ,"Location of ASCEND solvers"
692 ,default_install_solvers
693 )
694
695 vars.Add(
696 'INSTALL_DOC'
697 ,"Location of ASCEND documentation files"
698 ,"$INSTALL_SHARE/doc/ascend-"+version
699 )
700
701 vars.Add(
702 'INSTALL_INCLUDE'
703 ,'Location to put header files during installation'
704 ,default_install_include
705 )
706
707
708 vars.Add(
709 'INSTALL_ROOT'
710 ,'For use by RPM only: location of %{buildroot} during rpmbuild'
711 ,""
712 )
713
714 vars.Add(
715 'EXTLIB_SUFFIX'
716 ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
717 ,"_ascend$SHLIBSUFFIX"
718 )
719
720 vars.Add(
721 'EXTLIB_PREFIX'
722 ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
723 ,"$SHLIBPREFIX"
724 )
725
726 #----------------------
727
728 vars.Add(
729 'PYGTK_ASSETS'
730 ,'Default location for Glade assets (will be recorded in pygtk/config.py)'
731 ,default_install_assets
732 )
733
734 vars.Add(BoolVariable(
735 'DEBUG'
736 ,"Compile source with debugger symbols, eg for use with 'gdb'"
737 ,False
738 ))
739
740 vars.Add(BoolVariable(
741 'MALLOC_DEBUG'
742 ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
743 ,False
744 ))
745
746 #------ dmalloc --------
747 vars.Add(PackageVariable(
748 'DMALLOC_PREFIX'
749 ,"Where are your dmalloc files?"
750 ,default_prefix
751 ))
752
753 vars.Add(PackageVariable(
754 'DMALLOC_CPPPATH'
755 ,"Where are your dmalloc include files?"
756 ,default_cpppath
757 ))
758
759 vars.Add(PackageVariable(
760 'DMALLOC_LIBPATH'
761 ,"Where are your dmalloc libraries?"
762 ,default_libpath
763 ))
764
765 vars.Add(BoolVariable(
766 'WITH_DMALLOC'
767 ,"Link to the DMALLOC library (if available) for debugging of memory usage."
768 ,False
769 ))
770
771 #------ Graphviz --------
772 # vars.Add(PackageVariable(
773 # 'GRAPHVIZ_PREFIX'
774 # ,"Where are your GRAPHVIZ files?"
775 # ,default_prefix
776 # ))
777 #
778 # vars.Add(PackageVariable(
779 # 'GRAPHVIZ_CPPPATH'
780 # ,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
781 # ,default_cpppath
782 # ))
783 #
784 # vars.Add(PackageVariable(
785 # 'GRAPHVIZ_LIBPATH'
786 # ,"Where are your GRAPHVIZ libraries?"
787 # ,default_graphviz_libpath
788 # ))
789 #
790 # vars.Add(
791 # 'GRAPHVIZ_LIBS'
792 # ,"What are your GRAPHVIZ libraries named?"
793 # ,default_graphviz_libs
794 # )
795 #
796 # vars.Add(PackageVariable(
797 # 'GRAPHVIZ_RPATH'
798 # ,"What is your GRAPHVIZ rpath for locating libraries at runtime? (only required for old Ubuntu)"
799 # ,default_graphviz_rpath
800 # ))
801
802 vars.Add(BoolVariable(
803 'WITH_GRAPHVIZ'
804 ,"Link to the GRAPHVIZ library (if available, for generating incidence graphs)"
805 ,default_with_graphviz
806 ))
807
808
809 #------ ufsparse --------
810 vars.Add(PackageVariable(
811 'UFSPARSE_PREFIX'
812 ,"Where are your UFSPARSE files?"
813 ,default_prefix
814 ))
815
816 vars.Add(PackageVariable(
817 'UFSPARSE_CPPPATH'
818 ,"Where are your UFSPARSE include files?"
819 ,default_cpppath
820 ))
821
822 vars.Add(PackageVariable(
823 'UFSPARSE_LIBPATH'
824 ,"Where are your UFSPARSE libraries?"
825 ,default_libpath
826 ))
827
828 vars.Add(BoolVariable(
829 'WITH_UFSPARSE'
830 ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
831 ,True
832 ))
833
834 #-----------------------
835
836 vars.Add(BoolVariable(
837 'UPDATE_NO_YACC_LEX'
838 ,"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)"
839 ,False
840 ))
841
842 vars.Add(
843 'DISTTAR_NAME'
844 ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
845 ,"ascend-"+version
846 )
847
848 vars.Add(
849 'RELEASE'
850 ,"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."
851 ,"0"
852 )
853
854 vars.Add(BoolVariable(
855 'ABSOLUTE_PATHS'
856 ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
857 ,default_absolute_paths
858 ))
859
860 vars.Add(
861 'WIN_INSTALLER_NAME'
862 ,"Name of the installer .exe to create under Windows (minus the '.exe')"
863 ,"ascend-"+version+"-py"+pyversion+".exe"
864 )
865
866 vars.Add(BoolVariable(
867 'WITH_XTERM_COLORS'
868 ,"Set to 0 if you don't want xterm colour codes in the console output"
869 ,True
870 ))
871
872 vars.Add(BoolVariable(
873 'WITH_EXTFNS'
874 ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
875 ,True
876 ))
877
878 vars.Add(BoolVariable(
879 'WITH_SCROLLKEEPER'
880 ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
881 ,default_with_scrollkeeper
882 ))
883
884 vars.Add(BoolVariable(
885 'WITH_MSVCR71'
886 ,"Attempt to link against MSVCR71.DLL, to enable passing of FILE* objects to/from python"
887 ,False
888 ))
889
890
891 # TODO: OTHER OPTIONS?
892 # TODO: flags for optimisation
893 # TODO: turning on/off bintoken functionality
894 # TODO: Where will the 'Makefile.bt' file be installed?
895
896 # Import the outside environment
897
898 def c_escape(str):
899 return re.sub("\\\\","/",str)
900
901 envadditional={}
902
903 tools = [
904 'lex', 'yacc', 'fortran', 'swig', 'substinfile'
905 ,'disttar', 'tar', 'graphviz','sundials'
906 ]
907 if platform.system()=="Windows":
908 tools += ['nsis']
909
910 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
911 envenv = os.environ;
912 tools += ['mingw']
913 #TODO removed 'doxygen' for SCons 0.96.93
914 envadditional['IS_MINGW']=True
915 else:
916 print "Assuming VC++ build environment (Note: MinGW is preferred)"
917 envenv = {
918 'PATH':os.environ['PATH']
919 ,'INCLUDE':os.environ['INCLUDE']
920 ,'LIB':os.environ['LIB']
921 ,'MSVS_IGNORE_IDE_PATHS':1
922 }
923 tools += ['default']
924 #TODO removed 'doxygen' for SCons 0.96.93
925 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
926 else:
927 if os.environ.get('TARGET')=='mingw':
928 envenv = os.environ
929 tools += ['crossmingw']
930 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
931 envadditional['LIBS']=['gcc']
932 else:
933 envenv = os.environ
934 tools += ['default','doxygen','ipopt']
935
936 env = Environment(
937 ENV=envenv
938 , toolpath=['scons']
939 , tools=tools
940 , **envadditional
941 )
942
943 #print "PATH =",os.environ['PATH']
944 #print "PROGSUFFIX =",env['PROGSUFFIX']
945 #print "CPPPATH =",env['CPPPATH']
946
947 vars.Update(env)
948
949 for l in ['SUNDIALS','IPOPT']:
950 var = "%s_LIBS" % l
951 if env.get(var) and not isinstance(env[var],types.ListType):
952 env[var] = env[var].split(",")
953
954 if 'LSOD' in env['WITH_SOLVERS']:
955 if 'LSODE' not in env['WITH_SOLVERS']:
956 env['WITH_SOLVERS'].append('LSODE')
957 env['WITH_SOLVERS'].remove('LSOD')
958
959 vars.Save('options.cache',env)
960
961 Help(vars.GenerateHelpText(env))
962
963 with_tcltk = env.get('WITH_TCLTK')
964 without_tcltk_reason = "disabled by options/config.py"
965
966 with_python = env.get('WITH_PYTHON')
967 without_python_reason = "disabled by options/config.py"
968
969 with_cunit = env.get('WITH_CUNIT')
970 without_cunit_reason = "not requested"
971
972 with_extfns = env.get('WITH_EXTFNS')
973 without_extfn_reason = "disabled by options/config.py"
974
975 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
976 without_scrollkeeper_reason = "disabled by options/config.py"
977
978 with_dmalloc = env.get('WITH_DMALLOC')
979 without_dmalloc_reason = "disabled by options/config.py"
980
981 with_graphviz = env.get('WITH_GRAPHVIZ')
982 without_graphiviz_reason = "disabled by options/config.py"
983
984 with_ufsparse = env.get('WITH_UFSPARSE')
985 without_ufsparse_reason = "disabled by options/config.py"
986
987 with_mmio = env.get('WITH_MMIO')
988 without_mmio_reason = "disabled by options/config.py"
989
990 with_signals = env.get('WITH_SIGNALS')
991 without_signals_reason = "disabled by options/config.py"
992
993 with_doc = env.get('WITH_DOC')
994
995 with_doc_build = env.get('WITH_DOC_BUILD');
996 without_doc_build_reason = "disabled by options/config.py"
997 if not with_doc:
998 with_doc_build = False
999 without_doc_build_reason = "disabled by with_doc"
1000
1001 with_latex2html = False
1002
1003 if platform.system()=="Windows":
1004 with_installer=1
1005 else:
1006 with_installer=0
1007 without_installer_reason = "only possible under Windows"
1008
1009 with_lsode = 'LSODE' in env['WITH_SOLVERS']
1010 without_lsode_reason = "Not selected (see config option WITH_SOLVERS)"
1011
1012 with_ida = 'IDA' in env['WITH_SOLVERS']
1013 without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
1014
1015 with_dopri5 = 'DOPRI5' in env['WITH_SOLVERS']
1016 without_dopri5_reason = "Not selected (see config option WITH_SOLVERS)"
1017
1018 with_conopt = 'CONOPT' in env['WITH_SOLVERS']
1019 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
1020
1021 with_ipopt = 'IPOPT' in env['WITH_SOLVERS']
1022 without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
1023
1024
1025 #print "SOLVERS:",env['WITH_SOLVERS']
1026 #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
1027 #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
1028
1029 can_install = True
1030 if platform.system()=='Windows':
1031 can_install = False
1032
1033 env['CAN_INSTALL']=can_install
1034
1035 print "TCL=",env['TCL']
1036 print "TCL_CPPPATH =",env['TCL_CPPPATH']
1037 print "TCL_LIBPATH =",env['TCL_LIBPATH']
1038 print "TCL_LIB =",env['TCL_LIB']
1039 print "CC =",env['CC']
1040 print "CXX =",env['CXX']
1041 print "FORTRAN=",env.get('FORTRAN')
1042
1043 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
1044 print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
1045 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
1046 print "INSTALL_MODELS =",env['INSTALL_MODELS']
1047 print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
1048 print "INSTALL_PYTHON =",env['INSTALL_PYTHON']
1049 print "INSTALL_PYTHON_ASCEND =",env['INSTALL_PYTHON_ASCEND']
1050
1051 print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
1052 print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
1053
1054
1055 #------------------------------------------------------
1056 # SPECIAL CONFIGURATION TESTS
1057
1058 need_fortran = False
1059 need_fortran_reasons = []
1060
1061 #----------------
1062 # CC
1063
1064 cc_test_text = """
1065 int main(void){
1066 return 0;
1067 }
1068 """;
1069
1070 def CheckCC(context):
1071 context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
1072 is_ok = context.TryCompile(cc_test_text,".c")
1073 context.Result(is_ok)
1074 return is_ok
1075
1076 #----------------
1077 # CXX
1078
1079 cxx_test_text = """
1080 template<class X>
1081 class pair{
1082 public:
1083 X a;
1084 X b;
1085 };
1086
1087 int main(void){
1088 pair<double> P;
1089 P.a = 0;
1090 return 0;
1091 }
1092 """;
1093
1094 def CheckCXX(context):
1095 context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
1096 if not context.env.get('CXX'):
1097 context.Result("not found")
1098 return False
1099 is_ok = context.TryCompile(cxx_test_text,".cpp")
1100 context.Result(is_ok)
1101 return is_ok
1102
1103 #----------------
1104
1105 f77_test_text = """
1106 C Hello World in Fortran 77
1107
1108 PROGRAM HELLO
1109 PRINT*, 'Hello World!'
1110 END
1111 """;
1112
1113 def CheckF77(context):
1114 context.Message("Checking Fortran 77 compiler ('%s')..." % context.env.get('FORTRAN'))
1115 if not context.env.get('FORTRAN'):
1116 context.Result('not found')
1117 return False
1118 is_ok = context.TryCompile(f77_test_text,".f")
1119 context.Result(is_ok)
1120 return is_ok
1121
1122 #----------------
1123 # SWIG
1124
1125 import os,re
1126
1127 def get_swig_version(env):
1128 cmd = [env['SWIG'],'-version']
1129 p = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1130 output, err = p.communicate()
1131
1132 restr = r"\s*SWIG\s+Version\s+(?P<maj>[0-9]+)\.(?P<min>[0-9]+)\.(?P<pat>[0-9]+)\b"
1133 expr = re.compile(restr,re.MULTILINE|re.IGNORECASE);
1134 m = expr.match(output);
1135 if not m:
1136 raise RuntimeError("Failed match on output '%s'" % output)
1137 maj = int(m.group('maj'))
1138 min = int(m.group('min'))
1139 pat = int(m.group('pat'))
1140
1141 return (maj,min,pat)
1142
1143
1144 def CheckSwigVersion(context):
1145
1146 try:
1147 context.Message("Checking version of SWIG... ")
1148 maj,min,pat = get_swig_version(context.env)
1149 except Exception,e:
1150 context.Result("Failed to detect version, or failed to run SWIG (%s)" % str(e))
1151 return False;
1152
1153 context.env['SWIGVERSION']=tuple([maj,min,pat])
1154
1155 msg = "too old"
1156 res = False
1157 if maj == 1 and (
1158 min > 3
1159 or (min == 3 and pat >= 24)
1160 ):
1161 msg = "ok"
1162 res = True
1163 elif maj == 2:
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 p = subprocess.Popen(cmd,stdout=subprocess.PIPE)
1176 output = p.communicate()
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 lexdestroy_test_text = """
1375 %{
1376 #include <stdio.h>
1377 %}
1378 DIGIT [0-9]
1379 ID [a-z][a-z0-9]*
1380 %%
1381 {DIGIT}+ {
1382 printf("A digit: %s\\n",yytext);
1383 }
1384
1385 [ \\t\\n]+ /* ignore */
1386
1387 . {
1388 printf("Unrecognized guff");
1389 }
1390 %%
1391 main(){
1392 yylex();
1393 yylex_destroy();
1394 }
1395 """
1396
1397 def CheckLexDestroy(context):
1398 context.Message("Checking for yylex_destroy... ")
1399 is_ok, outstring = context.TryRun(lexdestroy_test_text,".l")
1400 context.Result(is_ok)
1401 return is_ok
1402
1403 #----------------
1404 # CUnit test
1405
1406 cunit_test_text = """
1407 #include <CUnit/CUnit.h>
1408 int maxi(int i1, int i2){
1409 return (i1 > i2) ? i1 : i2;
1410 }
1411
1412 void test_maxi(void){
1413 CU_ASSERT(maxi(0,2) == 2);
1414 CU_ASSERT(maxi(0,-2) == 0);
1415 CU_ASSERT(maxi(2,2) == 2);
1416
1417 }
1418 int main(void){
1419 /* CU_initialize_registry() */
1420 return 0;
1421 }
1422 """
1423
1424 def CheckCUnit(context):
1425 return CheckExtLib(context,'cunit',cunit_test_text)
1426
1427 #----------------
1428 # dmalloc test
1429
1430 dmalloc_test_text = """
1431 #include <stdlib.h>
1432 #include <dmalloc.h>
1433
1434 int main(void){
1435 char *c;
1436 c = (char *)malloc(100*sizeof(char));
1437 free(c);
1438 return 0;
1439 }
1440 """
1441
1442 def CheckDMalloc(context):
1443 return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1444
1445 #----------------
1446 # graphviz test
1447
1448 graphviz_test_text = """
1449 #ifdef __WIN32__
1450 # include <gvc.h>
1451 #else
1452 # include <graphviz/gvc.h>
1453 #endif
1454 int main(void){
1455 Agraph_t *g;
1456 GVC_t *gvc;
1457 gvc = gvContext();
1458 g = agopen("g", AGDIGRAPH);
1459 return 0;
1460 }
1461 """
1462
1463 def CheckGraphViz(context):
1464 return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
1465
1466 graphviz_boolean_test = """
1467 #ifdef __WIN32__
1468 # include <types.h>
1469 #else
1470 # include <graphviz/types.h>
1471 #endif
1472 #ifndef GV_TYPES_H
1473 # error WHERE IS GV_TYPES_H?
1474 #endif
1475 int main(void){
1476 boolean x;
1477 x = TRUE;
1478 return 0;
1479 }
1480 """
1481
1482 def CheckGraphVizBoolean(context):
1483 return CheckExtLib(context,'graphviz',graphviz_boolean_test,ext=".c" \
1484 ,testname="graphviz 'boolean' definition"
1485 )
1486
1487 #----------------
1488 # ufsparse test
1489
1490 ufsparse_test_text = """
1491 #include <ufsparse/cs.h>
1492 int main(void){
1493 cs *A,*B,*C;
1494 C = cs_multiply(A,B);
1495 return 0;
1496 }
1497 """
1498
1499 def CheckUFSparse(context):
1500 return CheckExtLib(context
1501 ,libname='cxsparse'
1502 ,varprefix='ufsparse'
1503 ,text=ufsparse_test_text
1504 ,ext=".c"
1505 )
1506
1507 #----------------
1508 # MATH test
1509
1510 math_test_text = """
1511 #ifndef _ALL_SOURCE
1512 # define _ALL_SOURCE
1513 #endif
1514 #ifndef _XOPEN_SOURCE
1515 # define _XOPEN_SOURCE
1516 #endif
1517 #ifndef _XOPEN_SOURCE_EXTENDED
1518 # define _XOPEN_SOURCE_EXTENDED 1
1519 #endif
1520 #include <math.h>
1521 int main(void){
1522 double x = 1.0; double y = 1.0; int i = 1;
1523 acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1524 j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1525 y0(x); y1(x); yn(i,x);
1526 /* this part causes problems with crossmingw... */
1527 #ifdef _THREAD_SAFE
1528 gamma_r(x,&i);
1529 lgamma_r(x,&i);
1530 #else
1531 gamma(x);
1532 lgamma(x);
1533 #endif
1534 hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
1535 return 0;
1536 }
1537 """
1538
1539 def CheckMath(context):
1540 context.Message('Checking for IEEE math library... ')
1541 libsave=context.env.get('LIBS');
1542 context.env.AppendUnique(LIBS=['m'])
1543 is_ok=context.TryLink(math_test_text,".c")
1544 context.Result(is_ok)
1545 if libsave is None:
1546 del(context.env['LIBS'])
1547 else:
1548 context.env['LIBS']=libsave
1549 return is_ok
1550
1551 #----------------
1552 # malloc.h test
1553
1554 malloc_test_text = """
1555 #include <stdlib.h>
1556 int main(){
1557 double *x;
1558 x = malloc(sizeof(double)*5);
1559 x[4] = 3.3;
1560 free(x);
1561 }
1562 """
1563
1564 def CheckMalloc(context):
1565 context.Message("Checking for malloc...")
1566 is_ok = context.TryLink(malloc_test_text,".c")
1567 context.Result(is_ok)
1568 return is_ok
1569
1570 #----------------
1571 # dlopen test
1572
1573 dlopen_test_text = """
1574 #ifdef __WIN32__
1575 # include <windows.h>
1576 #else
1577 # include <dlfcn.h>
1578 #endif
1579 int main(){
1580 #ifdef __WIN32__
1581 HINSTANCE d;
1582 LoadLibrary("imaginary_and_nonexistent.dll");
1583 #else
1584 void *d;
1585 d = dlopen("imaginary_and_nonexistent.so", 1);
1586 #endif
1587 return 0;
1588 }
1589 """
1590
1591 def CheckDLOpen(context):
1592 context.Message("Checking for ability to load shared libraries at runtime...")
1593 libsave=context.env.get('LIBS');
1594 if platform.system()!="Windows":
1595 context.env.Append(LIBS=['dl'])
1596 is_ok = context.TryLink(dlopen_test_text,".c")
1597 context.Result(is_ok)
1598 context.env['LIBS'] = libsave
1599 return is_ok
1600
1601 #----------------
1602 # libpython test
1603
1604 libpython_test_text = """
1605 #include <Python.h>
1606 int main(void){
1607 PyObject *p;
1608 p = Py_None;
1609 return 0;
1610 }
1611 """
1612
1613 def CheckPythonLib(context):
1614 context.Message('Checking for libpython... ')
1615
1616 if platform.system()=="Windows":
1617 python_lib='python%d%d'
1618 else:
1619 python_lib='python%d.%d'
1620
1621 try:
1622 python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1623 python_cpppath = [distutils.sysconfig.get_python_inc()]
1624 cfig = distutils.sysconfig.get_config_vars()
1625 except:
1626 context.Result("not found")
1627 return 0
1628
1629 lastLIBS = context.env.get('LIBS')
1630 lastLIBPATH = context.env.get('LIBPATH')
1631 lastCPPPATH = context.env.get('CPPPATH')
1632 lastLINKFLAGS = context.env.get('LINKFLAGS')
1633
1634 python_libpath = []
1635 python_linkflags = []
1636 if platform.system()=="Windows":
1637 python_libpath += [os.path.join(sys.prefix,"libs")]
1638 elif platform.system()=="Darwin":
1639 python_libpath += [cfig['LIBPL']]
1640 python_linkflags += cfig['LIBS'].split(' ')
1641 else:
1642 # checked on Linux and SunOS
1643 if cfig['LDLIBRARY']==cfig['LIBRARY']:
1644 sys.stdout.write("(static)")
1645 python_libpath += [cfig['LIBPL']]
1646 python_linkflags += cfig['LIBS'].split(' ')
1647
1648 context.env.AppendUnique(LIBS=python_libs)
1649 context.env.AppendUnique(LIBPATH=python_libpath)
1650 context.env.AppendUnique(CPPPATH=python_cpppath)
1651 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1652 result = context.TryLink(libpython_test_text,".c");
1653
1654 context.Result(result)
1655
1656 if(result):
1657 context.env['PYTHON_LIBPATH']=python_libpath
1658 context.env['PYTHON_LIB']=python_libs
1659 context.env['PYTHON_CPPPATH']=python_cpppath
1660 context.env['PYTHON_LINKFLAGS']=python_linkflags
1661
1662 context.env['LIBS'] = lastLIBS
1663 context.env['LIBPATH'] = lastLIBPATH
1664 context.env['CPPPATH'] = lastCPPPATH
1665 context.env['LINKFLAGS'] = lastLINKFLAGS
1666
1667 return result
1668
1669 #----------------
1670 # IDA test
1671
1672 sundials_version_major_required = 2
1673 sundials_version_minor_min = 2
1674 sundials_version_minor_max = 4
1675
1676 sundials_version_text = """
1677 #include <sundials/sundials_config.h>
1678 #include <stdio.h>
1679 int main(){
1680 printf("%s",SUNDIALS_PACKAGE_VERSION);
1681 return 0;
1682 }
1683 """
1684
1685 ida_test_text = """
1686 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1687 # include <sundials/sundials_config.h>
1688 # include <sundials/sundials_nvector.h>
1689 # include <nvector_serial.h>
1690 # include <ida.h>
1691 # include <ida/ida_spgmr.h>
1692 #else
1693 # include <sundials/sundials_config.h>
1694 # include <nvector/nvector_serial.h>
1695 # include <ida/ida.h>
1696 #endif
1697 int main(){
1698 void *ida_mem;
1699 ida_mem = IDACreate();
1700 return 0;
1701 }
1702 """
1703
1704 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1705 # so detect the version and act accordingly.
1706 def CheckSUNDIALS(context):
1707 keep = KeepContext(context,'SUNDIALS')
1708 context.Message("Checking for SUNDIALS... ")
1709 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1710 keep.restore(context)
1711 if not is_ok:
1712 context.Result(0)
1713 return 0
1714
1715 major,minor,patch = tuple([int(i) for i in output.split(".")])
1716 context.env['SUNDIALS_VERSION_MAJOR'] = major
1717 context.env['SUNDIALS_VERSION_MINOR'] = minor
1718 if major != sundials_version_major_required \
1719 or minor < sundials_version_minor_min \
1720 or minor > sundials_version_minor_max:
1721 context.Result(output+" (bad version)")
1722 # bad version
1723 return 0
1724
1725 # good version
1726 context.Result("%d.%d.%d, good" % (major,minor,patch))
1727
1728 return 1
1729
1730
1731 def CheckIDA(context):
1732 context.Message( 'Checking for IDA... ' )
1733
1734 keep = KeepContext(context,"SUNDIALS")
1735
1736 major = context.env['SUNDIALS_VERSION_MAJOR']
1737 minor = context.env['SUNDIALS_VERSION_MINOR']
1738
1739 cppdef = context.env.get('CPPDEFINES')
1740
1741 context.env.Append(CPPDEFINES=[
1742 ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1743 ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1744 ])
1745
1746 context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1747 if major==2 and minor==2:
1748 context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1749
1750 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1751 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1752 context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1753
1754 is_ok = context.TryLink(ida_test_text,".c")
1755 context.Result(is_ok)
1756
1757 if cppdef:
1758 context.env['CPPDEFINES']=cppdef
1759 else:
1760 del context.env['CPPDEFINES']
1761
1762 keep.restore(context)
1763
1764 return is_ok
1765
1766
1767 #----------------
1768 # CONOPT test
1769
1770 conopt_test_text = """
1771 #if !defined(_WIN32)
1772 # define FNAME_LCASE_DECOR
1773 #endif
1774
1775 #include <conopt.h>
1776 #include <stdlib.h>
1777 int main(){
1778 int s, *v, e;
1779 s = COIDEF_Size();
1780 v = (int *)malloc(s*sizeof(int));
1781 e = COIDEF_Ini(v);
1782 return e;
1783 }
1784 """
1785
1786 def CheckCONOPT(context):
1787 context.Message( 'Checking for CONOPT... ' )
1788
1789 keep = KeepContext(context,"CONOPT")
1790
1791 is_ok = context.TryLink(conopt_test_text,".c")
1792 context.Result(is_ok)
1793
1794 keep.restore(context)
1795
1796 return is_ok
1797
1798 #----------------
1799 # IPOPT test
1800
1801 ipopt_test_text = """
1802 #if !defined(_WIN32)
1803 # define FNAME_LCASE_DECOR
1804 #endif
1805
1806 #include <coin/IpStdCInterface.h>
1807 int main(){
1808 Number n;
1809 IpoptProblem nlp = 0;
1810 n = 1;
1811 FreeIpoptProblem(nlp); // probably a crash if you run this
1812 return 0;
1813 }
1814 """
1815
1816 def CheckIPOPT(context):
1817 context.Message( 'Checking for IPOPT... ' )
1818
1819 keep = KeepContext(context,"IPOPT")
1820 is_ok = context.TryLink(ipopt_test_text,".c")
1821 context.Result(is_ok)
1822
1823 keep.restore(context)
1824
1825 return is_ok
1826
1827 #----------------
1828 # Tcl test
1829
1830 # TCL and TK required version 8.1 through 8.5:
1831 tcltk_minor_newest_acceptable = 5
1832 tcltk_major_required = 8
1833
1834 tcl_check_text = r"""
1835 #include <tcl.h>
1836 #include <stdio.h>
1837 int main(void){
1838 printf("%s",TCL_PATCH_LEVEL);
1839 return 0;
1840 }
1841 """
1842
1843 def CheckTcl(context):
1844 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1845
1846 def CheckTclVersion(context):
1847 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1848 context.Message("Checking Tcl version... ")
1849 (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1850 keep.restore(context)
1851 if not is_ok:
1852 context.Result("failed to run check")
1853 return 0
1854
1855 major,minor,patch = tuple([int(i) for i in output.split(".")])
1856 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1857 context.Result(output+" (bad version)")
1858 # bad version
1859 return 0
1860
1861 # good version
1862 context.Result(output+", good")
1863 return 1
1864
1865 #----------------
1866 # Tk test
1867
1868 tk_check_text = r"""
1869 #include <tk.h>
1870 #include <stdio.h>
1871 int main(void){
1872 printf("%s",TK_PATCH_LEVEL);
1873 return 0;
1874 }
1875 """
1876 def CheckTk(context):
1877 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1878
1879
1880 def CheckTkVersion(context):
1881 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1882 context.Message("Checking Tk version... ")
1883 #print "LINKFLAGS =",context.env['LINKFLAGS']
1884 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1885 keep.restore(context)
1886 if not is_ok:
1887 context.Result("failed to run check")
1888 return 0
1889
1890 major,minor,patch = tuple([int(i) for i in output.split(".")])
1891 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1892 # bad version
1893 context.Result(output+" (bad version)")
1894 return 0
1895
1896 # good version
1897 context.Result(output+" (good)")
1898 return 1
1899
1900 #----------------
1901 # Tktable test
1902
1903 tktable_check_text = r"""
1904 #include <tkTable.h>
1905 #include <stdio.h>
1906 int main(void){
1907 Table mytable;
1908 return 0;
1909 }
1910 """
1911
1912 def CheckTkTable(context):
1913 return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1914
1915 #---------------
1916 # X11 test
1917
1918 x11_check_text = r"""
1919 #include <X11/Xlib.h>
1920 #include <X11/IntrinsicP.h>
1921 #include <X11/Intrinsic.h>
1922 #include <X11/ObjectP.h>
1923 #include <X11/Object.h>
1924 int main(void){
1925 Object mything;
1926 return 0;
1927 }
1928 """
1929
1930 def CheckX11(context):
1931 return CheckExtLib(context,'X11',x11_check_text)
1932
1933 #----------------
1934 # Check that we can raise and catch sigint
1935
1936 sigint_test_text = r"""
1937 #include <signal.h>
1938 #include <setjmp.h>
1939 #include <stdlib.h>
1940 static jmp_buf g_jmpenv;
1941 void sighandler(int sig){
1942 longjmp(g_jmpenv,sig);
1943 }
1944 void testsigint(){
1945 raise(SIGINT);
1946 }
1947 int main(void){
1948 signal(SIGINT,&sighandler);
1949 switch(setjmp(g_jmpenv)){
1950 case 0:
1951 testsigint();
1952 exit(1);
1953 case SIGINT:
1954 exit(0);
1955 default:
1956 exit(2);
1957 }
1958 }
1959 """
1960
1961 def CheckSIGINT(context):
1962 context.Message("Checking SIGINT is catchable... ")
1963 (is_ok,output)=context.TryRun(sigint_test_text,".c")
1964 context.Result(is_ok)
1965 return is_ok
1966
1967 #----------------
1968 # Check that we're able to catch floating point errors
1969
1970 sigfpe_test_text = r"""
1971 #include <signal.h>
1972 #include <setjmp.h>
1973 #include <stdlib.h>
1974 #include <fenv.h>
1975 static jmp_buf g_jmpenv;
1976 void fpehandler(int sig){
1977 longjmp(g_jmpenv,sig);
1978 }
1979 int main(void){
1980 fenv_t myfenv;
1981 fegetenv(&myfenv);
1982 fesetenv(&myfenv);
1983 feenableexcept(FE_ALL_EXCEPT);
1984 signal(SIGFPE,&fpehandler);
1985 double x;
1986 switch(setjmp(g_jmpenv)){
1987 case 0:
1988 x = 1.0 / 0.0;
1989 /* failed to catch */
1990 exit(1);
1991 case SIGFPE:
1992 exit(0);
1993 }
1994 }
1995 """
1996
1997 def CheckFPE(context):
1998 context.Message("Checking C99 FPE behaviour... ")
1999 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
2000 context.Result(is_ok)
2001 return is_ok
2002
2003 #----------------
2004 # signal reset needed?
2005
2006 sigreset_test_text = r"""
2007 #include <signal.h>
2008 #include <setjmp.h>
2009 #include <stdlib.h>
2010 #include <stdio.h>
2011 typedef void SigHandlerFn(int);
2012 static jmp_buf g_jmpenv;
2013 void sighandler(int sig){
2014 longjmp(g_jmpenv,sig);
2015 }
2016 void testsigint(){
2017 /* fprintf(stderr,"Raising SIGINT\n"); */
2018 raise(SIGINT);
2019 }
2020 int main(void){
2021 SigHandlerFn *last,*saved;
2022 saved = signal(SIGINT,&sighandler);
2023 if(saved!=SIG_DFL){
2024 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
2025 exit(3);
2026 }
2027 switch(setjmp(g_jmpenv)){
2028 case 0:
2029 testsigint();
2030 fprintf(stderr,"Back from SIGINT\n");
2031 exit(1);
2032 case SIGINT:
2033 break;
2034 default:
2035 exit(2);
2036 };
2037 last = signal(SIGINT,SIG_DFL);
2038 if(last!=&sighandler){
2039 printf("1");
2040 exit(0);
2041 }
2042 printf("0");
2043 exit(0);
2044 }
2045 """
2046
2047 def CheckSigReset(context):
2048 context.Message("Checking signal handler reset... ")
2049 libsave=context.env.get('LIBS')
2050 context.env.AppendUnique(LIBS=['m'])
2051 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
2052
2053 if libsave is None:
2054 del(context.env['LIBS'])
2055 else:
2056 context.env['LIBS']=libsave
2057
2058 if not is_ok:
2059 context.Result("ERROR")
2060 return False
2061 if int(output)==1:
2062 context.Result("required");
2063 context.env['ASC_RESETNEEDED'] = True
2064 else:
2065 context.Result("not required");
2066 context.env['ASC_RESETNEEDED'] = False
2067 return True
2068
2069 #----------------
2070 # LyX on this system?
2071
2072 def CheckLyx(context):
2073 context.Message("Checking for LyX... ")
2074 r = context.env.WhereIs("lyx")
2075 if r:
2076 context.Result(r)
2077 else:
2078 context.Result(0)
2079 return r
2080
2081 #----------------
2082 # Latex2HTML on this system?
2083
2084 def CheckLatex2HTML(context):
2085 context.Message("Checking for latex2html...")
2086 if context.env.WhereIs("latex2html"):
2087 r = True
2088 else:
2089 r = False
2090 context.Result(r)
2091 return r
2092
2093 #----------------
2094 # 'lmodern' package for LaTeX available?
2095
2096 lmodern_test_text = r"""
2097 \documentclass{article}
2098 \usepackage{lmodern}
2099 \title{Cartesian closed categories and the price of eggs}
2100 \author{Jane Doe}
2101 \date{September 1994}
2102 \begin{document}
2103 \maketitle
2104 Hello world!
2105 \end{document}
2106 """;
2107
2108 def CheckLModern(context):
2109 context.Message("Checking for lmodern...")
2110 b = context.env.get("DVI")
2111 if not b:
2112 context.Result(False)
2113 return False
2114 ff = context.env.get('LATEXFLAGS')
2115 context.env.Append(LATEXFLAGS=['-interaction=nonstopmode','-halt-on-error'])
2116 is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".latex")
2117 print "is_ok=",is_ok
2118 if ff is not None:
2119 context.env['LATEXFLAGS'] = ff
2120 else:
2121 del context.env['LATEXFLAGS']
2122 context.Result(is_ok)
2123 return is_ok
2124
2125 #----------------
2126 # GCC Version sniffing
2127
2128 # TODO FIXME
2129
2130 gcc_version4 = False
2131
2132 #------------------------------------------------------
2133 # CONFIGURATION
2134
2135 conf = Configure(env
2136 , custom_tests = {
2137 'CheckCC' : CheckCC
2138 , 'CheckCXX' : CheckCXX
2139 , 'CheckF77' : CheckF77
2140 , 'CheckMath' : CheckMath
2141 , 'CheckMalloc' : CheckMalloc
2142 , 'CheckDLOpen' : CheckDLOpen
2143 , 'CheckSwigVersion' : CheckSwigVersion
2144 , 'CheckPythonLib' : CheckPythonLib
2145 , 'CheckCUnit' : CheckCUnit
2146 , 'CheckDMalloc' : CheckDMalloc
2147 , 'CheckLyx' : CheckLyx
2148 , 'CheckLatex2HTML' : CheckLatex2HTML
2149 , 'CheckLModern' : CheckLModern
2150 , 'CheckGraphViz' : CheckGraphViz
2151 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
2152 , 'CheckUFSparse' : CheckUFSparse
2153 , 'CheckTcl' : CheckTcl
2154 , 'CheckTclVersion' : CheckTclVersion
2155 , 'CheckTk' : CheckTk
2156 , 'CheckTkVersion' : CheckTkVersion
2157 , 'CheckGcc' : CheckGcc
2158 , 'CheckGccVisibility' : CheckGccVisibility
2159 , 'CheckYacc' : CheckYacc
2160 , 'CheckLex' : CheckLex
2161 , 'CheckLexDestroy' : CheckLexDestroy
2162 , 'CheckTkTable' : CheckTkTable
2163 , 'CheckX11' : CheckX11
2164 , 'CheckIDA' : CheckIDA
2165 , 'CheckSUNDIALS' : CheckSUNDIALS
2166 , 'CheckCONOPT' : CheckCONOPT
2167 , 'CheckIPOPT' : CheckIPOPT
2168 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
2169 , 'CheckFPE' : CheckFPE
2170 , 'CheckSIGINT' : CheckSIGINT
2171 , 'CheckSigReset' : CheckSigReset
2172 # , 'CheckIsNan' : CheckIsNan
2173 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
2174 }
2175 # , config_h = "config.h"
2176 )
2177
2178 def sconsversioncheck():
2179
2180 # uncomment the following line to skip the version check:
2181 # return 1
2182
2183 import SCons
2184 v = SCons.__version__.split(".")
2185 if v[0] != '0':
2186 if v[0] == '1' or v[0] == '2':
2187 return 1;
2188 return 0
2189 if int(v[1]) >= 97:
2190 return 1
2191 if v[1] != '96':
2192 return 0
2193 micro = int(v[2])
2194 if micro == 92 or micro == 93 or micro == 96:
2195 return 1;
2196 return 0
2197
2198 if not sconsversioncheck():
2199 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2200 print "or consult the developers in the case of newer versions. Modify"
2201 print "the function 'sconsversioncheck' in the file SConstruct if you"
2202 print "want to *force* SCons to continue."
2203 Exit(1)
2204
2205 # check C compiler
2206
2207 if conf.CheckCC() is False:
2208 print "Failed to build simple test file with your C compiler."
2209 print "Check your compiler is installed and running correctly."
2210 Exit(1)
2211
2212 if conf.CheckCXX() is False:
2213 print "Failed to build simple test file with your C++ compiler."
2214 print "Check your compiler is installed and running correctly."
2215 print "You can set your C++ compiler using the CXX scons option."
2216 Exit(1)
2217
2218 # stdio -- just to check that compiler is behaving
2219
2220 if conf.CheckHeader('stdio.h') is False:
2221 print "CPPPATH =",env.get('CPPPATH')
2222 print "Did not find 'stdio.h'! Check your compiler configuration."
2223 print ""
2224 print "You environment is printed here:"
2225 for k,v in os.environ.iteritems():
2226 print "%-30s%s" % ("%s :" % k, v)
2227 Exit(1)
2228
2229 # sizes of vars used in libascend eg in gl_list etc.
2230
2231 _sizes = {
2232 "VOID_P" : "void *"
2233 ,"INT" : "int"
2234 ,"LONG" : "long"
2235 ,"LONG_LONG" : "long long"
2236 }
2237
2238 for _var,_type in _sizes.iteritems():
2239 _size = conf.CheckTypeSize(_type)
2240 if not _size:
2241 print "Couldn't determine 'sizeof(%s)'" % _type
2242 Exit(1)
2243 conf.env["SIZEOF_%s" % _var] = str(_size)
2244
2245 # check for some string functions
2246
2247 if conf.CheckFunc('snprintf') is False:
2248 print "Didn't find snprintf";
2249 Exit(1)
2250
2251 if conf.CheckFunc('strdup'):
2252 conf.env['HAVE_STRDUP'] = True
2253
2254 # attempt to support MSVCRT 7.1 on Windows
2255
2256 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2257 conf.env.Append(LIBS='msvcr71')
2258
2259 # Math library
2260
2261 conf.env['HAVE_IEEE']=True
2262
2263 if need_libm and (conf.CheckMath() is False):
2264 conf.env['HAVE_IEEE']=False
2265 print 'Did not find math library, exiting!'
2266 Exit(1)
2267
2268 # Malloc
2269
2270 if conf.CheckMalloc() is False:
2271 conf.env['HAVE_MALLOC']=False
2272 print "Did not find functioning 'malloc', exiting!"
2273 Exit(1)
2274
2275 # dlopen/LoadLibrary
2276
2277 # CURRENTLY BREAKS LATER TEST (libsave?)
2278 #if conf.CheckDLOpen() is False:
2279 # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2280 # Exit(1)
2281
2282 # Where is 'isnan'?
2283
2284 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2285 print "Didn't find isnan"
2286 # Exit(1)
2287
2288 # GCC visibility
2289
2290 if conf.CheckGcc():
2291 conf.env['HAVE_GCC']=True;
2292 if env.get('WITH_GCCVISIBILITY') and conf.CheckGccVisibility():
2293 conf.env['HAVE_GCCVISIBILITY']=True;
2294 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2295 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2296 conf.env.Append(CCFLAGS=['-Wall'])
2297
2298 # Catching SIGINT
2299
2300 if env['WITH_SIGNALS']:
2301 if not conf.CheckSIGINT():
2302 with_signals = False
2303 without_signals_reason = "SIGINT uncatchable"
2304
2305 # Catching SIGFPE
2306
2307 if conf.CheckFPE():
2308 conf.env['HAVE_C99FPE']=True
2309 else:
2310 conf.env['HAVE_C99FPE']=False
2311
2312 # Checking for signal reset requirement
2313
2314 if conf.CheckSigReset() is False:
2315 print "Unable to determine if signal reset is required"
2316 Exit(1)
2317
2318 # YACC
2319
2320 if conf.CheckYacc():
2321 conf.env['HAVE_YACC']=True
2322
2323 if conf.CheckLex():
2324 conf.env['HAVE_LEX']=True
2325
2326 if conf.CheckLexDestroy():
2327 conf.env['HAVE_LEXDESTROY']=True
2328
2329 # Tcl/Tk
2330
2331 if with_tcltk:
2332 if conf.CheckTcl():
2333 if conf.CheckTclVersion():
2334 if conf.CheckTk():
2335 if with_tcltk and conf.CheckTkVersion():
2336 if env['STATIC_TCLTK']:
2337 if conf.CheckTkTable():
2338 pass
2339 else:
2340 without_tcltk_reason = "TkTable not found"
2341 with_tcltk = False
2342 else:
2343 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2344 with_tcltk = False
2345 else:
2346 without_tcltk_reason = "Tk not found."
2347 with_tcltk = False
2348 else:
2349 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2350 with_tcltk = False
2351
2352 else:
2353 without_tcltk_reason = "Tcl not found."
2354 with_tcltk = False
2355
2356 if env['STATIC_TCLTK']:
2357 conf.CheckX11()
2358
2359 # Python... obviously we're already running python, so we just need to
2360 # check that we can link to the python library OK:
2361
2362 if not conf.CheckPythonLib():
2363 without_python_reason = 'libpython2.x not found or not linkable'
2364 with_python = False
2365 env['WITH_PYTHON']=False
2366
2367 # SWIG version
2368
2369 if with_python and conf.CheckSwigVersion() is False:
2370 without_python_reason = 'SWIG >= 1.3.24 is required'
2371 with_python = False
2372 env['WITH_PYTHON']=False
2373
2374 # CUnit
2375
2376 if with_cunit:
2377 if not conf.CheckCUnit():
2378 without_cunit_reason = 'CUnit not found'
2379 with_cunit = False
2380 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2381
2382 # DMALLOC
2383
2384 if with_dmalloc:
2385 if not conf.CheckDMalloc():
2386 without_dmalloc_reason = 'dmalloc not found'
2387 with_dmalloc = False
2388
2389 # GRAPHVIZ
2390
2391 if with_graphviz:
2392 if not conf.CheckGraphViz():
2393 without_graphviz_reason = 'graphviz not found'
2394 with_graphviz = False
2395 env['WITH_GRAPHVIZ'] = False
2396 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2397
2398 # UFSPARSE
2399
2400 if with_ufsparse:
2401 if not conf.CheckUFSparse():
2402 without_ufsparse_reason = 'ufsparse not found'
2403 with_ufsparse = False
2404 env['WITH_UFSPARSE'] = False
2405
2406 # IDA
2407
2408 if with_ida:
2409 if not conf.CheckSUNDIALS():
2410 with_ida = False
2411 without_ida_reason = "SUNDIALS not found, or bad version"
2412 elif not conf.CheckIDA():
2413 with_ida = False
2414 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2415
2416 # CONOPT
2417
2418 if not with_conopt:
2419 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2420 elif conf.CheckCONOPT() is False:
2421 if conf.env.get('CONOPT_LINKED'):
2422 conf.env['CONOPT_LINKED'] = False
2423 # we no longer require CONOPT at buildtime in order to build support for it
2424 #with_conopt = False
2425 #without_conpt_reason = "CONOPT not found"
2426
2427 # IPOPT
2428
2429 if not with_ipopt:
2430 without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2431 elif not conf.CheckIPOPT():
2432 with_ipopt = False
2433 without_ipopt_reason = "IPOPT not found"
2434
2435 # BLAS
2436
2437 need_blas=False
2438
2439 if with_lsode:
2440 need_fortran = True
2441 need_fortran_reasons.append("LSODE")
2442 need_blas=True
2443
2444 if with_ipopt:
2445 need_blas=True
2446
2447 if need_blas:
2448 if conf.CheckLib('blas'):
2449 with_local_blas = False
2450 without_local_blas_reason = "Found BLAS installed on system"
2451 else:
2452 with_local_blas = True
2453 need_fortran = True
2454 need_fortran_reasons.append("BLAS")
2455 else:
2456 with_local_blas= False;
2457 without_local_blas_reason = "BLAS not required"
2458
2459 # FORTRAN
2460
2461 if need_fortran:
2462 print "NEED FORTRAN"
2463 # Removed stuff for SCons 0.97 (Ubuntu 8.04) from here -- JP
2464 detect_fortran = conf.env.Detect(['gfortran','g77'])
2465 if detect_fortran:
2466 conf.env.Tool(detect_fortran)
2467 if detect_fortran == 'g77':
2468 print "Setting F2C_LIB to 'g2c' because G77 compiler in use"
2469 conf.env['F2C_LIB'] = 'g2c'
2470 #print "DETECT_FORTRAN =",detect_fortran
2471 #print "NOW, FORTAN =",env['FORTRAN']
2472 else:
2473 print "FAILED G77/FORTRAN DETECTION"
2474 with_lsode=False;
2475 without_lsode_reason="FORTRAN required but not detected"
2476 else:
2477 print "FORTRAN WAS NOT FOUND TO BE REQUIRED"
2478
2479 if need_fortran and conf.CheckF77() is False:
2480 print "Failed to build simple test file with your Fortran compiler."
2481 print "Check your compiler is installed and running correctly."
2482 print "You can set your Fortran compiler using the FORTRAN scons option."
2483 print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2484 print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2485 Exit(1)
2486
2487 #else:
2488 # print "FORTRAN not required"
2489
2490 # F2C
2491
2492 if need_fortran:
2493 if platform.system()=="Windows":
2494 pass
2495 #conf.env.Append(LIBPATH='c:\mingw\lib')
2496
2497 # scrollkeeper
2498
2499 if with_scrollkeeper:
2500 if conf.CheckScrollkeeperConfig() is False:
2501 with_scrollkeeper=False
2502 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2503
2504 # lyx
2505
2506 if with_doc_build:
2507 if not conf.CheckLyx():
2508 with_doc_build = False
2509 without_doc_build_reason="unable to locate LyX"
2510
2511 with_latex2html = conf.CheckLatex2HTML()
2512
2513 if conf.CheckLModern() is False:
2514 with_doc_build = False
2515 without_doc_build_reason="'lmodern' is not available"
2516
2517 # TODO: -D_HPUX_SOURCE is needed
2518
2519 # TODO: detect if dynamic libraries are possible or not
2520
2521 if platform.system()=="Windows" and env.has_key('MSVS'):
2522 _found_windows_h = conf.CheckHeader('Windows.h')
2523
2524 if not _found_windows_h:
2525 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2526 Exit(1)
2527
2528 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2529 with_python = 0;
2530 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2531
2532 conf.Finish()
2533
2534 #print "-=-=-=-=-=-=-=-=- LIBS =",env.get('LIBS')
2535
2536 #---------------------------------------
2537 # SUBSTITUTION DICTIONARY for .in files
2538
2539 release = env.get('RELEASE')
2540 if release=="0.":
2541 release="0"
2542
2543 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2544
2545 subst_dict = {
2546 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2547 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2548 , '@GLADE_FILE@':'ascend.glade'
2549 , '@HELP_ROOT@':''
2550 , '@ICON_EXTENSION@':icon_extension
2551 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2552 , '@INSTALL_BIN@':env['INSTALL_BIN']
2553 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2554 , '@INSTALL_LIB@':env['INSTALL_LIB']
2555 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2556 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2557 , '@INSTALL_PYTHON@':env['INSTALL_PYTHON']
2558 , '@INSTALL_PYTHON_ASCEND@':env['INSTALL_PYTHON_ASCEND']
2559 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2560 , '@VERSION@':version
2561 , '@RELEASE@':release
2562 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2563 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2564 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2565 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2566 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2567 , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2568 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2569 , '@PYTHON@' : python_exe
2570 , '@PYVERSION@' : pyversion
2571 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2572 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2573 #define ASC_ABSOLUTE_PATHS @ASC_ABSOLUTE_PATHS@
2574 #if ASC_ABSOLUTE_PATHS
2575 # define ASCENDDIST_DEFAULT "@ASCENDDIST_DEFAULT@"
2576 # define ASCENDTK_DEFAULT "@ASCENDTK_DEFAULT@"
2577 # define ASCENDLIBRARY_DEFAULT "@ASCENDLIBRARY_DEFAULT@"
2578 # define ASCENDSOLVERS_DEFAULT "@ASCENDSOLVERS_DEFAULT@"
2579 #else
2580 # define ASC_DIST_REL_BIN "@ASC_DIST_REL_BIN@"
2581 # define ASC_TK_REL_DIST "@ASC_TK_REL_DIST@"
2582 # define ASC_LIBRARY_REL_DIST "@ASC_LIBRARY_REL_DIST@"
2583 # define ASC_SOLVERS_REL_DIST "@ASC_SOLVERS_REL_DIST@"
2584 #endif
2585 , '@ASC_ABSOLUTE_PATHS@': str(int(env.get('ABSOLUTE_PATHS')))
2586 , '@ASCENDDIST_DEFAULT@': c_escape(env['INSTALL_PREFIX'])
2587 , '@ASCENDTK_DEFAULT@': c_escape(os.path.abspath(env.subst(env['INSTALL_TK'])))
2588 , '@ASCENDLIBRARY_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDLIBRARY'])))
2589 , '@ASCENDSOLVERS_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDSOLVERS'])))
2590 , '@ASC_DIST_REL_BIN@' : default_dist_rel_bin
2591 , '@ASC_TK_REL_DIST@' : default_tk_rel_dist
2592 , '@ASC_LIBRARY_REL_DIST@' : default_library_rel_dist
2593 , '@ASC_SOLVERS_REL_DIST@' : default_solvers_rel_dist
2594 , '@SIZEOF_VOID_P@' : env['SIZEOF_VOID_P']
2595 , '@SIZEOF_INT@' : env['SIZEOF_INT']
2596 , '@SIZEOF_LONG@' : env['SIZEOF_LONG']
2597 , '@SIZEOF_LONG_LONG@' : env['SIZEOF_LONG_LONG']
2598 }
2599
2600 if env.get('WITH_DOC'):
2601 print "WITH_DOC:",env['WITH_DOC']
2602 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2603
2604 # bool options...
2605 for k,v in {
2606 'ASC_WITH_DMALLOC':with_dmalloc
2607 ,'ASC_WITH_UFSPARSE':with_ufsparse
2608 ,'ASC_WITH_MMIO':with_mmio
2609 ,'ASC_SIGNAL_TRAPS':with_signals
2610 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2611 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2612 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2613 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2614 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2615 ,'ASC_HAVE_LEXDESTROY':env.get('HAVE_LEXDESTROY')
2616 }.iteritems():
2617
2618 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2619
2620 if with_python:
2621 subst_dict['@ASCXX_USE_PYTHON@']="1"
2622 env['WITH_PYTHON']=1;
2623
2624 if with_latex2html:
2625 env['WITH_LATEX2HTML']=1
2626
2627 if env.has_key('HAVE_GCCVISIBILITY'):
2628 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2629
2630 env.Append(SUBST_DICT=subst_dict)
2631
2632 #for k,v in subst_dict.iteritems():
2633 # print "%-50s%s" % ("'%s'"%k,v)
2634
2635 # REMOVED: long command-line support on Win2k
2636
2637 #------------------------------------------------------
2638 # RECIPE: SWIG scanner
2639
2640 import SCons.Script
2641
2642 SWIGScanner = SCons.Scanner.ClassicCPP(
2643 "SWIGScan"
2644 , ".i"
2645 , "CPPPATH"
2646 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2647 )
2648
2649 env.Append(SCANNERS=[SWIGScanner])
2650
2651 #------------------------------------------------------
2652 # Recipe for 'CHMOD' ACTION
2653
2654 import SCons
2655 from SCons.Script.SConscript import SConsEnvironment
2656 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2657 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2658
2659 def InstallPerm(env, dest, files, perm):
2660 obj = env.Install(dest, files)
2661 for i in obj:
2662 env.AddPostAction(i, env.Chmod(str(i), perm))
2663
2664 def InstallPermAs(env, dest, filen, perm):
2665 obj = env.InstallAs(dest, filen)
2666 for i in obj:
2667 env.AddPostAction(i, env.Chmod(str(i), perm))
2668 return dest
2669
2670 SConsEnvironment.InstallPerm = InstallPerm
2671
2672 # define wrappers
2673 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2674 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2675 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2676 SConsEnvironment.InstallSharedAs = lambda env, dest, files: InstallPermAs(env, dest, files, 0644)
2677 SConsEnvironment.InstallLibraryAs = lambda env, dest, files: InstallPermAs(env, dest, files, 0644)
2678
2679 #------------------------------------------------------
2680 # BUILD...
2681
2682 # so that #include <ascend/modulename/headername.h> works across all modules...
2683 env.AppendUnique(CPPPATH=['#'])
2684
2685 if env['DEBUG']:
2686 env.Append(
2687 CCFLAGS=['-g']
2688 ,LINKFLAGS=['-g']
2689 )
2690
2691 if env['GCOV']:
2692 env.Append(
2693 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2694 , LIBS=['gcov']
2695 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2696 )
2697
2698 if with_ida:
2699 env.Append(WITH_IDA=1)
2700
2701 if with_conopt:
2702 env.Append(WITH_CONOPT=1)
2703
2704 if with_ipopt:
2705 env.Append(WITH_IPOPT=1)
2706
2707 if with_dopri5:
2708 env.Append(WITH_DOPRI5=1)
2709
2710 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2711 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2712
2713 #-------------
2714 # TCL/TK GUI
2715
2716 if with_tcltk:
2717 env.SConscript(['tcltk/SConscript'],'env')
2718 else:
2719 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2720
2721 #-------------
2722 # PYTHON INTERFACE
2723
2724 if with_python:
2725 env.SConscript(['ascxx/SConscript'],'env')
2726 env.SConscript(['pygtk/SConscript'],'env')
2727 else:
2728 print "Skipping... Python bindings aren't being built:",without_python_reason
2729
2730 #------------
2731 # BASE/GENERIC SUBDIRECTORIES
2732
2733 libascend_env = env.Clone()
2734
2735 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2736
2737 srcs = []
2738 for d in dirs:
2739 heresrcs = libascend_env.SConscript('ascend/'+d+'/SConscript','libascend_env')
2740 srcs += heresrcs
2741
2742 #-------------
2743 # IMPORTED CODE: LSODE, BLAS, etc
2744
2745 #if with_lsode:
2746 # srcs += env.SConscript(['lsod/SConscript'],'env')
2747 # srcs += env.SConscript(['linpack/SConscript'],'env')
2748 #else:
2749 # print "Skipping... LSODE won't be built:", without_lsode_reason
2750
2751 if with_local_blas:
2752 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2753 else:
2754 env['blasobjs'] = []
2755 print "Skipping... BLAS won't be built:", without_local_blas_reason
2756
2757 if not with_ida:
2758 print "Skipping... IDA won't be built:", without_ida_reason
2759
2760 if not with_dopri5:
2761 print "Skipping... DOPRI5 won't be built:", without_dopri5_reason
2762
2763 if with_mmio:
2764 srcs += env.SConscript(['mmio/SConscript'],'env')
2765 else:
2766 print "Skipping... MMIO export won't be built:", without_mmio_reason
2767 #-------------
2768 # LIBASCEND -- all 'core' functionality
2769
2770 # FIXME want to move these bits to ascend/SConscript
2771
2772 libascend_env.Append(
2773 CPPPATH=['#']
2774 ,LIBS=['m']
2775 )
2776
2777 if platform.system()=="Linux":
2778 libascend_env.Append(LIBS=['dl'])
2779
2780 if with_dmalloc:
2781 libascend_env.Append(LIBS=['dmalloc'])
2782
2783 if with_ufsparse:
2784 libascend_env.Append(LIBS=['cxsparse'])
2785
2786 if platform.system()=="Linux":
2787 libascend_env.Append(LINKFLAGS=['-Wl,-soname,%s' % soname_full])
2788
2789 libascend = libascend_env.SharedLibrary('ascend',srcs)
2790
2791 # create local symlink for the soname stuff.
2792 #print "SONAME =",env.subst(soname_full)
2793
2794 env['libascend'] = libascend
2795 libtargets = [libascend]
2796
2797 if platform.system()=="Linux":
2798 if soname_major:
2799 libascend_env.Command(soname_full,libascend,Move("$TARGET","$SOURCE"))
2800 #print "MAKING LINK, SONAME_MAJOR =",soname_major
2801 liblink = libascend_env.Command(soname_full, libascend, "ln -s $SOURCE $TARGET")
2802 libtargets.append(liblink)
2803
2804 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2805
2806 env.Alias('libascend',libtargets)
2807
2808 #-------------
2809 # UNIT TESTS (C CODE)
2810
2811 test_env = env.Clone()
2812 test_env.Append(
2813 CPPPATH="#"
2814 )
2815
2816 if with_cunit:
2817 testdirs = ['general','solver','utilities','linear','compiler','packages']
2818 testsrcs = []
2819 for testdir in testdirs:
2820 path = 'ascend/'+testdir+'/test/'
2821 test_env.SConscript([path+'SConscript'],'test_env')
2822 testsrcs += [i.path for i in test_env['TESTSRCS_'+testdir.upper()]]
2823 test_env['TESTDIRS'] = testdirs
2824
2825 #print "TESTSRCS =",testsrcs
2826
2827 test_env.SConscript(['test/SConscript'],'test_env')
2828
2829 env.Alias('test',[env.Dir('test')])
2830
2831 else:
2832 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2833
2834 #-------------
2835 # EXTERNAL SOLVERS
2836
2837 env['extfns']=[]
2838
2839 env.SConscript(['solvers/SConscript'],'env')
2840
2841 #-------------
2842 # EXTERNAL FUNCTIONS
2843
2844 modeldirs = env.SConscript(['models/SConscript'],'env')
2845
2846 if not with_extfns:
2847 print "Skipping... External modules aren't being built:",without_extfns_reason
2848
2849 env.Alias('extfns',env['extfns'])
2850
2851 #-------------
2852 # FPROPS python bindings
2853
2854 env.Alias('pyfprops',env['pyfprops'])
2855
2856 #------------------------------------------------------
2857 # CREATE ASCEND-CONFIG scriptlet
2858
2859 ascendconfig = env.SubstInFile('ascend-config.in')
2860
2861 #------------------------------------------------------
2862 # INSTALLATION
2863
2864 if env.get('CAN_INSTALL'):
2865
2866 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC','INSTALL_PYTHON']
2867 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2868 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2869
2870 #env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2871
2872 libname = "${INSTALL_LIB}/%s%s" % (soname_full,soname_minor)
2873 install_lib = env.InstallLibraryAs("${INSTALL_ROOT}"+libname, [libascend])
2874 if env['ABSOLUTE_PATHS']:
2875 link_target = libname
2876 else:
2877 link_target = "%s%s" % (soname_full,soname_minor)
2878
2879 link1 = "${INSTALL_LIB}/%s" % soname_clean
2880 install_link1 = None
2881 if env.subst(link1) != env.subst(libname):
2882 # v--link to create v--file to link to command
2883 install_link1 = env.Command("${INSTALL_ROOT}"+link1,install_lib
2884 # v-- command to do it (note the trick about
2885 ,"ln -f -s %s $TARGET" % link_target
2886 )
2887
2888 link2 = "${INSTALL_LIB}/%s" % soname_full
2889 install_link2 = None
2890 if soname_minor:
2891 install_link2 = env.Command("${INSTALL_ROOT}"+link2,install_lib
2892 ,"ln -f -s %s $TARGET" % link_target
2893 )
2894
2895 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2896
2897 # MAC OS X INSTALL STUFF
2898 # in this case, we're installing to INSTALL_PREFIX, assumed to be a folder
2899 # created using Disk Utility as a new DMG which will be distributed.
2900 if platform.system()=="Darwin":
2901 # extra stuff for inside the .app
2902 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),"mac/Info.plist")
2903 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN/Resources/")),"mac/ascend.icns")
2904
2905 # related files the .dmg folder
2906 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PREFIX")),"README-osx.txt")
2907 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PREFIX")),"LICENSE.txt")
2908 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PREFIX")),"CHANGELOG.txt")
2909 env.Command("$INSTALL_ROOT$INSTALL_PREFIX/Applications Folder","/Applications","ln -f -s $SOURCE $TARGET")
2910 install_dirs += [Dir(env.subst("$INSTALL_ROOT$INSTALL_PREFIX"))]
2911
2912 # GTK libraries and related files
2913 gtkfiles = []
2914 gtksource = "dist/PyGTK.bundle/"
2915 def visit(gtkfiles,dirname,fnames):
2916 gtkfiles += Glob("%s/*" % dirname)
2917 os.path.walk(gtksource,visit,gtkfiles)
2918
2919 #print "GTKFILES ="
2920 #
2921 for f in gtkfiles:
2922 r = os.path.commonprefix([gtksource,f.path])
2923 dirname,filename = os.path.split(f.path[len(r):])
2924 dest = os.path.join(env.subst("$INSTALL_ROOT$INSTALL_BIN/PyGTK.bundle"),dirname)
2925 # print "%s --> %s" %(f,dest)
2926 env.Install(Dir(dest),f)
2927
2928 # ALIAS FOR ALL INSTALLATION
2929 env.Alias('install',install_dirs)
2930
2931 #------------------------------------------------------
2932 # WINDOWS INSTALLER
2933
2934 if not env.get('NSIS'):
2935 with_installer = False
2936 without_installer_reason = "NSIS not found"
2937
2938 if with_installer:
2939 env.Append(NSISDEFINES={
2940 'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2941 ,"VERSION":version
2942 ,'PYVERSION':pyversion
2943 ,'IPOPTDLL':os.path.normpath(env['IPOPT_DLL'])
2944 })
2945 installer = env.Installer('nsis/installer.nsi')
2946 env.Depends(installer,["pygtk","tcltk","ascend.dll","models","solvers","ascend-config",'pygtk/ascend'])
2947 env.Depends(installer,[os.path.normpath(env['IPOPT_DLL'])])
2948 env.Alias('installer',installer)
2949 else:
2950 print "Skipping... Windows installer isn't being built:",without_installer_reason
2951
2952 #------------------------------------------------------
2953 # CREATE the SPEC file for generation of RPM packages
2954
2955 if platform.system()=="Linux":
2956 env.SubstInFile('ascend.spec.in')
2957
2958 #------------------------------------------------------
2959 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2960
2961 #if with_scrollkeeper:
2962 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2963 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2964
2965 #------------------------------------------------------
2966 # DISTRIBUTION TAR FILE
2967
2968 env['DISTTAR_FORMAT']='bz2'
2969 env.Append(
2970 DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.lib','.cc','.cache',
2971 '.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx',
2972 '.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz',
2973 '.bz2','.7z','.deb','.dsc','.changes','.bak','.tex','.tmp']
2974 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2975 , DISTTAR_EXCLUDERES=[r"_wrap\.cc?$", r"~$", r"ascxx/ascpy\.py","ascxx/testipopt$"
2976 ,r"/lib.*\.so\.[.0-9]+$", r"tcltk/asc4dev$", r"tcltk/interface/typelex\.c$"
2977 ,r"ascend/compiler/ascParse\.[ch]$", r"ascend/solver/conoptconfig\.h$"
2978 ,r"ascend/utilities/config\.h$", r"pygtk/config\.h$", r"pygtk/config\.py$"
2979 ,r"pygtk/ascdev$", r"ascxx/testconopt$", r"ascend/compiler/scanner\.c$"
2980 ,r"tcltk/interface/ascend4$",r"ascxx/testslvreq$",r"test/test$"
2981 ,r"models/johnpye/datareader/.*\.tm2\.Z$"
2982 ,r"models/johnpye/fprops/[a-z][a-z0-9]+(.*\.exe)?$" # FPROPS test executables
2983 ,r"models/johnpye/fprops/fluids/fluids_list\.h$" # FPROPS fluids list
2984 ]
2985 )
2986
2987 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2988 , [env.Dir('#')]
2989 )
2990
2991 env.Depends(tar,'ascend.spec')
2992 env.Depends(tar,'doc/book.pdf')
2993
2994 #------------------------------------------------------
2995 # DEBIAN TARBALL for use with Build Service
2996
2997 import glob
2998 deb_files = glob.glob('debian/*.install')
2999 deb_files += glob.glob('debian/*.docs')
3000 deb_files += glob.glob('debian/*.dirs')
3001 deb_files += glob.glob('debian/*.man')
3002 deb_files += glob.glob('debian/*.manpages')
3003 deb_files += ['debian/%s' % s for s in ['rules','control','changelog','compat','copyright','dirs']]
3004
3005 deb_tar = env.Tar(
3006 'dist/debian.tar.gz'
3007 ,deb_files
3008 ,TARFLAGS = ['cz']
3009 )
3010
3011 Alias('dist',[tar,deb_tar])
3012
3013 #------------------------------------------------------
3014 # DOCUMENTATION
3015
3016 #print "WITH_DOC_BUILD = ",with_doc_build
3017
3018 if not with_doc_build:
3019 print "Skipping... Documentation isn't being built:",without_doc_build_reason
3020
3021 #user's manual
3022 env.SConscript('doc/SConscript',['env'])
3023
3024 #------------------------------------------------------
3025 # RPM BUILD
3026
3027 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
3028 # (check * for the version number used to create the tarball)
3029
3030 #------------------------------------------------------
3031 # DEFAULT TARGETS
3032
3033 default_targets =['libascend','solvers']
3034 if with_tcltk:
3035 default_targets.append('tcltk')
3036 if with_python:
3037 default_targets.append('ascxx')
3038 default_targets.append('pygtk')
3039 default_targets.append('pyfprops')
3040 #if with_installer:
3041 # default_targets.append('installer')
3042 if with_extfns:
3043 default_targets.append('extfns')
3044 if with_doc_build:
3045 default_targets.append('doc')
3046
3047 env.Default(default_targets)
3048
3049 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
3050
3051 # vim: set syntax=python:

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