/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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