/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2055 - (show annotations) (download)
Wed Jun 24 00:57:03 2009 UTC (9 years, 5 months ago) by jpye
File size: 70549 byte(s)
Empty message
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 0;
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 1;
1106 else:
1107 context.Result("too old, %d.%d.%d" % (maj,min,pat))
1108 return 0;
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 else:
1550 # checked on Linux and SunOS
1551 if cfig['LDLIBRARY']==cfig['LIBRARY']:
1552 sys.stdout.write("(static)")
1553 python_libpath += [cfig['LIBPL']]
1554 python_linkflags += cfig['LIBS'].split(' ')
1555
1556 context.env.AppendUnique(LIBS=python_libs)
1557 context.env.AppendUnique(LIBPATH=python_libpath)
1558 context.env.AppendUnique(CPPPATH=python_cpppath)
1559 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1560 result = context.TryLink(libpython_test_text,".c");
1561
1562 context.Result(result)
1563
1564 if(result):
1565 context.env['PYTHON_LIBPATH']=python_libpath
1566 context.env['PYTHON_LIB']=python_libs
1567 context.env['PYTHON_CPPPATH']=python_cpppath
1568 context.env['PYTHON_LINKFLAGS']=python_linkflags
1569
1570 context.env['LIBS'] = lastLIBS
1571 context.env['LIBPATH'] = lastLIBPATH
1572 context.env['CPPPATH'] = lastCPPPATH
1573 context.env['LINKFLAGS'] = lastLINKFLAGS
1574
1575 return result
1576
1577 #----------------
1578 # IDA test
1579
1580 sundials_version_major_required = 2
1581 sundials_version_minor_min = 2
1582 sundials_version_minor_max = 3
1583
1584 sundials_version_text = """
1585 #include <sundials/sundials_config.h>
1586 #include <stdio.h>
1587 int main(){
1588 printf("%s",SUNDIALS_PACKAGE_VERSION);
1589 return 0;
1590 }
1591 """
1592
1593 ida_test_text = """
1594 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1595 # include <sundials/sundials_config.h>
1596 # include <sundials/sundials_nvector.h>
1597 # include <nvector_serial.h>
1598 # include <ida.h>
1599 # include <ida/ida_spgmr.h>
1600 #else
1601 # include <sundials/sundials_config.h>
1602 # include <nvector/nvector_serial.h>
1603 # include <ida/ida.h>
1604 #endif
1605 int main(){
1606 void *ida_mem;
1607 ida_mem = IDACreate();
1608 return 0;
1609 }
1610 """
1611
1612 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1613 # so detect the version and act accordingly.
1614 def CheckSUNDIALS(context):
1615 keep = KeepContext(context,'SUNDIALS')
1616 context.Message("Checking for SUNDIALS... ")
1617 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1618 keep.restore(context)
1619 if not is_ok:
1620 context.Result(0)
1621 return 0
1622
1623 major,minor,patch = tuple([int(i) for i in output.split(".")])
1624 context.env['SUNDIALS_VERSION_MAJOR'] = major
1625 context.env['SUNDIALS_VERSION_MINOR'] = minor
1626 if major != sundials_version_major_required \
1627 or minor < sundials_version_minor_min \
1628 or minor > sundials_version_minor_max:
1629 context.Result(output+" (bad version)")
1630 # bad version
1631 return 0
1632
1633 # good version
1634 context.Result("%d.%d.%d, good" % (major,minor,patch))
1635
1636 return 1
1637
1638
1639 def CheckIDA(context):
1640 context.Message( 'Checking for IDA... ' )
1641
1642 keep = KeepContext(context,"SUNDIALS")
1643
1644 major = context.env['SUNDIALS_VERSION_MAJOR']
1645 minor = context.env['SUNDIALS_VERSION_MINOR']
1646
1647 cppdef = context.env.get('CPPDEFINES')
1648
1649 context.env.Append(CPPDEFINES=[
1650 ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1651 ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1652 ])
1653
1654 context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1655 if major==2 and minor==2:
1656 context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1657
1658 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1659 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1660 context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1661
1662 is_ok = context.TryLink(ida_test_text,".c")
1663 context.Result(is_ok)
1664
1665 if cppdef:
1666 context.env['CPPDEFINES']=cppdef
1667 else:
1668 del context.env['CPPDEFINES']
1669
1670 keep.restore(context)
1671
1672 return is_ok
1673
1674
1675 #----------------
1676 # CONOPT test
1677
1678 conopt_test_text = """
1679 #if !defined(_WIN32)
1680 # define FNAME_LCASE_DECOR
1681 #endif
1682
1683 #include <conopt.h>
1684 #include <stdlib.h>
1685 int main(){
1686 int s, *v, e;
1687 s = COIDEF_Size();
1688 v = (int *)malloc(s*sizeof(int));
1689 e = COIDEF_Ini(v);
1690 return e;
1691 }
1692 """
1693
1694 def CheckCONOPT(context):
1695 context.Message( 'Checking for CONOPT... ' )
1696
1697 keep = KeepContext(context,"CONOPT")
1698
1699 is_ok = context.TryLink(conopt_test_text,".c")
1700 context.Result(is_ok)
1701
1702 keep.restore(context)
1703
1704 return is_ok
1705
1706 #----------------
1707 # IPOPT test
1708
1709 ipopt_test_text = """
1710 #if !defined(_WIN32)
1711 # define FNAME_LCASE_DECOR
1712 #endif
1713
1714 #include <coin/IpStdCInterface.h>
1715 int main(){
1716 Number n;
1717 IpoptProblem nlp = 0;
1718 n = 1;
1719 FreeIpoptProblem(nlp); // probably a crash if you run this
1720 return 0;
1721 }
1722 """
1723
1724 def CheckIPOPT(context):
1725 context.Message( 'Checking for IPOPT... ' )
1726
1727 keep = KeepContext(context,"IPOPT")
1728 is_ok = context.TryLink(ipopt_test_text,".c")
1729 context.Result(is_ok)
1730
1731 keep.restore(context)
1732
1733 return is_ok
1734
1735 #----------------
1736 # Tcl test
1737
1738 # TCL and TK required version 8.1 through 8.5:
1739 tcltk_minor_newest_acceptable = 5
1740 tcltk_major_required = 8
1741
1742 tcl_check_text = r"""
1743 #include <tcl.h>
1744 #include <stdio.h>
1745 int main(void){
1746 printf("%s",TCL_PATCH_LEVEL);
1747 return 0;
1748 }
1749 """
1750
1751 def CheckTcl(context):
1752 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1753
1754 def CheckTclVersion(context):
1755 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1756 context.Message("Checking Tcl version... ")
1757 (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1758 keep.restore(context)
1759 if not is_ok:
1760 context.Result("failed to run check")
1761 return 0
1762
1763 major,minor,patch = tuple([int(i) for i in output.split(".")])
1764 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1765 context.Result(output+" (bad version)")
1766 # bad version
1767 return 0
1768
1769 # good version
1770 context.Result(output+", good")
1771 return 1
1772
1773 #----------------
1774 # Tk test
1775
1776 tk_check_text = r"""
1777 #include <tk.h>
1778 #include <stdio.h>
1779 int main(void){
1780 printf("%s",TK_PATCH_LEVEL);
1781 return 0;
1782 }
1783 """
1784 def CheckTk(context):
1785 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1786
1787
1788 def CheckTkVersion(context):
1789 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1790 context.Message("Checking Tk version... ")
1791 #print "LINKFLAGS =",context.env['LINKFLAGS']
1792 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1793 keep.restore(context)
1794 if not is_ok:
1795 context.Result("failed to run check")
1796 return 0
1797
1798 major,minor,patch = tuple([int(i) for i in output.split(".")])
1799 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1800 # bad version
1801 context.Result(output+" (bad version)")
1802 return 0
1803
1804 # good version
1805 context.Result(output+" (good)")
1806 return 1
1807
1808 #----------------
1809 # Tktable test
1810
1811 tktable_check_text = r"""
1812 #include <tkTable.h>
1813 #include <stdio.h>
1814 int main(void){
1815 Table mytable;
1816 return 0;
1817 }
1818 """
1819
1820 def CheckTkTable(context):
1821 return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1822
1823 #---------------
1824 # X11 test
1825
1826 x11_check_text = r"""
1827 #include <X11/Xlib.h>
1828 #include <X11/IntrinsicP.h>
1829 #include <X11/Intrinsic.h>
1830 #include <X11/ObjectP.h>
1831 #include <X11/Object.h>
1832 int main(void){
1833 Object mything;
1834 return 0;
1835 }
1836 """
1837
1838 def CheckX11(context):
1839 return CheckExtLib(context,'X11',x11_check_text)
1840
1841 #----------------
1842 # Check that we can raise and catch sigint
1843
1844 sigint_test_text = r"""
1845 #include <signal.h>
1846 #include <setjmp.h>
1847 #include <stdlib.h>
1848 static jmp_buf g_jmpenv;
1849 void sighandler(int sig){
1850 longjmp(g_jmpenv,sig);
1851 }
1852 void testsigint(){
1853 raise(SIGINT);
1854 }
1855 int main(void){
1856 signal(SIGINT,&sighandler);
1857 switch(setjmp(g_jmpenv)){
1858 case 0:
1859 testsigint();
1860 exit(1);
1861 case SIGINT:
1862 exit(0);
1863 default:
1864 exit(2);
1865 }
1866 }
1867 """
1868
1869 def CheckSIGINT(context):
1870 context.Message("Checking SIGINT is catchable... ")
1871 (is_ok,output)=context.TryRun(sigint_test_text,".c")
1872 context.Result(is_ok)
1873 return is_ok
1874
1875 #----------------
1876 # Check that we're able to catch floating point errors
1877
1878 sigfpe_test_text = r"""
1879 #include <signal.h>
1880 #include <setjmp.h>
1881 #include <stdlib.h>
1882 #include <fenv.h>
1883 static jmp_buf g_jmpenv;
1884 void fpehandler(int sig){
1885 longjmp(g_jmpenv,sig);
1886 }
1887 int main(void){
1888 fenv_t myfenv;
1889 fegetenv(&myfenv);
1890 fesetenv(&myfenv);
1891 feenableexcept(FE_ALL_EXCEPT);
1892 signal(SIGFPE,&fpehandler);
1893 double x;
1894 switch(setjmp(g_jmpenv)){
1895 case 0:
1896 x = 1.0 / 0.0;
1897 /* failed to catch */
1898 exit(1);
1899 case SIGFPE:
1900 exit(0);
1901 }
1902 }
1903 """
1904
1905 def CheckFPE(context):
1906 context.Message("Checking C99 FPE behaviour... ")
1907 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1908 context.Result(is_ok)
1909 return is_ok
1910
1911 #----------------
1912 # signal reset needed?
1913
1914 sigreset_test_text = r"""
1915 #include <signal.h>
1916 #include <setjmp.h>
1917 #include <stdlib.h>
1918 #include <stdio.h>
1919 typedef void SigHandlerFn(int);
1920 static jmp_buf g_jmpenv;
1921 void sighandler(int sig){
1922 longjmp(g_jmpenv,sig);
1923 }
1924 void testsigint(){
1925 /* fprintf(stderr,"Raising SIGINT\n"); */
1926 raise(SIGINT);
1927 }
1928 int main(void){
1929 SigHandlerFn *last,*saved;
1930 saved = signal(SIGINT,&sighandler);
1931 if(saved!=SIG_DFL){
1932 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1933 exit(3);
1934 }
1935 switch(setjmp(g_jmpenv)){
1936 case 0:
1937 testsigint();
1938 fprintf(stderr,"Back from SIGINT\n");
1939 exit(1);
1940 case SIGINT:
1941 break;
1942 default:
1943 exit(2);
1944 };
1945 last = signal(SIGINT,SIG_DFL);
1946 if(last!=&sighandler){
1947 printf("1");
1948 exit(0);
1949 }
1950 printf("0");
1951 exit(0);
1952 }
1953 """
1954
1955 def CheckSigReset(context):
1956 context.Message("Checking signal handler reset... ")
1957 libsave=context.env.get('LIBS')
1958 context.env.AppendUnique(LIBS=['m'])
1959 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1960
1961 if libsave is None:
1962 del(context.env['LIBS'])
1963 else:
1964 context.env['LIBS']=libsave
1965
1966 if not is_ok:
1967 context.Result("ERROR")
1968 return False
1969 if int(output)==1:
1970 context.Result("required");
1971 context.env['ASC_RESETNEEDED'] = True
1972 else:
1973 context.Result("not required");
1974 context.env['ASC_RESETNEEDED'] = False
1975 return True
1976
1977 #----------------
1978 # LyX on this system?
1979
1980 def CheckLyx(context):
1981 context.Message("Checking for LyX... ")
1982 r = context.env.WhereIs("lyx")
1983 if r:
1984 context.Result(r)
1985 else:
1986 context.Result(0)
1987 return r
1988
1989 #----------------
1990 # Latex2HTML on this system?
1991
1992 def CheckLatex2HTML(context):
1993 context.Message("Checking for latex2html...")
1994 if context.env.WhereIs("latex2html"):
1995 r = True
1996 else:
1997 r = False
1998 context.Result(r)
1999 return r
2000
2001 #----------------
2002 # 'lmodern' package for LaTeX available?
2003
2004 lmodern_test_text = r"""
2005 \documentclass{article}
2006 \usepackage{lmodern}
2007 \title{Cartesian closed categories and the price of eggs}
2008 \author{Jane Doe}
2009 \date{September 1994}
2010 \begin{document}
2011 \maketitle
2012 Hello world!
2013 \end{document}
2014 """;
2015
2016 def CheckLModern(context):
2017 context.Message("Checking for lmodern...")
2018 b = context.env.get("DVI")
2019 if not b:
2020 context.Result(False)
2021 return False
2022 ff = context.env.get('LATEXFLAGS')
2023 context.env.Append(LATEXFLAGS=['-interaction=nonstopmode','-halt-on-error'])
2024 is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".latex")
2025 print "is_ok=",is_ok
2026 if ff is not None:
2027 context.env['LATEXFLAGS'] = ff
2028 else:
2029 del context.env['LATEXFLAGS']
2030 context.Result(is_ok)
2031 return is_ok
2032
2033 #----------------
2034 # GCC Version sniffing
2035
2036 # TODO FIXME
2037
2038 gcc_version4 = False
2039
2040 #------------------------------------------------------
2041 # CONFIGURATION
2042
2043 conf = Configure(env
2044 , custom_tests = {
2045 'CheckCC' : CheckCC
2046 , 'CheckCXX' : CheckCXX
2047 , 'CheckF77' : CheckF77
2048 , 'CheckMath' : CheckMath
2049 , 'CheckMalloc' : CheckMalloc
2050 , 'CheckDLOpen' : CheckDLOpen
2051 , 'CheckSwigVersion' : CheckSwigVersion
2052 , 'CheckPythonLib' : CheckPythonLib
2053 , 'CheckCUnit' : CheckCUnit
2054 , 'CheckDMalloc' : CheckDMalloc
2055 , 'CheckLyx' : CheckLyx
2056 , 'CheckLatex2HTML' : CheckLatex2HTML
2057 , 'CheckLModern' : CheckLModern
2058 , 'CheckGraphViz' : CheckGraphViz
2059 , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
2060 , 'CheckUFSparse' : CheckUFSparse
2061 , 'CheckTcl' : CheckTcl
2062 , 'CheckTclVersion' : CheckTclVersion
2063 , 'CheckTk' : CheckTk
2064 , 'CheckTkVersion' : CheckTkVersion
2065 , 'CheckGcc' : CheckGcc
2066 , 'CheckGccVisibility' : CheckGccVisibility
2067 , 'CheckYacc' : CheckYacc
2068 , 'CheckLex' : CheckLex
2069 , 'CheckTkTable' : CheckTkTable
2070 , 'CheckX11' : CheckX11
2071 , 'CheckIDA' : CheckIDA
2072 , 'CheckSUNDIALS' : CheckSUNDIALS
2073 , 'CheckCONOPT' : CheckCONOPT
2074 , 'CheckIPOPT' : CheckIPOPT
2075 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
2076 , 'CheckFPE' : CheckFPE
2077 , 'CheckSIGINT' : CheckSIGINT
2078 , 'CheckSigReset' : CheckSigReset
2079 # , 'CheckIsNan' : CheckIsNan
2080 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
2081 }
2082 # , config_h = "config.h"
2083 )
2084
2085 def sconsversioncheck():
2086
2087 # uncomment the following line to skip the version check:
2088 # return 1
2089
2090 import SCons
2091 v = SCons.__version__.split(".")
2092 if v[0] != '0':
2093 if v[0] == '1':
2094 return 1;
2095 return 0
2096 if int(v[1]) >= 97:
2097 return 1
2098 if v[1] != '96':
2099 return 0
2100 micro = int(v[2])
2101 if micro == 92 or micro == 93 or micro == 96:
2102 return 1;
2103 return 0
2104
2105 if not sconsversioncheck():
2106 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
2107 print "or consult the developers in the case of newer versions. Modify"
2108 print "the function 'sconsversioncheck' in the file SConstruct if you"
2109 print "want to *force* SCons to continue."
2110 Exit(1)
2111
2112 # check C compiler
2113
2114 if conf.CheckCC() is False:
2115 print "Failed to build simple test file with your C compiler."
2116 print "Check your compiler is installed and running correctly."
2117 Exit(1)
2118
2119 if conf.CheckCXX() is False:
2120 print "Failed to build simple test file with your C++ compiler."
2121 print "Check your compiler is installed and running correctly."
2122 print "You can set your C++ compiler using the CXX scons option."
2123 Exit(1)
2124
2125 # stdio -- just to check that compiler is behaving
2126
2127 if conf.CheckHeader('stdio.h') is False:
2128 print "CPPPATH =",env.get('CPPPATH')
2129 print "Did not find 'stdio.h'! Check your compiler configuration."
2130 print ""
2131 print "You environment is printed here:"
2132 for k,v in os.environ.iteritems():
2133 print "%-30s%s" % ("%s :" % k, v)
2134 Exit(1)
2135
2136 # sizes of vars used in libascend eg in gl_list etc.
2137
2138 _sizes = {
2139 "VOID_P" : "void *"
2140 ,"INT" : "int"
2141 ,"LONG" : "long"
2142 ,"LONG_LONG" : "long long"
2143 }
2144
2145 for _var,_type in _sizes.iteritems():
2146 _size = conf.CheckTypeSize(_type)
2147 if not _size:
2148 print "Couldn't determine 'sizeof(%s)'" % _type
2149 Exit(1)
2150 conf.env["SIZEOF_%s" % _var] = str(_size)
2151
2152 # check for some string functions
2153
2154 if conf.CheckFunc('snprintf') is False:
2155 print "Didn't find snprintf";
2156 Exit(1)
2157
2158 if conf.CheckFunc('strdup'):
2159 conf.env['HAVE_STRDUP'] = True
2160
2161 # attempt to support MSVCRT 7.1 on Windows
2162
2163 if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2164 conf.env.Append(LIBS='msvcr71')
2165
2166 # Math library
2167
2168 conf.env['HAVE_IEEE']=True
2169
2170 if need_libm and (conf.CheckMath() is False):
2171 conf.env['HAVE_IEEE']=False
2172 print 'Did not find math library, exiting!'
2173 Exit(1)
2174
2175 # Malloc
2176
2177 if conf.CheckMalloc() is False:
2178 conf.env['HAVE_MALLOC']=False
2179 print "Did not find functioning 'malloc', exiting!"
2180 Exit(1)
2181
2182 # dlopen/LoadLibrary
2183
2184 # CURRENTLY BREAKS LATER TEST (libsave?)
2185 #if conf.CheckDLOpen() is False:
2186 # print "Did not find functioning dlopen/LoadLibrary, exiting!"
2187 # Exit(1)
2188
2189 # Where is 'isnan'?
2190
2191 if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2192 print "Didn't find isnan"
2193 # Exit(1)
2194
2195 # GCC visibility
2196
2197 if conf.CheckGcc():
2198 conf.env['HAVE_GCC']=True;
2199 if env.get('WITH_GCCVISIBILITY') and conf.CheckGccVisibility():
2200 conf.env['HAVE_GCCVISIBILITY']=True;
2201 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
2202 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2203 conf.env.Append(CCFLAGS=['-Wall'])
2204
2205 # Catching SIGINT
2206
2207 if env['WITH_SIGNALS']:
2208 if not conf.CheckSIGINT():
2209 with_signals = False
2210 without_signals_reason = "SIGINT uncatchable"
2211
2212 # Catching SIGFPE
2213
2214 if conf.CheckFPE():
2215 conf.env['HAVE_C99FPE']=True
2216 else:
2217 conf.env['HAVE_C99FPE']=False
2218
2219 # Checking for signal reset requirement
2220
2221 if conf.CheckSigReset() is False:
2222 print "Unable to determine if signal reset is required"
2223 Exit(1)
2224
2225 # YACC
2226
2227 if conf.CheckYacc():
2228 conf.env['HAVE_YACC']=True
2229
2230 if conf.CheckLex():
2231 conf.env['HAVE_LEX']=True
2232
2233 # Tcl/Tk
2234
2235 if with_tcltk:
2236 if conf.CheckTcl():
2237 if conf.CheckTclVersion():
2238 if conf.CheckTk():
2239 if with_tcltk and conf.CheckTkVersion():
2240 if env['STATIC_TCLTK']:
2241 if conf.CheckTkTable():
2242 pass
2243 else:
2244 without_tcltk_reason = "TkTable not found"
2245 with_tcltk = False
2246 else:
2247 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
2248 with_tcltk = False
2249 else:
2250 without_tcltk_reason = "Tk not found."
2251 with_tcltk = False
2252 else:
2253 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
2254 with_tcltk = False
2255
2256 else:
2257 without_tcltk_reason = "Tcl not found."
2258 with_tcltk = False
2259
2260 if env['STATIC_TCLTK']:
2261 conf.CheckX11()
2262
2263 # Python... obviously we're already running python, so we just need to
2264 # check that we can link to the python library OK:
2265
2266 if not conf.CheckPythonLib():
2267 without_python_reason = 'libpython2.x not found or not linkable'
2268 with_python = False
2269 env['WITH_PYTHON']=False
2270
2271 # SWIG version
2272
2273 if with_python and conf.CheckSwigVersion() is False:
2274 without_python_reason = 'SWIG >= 1.3.24 is required'
2275 with_python = False
2276 env['WITH_PYTHON']=False
2277
2278 # CUnit
2279
2280 if with_cunit:
2281 if not conf.CheckCUnit():
2282 without_cunit_reason = 'CUnit not found'
2283 with_cunit = False
2284 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
2285
2286 # DMALLOC
2287
2288 if with_dmalloc:
2289 if not conf.CheckDMalloc():
2290 without_dmalloc_reason = 'dmalloc not found'
2291 with_dmalloc = False
2292
2293 # GRAPHVIZ
2294
2295 if with_graphviz:
2296 if not conf.CheckGraphViz():
2297 without_graphviz_reason = 'graphviz not found'
2298 with_graphviz = False
2299 env['WITH_GRAPHVIZ'] = False
2300 env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()
2301
2302 # UFSPARSE
2303
2304 if with_ufsparse:
2305 if not conf.CheckUFSparse():
2306 without_ufsparse_reason = 'ufsparse not found'
2307 with_ufsparse = False
2308 env['WITH_UFSPARSE'] = False
2309
2310 # IDA
2311
2312 if with_ida:
2313 if not conf.CheckSUNDIALS():
2314 with_ida = False
2315 without_ida_reason = "SUNDIALS not found, or bad version"
2316 elif not conf.CheckIDA():
2317 with_ida = False
2318 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2319
2320 # CONOPT
2321
2322 if not with_conopt:
2323 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2324 elif conf.CheckCONOPT() is False:
2325 if conf.env.get('CONOPT_LINKED'):
2326 conf.env['CONOPT_LINKED'] = False
2327 # we no longer require CONOPT at buildtime in order to build support for it
2328 #with_conopt = False
2329 #without_conpt_reason = "CONOPT not found"
2330
2331 # IPOPT
2332
2333 if not with_ipopt:
2334 without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2335 elif not conf.CheckIPOPT():
2336 with_ipopt = False
2337 without_ipopt_reason = "IPOPT not found"
2338
2339 # BLAS
2340
2341 need_blas=False
2342
2343 if with_lsode:
2344 need_fortran = True
2345 need_fortran_reasons.append("LSODE")
2346 need_blas=True
2347
2348 if with_ipopt:
2349 need_blas=True
2350
2351 if need_blas:
2352 if conf.CheckLib('blas'):
2353 with_local_blas = False
2354 without_local_blas_reason = "Found BLAS installed on system"
2355 else:
2356 with_local_blas = True
2357 need_fortran = True
2358 need_fortran_reasons.append("BLAS")
2359 else:
2360 with_local_blas= False;
2361 without_local_blas_reason = "BLAS not required"
2362
2363 # FORTRAN
2364
2365 if need_fortran:
2366 print "NEED FORTRAN"
2367 import SCons
2368 if SCons.__version__[0:4]=="0.97":
2369 # Older SCons verions 0.97 (eg Ubuntu 8.04) doesn't have the 'gfortran' tool'.
2370 # On this system, the 'fortran' tool seems to detect gfortran OK.
2371 conf.env.Tool('fortran')
2372 else:
2373 conf.env.Tool('g77')
2374 conf.env.Tool('gfortran')
2375 detect_fortran = conf.env.Detect(['gfortran','g77'])
2376 if detect_fortran:
2377 # For some reason, g77 doesn't get detected properly on MinGW
2378 if not env.has_key('F77') and not env.has_key('FORTRAN'):
2379 print "Fixing detection of F77 on MinGW...(?)"
2380 conf.env.Replace(F77=detect_fortran)
2381 conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2382 conf.env.Replace(F77FLAGS='')
2383 #print "F77:",conf.env['F77']
2384 #print "F77COM:",conf.env['F77COM']
2385 #print "F77FLAGS:",conf.env['F77FLAGS']
2386 fortran_builder = Builder(
2387 action='$F77COM'
2388 , suffix='.o'
2389 , src_suffix='.f'
2390 )
2391 conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2392 if platform.system()=="Linux":
2393 print "APPARENTLY FORTRAN WAS DETECTED"
2394 # not needed under scons 1.2, at least.
2395 # conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2396 else:
2397 print "FAILED FORTRAN DETECTION"
2398 with_lsode=False;
2399 without_lsode_reason="FORTRAN-77 required but not found"
2400 else:
2401 print "FORTRAN WAS NOT FOUND TO BE REQUIRED"
2402
2403 if need_fortran and conf.CheckF77() is False:
2404 print "Failed to build simple test file with your Fortran compiler."
2405 print "Check your compiler is installed and running correctly."
2406 print "You can set your Fortran compiler using the FORTRAN scons option."
2407 print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2408 print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2409 Exit(1)
2410
2411 #else:
2412 # print "FORTRAN not required"
2413
2414 # F2C
2415
2416 if need_fortran:
2417 if platform.system()=="Windows":
2418 pass
2419 #conf.env.Append(LIBPATH='c:\mingw\lib')
2420
2421 # scrollkeeper
2422
2423 if with_scrollkeeper:
2424 if conf.CheckScrollkeeperConfig() is False:
2425 with_scrollkeeper=False
2426 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2427
2428 # lyx
2429
2430 if with_doc_build:
2431 if not conf.CheckLyx():
2432 with_doc_build = False
2433 without_doc_build_reason="unable to locate LyX"
2434
2435 with_latex2html = conf.CheckLatex2HTML()
2436
2437 if conf.CheckLModern() is False:
2438 with_doc_build = False
2439 without_doc_build_reason="'lmodern' is not available"
2440
2441 # TODO: -D_HPUX_SOURCE is needed
2442
2443 # TODO: detect if dynamic libraries are possible or not
2444
2445 if platform.system()=="Windows" and env.has_key('MSVS'):
2446 _found_windows_h = conf.CheckHeader('Windows.h')
2447
2448 if not _found_windows_h:
2449 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2450 Exit(1)
2451
2452 if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2453 with_python = 0;
2454 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
2455
2456 conf.Finish()
2457
2458 #print "-=-=-=-=-=-=-=-=- LIBS =",env.get('LIBS')
2459
2460 #---------------------------------------
2461 # SUBSTITUTION DICTIONARY for .in files
2462
2463 release = env.get('RELEASE')
2464 if release=="0.":
2465 release="0"
2466
2467 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2468
2469 subst_dict = {
2470 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2471 ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2472 , '@GLADE_FILE@':'ascend.glade'
2473 , '@HELP_ROOT@':''
2474 , '@ICON_EXTENSION@':icon_extension
2475 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
2476 , '@INSTALL_BIN@':env['INSTALL_BIN']
2477 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2478 , '@INSTALL_LIB@':env['INSTALL_LIB']
2479 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2480 , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2481 , '@INSTALL_PYTHON@':env['INSTALL_PYTHON']
2482 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2483 , '@VERSION@':version
2484 , '@RELEASE@':release
2485 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2486 , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2487 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2488 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2489 , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2490 , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2491 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2492 , '@PYTHON@' : python_exe
2493 , '@PYVERSION@' : pyversion
2494 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2495 , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2496 #define ASC_ABSOLUTE_PATHS @ASC_ABSOLUTE_PATHS@
2497 #if ASC_ABSOLUTE_PATHS
2498 # define ASCENDDIST_DEFAULT "@ASCENDDIST_DEFAULT@"
2499 # define ASCENDTK_DEFAULT "@ASCENDTK_DEFAULT@"
2500 # define ASCENDLIBRARY_DEFAULT "@ASCENDLIBRARY_DEFAULT@"
2501 # define ASCENDSOLVERS_DEFAULT "@ASCENDSOLVERS_DEFAULT@"
2502 #else
2503 # define ASC_DIST_REL_BIN "@ASC_DIST_REL_BIN@"
2504 # define ASC_TK_REL_DIST "@ASC_TK_REL_DIST@"
2505 # define ASC_LIBRARY_REL_DIST "@ASC_LIBRARY_REL_DIST@"
2506 # define ASC_SOLVERS_REL_DIST "@ASC_SOLVERS_REL_DIST@"
2507 #endif
2508 , '@ASC_ABSOLUTE_PATHS@': str(int(env.get('ABSOLUTE_PATHS')))
2509 , '@ASCENDDIST_DEFAULT@': c_escape(env['INSTALL_PREFIX'])
2510 , '@ASCENDTK_DEFAULT@': c_escape(os.path.abspath(env.subst(env['INSTALL_TK'])))
2511 , '@ASCENDLIBRARY_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDLIBRARY'])))
2512 , '@ASCENDSOLVERS_DEFAULT@': c_escape(os.path.abspath(env.subst(env['DEFAULT_ASCENDSOLVERS'])))
2513 , '@ASC_DIST_REL_BIN@' : default_dist_rel_bin
2514 , '@ASC_TK_REL_DIST@' : default_tk_rel_dist
2515 , '@ASC_LIBRARY_REL_DIST@' : default_library_rel_dist
2516 , '@ASC_SOLVERS_REL_DIST@' : default_solvers_rel_dist
2517 , '@SIZEOF_VOID_P@' : env['SIZEOF_VOID_P']
2518 , '@SIZEOF_INT@' : env['SIZEOF_INT']
2519 , '@SIZEOF_LONG@' : env['SIZEOF_LONG']
2520 , '@SIZEOF_LONG_LONG@' : env['SIZEOF_LONG_LONG']
2521 }
2522
2523 if env.get('WITH_DOC'):
2524 print "WITH_DOC:",env['WITH_DOC']
2525 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2526
2527 # bool options...
2528 for k,v in {
2529 'ASC_WITH_DMALLOC':with_dmalloc
2530 ,'ASC_WITH_UFSPARSE':with_ufsparse
2531 ,'ASC_WITH_MMIO':with_mmio
2532 ,'ASC_SIGNAL_TRAPS':with_signals
2533 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2534 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2535 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2536 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2537 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2538 }.iteritems():
2539
2540 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2541
2542 if with_python:
2543 subst_dict['@ASCXX_USE_PYTHON@']="1"
2544 env['WITH_PYTHON']=1;
2545
2546 if with_latex2html:
2547 env['WITH_LATEX2HTML']=1
2548
2549 if env.has_key('HAVE_GCCVISIBILITY'):
2550 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2551
2552 env.Append(SUBST_DICT=subst_dict)
2553
2554 #for k,v in subst_dict.iteritems():
2555 # print "%-50s%s" % ("'%s'"%k,v)
2556
2557 # REMOVED: long command-line support on Win2k
2558
2559 #------------------------------------------------------
2560 # RECIPE: SWIG scanner
2561
2562 import SCons.Script
2563
2564 SWIGScanner = SCons.Scanner.ClassicCPP(
2565 "SWIGScan"
2566 , ".i"
2567 , "CPPPATH"
2568 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2569 )
2570
2571 env.Append(SCANNERS=[SWIGScanner])
2572
2573 #------------------------------------------------------
2574 # Recipe for 'CHMOD' ACTION
2575
2576 import SCons
2577 from SCons.Script.SConscript import SConsEnvironment
2578 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2579 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2580
2581 def InstallPerm(env, dest, files, perm):
2582 obj = env.Install(dest, files)
2583 for i in obj:
2584 env.AddPostAction(i, env.Chmod(str(i), perm))
2585
2586 def InstallPermAs(env, dest, filen, perm):
2587 obj = env.InstallAs(dest, filen)
2588 for i in obj:
2589 env.AddPostAction(i, env.Chmod(str(i), perm))
2590 return dest
2591
2592 SConsEnvironment.InstallPerm = InstallPerm
2593
2594 # define wrappers
2595 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2596 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2597 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2598 SConsEnvironment.InstallLibraryAs = lambda env, dest, files: InstallPermAs(env, dest, files, 0644)
2599
2600 #------------------------------------------------------
2601 # BUILD...
2602
2603 # so that #include <ascend/modulename/headername.h> works across all modules...
2604 env.AppendUnique(CPPPATH=['#'])
2605
2606 if env['DEBUG']:
2607 env.Append(CCFLAGS=['-g'])
2608 env.Append(LINKFLAGS=['-g'])
2609
2610 if env['GCOV']:
2611 env.Append(
2612 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2613 , LIBS=['gcov']
2614 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2615 )
2616
2617 if with_ida:
2618 env.Append(WITH_IDA=1)
2619
2620 if with_conopt:
2621 env.Append(WITH_CONOPT=1)
2622
2623 if with_ipopt:
2624 env.Append(WITH_IPOPT=1)
2625
2626 if with_dopri5:
2627 env.Append(WITH_DOPRI5=1)
2628
2629 if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2630 env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2631
2632 #-------------
2633 # TCL/TK GUI
2634
2635 if with_tcltk:
2636 env.SConscript(['tcltk/SConscript'],'env')
2637 else:
2638 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2639
2640 #-------------
2641 # PYTHON INTERFACE
2642
2643 if with_python:
2644 env.SConscript(['pygtk/SConscript'],'env')
2645 else:
2646 print "Skipping... Python bindings aren't being built:",without_python_reason
2647
2648 #------------
2649 # BASE/GENERIC SUBDIRECTORIES
2650
2651 libascend_env = env.Clone()
2652
2653 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2654
2655 srcs = []
2656 for d in dirs:
2657 heresrcs = libascend_env.SConscript('ascend/'+d+'/SConscript','libascend_env')
2658 srcs += heresrcs
2659
2660 #-------------
2661 # IMPORTED CODE: LSODE, BLAS, etc
2662
2663 #if with_lsode:
2664 # srcs += env.SConscript(['lsod/SConscript'],'env')
2665 # srcs += env.SConscript(['linpack/SConscript'],'env')
2666 #else:
2667 # print "Skipping... LSODE won't be built:", without_lsode_reason
2668
2669 if with_local_blas:
2670 env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2671 else:
2672 env['blasobjs'] = []
2673 print "Skipping... BLAS won't be built:", without_local_blas_reason
2674
2675 if not with_ida:
2676 print "Skipping... IDA won't be built:", without_ida_reason
2677
2678 if not with_dopri5:
2679 print "Skipping... DOPRI5 won't be built:", without_dopri5_reason
2680
2681 if with_mmio:
2682 srcs += env.SConscript(['mmio/SConscript'],'env')
2683 else:
2684 print "Skipping... MMIO export won't be built:", without_mmio_reason
2685 #-------------
2686 # LIBASCEND -- all 'core' functionality
2687
2688 # FIXME want to move these bits to ascend/SConscript
2689
2690 libascend_env.Append(
2691 CPPPATH=['#']
2692 ,LIBS=['m']
2693 )
2694
2695 if platform.system()=="Linux":
2696 libascend_env.Append(LIBS=['dl'])
2697
2698 if with_dmalloc:
2699 libascend_env.Append(LIBS=['dmalloc'])
2700
2701 if with_ufsparse:
2702 libascend_env.Append(LIBS=['cxsparse'])
2703
2704 if platform.system()=="Linux":
2705 libascend_env.Append(LINKFLAGS=['-Wl,-soname,%s' % soname_full])
2706
2707 libascend = libascend_env.SharedLibrary('ascend',srcs)
2708
2709 # create local symlink for the soname stuff.
2710 print "SONAME =",env.subst(soname_full)
2711
2712 env['libascend'] = libascend
2713 libtargets = [libascend]
2714
2715 if platform.system()=="Linux":
2716 if soname_major:
2717 libascend_env.Command(soname_full,libascend,Move("$TARGET","$SOURCE"))
2718 print "MAKING LINK, SONAME_MAJOR =",soname_major
2719 liblink = libascend_env.Command(soname_full, libascend, "ln -s $SOURCE $TARGET")
2720 libtargets.append(liblink)
2721
2722 # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2723
2724 env.Alias('libascend',libtargets)
2725
2726 #-------------
2727 # UNIT TESTS (C CODE)
2728
2729 test_env = env.Clone()
2730 test_env.Append(
2731 CPPPATH="#"
2732 )
2733
2734 if with_cunit:
2735 testdirs = ['general','solver','utilities','linear','compiler']
2736 testsrcs = []
2737 for testdir in testdirs:
2738 path = 'ascend/'+testdir+'/test/'
2739 test_env.SConscript([path+'SConscript'],'test_env')
2740 testsrcs += [i.path for i in test_env['TESTSRCS_'+testdir.upper()]]
2741
2742 #print "TESTSRCS =",testsrcs
2743
2744 test_env.SConscript(['test/SConscript'],'test_env')
2745
2746 env.Alias('test',[env.Dir('test')])
2747
2748 else:
2749 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2750
2751 #-------------
2752 # EXTERNAL SOLVERS
2753
2754 env['extfns']=[]
2755
2756 env.SConscript(['solvers/SConscript'],'env')
2757
2758 #-------------
2759 # EXTERNAL FUNCTIONS
2760
2761 modeldirs = env.SConscript(['models/SConscript'],'env')
2762
2763 if not with_extfns:
2764 print "Skipping... External modules aren't being built:",without_extfns_reason
2765
2766 env.Alias('extfns',env['extfns'])
2767
2768 #------------------------------------------------------
2769 # CREATE ASCEND-CONFIG scriptlet
2770
2771 ascendconfig = env.SubstInFile('ascend-config.in')
2772
2773 #------------------------------------------------------
2774 # INSTALLATION
2775
2776 if env.get('CAN_INSTALL'):
2777
2778 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC','INSTALL_PYTHON']
2779 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2780 install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2781
2782 # TODO: add install options
2783 env.Alias('install',install_dirs)
2784
2785 #env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2786
2787 libname = "${INSTALL_LIB}/%s%s" % (soname_full,soname_minor)
2788 install_lib = env.InstallLibraryAs("${INSTALL_ROOT}"+libname, [libascend])
2789 if env['ABSOLUTE_PATHS']:
2790 link_target = libname
2791 else:
2792 link_target = "%s%s" % (soname_full,soname_minor)
2793
2794 link1 = "${INSTALL_LIB}/%s" % soname_clean
2795 install_link1 = None
2796 if env.subst(link1) != env.subst(libname):
2797 # v--link to create v--file to link to command
2798 install_link1 = env.Command("${INSTALL_ROOT}"+link1,install_lib
2799 # v-- command to do it (note the trick about
2800 ,"ln -f -s %s $TARGET" % link_target
2801 )
2802
2803 link2 = "${INSTALL_LIB}/%s" % soname_full
2804 install_link2 = None
2805 if soname_minor:
2806 install_link2 = env.Command("${INSTALL_ROOT}"+link2,install_lib
2807 ,"ln -f -s %s $TARGET" % link_target
2808 )
2809
2810 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2811
2812 #------------------------------------------------------
2813 # WINDOWS INSTALLER
2814
2815 if not env.get('NSIS'):
2816 with_installer = False
2817 without_installer_reason = "NSIS not found"
2818
2819 if with_installer:
2820 env.Append(NSISDEFINES={
2821 'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2822 ,"VERSION":version
2823 ,'PYVERSION':pyversion
2824 })
2825 installer = env.Installer('nsis/installer.nsi')
2826 Depends(installer,["pygtk","tcltk","ascend.dll","models","solvers","ascend-config",'pygtk/ascend'])
2827 env.Alias('installer',installer)
2828 else:
2829 print "Skipping... Windows installer isn't being built:",without_installer_reason
2830
2831 #------------------------------------------------------
2832 # CREATE the SPEC file for generation of RPM packages
2833
2834 if platform.system()=="Linux":
2835 env.SubstInFile('ascend.spec.in')
2836
2837 #------------------------------------------------------
2838 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2839
2840 #if with_scrollkeeper:
2841 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2842 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2843
2844 #------------------------------------------------------
2845 # DISTRIBUTION TAR FILE
2846
2847 env['DISTTAR_FORMAT']='bz2'
2848 env.Append(
2849 DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.lib','.cc','.cache',
2850 '.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx',
2851 '.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz',
2852 '.bz2','.7z','.deb','.dsc','.changes']
2853 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2854 )
2855
2856 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2857 , [env.Dir('#')]
2858 )
2859
2860 env.Depends(tar,'ascend.spec')
2861 env.Depends(tar,'#doc/book.pdf')
2862
2863 #------------------------------------------------------
2864 # DEBIAN TARBALL for use with Build Service
2865
2866 import glob
2867 deb_files = glob.glob('debian/*.install')
2868 deb_files += glob.glob('debian/*.docs')
2869 deb_files += glob.glob('debian/*.dirs')
2870 deb_files += glob.glob('debian/*.man')
2871 deb_files += glob.glob('debian/*.manpages')
2872 deb_files += ['debian/%s' % s for s in ['rules','control','changelog','compat','copyright','dirs']]
2873
2874 deb_tar = env.Tar(
2875 'dist/debian.tar.gz'
2876 ,deb_files
2877 ,TARFLAGS = ['cz']
2878 )
2879
2880 Alias('dist',[tar,deb_tar])
2881
2882 #------------------------------------------------------
2883 # DOCUMENTATION
2884
2885 #print "WITH_DOC_BUILD = ",with_doc_build
2886
2887 if not with_doc_build:
2888 print "Skipping... Documentation isn't being built:",without_doc_build_reason
2889
2890 #user's manual
2891 env.SConscript('doc/SConscript',['env'])
2892
2893 #------------------------------------------------------
2894 # RPM BUILD
2895
2896 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2897 # (check * for the version number used to create the tarball)
2898
2899 #------------------------------------------------------
2900 # DEFAULT TARGETS
2901
2902 default_targets =['libascend','solvers']
2903 if with_tcltk:
2904 default_targets.append('tcltk')
2905 if with_python:
2906 default_targets.append('pygtk')
2907 if with_installer:
2908 default_targets.append('installer')
2909 if with_extfns:
2910 default_targets.append('extfns')
2911 if with_doc_build:
2912 default_targets.append('doc')
2913
2914 env.Default(default_targets)
2915
2916 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2917
2918 # vim: set syntax=python:

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