/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

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