/[ascend]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1464 - (show annotations) (download)
Sun Jun 3 04:09:36 2007 UTC (12 years, 6 months ago) by jpye
File size: 53083 byte(s)
Added 'alert' option to 'loading' module.
Added start menu shortcut to Model Library
Bumped version to 0.9.5.111.
Fixed loading of fourbarplot.py example when matplotlib not available.
1 import sys, os, commands, platform, distutils.sysconfig, os.path, re
2
3 version = "0.9.5.111"
4
5 #------------------------------------------------------
6 # OPTIONS
7 #
8 # Note that if you set the options via the command line, they will be
9 # remembered in the file 'options.cache'. It's a feature ;-)
10
11 opts = Options(['options.cache', 'config.py'])
12 #print "PLATFORM = ",platform.system()
13
14 if platform.system()=="Windows":
15 default_tcl_lib = "tcl84"
16 default_tk_lib = "tk84"
17 default_tktable_lib = "Tktable28"
18 default_install_assets = "glade/"
19 icon_extension = '.png'
20 default_tcl = "c:\\Tcl"
21 if os.environ.get('MSYSTEM')=="MINGW32":
22 default_tcl_libpath="$TCL\\bin"
23 else:
24 default_tcl_libpath="$TCL\\lib"
25 default_rel_distdir = '.'
26 default_absolute_paths = False
27
28 default_ida_prefix = "c:\\MinGW"
29 if not os.path.exists(default_ida_prefix):
30 default_ida_prefix = None
31
32 default_conopt_prefix = "c:\\Program Files\\CONOPT"
33 default_conopt_libpath="$CONOPT_PREFIX"
34 default_conopt_cpppath="$CONOPT_PREFIX"
35 default_conopt_dlpath="$CONOPT_PREFIX"
36 default_conopt_lib="conopt3"
37 default_conopt_envvar="CONOPT_PATH"
38
39 default_prefix="c:\\MinGW"
40 default_libpath="$DEFAULT_PREFIX\\lib"
41 default_cpppath="$DEFAULT_PREFIX\\include"
42
43 if not os.path.exists(default_conopt_prefix):
44 default_conopt_prefix = None
45
46 need_libm = False
47 python_exe = "c:\\Python24\\python.exe"
48 default_with_scrollkeeper=False
49 else:
50 default_tcl_lib = "tcl8.4"
51 default_tk_lib = "tk8.4"
52 default_tktable_lib = "Tktable2.8"
53 default_install_assets = "$INSTALL_ASCDATA/glade/"
54 icon_extension = '.svg'
55 default_tcl = '/usr'
56 default_tcl_libpath = "$TCL/lib"
57 default_rel_distdir = '../share/ascend'
58 default_absolute_paths = True
59 default_ida_prefix="/usr"
60 default_conopt_prefix="/usr"
61 default_conopt_libpath="$CONOPT_PREFIX/lib"
62 default_conopt_cpppath="$CONOPT_PREFIX/include"
63 default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
64 default_conopt_lib="consub3"
65 default_conopt_envvar="CONOPT_PATH"
66
67 default_prefix="/usr"
68 default_libpath="$DEFAULT_PREFIX/lib"
69 default_cpppath="$DEFAULT_PREFIX/include"
70
71 need_libm = True
72 if not os.path.isdir(default_tcl):
73 default_tcl = '/usr'
74 python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
75 default_with_scrollkeeper=False
76
77 opts.Add(
78 'CC'
79 ,'C Compiler command'
80 ,None
81 )
82
83 opts.Add(
84 'CXX'
85 ,'C++ Compiler command'
86 ,None
87 )
88
89 opts.Add(BoolOption(
90 'GCOV'
91 , 'Whether to enable coverage testing in object code'
92 , False
93 ))
94
95 # Package linking option
96 opts.Add(EnumOption(
97 'PACKAGE_LINKING'
98 , 'Style of linking for external libraries'
99 , 'DYNAMIC_PACKAGES'
100 , ['DYNAMIC_PACKAGES', 'STATIC_PACKAGES', 'NO_PACKAGES']
101 ))
102
103 opts.Add(BoolOption(
104 'WITH_GCCVISIBILITY'
105 ,"Whether to use GCC Visibility features (only applicable if available)"
106 ,True
107 ))
108
109 opts.Add(BoolOption(
110 'WITH_SIGNALS'
111 ,"Whether to permit use of signals for flow control in the C-level code"
112 ,True
113 ))
114
115 # You can turn off building of Tcl/Tk interface
116 opts.Add(BoolOption(
117 'WITH_TCLTK'
118 ,"Set to False if you don't want to build the original Tcl/Tk GUI."
119 , True
120 ))
121
122 # You can turn off the building of the Python interface
123 opts.Add(BoolOption(
124 'WITH_PYTHON'
125 ,"Set to False if you don't want to build Python wrappers."
126 , True
127 ))
128
129 # Which solvers will we allow?
130 opts.Add(ListOption(
131 'WITH_SOLVERS'
132 ,"List of the solvers you want to build. The default is the minimum that"
133 +" works."
134 ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]
135 ,['QRSLV','MPS','SLV','OPTSQP'
136 ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
137 ,'LSOD','OPTSQP',"IDA"
138 ]
139 ))
140
141 # Where will the local copy of the help files be kept?
142 opts.Add(BoolOption(
143 'WITH_DOC'
144 , "Should we try to build and install help files? If not, ASCEND will access online help files"
145 , True
146 ))
147
148 opts.Add(BoolOption(
149 'WITH_DOC_BUILD'
150 , "If true, we'll attempt to build docs. Set false, we'll assume we already have then (eg from the tarball)"
151 , "$WITH_DOC"
152 ))
153
154 opts.Add(BoolOption(
155 'WITH_DOC_INSTALL'
156 , "If true, SCons will install the documentation file(s). If false, assume rpm or dpkg is going to do it."
157 , "$WITH_DOC"
158 ))
159
160 opts.Add(
161 'HELP_ROOT'
162 , "Location of the main help file"
163 , "$INSTALL_DOC/book.pdf"
164 )
165
166 # Will bintoken support be enabled?
167 opts.Add(BoolOption(
168 'WITH_BINTOKEN'
169 ,"Enable bintoken support? This means compiling models as C-code before"
170 +" running them, to increase solving speed for large models."
171 ,False
172 ))
173
174 # What should the default ASCENDLIBRARY path be?
175 # Note: users can change it by editing their ~/.ascend.ini
176 opts.Add(
177 'DEFAULT_ASCENDLIBRARY'
178 ,"Set the default value of the ASCENDLIBRARY -- the location where"
179 +" ASCEND will look for models when running ASCEND"
180 ,"$INSTALL_ASCDATA/models"
181 )
182
183 # Where is SWIG?
184 opts.Add(
185 'SWIG'
186 ,"SWIG location, probably only required for MinGW and MSVC users."
187 +" Enter the location as a Windows-style path, for example"
188 +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
189 )
190
191 # Build the test suite?
192 opts.Add(BoolOption(
193 'WITH_CUNIT'
194 ,"You can disable CUnit tests with this option. This will basically stop"
195 +" SCons from parsing the SConscript files relating to the 'test'"
196 +" target, which just might make things marginally faster. Probably"
197 +" you can just ignore this option though. SCons will sniff for Cunit"
198 +" but build the tests only if you specify the 'test' target."
199 ,True
200 ))
201
202 # Build with MMIO matrix export support?
203 opts.Add(BoolOption(
204 'WITH_MMIO'
205 ,"Include support for exporting matrices in Matrix Market format"
206 ,True
207 ))
208
209 #----- default paths -----
210 opts.Add(PackageOption(
211 'DEFAULT_PREFIX'
212 ,"Where are most of the shared libraries located on your system?"
213 ,default_prefix
214 ))
215
216 #------ install location for python extensions ------
217
218 # (removed for the moment)
219
220 #------ cunit --------
221 # Where was CUNIT installed?
222 opts.Add(PackageOption(
223 'CUNIT_PREFIX'
224 ,"Where are your CUnit files?"
225 ,"$DEFAULT_PREFIX"
226 ))
227
228 # Where are the CUnit includes?
229 opts.Add(PackageOption(
230 'CUNIT_CPPPATH'
231 ,"Where are your CUnit include files?"
232 ,"$CUNIT_PREFIX/include"
233 ))
234
235 # Where are the CUnit libraries?
236 opts.Add(PackageOption(
237 'CUNIT_LIBPATH'
238 ,"Where are your CUnit libraries?"
239 ,"$CUNIT_PREFIX/lib"
240 ))
241
242 #-------- ida -------
243
244 opts.Add(PackageOption(
245 "SUNDIALS_PREFIX"
246 ,"Prefix for your IDA install (IDA ./configure --prefix)"
247 ,default_ida_prefix
248 ))
249
250 opts.Add(
251 'SUNDIALS_CPPPATH'
252 ,"Where is your ida.h?"
253 ,"$SUNDIALS_PREFIX/include"
254 )
255
256 #
257 opts.Add(
258 'SUNDIALS_LIBPATH'
259 ,"Where are your SUNDIALS libraries installed?"
260 ,"$SUNDIALS_PREFIX/lib"
261 )
262
263 opts.Add(
264 'SUNDIALS_LIBS'
265 ,"Where are your SUNDIALS libraries installed?"
266 ,['sundials_nvecserial','sundials_ida','m']
267 )
268
269 # ----- conopt-----
270
271 opts.Add(PackageOption(
272 "CONOPT_PREFIX"
273 ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
274 ,default_conopt_prefix
275 ))
276
277 opts.Add(
278 "CONOPT_LIB"
279 ,"Library linked to for CONOPT"
280 ,default_conopt_lib
281 )
282
283 opts.Add(
284 'CONOPT_CPPPATH'
285 ,"Where is your conopt.h?"
286 ,default_conopt_cpppath
287 )
288
289 opts.Add(
290 'CONOPT_LIBPATH'
291 ,"Where is your CONOPT library installed?"
292 ,default_conopt_libpath
293 )
294
295 opts.Add(
296 'CONOPT_DLPATH'
297 ,"What is the default search path that ASCEND should use when dlopening the CONOPT library at runtime?"
298 ,default_conopt_dlpath
299 )
300
301 opts.Add(
302 'CONOPT_ENVVAR'
303 ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
304 ,default_conopt_envvar
305 )
306
307 #-------- f2c ------
308
309 opts.Add(
310 "F2C_LIB"
311 ,"F2C library (eg. g2c, gfortran, f2c)"
312 ,"gfortran" # the default is gfortran now
313 )
314
315 opts.Add(PackageOption(
316 "F2C_LIBPATH"
317 ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
318 ,"off"
319 ))
320
321 opts.Add(
322 "FORTRAN"
323 ,"Fortran compiler (eg g77, gfortran)"
324 ,"gfortran"
325 )
326
327 #------- tcl/tk --------
328
329 opts.Add(
330 'TCL'
331 ,'Base of Tcl distribution'
332 ,default_tcl
333 )
334
335 # Where are the Tcl includes?
336 opts.Add(
337 'TCL_CPPPATH'
338 ,"Where are your Tcl include files?"
339 ,"$TCL/include"
340 )
341
342 # Where are the Tcl libs?
343 opts.Add(
344 'TCL_LIBPATH'
345 ,"Where are your Tcl libraries?"
346 ,default_tcl_libpath
347 )
348
349 # What is the name of the Tcl lib?
350 opts.Add(
351 'TCL_LIB'
352 ,"Name of Tcl lib (eg 'tcl' or 'tcl83'), for full path to static library (if STATIC_TCLTK is set)"
353 ,default_tcl_lib
354 )
355
356 # Where are the Tk includes?
357 opts.Add(
358 'TK_CPPPATH'
359 ,"Where are your Tk include files?"
360 ,'$TCL_CPPPATH'
361 )
362
363 # Where are the Tk libs?
364 opts.Add(
365 'TK_LIBPATH'
366 ,"Where are your Tk libraries?"
367 ,'$TCL_LIBPATH'
368 )
369
370 # What is the name of the Tk lib?
371 opts.Add(
372 'TK_LIB'
373 ,"Name of Tk lib (eg 'tk' or 'tk83'), or full path to static library"
374 ,default_tk_lib
375 )
376
377 # Static linking to TkTable
378
379 opts.Add(BoolOption(
380 'STATIC_TCLTK'
381 ,'Set true for static linking for Tcl/Tk and TkTable. EXPERIMENTAL'
382 ,False
383 ))
384
385 opts.Add(
386 'TKTABLE_LIBPATH'
387 ,'Location of TkTable static library'
388 ,'$TCL_LIBPATH/Tktable2.8'
389 )
390
391 opts.Add(
392 'TKTABLE_LIB'
393 ,'Stem name of TkTable (eg tktable2.8, no ".so" or "lib") shared library, or full path of static tktable (/usr/lib/...)'
394 ,default_tktable_lib
395 )
396
397 opts.Add(
398 'TKTABLE_CPPPATH'
399 ,'Location of TkTable header file'
400 ,'$TCL_CPPPATH'
401 )
402
403 opts.Add(
404 'X11'
405 ,'Base X11 directory. Only used when STATIC_TCLTK is turned on. EXPERIMENTAL'
406 ,'/usr/X11R6'
407 )
408
409 opts.Add(
410 'X11_LIBPATH'
411 ,'Location of X11 lib. EXPERIMENTAL'
412 ,'$X11/lib'
413 )
414
415 opts.Add(
416 'X11_CPPPATH'
417 ,'Location of X11 includes. EXPERIMENTAL'
418 ,'$X11/include'
419 )
420
421 opts.Add(
422 'X11_LIB'
423 ,'Name of X11 lib. EXPERIMENTAL'
424 ,'X11'
425 )
426
427 #----- installed file locations (for 'scons install') -----
428
429 opts.Add(
430 'INSTALL_PREFIX'
431 ,'Root location for installed files'
432 ,'/usr/local'
433 )
434
435 opts.Add(
436 'INSTALL_BIN'
437 ,'Location to put binaries during installation'
438 ,"$INSTALL_PREFIX/bin"
439 )
440
441 opts.Add(
442 'INSTALL_LIB'
443 ,'Location to put libraries during installation'
444 ,"$INSTALL_PREFIX/lib"
445 )
446
447 opts.Add(
448 'INSTALL_SHARE'
449 ,'Common shared-file location on this system'
450 ,"$INSTALL_PREFIX/share"
451 )
452
453 opts.Add(
454 'INSTALL_ASCDATA'
455 ,"Location of ASCEND shared data (TK, python, models etc)"
456 ,"$INSTALL_SHARE/ascend"
457 )
458
459 opts.Add(
460 'INSTALL_DOC'
461 ,"Location of ASCEND documentation files"
462 ,"$INSTALL_SHARE/doc/ascend-"+version
463 )
464
465 opts.Add(
466 'INSTALL_INCLUDE'
467 ,'Location to put header files during installation'
468 ,"$INSTALL_PREFIX/include"
469 )
470
471
472 opts.Add(
473 'INSTALL_ROOT'
474 ,'For use by RPM only: location of %{buildroot} during rpmbuild'
475 ,""
476 )
477
478 #----------------------
479
480 opts.Add(
481 'PYGTK_ASSETS'
482 ,'Default location for Glade assets (placed in pygtk/config.py)'
483 ,default_install_assets
484 )
485
486 opts.Add(BoolOption(
487 'DEBUG'
488 ,"Compile source with debugger symbols, eg for use with 'gdb'"
489 ,False
490 ))
491
492 opts.Add(BoolOption(
493 'MALLOC_DEBUG'
494 ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
495 ,False
496 ))
497
498 #------ dmalloc --------
499 opts.Add(PackageOption(
500 'DMALLOC_PREFIX'
501 ,"Where are your dmalloc files?"
502 ,default_prefix
503 ))
504
505 opts.Add(PackageOption(
506 'DMALLOC_CPPPATH'
507 ,"Where are your dmalloc include files?"
508 ,default_cpppath
509 ))
510
511 opts.Add(PackageOption(
512 'DMALLOC_LIBPATH'
513 ,"Where are your dmalloc libraries?"
514 ,default_libpath
515 ))
516
517 opts.Add(BoolOption(
518 'WITH_DMALLOC'
519 ,"Link to the DMALLOC library (if available) for debugging of memory usage."
520 ,False
521 ))
522
523 #------ f --------
524 opts.Add(PackageOption(
525 'MFGRAPH_PREFIX'
526 ,"Where are your MFGRAPH files?"
527 ,default_prefix
528 ))
529
530 opts.Add(PackageOption(
531 'MFGRAPH_CPPPATH'
532 ,"Where are your MFGRAPH include files?"
533 ,default_cpppath
534 ))
535
536 opts.Add(PackageOption(
537 'MFGRAPH_LIBPATH'
538 ,"Where are your MFGRAPH libraries?"
539 ,default_libpath
540 ))
541
542 opts.Add(BoolOption(
543 'WITH_MFGRAPH'
544 ,"Link to the MFGRAPH library (if available, for generating incidence graphs)"
545 ,True
546 ))
547
548
549 #------ ufsparse --------
550 opts.Add(PackageOption(
551 'UFSPARSE_PREFIX'
552 ,"Where are your UFSPARSE files?"
553 ,default_prefix
554 ))
555
556 opts.Add(PackageOption(
557 'UFSPARSE_CPPPATH'
558 ,"Where are your UFSPARSE include files?"
559 ,default_cpppath
560 ))
561
562 opts.Add(PackageOption(
563 'UFSPARSE_LIBPATH'
564 ,"Where are your UFSPARSE libraries?"
565 ,default_libpath
566 ))
567
568 opts.Add(BoolOption(
569 'WITH_UFSPARSE'
570 ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
571 ,True
572 ))
573
574 #-----------------------
575
576 opts.Add(
577 'DISTTAR_NAME'
578 ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
579 ,"ascend-"+version
580 )
581
582 opts.Add(
583 'RELEASE'
584 ,"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."
585 ,"0"
586 )
587
588 opts.Add(BoolOption(
589 'ABSOLUTE_PATHS'
590 ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
591 ,default_absolute_paths
592 ))
593
594 opts.Add(
595 'WIN_INSTALLER_NAME'
596 ,"Name of the installer .exe to create under Windows (minus the '.exe')"
597 ,"ascend-"+version
598 )
599
600 opts.Add(BoolOption(
601 'WITH_XTERM_COLORS'
602 ,"Set to 0 if you don't want xterm colour codes in the console output"
603 ,True
604 ))
605
606 opts.Add(BoolOption(
607 'WITH_EXTFNS'
608 ,"Set to 0 if you don't want to attempt to build external modules bundled"
609 + " with ASCEND."
610 ,True
611 ))
612
613 opts.Add(BoolOption(
614 'WITH_SCROLLKEEPER'
615 ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
616 ,default_with_scrollkeeper
617 ))
618
619 if platform.system()!="Windows":
620 opts.Add(BoolOption(
621 'WITH_GCCVISIBILITY'
622 , 'Whether to use GCC Visibility extensions when building with GCC 4.0'
623 , True
624 ))
625
626
627
628 # TODO: OTHER OPTIONS?
629 # TODO: flags for optimisation
630 # TODO: turning on/off bintoken functionality
631 # TODO: Where will the 'Makefile.bt' file be installed?
632
633 # Import the outside environment
634
635 def c_escape(str):
636 return re.sub("\\\\","/",str)
637
638 envadditional={}
639
640 tools = ['lex','yacc','fortran','swig','nsis','substinfile','disttar']
641 if platform.system()=="Windows":
642 if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
643 envenv = os.environ;
644 tools += ['mingw']
645 #TODO removed 'doxygen' for SCons 0.96.93
646 envadditional['IS_MINGW']=True
647 else:
648 print "Assuming VC++ build environment (Note: MinGW is preferred)"
649 envenv = {
650 'PATH':os.environ['PATH']
651 ,'INCLUDE':os.environ['INCLUDE']
652 ,'LIB':os.environ['LIB']
653 ,'MSVS_IGNORE_IDE_PATHS':1
654 }
655 tools += ['default']
656 #TODO removed 'doxygen' for SCons 0.96.93
657 envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
658 else:
659 if os.environ.get('TARGET')=='mingw':
660 envenv = os.environ
661 tools += ['crossmingw']
662 envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
663 envadditional['LIBS']=['gcc']
664 else:
665 envenv = os.environ
666 tools += ['default']
667 #TODO removed 'doxygen' for SCons 0.96.93
668
669
670 env = Environment(
671 ENV=envenv
672 , toolpath=['scons']
673 , tools=tools
674 , **envadditional
675 )
676
677 #print "PATH =",os.environ['PATH']
678 #print "PROGSUFFIX =",env['PROGSUFFIX']
679 #print "CPPPATH =",env['CPPPATH']
680
681 opts.Update(env)
682 opts.Save('options.cache',env)
683
684 Help(opts.GenerateHelpText(env))
685
686 with_tcltk = env.get('WITH_TCLTK')
687 without_tcltk_reason = "disabled by options/config.py"
688
689 with_python = env.get('WITH_PYTHON')
690 without_python_reason = "disabled by options/config.py"
691
692 with_cunit = env.get('WITH_CUNIT')
693 without_cunit_reason = "not requested"
694
695 with_extfns = env.get('WITH_EXTFNS')
696 without_extfn_reason = "disabled by options/config.py"
697
698 with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
699 without_scrollkeeper_reason = "disabled by options/config.py"
700
701 with_dmalloc = env.get('WITH_DMALLOC')
702 without_dmalloc_reason = "disabled by options/config.py"
703
704 with_mfgraph = env.get('WITH_MFGRAPH')
705 without_mfgraph_reason = "disabled by options/config.py"
706
707 with_ufsparse = env.get('WITH_UFSPARSE')
708 without_ufsparse_reason = "disabled by options/config.py"
709
710 with_mmio = env.get('WITH_MMIO')
711 without_mmio_reason = "disabled by options/config.py"
712
713 with_signals = env.get('WITH_SIGNALS')
714 without_signals_reason = "disabled by options/config.py"
715
716 with_doc = env.get('WITH_DOC')
717 without_doc_reason = "disabled by options/config.py"
718
719 with_doc_build = env.get('WITH_DOC_BUILD');
720 without_doc_build = "disabled by options/config.py"
721 if not with_doc:
722 without_doc_build = "disabled by with_doc"
723
724 with_latex2html = False
725
726 if platform.system()=="Windows":
727 with_installer=1
728 else:
729 with_installer=0
730 without_installer_reason = "only possible under Windows"
731
732 if 'LSOD' in env['WITH_SOLVERS']:
733 with_lsode=True
734 else:
735 with_lsode=False
736 without_lsode_reason = "not requested (WITH_SOLVERS)"
737
738 if 'IDA' in env['WITH_SOLVERS']:
739 with_ida=True
740 else:
741 with_ida=False
742 without_ida_reason = "not requested (WITH_SOLVERS)"
743
744
745 if 'CONOPT' in env['WITH_SOLVERS']:
746 with_conopt=True
747 else:
748 with_conopt=False
749 without_conopt_reason = "not requested (WITH_SOLVERS)"
750
751
752 #print "SOLVERS:",env['WITH_SOLVERS']
753 #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
754 #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
755
756 can_install = True
757 if platform.system()=='Windows':
758 can_install = False
759
760 env['CAN_INSTALL']=can_install
761 env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"
762
763 print "TCL=",env['TCL']
764 print "TCL_CPPPATH =",env['TCL_CPPPATH']
765 print "TCL_LIBPATH =",env['TCL_LIBPATH']
766 print "TCL_LIB =",env['TCL_LIB']
767 print "CC =",env['CC']
768 print "CXX =",env['CXX']
769 print "FORTRAN=",env.get('FORTRAN')
770
771 print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
772 print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
773 #------------------------------------------------------
774 # SPECIAL CONFIGURATION TESTS
775
776 need_fortran = False
777
778 #----------------
779 # CC
780
781 cc_test_text = """
782 int main(void){
783 return 0;
784 }
785 """;
786
787 def CheckCC(context):
788 context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
789 is_ok = context.TryCompile(cc_test_text,".c")
790 context.Result(is_ok)
791 return is_ok
792
793 #----------------
794 # CXX
795
796 cxx_test_text = """
797 template<class X>
798 class pair{
799 public:
800 X a;
801 X b;
802 };
803
804 int main(void){
805 pair<double> P;
806 P.a = 0;
807 return 0;
808 }
809 """;
810
811 def CheckCXX(context):
812 context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
813 is_ok = context.TryCompile(cc_test_text,".cpp")
814 context.Result(is_ok)
815 return is_ok
816
817
818
819 #----------------
820 # SWIG
821
822 import os,re
823
824 def get_swig_version(env):
825 cmd = env['SWIG']+' -version'
826 (cin,coutcerr) = os.popen4(cmd)
827 output = coutcerr.read()
828
829 restr = "SWIG\\s+Version\\s+(?P<maj>[0-9]+)\\.(?P<min>[0-9]+)\\.(?P<pat>[0-9]+)\\s*$"
830 expr = re.compile(restr,re.M);
831 m = expr.search(output);
832 if not m:
833 return None
834 maj = int(m.group('maj'))
835 min = int(m.group('min'))
836 pat = int(m.group('pat'))
837
838 return (maj,min,pat)
839
840
841 def CheckSwigVersion(context):
842
843 try:
844 context.Message("Checking version of SWIG... ")
845 maj,min,pat = get_swig_version(context.env)
846 except:
847 context.Result("Failed to detect version, or failed to run SWIG")
848 return 0;
849
850 context.env['SWIGVERSION']=tuple([maj,min,pat])
851
852 if maj == 1 and (
853 min > 3
854 or (min == 3 and pat >= 24)
855 ):
856 context.Result("ok, %d.%d.%d" % (maj,min,pat))
857 return 1;
858 else:
859 context.Result("too old, %d.%d.%d" % (maj,min,pat))
860 return 0;
861
862 #----------------
863 # Scrollkeeper (Linux documentation system)
864
865 def get_scrollkeeper_omfdir(env):
866 cmd = 'scrollkeeper-config --omfdir'
867 (cin,coutcerr) = os.popen4(cmd)
868 output = coutcerr.read()
869 return output.strip()
870
871 def CheckScrollkeeperConfig(context):
872 try:
873 context.Message("Checking for scrollkeeper...")
874 dir=get_scrollkeeper_omfdir(context.env)
875 except:
876 context.Result("Failed to run 'scrollkeeper-config'")
877 return 0
878 context.env['OMFDIR']=dir
879 context.Result("OK, %s" % dir)
880 return 1
881
882 #----------------
883 # General purpose library-and-header test
884
885 class KeepContext:
886 def __init__(self,context,varprefix,static=False):
887 self.keep = {}
888 for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
889 #print "Keeping env %s = %s" % (k,context.env.get(k))
890 self.keep[k]=context.env.get(k)
891
892 if context.env.has_key(varprefix+'_CPPPATH'):
893 context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
894 #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
895
896 if static:
897 staticlib=env[varprefix+'_LIB']
898 #print "STATIC LIB = ",staticlib
899 context.env.Append(
900 LINKFLAGS=[staticlib]
901 )
902 else:
903 if context.env.has_key(varprefix+'_LIBPATH'):
904 context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
905 #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
906
907 if context.env.has_key(varprefix+'_LIB'):
908 context.env.Append(LIBS=[env[varprefix+'_LIB']])
909 #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"
910
911 def restore(self,context):
912 #print "RESTORING CONTEXT"
913 #print self.keep
914 #print "..."
915 for k in self.keep:
916 if self.keep[k]==None:
917 if context.env.has_key(k):
918 #print "Clearing "+str(k)
919 del context.env[k];
920 else:
921 #print "Restoring %s to '%s'" %(k,self.keep.get(k))
922 context.env[k]=self.keep[k];
923
924 def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):
925 """This method will check for variables LIBNAME_LIBPATH
926 and LIBNAME_CPPPATH and try to compile and link the
927 file with the provided text, linking with the
928 library libname."""
929
930 if static:
931 context.Message( 'Checking for static '+libname+'... ' )
932 else:
933 context.Message( 'Checking for '+libname+'... ' )
934
935 if varprefix==None:
936 varprefix = libname.upper()
937
938 #print "LIBS is currently:",context.env.get('LIBS')
939 keep = KeepContext(context,varprefix,static)
940
941 if not context.env.has_key(varprefix+'_LIB'):
942 # if varprefix_LIB were in env, KeepContext would
943 # have appended it already
944 context.env.Append(LIBS=[libname])
945
946 is_ok = context.TryLink(text,ext)
947
948 #print "Link success? ",(is_ok != 0)
949
950 keep.restore(context)
951
952 # print "Restored CPPPATH="+str(context.env['CPPPATH'])
953 # print "Restored LIBS="+str(context.env['LIBS'])
954 # print "Restored LIBPATH="+str(context.env['LIBPATH'])
955
956 context.Result(is_ok)
957 return is_ok
958
959 #----------------
960 # GCC
961
962 gcc_test_text = """
963 #ifndef __GNUC__
964 # error "Not using GCC"
965 #endif
966
967 int main(void){
968 return __GNUC__;
969 }
970 """
971
972 def CheckGcc(context):
973 context.Message("Checking for GCC... ")
974 is_ok = context.TryCompile(gcc_test_text,".c")
975 context.Result(is_ok)
976 return is_ok
977
978 #----------------
979 # GCC VISIBILITY feature
980
981 gccvisibility_test_text = """
982 #if __GNUC__ < 4
983 # error "Require GCC version 4 or newer"
984 #endif
985
986 __attribute__ ((visibility("default"))) int x;
987
988 int main(void){
989 extern int x;
990 x = 4;
991 }
992 """
993
994 def CheckGccVisibility(context):
995 context.Message("Checking for GCC 'visibility' capability... ")
996 if not context.env.has_key('WITH_GCCVISIBILITY') or not env['WITH_GCCVISIBILITY']:
997 context.Result("disabled")
998 return 0
999 is_ok = context.TryCompile(gccvisibility_test_text,".c")
1000 context.Result(is_ok)
1001 return is_ok
1002
1003 #----------------
1004 # YACC
1005
1006 yacc_test_text = """
1007 %{
1008 #include <stdio.h>
1009
1010 /* MSVC++ needs this before it can swallow Bison output */
1011 #ifdef _MSC_VER
1012 # define __STDC__
1013 #endif
1014 %}
1015 %token MSG
1016 %start ROOT
1017 %%
1018 ROOT:
1019 MSG { printf("HELLO"); }
1020 ;
1021 %%
1022 """
1023
1024 def CheckYacc(context):
1025 context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
1026 is_ok = context.TryCompile(yacc_test_text,".y")
1027 context.Result(is_ok)
1028 return is_ok
1029
1030 #----------------
1031 # LEX
1032
1033 lex_test_text = """
1034 %{
1035 #include <stdio.h>
1036 %}
1037 DIGIT [0-9]
1038 ID [a-z][a-z0-9]*
1039 %%
1040 {DIGIT}+ {
1041 printf("A digit: %s\\n",yytext);
1042 }
1043
1044 [ \\t\\n]+ /* ignore */
1045
1046 . {
1047 printf("Unrecognized guff");
1048 }
1049 %%
1050 main(){
1051 yylex();
1052 }
1053 """
1054
1055 def CheckLex(context):
1056 context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1057 is_ok = context.TryCompile(lex_test_text,".l")
1058 context.Result(is_ok)
1059 return is_ok
1060
1061 #----------------
1062 # CUnit test
1063
1064 cunit_test_text = """
1065 #include <CUnit/CUnit.h>
1066 int maxi(int i1, int i2){
1067 return (i1 > i2) ? i1 : i2;
1068 }
1069
1070 void test_maxi(void){
1071 CU_ASSERT(maxi(0,2) == 2);
1072 CU_ASSERT(maxi(0,-2) == 0);
1073 CU_ASSERT(maxi(2,2) == 2);
1074
1075 }
1076 int main(void){
1077 /* CU_initialize_registry() */
1078 return 0;
1079 }
1080 """
1081
1082 def CheckCUnit(context):
1083 return CheckExtLib(context,'cunit',cunit_test_text)
1084
1085 #----------------
1086 # dmalloc test
1087
1088 dmalloc_test_text = """
1089 #include <stdlib.h>
1090 #include <dmalloc.h>
1091
1092 int main(void){
1093 char *c;
1094 c = malloc(100*sizeof(char));
1095 free(c);
1096 return 0;
1097 }
1098 """
1099
1100 def CheckDMalloc(context):
1101 return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1102
1103 #----------------
1104 # mfgraph test
1105
1106 mfgraph_test_text = """
1107 #include <mfgraph/mfg_draw_graph.h>
1108 int main(void){
1109 using namespace mfg;
1110 DrawGraph g;
1111 return 0;
1112 }
1113 """
1114
1115 def CheckMFGraph(context):
1116 return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")
1117
1118 #----------------
1119 # ufsparse test
1120
1121 ufsparse_test_text = """
1122 #include <ufsparse/cs.h>
1123 int main(void){
1124 cs *A,*B,*C;
1125 C = cs_multiply(A,B);
1126 return 0;
1127 }
1128 """
1129
1130 def CheckUFSparse(context):
1131 return CheckExtLib(context
1132 ,libname='cxsparse'
1133 ,varprefix='ufsparse'
1134 ,text=ufsparse_test_text
1135 ,ext=".c"
1136 )
1137
1138 #----------------
1139 # MATH test
1140
1141 math_test_text = """
1142 #ifndef _ALL_SOURCE
1143 # define _ALL_SOURCE
1144 #endif
1145 #ifndef _XOPEN_SOURCE
1146 # define _XOPEN_SOURCE
1147 #endif
1148 #ifndef _XOPEN_SOURCE_EXTENDED
1149 # define _XOPEN_SOURCE_EXTENDED 1
1150 #endif
1151 #include <math.h>
1152 int main(void){
1153 double x = 1.0; double y = 1.0; int i = 1;
1154 acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1155 j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1156 y0(x); y1(x); yn(i,x);
1157 /* this part causes problems with crossmingw... */
1158 #ifdef _THREAD_SAFE
1159 gamma_r(x,&i);
1160 lgamma_r(x,&i);
1161 #else
1162 gamma(x);
1163 lgamma(x);
1164 #endif
1165 hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
1166 return 0;
1167 }
1168 """
1169
1170 def CheckMath(context):
1171 context.Message('Checking for IEEE math library... ')
1172 libsave=context.env.get('LIBS');
1173 context.env.AppendUnique(LIBS=['m'])
1174 is_ok=context.TryLink(math_test_text,".c")
1175 context.Result(is_ok)
1176 if not is_ok:
1177 context.env['LIBS']=libsave
1178 return is_ok
1179
1180 #----------------
1181 # libpython test
1182
1183 libpython_test_text = """
1184 #include <Python.h>
1185 int main(void){
1186 PyObject *p;
1187 p = Py_None;
1188 return 0;
1189 }
1190 """
1191
1192 def CheckPythonLib(context):
1193 context.Message('Checking for libpython... ')
1194
1195 if platform.system()=="Windows":
1196 python_lib='python%d%d'
1197 else:
1198 python_lib='python%d.%d'
1199 python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1200
1201 python_cpppath = [distutils.sysconfig.get_python_inc()]
1202 cfig = distutils.sysconfig.get_config_vars()
1203
1204 lastLIBS = context.env.get('LIBS')
1205 lastLIBPATH = context.env.get('LIBPATH')
1206 lastCPPPATH = context.env.get('CPPPATH')
1207 lastLINKFLAGS = context.env.get('LINKFLAGS')
1208
1209 python_libpath = []
1210 python_linkflags = []
1211 if platform.system()=="Windows":
1212 python_libpath+=[cfig['prefix']]
1213 else:
1214 # checked on Linux and SunOS
1215 if cfig['LDLIBRARY']==cfig['LIBRARY']:
1216 sys.stdout.write("(static)")
1217 python_libpath += [cfig['LIBPL']]
1218 python_linkflags += cfig['LIBS'].split(' ')
1219
1220 context.env.AppendUnique(LIBS=python_libs)
1221 context.env.AppendUnique(LIBPATH=python_libpath)
1222 context.env.AppendUnique(CPPPATH=python_cpppath)
1223 context.env.AppendUnique(LINKFLAGS=python_linkflags)
1224 result = context.TryLink(libpython_test_text,".c");
1225
1226 context.Result(result)
1227
1228 if(result):
1229 context.env['PYTHON_LIBPATH']=python_libpath
1230 context.env['PYTHON_LIB']=python_libs
1231 context.env['PYTHON_CPPPATH']=python_cpppath
1232 context.env['PYTHON_LINKFLAGS']=python_linkflags
1233
1234 context.env['LIBS'] = lastLIBS
1235 context.env['LIBPATH'] = lastLIBPATH
1236 context.env['CPPPATH'] = lastCPPPATH
1237 context.env['LINKFLAGS'] = lastLINKFLAGS
1238
1239 return result
1240
1241 #----------------
1242 # IDA test
1243
1244 sundials_version_major_required = 2
1245 sundials_version_minor_min = 2
1246 sundials_version_minor_max = 3
1247
1248 sundials_version_text = """
1249 #include <sundials/sundials_config.h>
1250 #include <stdio.h>
1251 int main(){
1252 printf("%s",SUNDIALS_PACKAGE_VERSION);
1253 return 0;
1254 }
1255 """
1256
1257 ida_test_text = """
1258 #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1259 # include <sundials/sundials_config.h>
1260 # include <sundials/sundials_nvector.h>
1261 # include <nvector_serial.h>
1262 # include <ida.h>
1263 # include <ida/ida_spgmr.h>
1264 #else
1265 # include <sundials/sundials_config.h>
1266 # include <nvector/nvector_serial.h>
1267 # include <ida/ida.h>
1268 #endif
1269 int main(){
1270 void *ida_mem;
1271 ida_mem = IDACreate();
1272 return 0;
1273 }
1274 """
1275
1276 # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1277 # so detect the version and act accordingly.
1278 def CheckSUNDIALS(context):
1279 keep = KeepContext(context,'SUNDIALS')
1280 context.Message("Checking for SUNDIALS... ")
1281 (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1282 keep.restore(context)
1283 if not is_ok:
1284 context.Result(0)
1285 return 0
1286
1287 major,minor,patch = tuple([int(i) for i in output.split(".")])
1288 context.env['SUNDIALS_VERSION_MAJOR'] = major
1289 context.env['SUNDIALS_VERSION_MINOR'] = minor
1290 if major != sundials_version_major_required \
1291 or minor < sundials_version_minor_min \
1292 or minor > sundials_version_minor_max:
1293 context.Result(output+" (bad version)")
1294 # bad version
1295 return 0
1296
1297 # good version
1298 context.Result("%d.%d.%d, good" % (major,minor,patch))
1299
1300 return 1
1301
1302
1303 def CheckIDA(context):
1304 context.Message( 'Checking for IDA... ' )
1305
1306 keep = KeepContext(context,"SUNDIALS")
1307
1308 major = context.env['SUNDIALS_VERSION_MAJOR']
1309 minor = context.env['SUNDIALS_VERSION_MINOR']
1310
1311 cppdef = context.env.get('CPPDEFINES')
1312
1313 context.env.Append(CPPDEFINES=[
1314 ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1315 ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1316 ])
1317
1318 context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1319 if major==2 and minor==2:
1320 context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1321
1322 context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1323 context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1324 context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1325
1326 is_ok = context.TryLink(ida_test_text,".c")
1327 context.Result(is_ok)
1328
1329 if cppdef:
1330 context.env['CPPDEFINES']=cppdef
1331 keep.restore(context)
1332
1333 return is_ok
1334
1335
1336 #----------------
1337 # CONOPT test
1338
1339 conopt_test_text = """
1340 #if !defined(_WIN32)
1341 # define FNAME_LCASE_DECOR
1342 #endif
1343
1344 #include <conopt.h>
1345 #include <stdlib.h>
1346 int main(){
1347 int s, *v, e;
1348 s = COIDEF_Size();
1349 v = (int *)malloc(s*sizeof(int));
1350 e = COIDEF_Ini(v);
1351 return e;
1352 }
1353 """
1354
1355 def CheckCONOPT(context):
1356 context.Message( 'Checking for CONOPT... ' )
1357
1358 keep = KeepContext(context,"CONOPT")
1359
1360 is_ok = context.TryLink(conopt_test_text,".c")
1361 context.Result(is_ok)
1362
1363 keep.restore(context)
1364
1365 return is_ok
1366
1367 #----------------
1368 # Tcl test
1369
1370 # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:
1371 tcltk_minor_newest_acceptable = 4
1372 tcltk_major_required = 8
1373
1374 tcl_check_text = r"""
1375 #include <tcl.h>
1376 #include <stdio.h>
1377 int main(void){
1378 printf("%s",TCL_PATCH_LEVEL);
1379 return 0;
1380 }
1381 """
1382
1383 def CheckTcl(context):
1384 return CheckExtLib(context,'tcl',tcl_check_text,static=env['STATIC_TCLTK'])
1385
1386 def CheckTclVersion(context):
1387 keep = KeepContext(context,'TCL',static=env['STATIC_TCLTK'])
1388 context.Message("Checking Tcl version... ")
1389 (is_ok,output) = context.TryRun(tcl_check_text,'.c')
1390 keep.restore(context)
1391 if not is_ok:
1392 context.Result("failed to run check")
1393 return 0
1394
1395 major,minor,patch = tuple([int(i) for i in output.split(".")])
1396 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1397 context.Result(output+" (bad version)")
1398 # bad version
1399 return 0
1400
1401 # good version
1402 context.Result(output+", good")
1403 return 1
1404
1405 #----------------
1406 # Tk test
1407
1408 tk_check_text = r"""
1409 #include <tk.h>
1410 #include <stdio.h>
1411 int main(void){
1412 printf("%s",TK_PATCH_LEVEL);
1413 return 0;
1414 }
1415 """
1416 def CheckTk(context):
1417 return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1418
1419
1420 def CheckTkVersion(context):
1421 keep = KeepContext(context,'TK',static=context.env['STATIC_TCLTK'])
1422 context.Message("Checking Tk version... ")
1423 #print "LINKFLAGS =",context.env['LINKFLAGS']
1424 (is_ok,output) = context.TryRun(tk_check_text,'.c')
1425 keep.restore(context)
1426 if not is_ok:
1427 context.Result("failed to run check")
1428 return 0
1429
1430 major,minor,patch = tuple([int(i) for i in output.split(".")])
1431 if major != tcltk_major_required or minor > tcltk_minor_newest_acceptable:
1432 # bad version
1433 context.Result(output+" (bad version)")
1434 return 0
1435
1436 # good version
1437 context.Result(output+" (good)")
1438 return 1
1439
1440 #----------------
1441 # Tktable test
1442
1443 tktable_check_text = r"""
1444 #include <tkTable.h>
1445 #include <stdio.h>
1446 int main(void){
1447 Table mytable;
1448 return 0;
1449 }
1450 """
1451
1452 def CheckTkTable(context):
1453 return CheckExtLib(context,'tktable',tktable_check_text,static=env['STATIC_TCLTK'])
1454
1455 #---------------
1456 # X11 test
1457
1458 x11_check_text = r"""
1459 #include <X11/Xlib.h>
1460 #include <X11/IntrinsicP.h>
1461 #include <X11/Intrinsic.h>
1462 #include <X11/ObjectP.h>
1463 #include <X11/Object.h>
1464 int main(void){
1465 Object mything;
1466 return 0;
1467 }
1468 """
1469
1470 def CheckX11(context):
1471 return CheckExtLib(context,'X11',x11_check_text)
1472
1473 #----------------
1474 # Check that we can raise and catch sigint
1475
1476 sigint_test_text = r"""
1477 #include <signal.h>
1478 #include <setjmp.h>
1479 #include <stdlib.h>
1480 static jmp_buf g_jmpenv;
1481 void sighandler(int sig){
1482 longjmp(g_jmpenv,sig);
1483 }
1484 void testsigint(){
1485 raise(SIGINT);
1486 }
1487 int main(void){
1488 signal(SIGINT,&sighandler);
1489 switch(setjmp(g_jmpenv)){
1490 case 0:
1491 testsigint();
1492 exit(1);
1493 case SIGINT:
1494 exit(0);
1495 default:
1496 exit(2);
1497 }
1498 }
1499 """
1500
1501 def CheckSIGINT(context):
1502 context.Message("Checking SIGINT is catchable... ")
1503 (is_ok,output)=context.TryRun(sigint_test_text,".c")
1504 context.Result(is_ok)
1505 return is_ok
1506
1507 #----------------
1508 # Check that we're able to catch floating point errors
1509
1510 sigfpe_test_text = r"""
1511 #include <signal.h>
1512 #include <setjmp.h>
1513 #include <stdlib.h>
1514 #include <fenv.h>
1515 static jmp_buf g_jmpenv;
1516 void fpehandler(int sig){
1517 longjmp(g_jmpenv,sig);
1518 }
1519 int main(void){
1520 fenv_t myfenv;
1521 fegetenv(&myfenv);
1522 fesetenv(&myfenv);
1523 feenableexcept(FE_ALL_EXCEPT);
1524 signal(SIGFPE,&fpehandler);
1525 double x;
1526 switch(setjmp(g_jmpenv)){
1527 case 0:
1528 x = 1.0 / 0.0;
1529 /* failed to catch */
1530 exit(1);
1531 case SIGFPE:
1532 exit(0);
1533 }
1534 }
1535 """
1536
1537 def CheckFPE(context):
1538 context.Message("Checking C99 FPE behaviour... ")
1539 (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1540 context.Result(is_ok)
1541 return is_ok
1542
1543 #----------------
1544 # signal reset needed?
1545
1546 sigreset_test_text = r"""
1547 #include <signal.h>
1548 #include <setjmp.h>
1549 #include <stdlib.h>
1550 #include <stdio.h>
1551 typedef void SigHandlerFn(int);
1552 static jmp_buf g_jmpenv;
1553 void sighandler(int sig){
1554 longjmp(g_jmpenv,sig);
1555 }
1556 void testsigint(){
1557 /* fprintf(stderr,"Raising SIGINT\n"); */
1558 raise(SIGINT);
1559 }
1560 int main(void){
1561 SigHandlerFn *last,*saved;
1562 saved = signal(SIGINT,&sighandler);
1563 if(saved!=SIG_DFL){
1564 fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1565 exit(3);
1566 }
1567 switch(setjmp(g_jmpenv)){
1568 case 0:
1569 testsigint();
1570 fprintf(stderr,"Back from SIGINT\n");
1571 exit(1);
1572 case SIGINT:
1573 break;
1574 default:
1575 exit(2);
1576 };
1577 last = signal(SIGINT,SIG_DFL);
1578 if(last!=&sighandler){
1579 printf("1");
1580 exit(0);
1581 }
1582 printf("0");
1583 exit(0);
1584 }
1585 """
1586
1587 def CheckSigReset(context):
1588 context.Message("Checking signal handler reset... ")
1589 (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1590 if not is_ok:
1591 context.Result("ERROR")
1592 return False
1593 if int(output)==1:
1594 context.Result("required");
1595 context.env['ASC_RESETNEEDED'] = True
1596 else:
1597 context.Result("not required");
1598 context.env['ASC_RESETNEEDED'] = False
1599 return is_ok
1600
1601 #----------------
1602 # LyX on this system?
1603
1604 def CheckLyx(context):
1605 context.Message("Checking for LyX... ")
1606 r = context.env.WhereIs("lyx")
1607 context.Result(r)
1608 return r
1609
1610 #----------------
1611 # Latex2HTML on this system?
1612
1613 def CheckLatex2HTML(context):
1614 context.Message("Checking for latex2html...")
1615 if context.env.WhereIs("latex2html"):
1616 r = True
1617 else:
1618 r = False
1619 context.Result(r)
1620 return r
1621
1622 #----------------
1623 # GCC Version sniffing
1624
1625 # TODO FIXME
1626
1627 gcc_version4 = False
1628
1629 #------------------------------------------------------
1630 # CONFIGURATION
1631
1632 conf = Configure(env
1633 , custom_tests = {
1634 'CheckCC' : CheckCC
1635 , 'CheckCXX' : CheckCXX
1636 , 'CheckMath' : CheckMath
1637 , 'CheckSwigVersion' : CheckSwigVersion
1638 , 'CheckPythonLib' : CheckPythonLib
1639 , 'CheckCUnit' : CheckCUnit
1640 , 'CheckDMalloc' : CheckDMalloc
1641 , 'CheckLyx' : CheckLyx
1642 , 'CheckLatex2HTML' : CheckLatex2HTML
1643 , 'CheckMFGraph' : CheckMFGraph
1644 , 'CheckUFSparse' : CheckUFSparse
1645 , 'CheckTcl' : CheckTcl
1646 , 'CheckTclVersion' : CheckTclVersion
1647 , 'CheckTk' : CheckTk
1648 , 'CheckTkVersion' : CheckTkVersion
1649 , 'CheckGcc' : CheckGcc
1650 , 'CheckGccVisibility' : CheckGccVisibility
1651 , 'CheckYacc' : CheckYacc
1652 , 'CheckLex' : CheckLex
1653 , 'CheckTkTable' : CheckTkTable
1654 , 'CheckX11' : CheckX11
1655 , 'CheckIDA' : CheckIDA
1656 , 'CheckSUNDIALS' : CheckSUNDIALS
1657 , 'CheckCONOPT' : CheckCONOPT
1658 , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1659 , 'CheckFPE' : CheckFPE
1660 , 'CheckSIGINT' : CheckSIGINT
1661 , 'CheckSigReset' : CheckSigReset
1662 # , 'CheckIsNan' : CheckIsNan
1663 # , 'CheckCppUnitConfig' : CheckCppUnitConfig
1664 }
1665 # , config_h = "config.h"
1666 )
1667
1668 def sconsversioncheck():
1669
1670 # uncomment the following line to skip the version check:
1671 # return 1
1672
1673 import SCons
1674 v = SCons.__version__.split(".")
1675 if v[0] != '0':
1676 return 0
1677 if int(v[1]) >= 97:
1678 return 1
1679 if v[1] != '96':
1680 return 0
1681 micro = int(v[2])
1682 if micro == 92 or micro == 93 or micro == 96:
1683 return 1;
1684 return 0
1685
1686 if not sconsversioncheck():
1687 print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
1688 print "or consult the developers in the case of newer versions. Modify"
1689 print "the function 'sconsversioncheck' in the file SConstruct if you"
1690 print "want to *force* SCons to continue."
1691 Exit(1)
1692
1693 # check C compiler
1694
1695 if not conf.CheckCC():
1696 print "Failed to build simple test file with your C compiler."
1697 print "Check your compiler is installed and running correctly."
1698 Exit(1)
1699
1700 if not conf.CheckCXX():
1701 print "Failed to build simple test file with your C++ compiler."
1702 print "Check your compiler is installed and running correctly."
1703 Exit(1)
1704
1705 # stdio -- just to check that compiler is behaving
1706
1707 if not conf.CheckHeader('stdio.h'):
1708 print "CPPPATH =",env.get('CPPPATH')
1709 print "Did not find 'stdio.h'! Check your compiler configuration."
1710 print ""
1711 print "You environment is printed here:"
1712 for k,v in os.environ.iteritems():
1713 print "%-30s%s" % ("%s :" % k, v)
1714 Exit(1)
1715
1716 if not conf.CheckFunc('snprintf'):
1717 print "Didn't find snprintf";
1718 exit(1)
1719
1720 # Math library
1721
1722 conf.env['HAVE_IEEE']=True
1723
1724 if need_libm and not conf.CheckMath():
1725 conf.env['HAVE_IEEE']=False
1726 print 'Did not find math library, exiting!'
1727 Exit(1)
1728
1729 # Where is 'isnan'?
1730
1731 if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1732 print "Didn't find isnan"
1733 # Exit(1)
1734
1735 # GCC visibility
1736
1737 if conf.CheckGcc():
1738 conf.env['HAVE_GCC']=True;
1739 if env['WITH_GCCVISIBILITY'] and conf.CheckGccVisibility():
1740 conf.env['HAVE_GCCVISIBILITY']=True;
1741 conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1742 conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1743 conf.env.Append(CCFLAGS=['-Wall'])
1744
1745 # Catching SIGINT
1746
1747 if env['WITH_SIGNALS']:
1748 if not conf.CheckSIGINT():
1749 with_signals = False
1750 without_signals_reason = "SIGINT uncatchable"
1751
1752 # Catching SIGFPE
1753
1754 if conf.CheckFPE():
1755 conf.env['HAVE_C99FPE']=True
1756 else:
1757 conf.env['HAVE_C99FPE']=False
1758
1759 # Checking for signal reset requirement
1760
1761 if not conf.CheckSigReset():
1762 print "Unable to determine if signal reset is required"
1763 Exit(1)
1764
1765 # YACC
1766
1767 if not conf.CheckYacc():
1768 print "YACC NOT FOUND OR NOT WORKING"
1769 else:
1770 conf.env['HAVE_YACC']=True
1771
1772 if not conf.CheckLex():
1773 print "YACC NOT FOUND OR NOT WORKING"
1774 else:
1775 conf.env['HAVE_LEX']=True
1776
1777 # Tcl/Tk
1778
1779 if with_tcltk:
1780 if conf.CheckTcl():
1781 if conf.CheckTclVersion():
1782 if conf.CheckTk():
1783 if with_tcltk and conf.CheckTkVersion():
1784 if env['STATIC_TCLTK']:
1785 if conf.CheckTkTable():
1786 pass
1787 else:
1788 without_tcltk_reason = "TkTable not found"
1789 with_tcltk = False
1790 else:
1791 without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
1792 with_tcltk = False
1793 else:
1794 without_tcltk_reason = "Tk not found."
1795 with_tcltk = False
1796 else:
1797 without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
1798 with_tcltk = False
1799
1800 else:
1801 without_tcltk_reason = "Tcl not found."
1802 with_tcltk = False
1803
1804 if env['STATIC_TCLTK']:
1805 conf.CheckX11()
1806
1807 # Python... obviously we're already running python, so we just need to
1808 # check that we can link to the python library OK:
1809
1810 if not conf.CheckPythonLib():
1811 without_python_reason = 'libpython2.x not found or not linkable'
1812 with_python = False
1813 env['WITH_PYTHON']=False
1814
1815 # SWIG version
1816
1817 if with_python and not conf.CheckSwigVersion():
1818 without_python_reason = 'SWIG >= 1.3.24 is required'
1819 with_python = False
1820 env['WITH_PYTHON']=False
1821
1822 # CUnit
1823
1824 if with_cunit:
1825 if not conf.CheckCUnit():
1826 without_cunit_reason = 'CUnit not found'
1827 with_cunit = False
1828 #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1829
1830 # DMALLOC
1831
1832 if with_dmalloc:
1833 if not conf.CheckDMalloc():
1834 without_dmalloc_reason = 'dmalloc not found'
1835 with_dmalloc = False
1836
1837 # MFGRAPH
1838
1839 if with_mfgraph:
1840 if not conf.CheckMFGraph():
1841 without_mfgraph_reason = 'mfgraph not found'
1842 with_mfgraph = False
1843 env['WITH_MFGRAPH'] = False
1844
1845 # UFSPARSE
1846
1847 if with_ufsparse:
1848 if not conf.CheckUFSparse():
1849 without_ufsparse_reason = 'mfgraph not found'
1850 with_ufsparse = False
1851 env['WITH_UFSPARSE'] = False
1852
1853 # IDA
1854
1855 if not with_ida:
1856 without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
1857 elif not conf.CheckSUNDIALS():
1858 with_ida = False
1859 without_ida_reason = "SUNDIALS not found, or bad version"
1860 elif not conf.CheckIDA():
1861 with_ida = False
1862 without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
1863
1864 # CONOPT
1865
1866 if not with_conopt:
1867 without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
1868 elif not conf.CheckCONOPT():
1869 with_conopt = False
1870 without_conpt_reason = "CONOPT not found"
1871
1872 # BLAS
1873
1874 need_blas=False
1875
1876 if with_lsode:
1877 need_fortran = True
1878 need_blas=True
1879
1880 if need_blas:
1881 if conf.CheckLib('blas'):
1882 with_local_blas = False
1883 without_local_blas_reason = "Found BLAS installed on system"
1884 else:
1885 with_local_blas = True
1886 need_fortran = True
1887 else:
1888 with_local_blas= False;
1889 without_local_blas_reason = "BLAS not required"
1890
1891 # FORTRAN
1892
1893 if need_fortran:
1894 conf.env.Tool('fortran')
1895 detect_fortran = conf.env.Detect(['gfortran','g77'])
1896 if detect_fortran:
1897 # For some reason, g77 doesn't get detected properly on MinGW
1898 if not env.has_key('F77') and not env.has_key('FORTRAN'):
1899 print "Fixing detection of F77 on MinGW...(?)"
1900 conf.env.Replace(F77=detect_fortran)
1901 conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
1902 conf.env.Replace(F77FLAGS='')
1903 #print "F77:",conf.env['F77']
1904 #print "F77COM:",conf.env['F77COM']
1905 #print "F77FLAGS:",conf.env['F77FLAGS']
1906 fortran_builder = Builder(
1907 action='$F77COM'
1908 , suffix='.o'
1909 , src_suffix='.f'
1910 )
1911 conf.env.Append(BUILDERS={'Fortran':fortran_builder})
1912 if platform.system()=="Linux":
1913 conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
1914 else:
1915 with_lsode=False;
1916 without_lsode_reason="FORTRAN-77 required but not found"
1917
1918 #else:
1919 # print "FORTRAN not required"
1920
1921 # F2C
1922
1923 if need_fortran:
1924 if platform.system()=="Windows":
1925 pass
1926 #conf.env.Append(LIBPATH='c:\mingw\lib')
1927
1928 # scrollkeeper
1929
1930 if with_scrollkeeper:
1931 if not conf.CheckScrollkeeperConfig():
1932 with_scrollkeeper=False
1933 without_scrollkeeper_reason="unable to detect scrollkeeper-config"
1934
1935 # lyx
1936
1937 if with_doc:
1938 if not conf.CheckLyx():
1939 with_doc = False
1940 without_doc_reason="unable to locate lyx"
1941
1942 with_latext2html = conf.CheckLatex2HTML()
1943
1944 # TODO: -D_HPUX_SOURCE is needed
1945
1946 # TODO: check size of void*
1947
1948 # TODO: detect if dynamic libraries are possible or not
1949
1950 if platform.system()=="Windows" and env.has_key('MSVS'):
1951 _found_windows_h = conf.CheckHeader('Windows.h')
1952
1953 if not _found_windows_h:
1954 print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
1955 Exit(1)
1956
1957 if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
1958 with_python = 0;
1959 without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
1960
1961 conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])
1962
1963 conf.Finish()
1964
1965 #---------------------------------------
1966 # SUBSTITUTION DICTIONARY for .in files
1967
1968 release = env.get('RELEASE')
1969 if release=="0.":
1970 release="0"
1971
1972 #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
1973
1974 subst_dict = {
1975 '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
1976 , '@GLADE_FILE@':'ascend.glade'
1977 , '@HELP_ROOT@':''
1978 , '@ICON_EXTENSION@':icon_extension
1979 , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
1980 , '@INSTALL_BIN@':env['INSTALL_BIN']
1981 , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
1982 , '@INSTALL_LIB@':env['INSTALL_LIB']
1983 , '@INSTALL_MODELS@':env['INSTALL_MODELS']
1984 , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
1985 , '@VERSION@':version
1986 , '@RELEASE@':release
1987 , '@DISTTAR_NAME@':env['DISTTAR_NAME']
1988 , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
1989 , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
1990 , '@SHLIBPREFIX@':env['SHLIBPREFIX']
1991 , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
1992 , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
1993 , '@PYTHON@' : python_exe
1994 , '@PYVERSION@' : "%d.%d" % (sys.version_info[0],sys.version_info[1])
1995 , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
1996 , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
1997 , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
1998 , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
1999 }
2000
2001 if env.get('WITH_DOC'):
2002 print "WITH_DOC:",env['WITH_DOC']
2003 subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2004
2005 # bool options...
2006 for k,v in {
2007 'ASC_WITH_IDA':with_ida
2008 ,'ASC_WITH_DMALLOC':with_dmalloc
2009 ,'ASC_WITH_MFGRAPH':with_mfgraph
2010 ,'ASC_WITH_UFSPARSE':with_ufsparse
2011 ,'ASC_WITH_CONOPT':with_conopt
2012 ,'ASC_WITH_LSODE':with_lsode
2013 ,'ASC_WITH_MMIO':with_mmio
2014 ,'ASC_SIGNAL_TRAPS':with_signals
2015 ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2016 ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2017 ,'HAVE_IEEE':env.get('HAVE_IEEE')
2018 ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2019 ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2020 ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2021 }.iteritems():
2022
2023 if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2024
2025 if with_python:
2026 subst_dict['@ASCXX_USE_PYTHON@']="1"
2027 env['WITH_PYTHON']=1;
2028
2029 if with_latex2html:
2030 env['WITH_LATEX2HTML']=1
2031
2032 if env.has_key('HAVE_GCCVISIBILITY'):
2033 subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2034
2035 env.Append(SUBST_DICT=subst_dict)
2036
2037 #for k,v in subst_dict.iteritems():
2038 # print "%-50s%s" % ("'%s'"%k,v)
2039
2040 # REMOVED: long command-line support on Win2k
2041
2042 #------------------------------------------------------
2043 # RECIPE: SWIG scanner
2044
2045 import SCons.Script
2046
2047 SWIGScanner = SCons.Scanner.ClassicCPP(
2048 "SWIGScan"
2049 , ".i"
2050 , "CPPPATH"
2051 , '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2052 )
2053
2054 env.Append(SCANNERS=[SWIGScanner])
2055
2056 #------------------------------------------------------
2057 # Recipe for 'CHMOD' ACTION
2058
2059 import SCons
2060 from SCons.Script.SConscript import SConsEnvironment
2061 SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod,
2062 lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))
2063
2064 def InstallPerm(env, dest, files, perm):
2065 obj = env.Install(dest, files)
2066 for i in obj:
2067 env.AddPostAction(i, env.Chmod(str(i), perm))
2068
2069 SConsEnvironment.InstallPerm = InstallPerm
2070
2071 # define wrappers
2072 SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)
2073 SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2074 SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
2075
2076 #------------------------------------------------------
2077 # BUILD...
2078
2079 # so that #include <modulename/headername.h> works across all modules...
2080 env.AppendUnique(CPPPATH=['#base/generic'])
2081
2082 if env['DEBUG']:
2083 env.Append(CCFLAGS=['-g'])
2084
2085 if env['GCOV']:
2086 env.Append(
2087 CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
2088 , LIBS=['gcov']
2089 , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
2090 )
2091
2092 if with_ida:
2093 env.Append(WITH_IDA=1)
2094
2095 if with_conopt:
2096 env.Append(WITH_CONOPT=1)
2097
2098 #-------------
2099 # TCL/TK GUI
2100
2101 if with_tcltk:
2102 env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2103 else:
2104 print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2105
2106 #-------------
2107 # PYTHON INTERFACE
2108
2109 if with_python:
2110 env.SConscript(['pygtk/SConscript'],'env')
2111 else:
2112 print "Skipping... Python bindings aren't being built:",without_python_reason
2113
2114 #------------
2115 # BASE/GENERIC SUBDIRECTORIES
2116
2117 libascend_env = env.Copy()
2118
2119 dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2120
2121 srcs = []
2122 for d in dirs:
2123 heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
2124 srcs += heresrcs
2125
2126 #-------------
2127 # IMPORTED CODE: LSODE, BLAS, etc
2128
2129 if with_lsode:
2130 srcs += env.SConscript(['lsod/SConscript'],'env')
2131 srcs += env.SConscript(['linpack/SConscript'],'env')
2132 else:
2133 print "Skipping... LSODE won't be built:", without_lsode_reason
2134
2135 if with_local_blas:
2136 srcs += env.SConscript(['blas/SConscript'],'env')
2137 else:
2138 print "Skipping... BLAS won't be built:", without_local_blas_reason
2139
2140 if not with_ida:
2141 print "Skipping... IDA won't be built:", without_ida_reason
2142
2143 if with_mmio:
2144 srcs += env.SConscript(['mmio/SConscript'],'env')
2145 else:
2146 print "Skipping... MMIO export won't be built:", without_mmio_reason
2147 #-------------
2148 # LIBASCEND -- all base/generic functionality
2149
2150 if with_dmalloc:
2151 libascend_env.Append(LIBS=['dmalloc'])
2152
2153 if with_ufsparse:
2154 libascend_env.Append(LIBS=['cxsparse'])
2155
2156 libascend = libascend_env.SharedLibrary('ascend',srcs)
2157
2158 env.Alias('libascend',libascend)
2159
2160 #-------------
2161 # UNIT TESTS (C CODE)
2162
2163 if with_cunit:
2164 testdirs = ['general','solver','utilities','linear']
2165 testsrcs = []
2166 for testdir in testdirs:
2167 path = 'base/generic/'+testdir+'/test/'
2168 env.SConscript([path+'SConscript'],'env')
2169 testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
2170
2171 #print "TESTSRCS =",testsrcs
2172
2173 env.SConscript(['test/SConscript'],'env')
2174 env.SConscript(['base/generic/test/SConscript'],'env')
2175
2176 env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
2177
2178 else:
2179 print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2180
2181 #-------------
2182 # EXTERNAL FUNCTIONS
2183
2184 env['extfns']=[]
2185 modeldirs = env.SConscript(['models/SConscript'],'env')
2186
2187 if not with_extfns:
2188 print "Skipping... External modules aren't being built:",without_extfns_reason
2189
2190 env.Alias('extfns',env['extfns'])
2191
2192 #------------------------------------------------------
2193 # CREATE ASCEND-CONFIG scriptlet
2194
2195 ascendconfig = env.SubstInFile('ascend-config.in')
2196
2197 #------------------------------------------------------
2198 # INSTALLATION
2199
2200 if env.get('CAN_INSTALL'):
2201
2202 dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2203 install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2204 install_dirs += modeldirs
2205
2206 # TODO: add install options
2207 env.Alias('install',install_dirs)
2208
2209 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2210
2211 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2212
2213 #------------------------------------------------------
2214 # WINDOWS INSTALLER
2215 # For the windows installer, please see pygtk/SConscript
2216
2217 if with_installer:
2218 pass
2219 else:
2220 print "Skipping... Windows installer isn't being built:",without_installer_reason
2221
2222 #------------------------------------------------------
2223 # PROJECT FILE for MSVC
2224
2225 env.SConscript(['base/msvc/SConscript'],['env','libascend']);
2226
2227 #------------------------------------------------------
2228 # CREATE the SPEC file for generation of RPM packages
2229
2230 if platform.system()=="Linux":
2231 env.SubstInFile('ascend.spec.in')
2232
2233 #------------------------------------------------------
2234 # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2235
2236 #if with_scrollkeeper:
2237 # #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2238 # #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2239
2240 #------------------------------------------------------
2241 # DISTRIBUTION TAR FILE
2242
2243 env['DISTTAR_FORMAT']='bz2'
2244 env.Append(
2245 DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.lib','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx','.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz','.bz2','.7z']
2246 , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2247 )
2248
2249 tar = env.DistTar("dist/"+env['DISTTAR_NAME']
2250 , [env.Dir('#')]
2251 )
2252
2253 env.Depends(tar,'ascend.spec')
2254 env.Depends(tar,'#doc/book.pdf')
2255
2256 Alias('dist',tar)
2257
2258 #------------------------------------------------------
2259 # USER'S MANUAL
2260
2261 env.SConscript('doc/SConscript',['env'])
2262
2263
2264 #------------------------------------------------------
2265 # LIBASCEND DOXYGEN DOCUMENTATION
2266
2267 env.SConscript('base/doc/SConscript',['env'])
2268
2269 #------------------------------------------------------
2270 # RPM BUILD
2271
2272 # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2273 # (check * for the version number used to create the tarball)
2274
2275 #------------------------------------------------------
2276 # DEFAULT TARGETS
2277
2278 default_targets =['libascend']
2279 if with_tcltk:
2280 default_targets.append('tcltk')
2281 if with_python:
2282 default_targets.append('pygtk')
2283 if with_installer:
2284 default_targets.append('installer')
2285 if with_extfns:
2286 default_targets.append('extfns')
2287 if with_doc_build:
2288 default_targets.append('doc')
2289
2290 env.Default(default_targets)
2291
2292 print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2293
2294 # vim: set syntax=python:

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